sim_telarray#
Support modules for running sim_telarray.
simtel_config_reader#
Read model parameters and configuration from sim_telarray configuration files.
- class simtel.simtel_config_reader.SimtelConfigReader(schema_file, simtel_config_file, simtel_telescope_name, parameter_name=None, camera_pixels=None)[source]#
Reads model parameters from configuration files and converts to the simtools representation.
The output format are simtool-db-style json dicts. Model parameters are read from sim_telarray configuration files. The sim_telarray configuration can be generated using e.g., the following sim_telarray command:
… code-block:: console
sim_telarray/bin/sim_telarray -c sim_telarray/cfg/CTA/CTA-PROD6-LaPalma.cfg -C limits=no-internal -C initlist=no-internal -C list=no-internal -C typelist=no-internal -C maximum_telescopes=30 -DNSB_AUTOSCALE -DNECTARCAM -DHYPER_LAYOUT -DNUM_TELESCOPES=30 /dev/null 2>|/dev/null | grep ‘(@cfg)’ | sed ‘s/^(@cfg)
- Parameters:
- schema_file: str
Schema file describing the model parameter.
- simtel_config_file: str or Path
Path of the file to read from.
- simtel_telescope_name: str
Telescope name (sim_telarray convention)
- parameter_name: str
Parameter name (default: read from schema file)
- camera_pixels: int
Number of camera pixels
- compare_simtel_config_with_schema()[source]#
Compare limits and defaults reported by simtel_array with schema.
This is mostly for debugging purposes and includes simple printing. Check for differences in ‘default’ and ‘limits’ entries.
- read_simtel_config_file(simtel_config_file, simtel_telescope_name)[source]#
Read sim_telarray configuration file and return a dictionary with the parameter values.
- Parameters:
- simtel_config_file: str or Path
Path of the file to read from.
- simtel_telescope_name: str
Telescope name (sim_telarray convention)
- Returns:
- dict
Dictionary with the parameter values.
simtel_config_writer#
Configuration file writer for sim_telarray.
- class simtel.simtel_config_writer.SimtelConfigWriter(site, model_version, layout_name=None, telescope_model_name=None, label=None)[source]#
SimtelConfigWriter writes sim_telarray configuration files.
It is designed to be used by model classes (TelescopeModel and ArrayModel) only.
- Parameters:
- site: str
South or North.
- model_version: str
Model version.
- telescope_model_name: str
Telescope model name.
- layout_name: str
Layout name.
- label: str
Instance label. Important for output file naming.
- write_array_config_file(config_file_path, telescope_model, site_model)[source]#
Write the sim_telarray config file for an array of telescopes.
- Parameters:
- config_file_path: str or Path
Path of the file to write on.
- telescope_model: dict of TelescopeModel
Dictionary of TelescopeModel’s instances as used by the ArrayModel instance.
- site_model: Site model
Site model.
- write_single_mirror_list_file(mirror_number, mirrors, single_mirror_list_file, set_focal_length_to_zero=False)[source]#
Write the sim_telarray mirror list file for a single mirror.
- Parameters:
- mirror_number: int
Mirror number.
- mirrors: Mirrors
Instance of Mirrors.
- single_mirror_list_file: str or Path
Path of the file to write on.
- set_focal_length_to_zero: bool
Flag to set the focal length to zero.
- write_telescope_config_file(config_file_path, parameters, config_parameters=None)[source]#
Write the sim_telarray config file for a single telescope.
- Parameters:
- config_file_path: str or Path
Path of the file to write on.
- parameters: dict
Model parameters
- config_parameters: dict
Simulation software configuration parameters
simtel_table_reader#
Read tabular data in sim_telarray format and return as astropy table.
simtel_io_event_reader#
Read a reduced dataset from file.
Allow to filter the events based on the triggered telescopes. Provide functionality to list events, e.g. through
from simtools.simtel.simtel_io_event_reader import SimtelIOEventDataReader
reader = SimtelIOEventDataReader("gamma_diffuse_60deg.hdf5", [1,2,3,4])
reader.print_event_table()
- class simtel.simtel_io_event_reader.SimtelIOEventDataReader(event_data_file, telescope_list=None)[source]#
Read reduced MC data set from file.
Calculate some standard derivation like core position in shower coordinates.
- Parameters:
- event_data_filestr
Path to the HDF5 file containing the event data.
- telescope_listlist, optional
List of telescope IDs to filter the events (default is None).
simtel_io_event_writer#
Generate a reduced dataset from given simulation event list and save the output to file.
- class simtel.simtel_io_event_writer.ShowerEventData(simulated_energy: list = <factory>, x_core: list = <factory>, y_core: list = <factory>, shower_azimuth: list = <factory>, shower_altitude: list = <factory>, shower_id: list = <factory>, area_weight: list = <factory>, x_core_shower: list = <factory>, y_core_shower: list = <factory>, core_distance_shower: list = <factory>)[source]#
Shower event data.
- class simtel.simtel_io_event_writer.SimtelIOEventDataWriter(input_files, output_file, max_files=100)[source]#
Generate a reduced dataset from given simulation event list and save the output to file.
- Attributes:
- input_fileslist
List of input file paths to process.
- output_filestr
Path to the output file.
- max_filesint, optional
Maximum number of files to process.
simtel_io_histograms#
Reads the content of multiples files from sim_telarray.
- class simtel.simtel_io_histograms.SimtelIOHistograms(histogram_files, test=False, area_from_distribution=False, energy_range=None, view_cone=None)[source]#
Read the content of either multiple histogram (.hdata, or .hdata.zst) or simtel_array files.
Allow both the .hdata.zst histogram and the .simtel.zst output file type. It uses the SimtelIOHistogram class to deal with individual files. Histogram files are ultimately handled by using eventio library.
- Parameters:
- histogram_files: list
List of sim_telarray histogram files (str of Path).
- test: bool
If True, only a fraction of the histograms will be processed, leading to a much shorter runtime.
- area_from_distribution: bool
If true, the area thrown (the area in which the simulated events are distributed) in the trigger rate calculation is estimated based on the event distribution. The expected shape of the distribution of events as function of the core distance is triangular up to the maximum distance. The weighted mean radius of the triangular distribution is 2/3 times the upper edge. Therefore, when using the
area_from_distribution
flag, the mean distance times 3/2, returns just the position of the upper edge in the triangle distribution with little impact of the binning and little dependence on the scatter area defined in the simulation. This is special useful when calculating trigger rate for individual telescopes. If false, the area thrown is estimated based on the maximum distance as given in the simulation configuration.- energy_range: list
The energy range used in the simulation. It must be passed as a list of floats and the energy must be in TeV (as in the CORSIKA configuration). This argument is only needed and used if histogram_file is a .hdata file, in which case the energy range cannot be retrieved directly from the file.
- view_cone: list
The view cone used in the simulation. It must be passed as a list of floats and the view cone must be in deg (as in the CORSIKA configuration). This argument is only needed and used if histogram_file is a .hdata file, in which case the view cone cannot be retrieved directly from the file.
- calculate_trigger_rates(print_info=False, stack_files=False)[source]#
Calculate the triggered and simulated event rate considering the histograms in each file.
It returns also a list with the tables where the energy dependent trigger rate for each file can be found.
- Parameters:
- print_info: bool
if True, prints out the information about the histograms such as energy range, area, etc.
- stack_files: bool
if True, stack the histograms from the different files into single histograms. Useful to increase event statistics when calculating the trigger rate.
- Returns:
- sim_event_rates: list of astropy.Quantity[1/time]
The simulated event rates.
- triggered_event_rates: list of astropy.Quantity[1/time]
The triggered event rates.
- triggered_event_rate_uncertainties: list of astropy.Quantity[1/time]
The uncertainties in the triggered event rates.
- trigger_rate_in_tables: list of astropy.QTable
The energy dependent trigger rates. Only filled if stack_files is False.
- property combined_hists#
Combine histograms of same type of histogram.
Histograms are read from various lists into a single histogram list.
- export_histograms(hdf5_file_name, overwrite=False)[source]#
Export sim_telarray histograms to hdf5 files.
- Parameters:
- hdf5_file_name: str
Name of the file to be saved with the hdf5 tables.
- overwrite: bool
If True overwrites histograms already saved in the hdf5 file.
- get_stacked_num_events()[source]#
Return stacked number of simulated events and triggered events.
- Returns:
- int:
total number of simulated events for the stacked dataset.
- int:
total number of triggered events for the stacked dataset.
- property list_of_histograms#
Returns a list with the histograms for each file.
- Returns:
- list:
List of histograms.
- property number_of_files#
Returns number of histograms.
simulator_array#
Simulation runner for array simulations.
- class simtel.simulator_array.SimulatorArray(corsika_config, simtel_path, label=None, use_multipipe=False, sim_telarray_seeds=None)[source]#
SimulatorArray is the interface with sim_telarray to perform array simulations.
- Parameters:
- corsika_config_data: CorsikaConfig
CORSIKA configuration.
- simtel_path: str or Path
Location of source of the sim_telarray/CORSIKA package.
- label: str
Instance label.
- use_multipipe: bool
Use multipipe to run CORSIKA and sim_telarray.
- static get_power_law_for_sim_telarray_histograms(primary)[source]#
Get the power law index for sim_telarray.
Events will be histogrammed in sim_telarray with a weight according to the difference between this exponent and the one used for the shower simulations.
- Parameters:
- primary: str
Primary particle.
- Returns:
- float
Power law index.
simulator_camera_efficiency#
Simulation runner for camera efficiency calculations.
- class simtel.simulator_camera_efficiency.SimulatorCameraEfficiency(telescope_model, label=None, simtel_path=None, file_simtel=None, file_log=None, zenith_angle=None, nsb_spectrum=None, skip_correction_to_nsb_spectrum=False)[source]#
Interface with the testeff tool of sim_telarray to perform camera efficiency simulations.
- Parameters:
- telescope_model: str
Instance of TelescopeModel class.
- label: str
Instance label. Important for output file naming.
- simtel_path: str or Path
Location of sim_telarray installation.
- file_simtel: str or Path
Location of the sim_telarray testeff tool output file.
- zenith_angle: float
Zenith angle given in the config to CameraEfficiency.
- nsb_spectrum: str or Path
Path to the nsb spectrum file.
- property nsb_spectrum#
nsb_spectrum property.
simulator_light_emission#
Simulation using the light emission package for calibration.
- class simtel.simulator_light_emission.SimulatorLightEmission(telescope_model, calibration_model, site_model, light_emission_config, le_application, simtel_path, light_source_type, label=None, test=False)[source]#
Interface with sim_telarray to perform light emission package simulations.
The light emission package is used to simulate an artificial light source, used for calibration.
- calculate_distance_telescope_calibration_device()[source]#
Calculate the distance(s) between the telescope and the calibration device.
- Returns:
- list of astropy.Quantity
A list of distances for variable positions or a single distance for layout positions.
- calibration_pointing_direction()[source]#
Calculate the pointing of the calibration device towards the telescope.
- Returns:
- list
The pointing vector from the calibration device to the telescope.
- distance_list(arg)[source]#
Convert distance list to astropy quantities.
- Parameters:
- arg: list
List of distances.
- Returns:
- values: list
List of distances as astropy quantities.
- static light_emission_default_configuration()[source]#
Get default light emission configuration.
- Returns:
- dict
Default configuration light emission.
- prepare_script(generate_postscript=False, **kwargs)[source]#
Build and return bash run script containing the light-emission command.
- Parameters:
- plot: bool
If output should be plotted.
- generate_postscript: bool
If postscript should be generated with read_cta.
- Returns:
- Path
Full path of the run script.
simulator_ray_tracing#
Simulation runner for ray tracing simulations.
- class simtel.simulator_ray_tracing.SimulatorRayTracing(telescope_model, label=None, simtel_path=None, config_data=None, force_simulate=False, test=False)[source]#
Perform ray tracing simulations with sim_telarray.
- Parameters:
- telescope_model: TelescopeModel
telescope model
- label: str
label used for output file naming.
- simtel_path: str or Path
Location of sim_telarray installation.
- config_data: namedtuple
namedtuple containing the configurable parameters as values (expected units in brackets): zenith_angle (deg), off_axis_angle (deg), source_distance (km), single_mirror_mode, use_random_focal_length, mirror_numbers.
- force_simulate: bool
Remove existing files and force re-running of the ray-tracing simulation.