Simulation base classes

Perform simulations of air showers on a cluster of stations

This base class can be subclassed to provide various kinds of simulations. These simulations will inherit the base functionality from this class, including the creation of event and coincidence tables to store the results, which will look similar to regular HiSPARC data, such that the same reconstruction analysis can be applied to both.

Example usage:

>>> import tables

>>> from sapphire.simulations.base import BaseSimulation
>>> from sapphire import ScienceParkCluster

>>> data = tables.open_file('/tmp/test_base_simulation.h5', 'w')
>>> cluster = ScienceParkCluster()

>>> sim = BaseSimulation(cluster, data, '/simulations/this_run', 10)
>>> sim.run()
class sapphire.simulations.base.BaseSimulation(cluster, data, output_path='/', n=1, seed=None, progress=True)

Base class for simulations.

Parameters:
  • clusterBaseCluster instance.

  • data – writeable PyTables file handle.

  • output_path – path (as string) to the PyTables group (need not exist) in which the result tables will be created.

  • n – number of simulations to perform.

  • seed – seed for the pseudo-random number generators.

  • progress – if True show a progressbar while simulating.

run()

Run the simulations.

generate_shower_parameters()

Generate shower parameters like core position, energy, etc.

simulate_events_for_shower(shower_parameters)

Simulate station events for a single shower

simulate_station_response(station, shower_parameters)

Simulate station response to a shower.

simulate_all_detectors(detectors, shower_parameters)

Simulate response of all detectors in a station.

Parameters:
  • detectors – list of detectors

  • shower_parameters – parameters of the shower

simulate_detector_response(detector, shower_parameters)

Simulate detector response to a shower.

Parameters:
  • detectorDetector instance

  • shower_parameters – shower parameters

Returns:

dictionary with keys ‘n’ (number of particles in detector) and ‘t’ (time of arrival of first detected particle).

simulate_trigger(detector_observables)

Simulate a trigger response.

simulate_gps(station_observables, shower_parameters, station)

Simulate gps timestamp.

process_detector_observables(detector_observables)

Process detector observables for a station.

The list of detector observables is converted into a dictionary containing the familiar observables like pulseheights, n1, n2, …, t1, t2, …, integrals, etc.

Parameters:

detector_observables – list of observables of the detectors making up a station.

Returns:

dictionary containing the familiar station observables like n1, n2, n3, etc.

store_station_observables(station_id, station_observables)

Store station observables.

Parameters:
  • station_id – the id of the station in self.cluster

  • station_observables – A dictionary containing the variables to be stored for this event.

Returns:

The index (row number) of the newly added event.

store_coincidence(shower_id, shower_parameters, station_events)

Store coincidence.

Store the information to find events of different stations belonging to the same simulated shower in the coincidences tables.

Parameters:
  • shower_id – The shower number for the coincidence id.

  • shower_parameters – A dictionary with the parameters of the simulated shower.

  • station_events – A list of tuples containing the station_id and event_index referring to the events that participated in the coincidence.