Runners for simulation software#
Support modules for running simtools, CORSIKA, and sim_telarray.
Science workflows#
simtools_runner#
Tools for running applications in the simtools framework.
- runners.simtools_runner.apply_execution_overrides(configurations, args, model_source, env_file)[source]#
Apply inherited settings before recording or running applications.
- runners.simtools_runner.get_explicit_env_file(args_dict)[source]#
Return the runner env file when it was explicitly supplied on the CLI.
- runners.simtools_runner.model_source_options(args_dict)[source]#
Return configured model-source options for child applications.
- runners.simtools_runner.prepare_runtime_environment(runtime_environment_file)[source]#
Read and prepare a standalone runtime environment.
- Parameters:
- runtime_environment_filestr or pathlib.Path
YAML file with a top-level
runtime_environmentmapping.
- Returns:
- tuple[dict, list[str]]
Runtime-environment configuration and prepared runtime command.
- Raises:
- ValueError
If the YAML content is not a mapping or lacks
runtime_environment.- jsonschema.ValidationError
If the configuration does not conform to the runtime-environment schema.
- runners.simtools_runner.prepare_workflow(args_dict, replacements=None)[source]#
Resolve a workflow and its backend configuration without executing it.
- runners.simtools_runner.read_runtime_environment(runtime_environment)[source]#
Read the runtime environment (e.g. docker runtime) and return the required command.
- runners.simtools_runner.resolve_nested_configuration_files(configurations, replacements)[source]#
Resolve placeholders in referenced backend configuration files.
- runners.simtools_runner.run_applications(args_dict, run_time=None, replacements=None, context=None)[source]#
Run simtools applications step-by-step as defined in a configuration file.
- Parameters:
- args_dictdict
Command line arguments. Optional keys:
overwrite_collection_files(allow overwriting collection files with the same basename) andprovenance_path(False omits the resolved workflow file).- run_timelist or None
Prepared runtime command, reused instead of preparing the runtime environment.
- replacementsdict or None
Placeholder replacements applied recursively;
__CONFIG_DIRECTORY__is added automatically.- contextRunContext, optional
Run context used to report software versions and collect workflow metadata.
stages#
Simulation stages (e.g. CORSIKA, sim_telarray), the data products connecting them, and simulation chains.
Simulation stages and the chains built from them.
A stage is one step of a simulation, run by one program (e.g. CORSIKA, sim_telarray or an obdeect program). Stages are connected by the data products they consume and produce, either through files or as a stream. A chain is an ordered list of stage names.
The stages are declared in resources/simulation_software.yml (see
simtools.runtime.software_catalog): name, software, products, options, files and role. The
class of a stage is its catalog implementation; it holds only how the stage runs. Other code
asks a stage for its role (stages_with(), stage_role()) instead of naming it.
simtools.runners.chain_spec.SimulationChain checks that each stage consumes the data product
of the stage before it when the chain is created. Converter stages only change the format of
photons; a chain may leave them out.
- class runners.stages.CatalogStage[source]#
Base class of the stage implementations of the software catalog.
The registry makes a subclass per catalog stage that sets the name, the products and the catalog entry (
spec); an implementation holds only how the stage runs.
- runners.stages.STAGES = {}#
Stage classes by name: the catalog stages (built on first use, see
registry()) and the stages added withregister_stage().
- class runners.stages.SimulationStage(*args, **kwargs)[source]#
One program of a simulation chain.
The name, the products and the catalog entry (
spec, seesimtools.runtime.software_catalog.StageSpec) come from the software catalog. The roles a stage can have in a chain are catalog fields (stage_role()):software,source(air_showerorlight_source),converter,thins_photons,single_array_model,required_arguments,production_resultand the efficiency factors it applies.- classmethod instances(inputs, label=None)[source]#
Return the stage instances for a run (e.g. one per array model).
- prepare(run_number, input_file=None, output=None)[source]#
Write the stage inputs and return the shell lines that run the stage.
- Parameters:
- run_numberint
Run number.
- input_filestr or Path or None
Input file,
STDINwhen reading a stream, or None for the first stage.- outputStreamTo or None
Downstream commands when the output is streamed; None writes the stage’s file.
- Returns:
- list[str]
Shell lines.
- class runners.stages.StageInputs(array_models, simulation_parameters, shower_configurations, args, context=None, chain=None, calibration=None)[source]#
What a simulation provides to create its stage instances.
- options_of(stage)[source]#
Return the checked options of a stage, with their defaults (empty without a chain).
- property stages#
Return the stage names of the chain (empty without a chain).
- runners.stages.applied_factors_of(stage, options, upstream=frozenset({}))[source]#
Return the efficiency factors a stage applies, given the factors applied upstream.
The factors follow the catalog declaration of the stage (
applies,applies_by_option,skips_if_applied_upstream); a stage outside the catalog applies none.
- runners.stages.check_array_models(stages, array_models)[source]#
Raise ValueError if a stage that runs for one array model gets several.
- Parameters:
- stagesiterable of str
Stage names of the chain.
- array_modelssequence
Array models of the run (one per model version).
- runners.stages.connects(upstream, downstream)[source]#
Return whether stage class
downstreamconsumes what stage classupstreamproduces.
- runners.stages.converter_stages()[source]#
Return the names of the converter stages (role
converter).
- runners.stages.efficiency_envelope_enabled(inputs)[source]#
Return True if a thinning stage of the chain thins the photons by the efficiency envelope.
A thinning stage declares this with the role method
efficiency_envelope(inputs).- Parameters:
- inputsStageInputs
Inputs of the stages (chain stages and chain options).
- runners.stages.ends_camera_only(inputs)[source]#
Return True if the last stage of the chain simulates the camera only.
The last stage declares this in the catalog (
camera_only: option values).- Parameters:
- inputsStageInputs
Inputs of the stages (chain stages and chain options).
- runners.stages.files_of_run(inputs, label=None, required=True)[source]#
Return the file naming of a run (
RunnerServices), shared by the stages of its chain.A light-emission run names its files after the light-emission simulation; a shower run after the run of its first stage (run type: the software of that stage; the first shower configuration).
- Parameters:
- inputsStageInputs
Inputs of the stages.
- labelstr, optional
Instance label.
- requiredbool
Raise if the run has no configuration; otherwise return None (a stage that only streams writes no file).
- runners.stages.register_stage(stage_class)[source]#
Register a stage class under its name, replacing any stage registered under it.
A stage of simtools is an entry of
resources/simulation_software.yml; this adds a stage outside the catalog (e.g. in tests). The class declaresname,consumesandproduces, and the role attributes it has (seeSimulationStage).- Parameters:
- stage_classtype
Stage class.
- runners.stages.registry()[source]#
Return the stage classes by name: the catalog stages and the registered stages.
- runners.stages.single_downstream(output, stage_name)[source]#
Return the one downstream command of a streamed output; raise if there are several.
- runners.stages.stage_file(stage, use, run_number)[source]#
Return a file of a stage instance:
<run base name>.<stage name><suffix>.The file product of the use (
output,log, …) is the catalogfilesentry of the stage; the instance has the file naming of its run (run_files).- Parameters:
- stageobject
Stage instance with
specandrun_files.- usestr
Use of the file.
- run_numberint
Run number.
- runners.stages.stage_role(stage_class, role, default=None)[source]#
Return a role of a stage class: its catalog field, or else its attribute.
- Parameters:
- stage_classtype
Stage class.
- rolestr
Role (see
SimulationStage).- defaultobject
Value if the stage does not declare the role.
- runners.stages.stages_software(names)[source]#
Return the software needed by stages.
- Parameters:
- namesiterable of str
Stage names.
- Returns:
- frozenset of str
Software of all stages.
- Raises:
- ValueError
If a stage is unknown.
- runners.stages.stages_with(names, role, value=True)[source]#
Return the names of the stages that have a role.
- Parameters:
- namesiterable of str
Stage names (e.g. the stages of a chain).
- rolestr
Role attribute (see
SimulationStage).- valueobject
Value of the role attribute.
- Returns:
- list of str
Names of the stages whose role attribute equals
value, in the given order.
stage_types#
Stream input and output of simulation stages.
- runners.stage_types.STDIN = '-'#
Stream marker of a stage input read from the standard input of the chain.
chain_runner#
Run script for a chain of simulation stages.
- class runners.chain_runner.ChainRunner(chain, inputs, label=None)[source]#
Write the run script of a simulation chain.
Stages that both stream are connected by a stream (the upstream stage receives the downstream commands); otherwise the upstream output file is the downstream input. A stage may run as several instances (e.g. one per array model).
- Parameters:
- chainSimulationChain
Ordered simulation stages.
- inputsStageInputs
Array models, simulation parameters, shower configurations and arguments.
- labelstr
Instance label.
- prepare_run(run_number, sub_script, input_file=None, extra_commands=None)[source]#
Write the run script for one run.
- Parameters:
- run_numberint
Run number.
- sub_scriptstr or Path
Run script to write.
- input_filestr or Path, optional
Input file of the first stage (when it does not generate showers).
- extra_commandsstr or list[str], optional
Commands written before the simulation commands.
corsika_stage#
CORSIKA as a simulation stage (air showers and Cherenkov photons).
- class runners.corsika_stage.CorsikaStage(corsika_config, label=None, sequential=False, save_output=False, context=None)[source]#
CORSIKA air-shower simulation stage.
Writes the CORSIKA input card and the commands that run CORSIKA. A streamed output is passed to the downstream commands with
multipipe_corsika.- Parameters:
- corsika_configCorsikaConfig
CORSIKA configuration.
- labelstr
Instance label.
- sequentialbool
Run multipipe_corsika in sequential mode (no parallel CORSIKA/downstream execution).
- save_outputbool
Also save the streamed CORSIKA output to a compressed file.
- classmethod instances(inputs, label=None)[source]#
Return the CORSIKA stage of a run (the first shower configuration defines it).
- prepare(run_number, input_file=None, output=None)[source]#
Write the CORSIKA input card (and stream configuration) and return the run lines.
- Parameters:
- run_numberint
Run number.
- input_fileNone
CORSIKA reads no input product.
- outputStreamTo or None
Downstream commands receiving the CORSIKA output stream; None writes the CORSIKA output file.
- Returns:
- list[str]
Shell lines running CORSIKA.
sim_telarray_stage#
sim_telarray as a simulation stage (telescope and camera response).
- runners.sim_telarray_stage.BYPASS_NONE = 'none'#
Option values: sim_telarray optics on the photons of the source (default); photons at the camera entrance (Bypass_Optics 1 or 2 from the mirror class); camera only (Bypass_Optics 3).
- runners.sim_telarray_stage.BYPASS_OPTICS_OPTION = 'bypass_optics'#
Chain option selecting the photons sim_telarray simulates (values: see the catalog).
- runners.sim_telarray_stage.CAMERA_ONLY_BYPASS_LEVEL = 3#
sim_telarray Bypass_Optics value of the camera-only simulation.
- class runners.sim_telarray_stage.LightSimTelArrayStage(stage_class, calibration, bypass_optics=None, atmospheric_transmission=None)[source]#
sim_telarray run on the photons of a calibration light source (one telescope).
The command is that of
SimulatorLightEmission.make_sim_telarray_command. The photon file is handed over by the stage before it.- Parameters:
- stage_classtype
Stage class of the chain (name and products).
- calibrationSimulatorLightEmission
Light-emission simulation of one telescope and one light source.
- bypass_opticsint or None
Bypass_Optics value (None: derived by the light-emission simulation from the light source).
- atmospheric_transmissionstr or Path or None
Zero-depth transmission table read by sim_telarray (None: none).
- prepare(run_number, input_file=None, output=None)[source]#
Return the shell lines that run sim_telarray.
- Parameters:
- run_numberint
Run number (the file names are those of the light-emission simulation).
- input_filestr or Path or None
Photon file of the stage before (default: the IACT file of the LightEmission program).
- outputNone
sim_telarray writes its output file.
- Returns:
- list of str
Shell lines; the IACT file of the LightEmission program is removed afterwards.
- class runners.sim_telarray_stage.SimTelArrayStage(simulation_parameters, array_model, label=None, context=None, bypass_optics=None, atmospheric_transmission=None, efficiency_envelope=False, photons_thinned=False)[source]#
sim_telarray array simulation stage, one instance per array model.
- Parameters:
- simulation_parametersSimulationParameters
Physical run settings.
- array_modelArrayModel
Telescope and site models.
- labelstr
Instance label.
- bypass_opticsint or None
Bypass_Optics value of the run (None: sim_telarray applies its optics to the photons).
- atmospheric_transmissionstr or Path or None
Zero-depth transmission table read by sim_telarray (None: sim_telarray applies the atmospheric extinction itself).
- efficiency_envelopebool
True if the photons are thinned by the quantum-efficiency envelope: sim_telarray then reads the QE table divided by the envelope (see
simtools.simulation_software.efficiency).- photons_thinnedbool
True if an upstream stage thins the photons (sim_telarray runs with min_photons disabled).
- property file_list#
Files of this stage by file type.
- classmethod instances(inputs, label=None)[source]#
Return one sim_telarray stage per array model (one for a light-emission run).
- prepare(run_number, input_file=None, output=None)[source]#
Write the sim_telarray configuration and return the run lines.
- Parameters:
- run_numberint
Run number.
- input_filestr or Path
CORSIKA output file, or
STDINwhen reading a stream.- outputNone
sim_telarray writes its output file.
- Returns:
- list[str]
Shell lines running sim_telarray (one per run of a run set; one line when reading a stream).
- property runner_service#
File naming of this stage.
- runners.sim_telarray_stage.THINNED_MIN_PHOTONS = 0#
sim_telarray min_photons when an upstream stage thins photons. sim_telarray skips a telescope event below min_photons, counted on the thinned photons, so the cut is disabled (the min_photoelectrons cut still applies after the QE).
- runners.sim_telarray_stage.ZERO_TRANSMISSION_DIRECTORY = 'atmosphere_zero'#
Output directory of the zero-depth transmission table (sim_telarray, bypass 1 or 2). Separate from the atmosphere stage: exporting the site table here must not overwrite its table.
simtel_runner#
Base class for running sim_telarray simulations.
- class simtel.simtel_runner.SimtelRunner(label=None, config=None, array_model=None, context=None)[source]#
Base class for running simulations based on the sim_telarray software stack.
The sim_telarray software stack includes sim_telarray itself and auxiliary tools, LightEmission, and other software packages.
- Parameters:
- label: str
Instance label. Important for output file naming.
- config: CorsikaConfig or dict
Configuration parameters.
runner_services#
Base service methods for simulation runners.
- class job_execution.runner_services.RunnerServices(config, run_type, label=None, array_model=None, context=None)[source]#
Base service methods for simulation runners.
Includes file naming and directory management.
- Parameters:
- config: CorsikaConfig, dict
Configuration parameters.
- run_typestr
Type of simulation runner.
- labelstr
Label.
- get_file_name(file_type, run_number=None)[source]#
Get a file name depending on file type and run number.
- Parameters:
- file_typestr
The type of file (determines the file suffix).
- run_numberint
Run number.
- Returns:
- str
File name with full path.
- Raises:
- ValueError
If file_type is unknown.
- get_resources(runtime=None)[source]#
Return resources used by a simulation run.
- Parameters:
- runtime: float, optional
Wall-clock runtime in seconds measured by the Python subprocess caller.
- Returns:
- dict
run time and number of simulated events
- get_stage_file_name(stage_name, file_type, run_number=None)[source]#
Return a file of a simulation stage:
<base name>.<stage name><suffix>.The suffix and the directory are those of the file type (the file catalog, which includes
resources/simulation_software.yml), so the files of all stages of a run share one naming scheme.- Parameters:
- stage_namestr
Name of the stage.
- file_typestr
File type of the stage (e.g.
photon_stream,stage_log).- run_numberint
Run number.
- Returns:
- Path
File name with full path.
- job_execution.runner_services.validate_corsika_run_number(run_number)[source]#
Validate run number and return it.
- Parameters:
- run_number: int
Run number.
- Returns:
- int
Run number.
- Raises:
- ValueError
If run_number is not a valid value (< 1 or > 999999).
- job_execution.runner_services.warn_if_file_name_exceeds_dirac_limit(file_name, file_type)[source]#
Warn when a generated file name exceeds the current DIRAC limit.
- Parameters:
- file_namestr
Final file name without its directory path.
- file_typestr
Internal simtools file type used to generate the file name.
setting_workflow#
Create and execute versioned workflows for simple model-parameter settings.
- runners.setting_workflow.create_setting_workflow(args, model_reader=None, context=None)[source]#
Create validated input files, or reuse an identical setting.
- Parameters:
- argsdict
Parameter, instrument, value, parameter_version, description, and optional site, source_url, workflow_runtime_file, output_path (repository root), model_parameter_schema_version, and standard contact arguments.
- model_readerobject, optional
Reader used to check for an already submitted parameter version.
- Returns:
- pathlib.Path
Path to the prepared workflow configuration.
- Raises:
- ValueError
If inputs are invalid or this version has conflicting input files.
- runners.setting_workflow.run_setting_workflow(config_file, args, context=None)[source]#
Execute a prepared setting in its activity output directory.
- Parameters:
- config_filepathlib.Path
Configuration returned by create_setting_workflow.
- argsdict
Runner options, including model-source options and ignore_runtime_environment.
- Returns:
- pathlib.Path
Output directory used by this execution.
runtime_releases#
Resolve released setting-workflow runtimes to immutable references.
Simulation software#
Atmosphere of the simulation chain: request and its construction from the models.
The atmosphere applies the atmospheric transmission and the in-telescope path of each telescope
to a photon stream, moves photons from the sky to the ground frame, and thins or weights the
photons. This module holds the model inputs (AtmosphereRequest) and does not depend on
a program. The command line of the obdeect program is in
simtools.simulation_software.obdeect.atmosphere; the simulation stage is in
simtools.runners.atmosphere_stage.
- class simulation_software.atmosphere.AtmosphereRequest(site, observation_level_m, profile_file, transmission_file, seed, mode='thinned', wavelength_range_nm=None, telescope_pathlen_m=<factory>, geometry='plane_parallel')[source]#
Inputs of the atmosphere of one array.
- Parameters:
- sitestr
Site name.
- observation_level_mfloat
Observation level [m a.s.l.].
- profile_filePath
Atmospheric profile (atmprof format).
- transmission_filePath
Atmospheric transmission table (extinction-table format).
- seedint
Seed of the random numbers of the thinning.
- modestr
Output mode,
thinned(one photon per surviving photon) orweighted.- wavelength_range_nmtuple of float or None
Wavelength range [nm] of photons without a wavelength; None uses the run keys.
- telescope_pathlen_mdict
Path length inside each telescope [m], keyed by the stream telescope id.
- geometrystr
Atmosphere geometry. Only
plane_parallelis available.
- simulation_software.atmosphere.DEFAULT_MODE = 'thinned'#
Output mode of the thinning: one photon per surviving photon.
- simulation_software.atmosphere.DEFAULT_SEED = 1#
Seed of the thinning if the telescope models give no simulation seed.
- simulation_software.atmosphere.OBDEECT_MAX_WAVELENGTH_NM = 1000#
obdeect reads transmission wavelengths that are integers below this value [nm].
- simulation_software.atmosphere.PROFILE_FILE_NAME = 'atmosphere-profile.dat'#
Name of the atmospheric profile exported from an ECSV model parameter (atmprof format).
- simulation_software.atmosphere.TRANSMISSION_FILE_NAME = 'atmosphere-transmission.dat'#
Name of the transmission table exported from an ECSV model parameter.
- simulation_software.atmosphere.ZERO_TRANSMISSION_FILE_NAME = 'atmosphere-zero-transmission.dat'#
Name of the transmission table with optical depth 0 (sim_telarray, bypass 1 or 2).
- simulation_software.atmosphere.build_atmosphere_request(site_model, telescope_models, *, seed=1, mode='thinned', wavelength_range_nm=None, directory=None)[source]#
Build the atmosphere request of an array from its site and telescope models.
Telescope ids are the 1-based positions of the telescopes in
telescope_models.- Parameters:
- site_modelSiteModel
Site model of the array.
- telescope_modelsdict
Telescope models keyed by array element name, in the order of the array.
- seedint
Seed of the thinning.
- modestr
Output mode (
thinnedorweighted).- wavelength_range_nmtuple of float or None
Wavelength range [nm] of photons without a wavelength.
- directoryPath or None
Directory of the exported transmission table (see
export_atmosphere_files()).
- Returns:
- AtmosphereRequest
Atmosphere request.
- simulation_software.atmosphere.export_atmosphere_files(site_model, directory=None)[source]#
Export the atmospheric profile and transmission of a site model as files.
- Parameters:
- site_modelSiteModel
Site model.
- directoryPath or None
Directory of the transmission table exported from an ECSV model parameter; default is the configuration directory of the site model.
- Returns:
- tuple of Path
Profile file and transmission table file.
- simulation_software.atmosphere.in_telescope_pathlength_m(telescope_model)[source]#
Return the path length inside a telescope [m] used by the extinction.
Dual-mirror telescopes use 0 m (sim_telarray zeroes the constant term of the path for mirror class 2); single-mirror telescopes use the focal length.
- Parameters:
- telescope_modelTelescopeModel
Telescope model.
- Returns:
- float
Path length [m].
- simulation_software.atmosphere.write_obdeect_transmission(transmission_file, directory)[source]#
Write the transmission table as obdeect reads it and return its file.
obdeect accepts wavelengths that are integers in [0, 1000) nm; other rows are dropped (the table ends at 1000 nm, where no photon is simulated). Lines that do not start with a number are copied.
- Parameters:
- transmission_filePath
Atmospheric transmission table (extinction-table format).
- directoryPath
Directory of the written table (created if it does not exist).
- Returns:
- Path
Transmission table written.
- simulation_software.atmosphere.write_zero_transmission(transmission_file, directory)[source]#
Write the transmission table with optical depth 0 at all altitudes and return its file.
Used by sim_telarray with Bypass_Optics 1 or 2 when an upstream stage applies the atmospheric extinction: sim_telarray then reads this table and applies no extinction. The wavelengths of the table are kept; lines that do not start with a number are copied.
- Parameters:
- transmission_filePath
Atmospheric transmission table (extinction-table format).
- directoryPath
Directory of the written table (created if it does not exist).
- Returns:
- Path
Zero-depth transmission table written.
Trace flasher light through telescope obscurers and write camera-frame photon streams.
- simulation_software.flasher_stream.create_telescope_model(request, simulation_models_path=None, context=None)[source]#
Return the telescope model of a flasher request.
- simulation_software.flasher_stream.light_source_request(request)[source]#
Return the ray-tracing light-source request of a
FlasherRequest.The flasher emits along the optical axis; the telescope points to the zenith.
- simulation_software.flasher_stream.main(argv=None, *, telescope_model_factory=<function create_telescope_model>)[source]#
Run the flasher stream process.
- Parameters:
- argvlist of str or None
Command-line arguments (default:
sys.argv).- telescope_model_factorycallable
Returns the telescope model of a
FlasherRequest(keyword argumentssimulation_models_pathandcontext).
- Returns:
- int
Exit status.
- simulation_software.flasher_stream.parse_args(argv=None)[source]#
Parse the command line of the flasher stream process.
- simulation_software.flasher_stream.stream_columns(block, emission_altitude_m)[source]#
Return the float32 stream columns of a block of photons at the camera plane.
The emission altitude (
zem) is the same for all photons of the flasher.
- simulation_software.flasher_stream.telescope_run_fields(telescope_model)[source]#
Return the telescope arrays of the run record (one telescope at the origin).
The flasher photons are in the camera frame, so the telescope is at the origin (as in the default light-emission chain, ff-1m writes its telescope at the origin). Its radius is the telescope sphere radius of the model, as written to the CORSIKA telescope list.
- simulation_software.flasher_stream.write_flasher_stream(tracer, request, output)[source]#
Trace the light of a flasher and write the camera-frame photon stream.
- Parameters:
- tracerObdeectRayTracer
Ray tracer of the telescope model.
- requestFlasherRequest
Flasher request.
- outputstr or Path
Output file, or
-for stdout.
- Returns:
- int
Number of photons written.
Build flasher and illuminator requests from calibration and telescope models.
- class simulation_software.light_sources.AngularDistribution(shape, width_deg)[source]#
Angular emission profile: shape name (as the model parameter) and width [deg].
- class simulation_software.light_sources.FlasherRequest(position_m, camera_radius_m, events, photons, wavelength_nm, angular, pulse, observation_level_m, telescope='', site='', model_version='', run_number=1, seed=1, instrument_seed=1, emission_altitude_m=None)[source]#
Flasher inside a telescope, lighting the camera directly.
- Parameters:
- position_mtuple of float
Flasher position in the telescope frame [m] (+z along the optical axis).
- camera_radius_mfloat
Fiducial radius of the camera [m].
- eventstuple of int
Events (pulses) per photon level.
- photonstuple of int
Photons emitted into 4 pi per pulse, one value per photon level.
- wavelength_nmfloat
Wavelength [nm].
- angularAngularDistribution
Angular emission profile.
- pulsePulseShape
Time profile of the pulse.
- observation_level_mfloat
Observation level [m].
- telescope, site, model_versionstr
Telescope model that traces the light.
- run_numberint
Run number.
- seedint
Simulation seed.
- instrument_seedint
Seed of the random instrument realisation.
- emission_altitude_mfloat or None
Emission altitude of the flasher [m a.s.l.] (sim_telarray
zem); None uses the observation level.
- property photons_per_pulse#
Return the photons emitted into 4 pi in each pulse (one entry per event).
- class simulation_software.light_sources.IlluminatorRequest(position_m, pointing, telescope_position_m, telescope_radius_m, telescope_pointing_deg, events, photons, bunch_size, wavelength_nm, angular, pulse, observation_level_m, run_number=1, seed=1)[source]#
Illuminator outside the telescope, lighting it from a distance (sky-frame photons).
- Parameters:
- position_mtuple of float
Illuminator position in the ground frame [m] (array frame: x north, y west, z up).
- pointingtuple of float
Unit vector of the illuminator axis (ground frame).
- telescope_position_mtuple of float
Telescope position in the ground frame [m], corrected for the axes offsets.
- telescope_radius_mfloat
Radius of the telescope sphere [m].
- telescope_pointing_degtuple of float
Zenith and azimuth angle of the telescope pointing towards the illuminator [deg].
- eventsint
Events per photon level.
- photonstuple of int
Photons emitted into 4 pi per event, one value per photon level.
- bunch_sizefloat
Photons per bunch.
- wavelength_nmfloat
Wavelength [nm].
- angularAngularDistribution
Angular emission profile.
- pulsePulseShape
Time profile of the pulse.
- observation_level_mfloat
Observation level [m].
- run_numberint
Run number.
- seedint
Random seed.
- simulation_software.light_sources.POINTING_DOWN = (0.0, 0.0, -1.0)#
Illuminator pointing of the artificial setup with the telescope at the origin.
- class simulation_software.light_sources.PulseShape(shape, width_ns, decay_ns)[source]#
Time profile of a pulse: shape name (as the model parameter), width and decay [ns].
- simulation_software.light_sources.angular_distribution(calibration_model)[source]#
Return the angular emission profile of the calibration device model.
- simulation_software.light_sources.build_request(name, calibration_model, telescope_model, site_model, config, seed=1)[source]#
Build the request of a light-source type (
requestin the software catalog).
- simulation_software.light_sources.event_photon_sequences(number_of_events, photons)[source]#
Return the events and photons per photon level.
One event value applies to all photon levels; otherwise there is one value per level.
- Parameters:
- number_of_eventsint, list of int or str
Events (one value, or one value per photon level).
- photonsint, list of int or str
Photons per event (one value per photon level).
- Returns:
- tuple of tuple of int
Events and photons, one value each per photon level.
- simulation_software.light_sources.flasher_request(calibration_model, telescope_model, site_model, config, seed=1)[source]#
Return the request of a flasher (flat-fielding light source) in a telescope.
The flasher position is given in the primary-mirror frame and converted to the telescope frame (
mirror_offset).- Parameters:
- calibration_modelCalibrationModel
Flasher model.
- telescope_modelTelescopeModel
Telescope model.
- site_modelSiteModel
Site model.
- configdict
Settings of the light-emission run;
telescope,site,model_versionandinstrument_seedidentify the telescope model and its random realisation.- seedint
Simulation seed.
- Returns:
- FlasherRequest
Flasher request.
- simulation_software.light_sources.flasher_request_from_json(path)[source]#
Return the
FlasherRequestwritten byrequest_to_json().
- simulation_software.light_sources.illuminator_position_m(calibration_model, config)[source]#
Return the illuminator emission position in the ground frame [m] (array).
- simulation_software.light_sources.illuminator_request(calibration_model, telescope_model, site_model, config, seed=1)[source]#
Return the request of an illuminator (external light source) and a telescope.
- Parameters:
- calibration_modelCalibrationModel
Illuminator model.
- telescope_modelTelescopeModel
Telescope model.
- site_modelSiteModel
Site model.
- configdict
Settings of the light-emission run (
light_source_positionin m andlight_source_pointingoverride the model).- seedint
Random seed.
- Returns:
- IlluminatorRequest
Illuminator request.
- simulation_software.light_sources.pointing_towards_telescope(illuminator_m, telescope_m)[source]#
Return the illuminator pointing to the telescope and the telescope pointing angles.
- Returns:
- tuple
Unit vector from the illuminator to the telescope (rounded to 1e-6), and the telescope zenith and azimuth angle [deg] when pointing to the illuminator.
- simulation_software.light_sources.pulse_shape(calibration_model)[source]#
Return the pulse shape of the calibration device model.
- simulation_software.light_sources.request_to_json(request, path)[source]#
Write a
FlasherRequestas JSON and return the path.
- simulation_software.light_sources.requested_wavelength(value)[source]#
Return a configured wavelength as a quantity (None if not given); a number is in nm.
- Parameters:
- valuefloat, astropy.units.Quantity, list or None
One wavelength, or a list with one wavelength.
- Raises:
- ValueError
If more than one wavelength is given.
- simulation_software.light_sources.select_wavelength(calibration_model, requested=None)[source]#
Return the wavelength [nm] of the light source.
- Parameters:
- calibration_modelCalibrationModel
Calibration device model (parameter
flasher_wavelength).- requestedastropy.units.Quantity, optional
Requested wavelength; it must match a model wavelength within 0.5 nm.
- Returns:
- float
Wavelength of the model closest to the requested wavelength [nm].
- simulation_software.light_sources.source_command(name, request, work_directory, output=None, file_token='', executable=None, simulation_models_path=None)[source]#
Return the command tokens of a light-source type (
commandin the software catalog).
- simulation_software.light_sources.source_name_for_model(light_source_type)[source]#
Return the light-source type that simulates a model
flasher_typevalue.
- simulation_software.light_sources.telescope_position_m(telescope_model, illuminator_m, config)[source]#
Return the telescope position in the ground frame [m], corrected for the axes offsets.
The telescope is at the origin for an illuminator at a configured position with the downward beam (artificial setup).
- simulation_software.light_sources.uses_telescope_position(pointing_vector)[source]#
Return False for the downward beam used with an artificial telescope at the origin.
Telescope optics of the simulation chain: the request of one telescope.
An OpticsRequest describes what is traced for one telescope of an array model: the model
it is built from, the pointing, the seeds and the telescope transmission mode. It does not depend
on a program. The optical model file and the command line of obdeect ray-tracing trace-stream,
which traces a photon stream (ground or telescope frame) through the optics to camera-frame
photons, are made in simtools.simulation_software.obdeect.optics.
Frames: the ground frame is the horizontal plane through the telescope sphere centre (x north, y west, z up); the pointing is the telescope zenith and azimuth in that frame. The camera frame is the position on the camera entrance, the direction and the time of the photons. The tracing moves ground-frame photons to an input plane above the incoming obscurers by itself.
- class simulation_software.optics.OpticsRequest(telescope_type, telescope_name, telescope_id, model_version, site, dual_mirror, zenith_deg, azimuth_deg, instrument_seed, tracing_seed, telescope_transmission='full', threads=1)[source]#
Optics job of one telescope of one array model.
- Parameters:
- telescope_typestr
Telescope type (model name, e.g.
LSTN-design).- telescope_namestr
Array element name of the telescope.
- telescope_idint
Telescope id in the photon stream.
- model_versionstr
Model version.
- sitestr
Site (
NorthorSouth).- dual_mirrorbool
Whether the telescope has two mirrors.
- zenith_deg, azimuth_degfloat
Telescope pointing [deg] in the array frame (x north, y west).
- instrument_seedint
Seed of the random instrument (mirror errors) of this telescope.
- tracing_seedint
Seed of the random draws of the photon tracing.
- telescope_transmissionstr
Only
full(the telescope transmission is applied completely).- threadsint
Tracing threads (0 uses all cores).
- property model_file_name#
Name of the optical model file of this request (telescope, version, pointing, seed).
- simulation_software.optics.SEED_FILE_PREFIX = 'file-by-run:'#
Prefix of the seed string of a seed file, see
SimtelSeeds.
- simulation_software.optics.derive_seed(seed, *keys)[source]#
Return a reproducible 32-bit seed for the given non-negative integer keys.
- simulation_software.optics.optics_requests(array_model, simulation_parameters, telescope_ids, *, stream_id_offset=0, telescope_transmission='full', threads=1)[source]#
Return the optics requests of an array model, one per telescope.
Each telescope has its own random instrument: its instrument seed is derived from the instrument seed and the telescope id, as in the shower route.
- Parameters:
- array_modelArrayModel
Telescope and site models, and the seeds.
- simulation_parametersSimulationParameters
Provides the telescope pointing.
- telescope_idsdict
IACT telescope id (position in the CORSIKA telescope list) of each array element name.
- stream_id_offsetint
Added to the IACT telescope id to give the telescope id in the photon stream.
- telescope_transmissionstr
Telescope transmission mode.
- threadsint
Tracing threads of each request.
- Returns:
- list of OpticsRequest
One request per telescope, in the order of the array.
- simulation_software.optics.seeds_of(sim_telarray_seed)[source]#
Return the instrument seed and the tracing seed of the sim_telarray seeds.
The seeds are read from the seed string (“instrument seed,simulation seed”). For a seed file (“file-by-run:…”), the instrument seed is taken from the seed object and the simulation seed is the tracing seed.
- Parameters:
- sim_telarray_seedSimtelSeeds
Seeds of the sim_telarray simulations.
- Returns:
- tuple of int
Instrument seed and tracing seed.
- simulation_software.optics.write_telescope_map(requests, path)[source]#
Write the telescopes of the optics requests as a JSON file (documentation of the job).
- Parameters:
- requestsiterable of OpticsRequest
Optics requests of an array model.
- pathPath
Output file.
- Returns:
- Path
The file written.
Locate the executables of the simulation software (programs in the software catalog).
- simulation_software.programs.STDIO = '-'#
Stream marker of a command: standard input when read, standard output when written.
- simulation_software.programs.program_command(software, name)[source]#
Return the command tokens of a program of a simulation software.
- Parameters:
- softwarestr
Simulation software (catalog name) with a Python package.
- namestr
The software’s
commandor one of itsprograms.
- Raises:
- ValueError
If the software has no package, the program is unknown or not installed.
Build obdeect atmospheric propagation commands.
- simulation_software.obdeect.atmosphere.propagation_command(request, *, input_file='-', output_file='-', envelope_file=None, program=None)[source]#
Return the command-line tokens of the obdeect propagation for an atmosphere request.
- Parameters:
- requestAtmosphereRequest
Atmosphere request.
- input_filestr or Path
Input photon stream;
-reads stdin.- output_filestr or Path
Output photon stream;
-writes stdout.- envelope_filestr or Path, optional
Quantum-efficiency bound (two-column nm, value) thinning the photons (
--envelope qe).- programstr, Path or list of str, optional
Propagation program (command tokens); default: the program of the program catalog.
- Returns:
- list[str]
Command-line tokens.
Export optical models and build obdeect photon-stream tracing commands.
- simulation_software.obdeect.optics.trace_stream_command(requests, model_files, input_file='-', output_file='-')[source]#
Return the tokens of the obdeect command tracing a photon stream through several telescopes.
One process traces every telescope of the requests with its own optical model and writes one camera-frame stream in event order; telescopes without a request are dropped.
- Parameters:
- requestssequence of OpticsRequest
Optics jobs, one per telescope, with the same pointing, tracing seed, telescope transmission and threads.
- model_filessequence of str or Path
Optical model file of each request (see
write_optical_model()).- input_file, output_filestr or Path
Photon stream files;
-is standard input or output.
- Returns:
- list of str
Command tokens.
- Raises:
- ValueError
If there is no request, the numbers of requests and model files differ, or the requests differ in a shared field.
- simulation_software.obdeect.optics.write_optical_model(request, telescope_model, directory=None)[source]#
Compile the optical model of a request from its telescope model and write it as a file.
The model is compiled by the obdeect ray-tracing backend (
optical_model) for the pointing zenith angle and the instrument seed of the request.- Parameters:
- requestOpticsRequest
Optics job.
- telescope_modelTelescopeModel
Model of the telescope of the request.
- directoryPath or None
Directory of the file; default: the configuration directory of the telescope model.
- Returns:
- Path
Optical model file.
Build obdeect flasher and illuminator commands from light-source requests.
- simulation_software.obdeect.sources.flasher_command(request, work_directory, output=None, file_token='', executable=None, simulation_models_path=None)[source]#
Return the command tokens that make the photons of a flasher request.
The command runs
simtools.simulation_software.flasher_stream, which traces the light of the flasher to the camera plane (obscurers of the telescope tested, mirrors bypassed).- Parameters:
- requestFlasherRequest
Flasher request; it is written to
work_directory.- work_directorystr or Path
Directory of the request file and the exported model files.
- outputstr or Path, optional
Output file; without it the program writes the photon stream to stdout.
- file_tokenstr
Suffix of the request file name.
- executablestr, optional
Python interpreter (default: the running one).
- simulation_models_pathstr or Path, optional
Simulation models root of the run. The subprocess reads the telescope model from it (without it the subprocess has no model source).
- Returns:
- list of str
Command tokens.
- simulation_software.obdeect.sources.illuminator_angular_token(angular, work_directory, file_token='')[source]#
Return the angular distribution as point-source option value (a table when needed).
- simulation_software.obdeect.sources.illuminator_command(request, work_directory, output=None, file_token='', executable=None, simulation_models_path=None)[source]#
Return the command tokens that make the photons of an illuminator request.
The telescope position file (
x y z rin cm) and the tables of a profile without a program token are written towork_directory.- Parameters:
- requestIlluminatorRequest
Illuminator request.
- work_directorystr or Path
Directory for the telescope position file and tables.
- outputstr or Path, optional
Output file; without it the program writes the photon stream to stdout.
- file_tokenstr
Suffix of the table file names.
- executablestr, optional
Program (default: the point-source program of the program catalog).
- simulation_models_pathstr or Path, optional
Not used: the illuminator needs no model files (same signature as the flasher).
- Returns:
- list of str
Command tokens.
- simulation_software.obdeect.sources.illuminator_pulse_token(pulse, work_directory, file_token='')[source]#
Return the pulse shape as point-source option value (a table when needed).
Convert CORSIKA IACT photons to streams and camera streams to sim_telarray input.
- simulation_software.obdeect.streams.STREAM_TELESCOPE_ID_OFFSET = 1#
Photon-stream id of a telescope = its CORSIKA IACT id + this offset (streams start at 1).
- simulation_software.obdeect.streams.from_corsika_command(input_file)[source]#
Return the command tokens converting a CORSIKA output file to a photon stream.
- Parameters:
- input_filestr or Path
CORSIKA output file, or
STDINwhen reading a stream.
- Returns:
- list of str
Command tokens; the stream is written to stdout.
- simulation_software.obdeect.streams.to_simtel_command(camera_map, input_file, allow_pending=(), scaled_factors=(), atmprof=None)[source]#
Return the command tokens converting a camera-frame photon stream to sim_telarray input.
- Parameters:
- camera_mapstr or Path
Camera map file (see
write_camera_map()).- input_filestr or Path
Photon stream file, or
STDINwhen reading a stream.- allow_pendingiterable of str
Efficiency factors pending upstream that sim_telarray does not apply.
- scaled_factorsiterable of str
Efficiency factors whose sim_telarray table holds f/f_env.
- atmprofstr or Path, optional
Atmospheric profile (atmprof text) written as ATMPROF before the events. Needed when the stream has no ATMPROF block of its own (e.g. light-source streams).
- Returns:
- list of str
Command tokens; the converted stream is written to stdout.
- simulation_software.obdeect.streams.write_camera_map(telescope_models, path)[source]#
Write the camera map of the telescopes of an array and return its file.
Each line is
telescope_id mirror_class camera_rotation_deg(mirror class 1 single, 2 dual). The telescope id is the photon-stream id of the telescope: the CORSIKA IACT id plusSTREAM_TELESCOPE_ID_OFFSET(obdeect streams number telescopes from 1; stream-to-simtel rejects ids below 1).- Parameters:
- telescope_modelsdict
Telescope models keyed by array element name, in the order of the array.
- pathPath
Camera map file.
- Returns:
- Path
The file written.
Simulation chain stages#
Convert CORSIKA photons to streams and camera streams to sim_telarray input.
- class runners.adapter_stages.CorsikaToStreamStage(run_files)[source]#
Convert CORSIKA IACT photon bunches to a photon stream in the ground frame.
- Parameters:
- run_filesRunnerServices
File naming of the run.
- prepare(run_number, input_file=None, output=None)[source]#
Return the shell lines converting the CORSIKA output.
- Parameters:
- run_numberint
Run number.
- input_filestr or Path
CORSIKA output file, or
STDINwhen reading a stream.- outputStreamTo or None
Downstream command receiving the photon stream; None writes the stream to the stage output file.
- Returns:
- list[str]
Shell lines.
- class runners.adapter_stages.StreamToSimtelStage(run_files, array_model, allow_pending=(), scaled_factors=(), write_atmprof=False)[source]#
Convert a camera-frame photon stream to sim_telarray input.
All telescopes of the array are listed in the camera map: their CORSIKA telescope ids, mirror class and camera rotation. The photons are given at the camera entrance, so sim_telarray needs Bypass_Optics for the telescopes (see
SimTelArrayStage).- Parameters:
- run_filesRunnerServices
File naming of the run.
- array_modelArrayModel
Telescope models of the array.
- allow_pendingtuple of str
Efficiency factors pending upstream that sim_telarray does not apply (
--allow-pending).- scaled_factorstuple of str
Efficiency factors whose sim_telarray table holds f/f_env (
--scaled-factor).- write_atmprofbool
Write the atmospheric profile of the site for the converter (light-source streams).
- classmethod instances(inputs, label=None)[source]#
Return the stage of the array model (the first array model of the run).
- prepare(run_number, input_file=None, output=None)[source]#
Write the camera map and return the shell lines converting the photon stream.
- Parameters:
- run_numberint
Run number.
- input_filestr or Path
Photon stream file, or
STDINwhen reading a stream.- outputStreamTo or None
Downstream command (sim_telarray) receiving the converted stream; None writes the stream to the stage output file.
- Returns:
- list[str]
Shell lines.
Atmosphere stage of the obdeect chain: extinction and in-telescope path of the photons.
- runners.atmosphere_stage.MONOCHROMATIC_BAND_NM = 1.0#
Width [nm] added above a monochromatic light-source wavelength (see
_wavelength_range).
- class runners.atmosphere_stage.ObdeectAtmosphereStage(request, run_files=None, context=None, envelope_model=None, seed_per_run=False)[source]#
Atmosphere stage: applies the atmospheric extinction and the in-telescope path to photons.
The stage reads a photon stream in the sky or ground frame (stdin or file) and writes the photon stream in the ground frame. A streamed output is piped into the downstream command.
- Parameters:
- requestAtmosphereRequest
Atmosphere inputs of one array.
- run_filesRunnerServices
File naming of the run.
- contextRunContext or None
Run context (output directory); default: the environment context.
- envelope_modelArrayModel or None
Array model whose telescope types bound the efficiency envelope; None: no envelope.
- seed_per_runbool
Derive the seed of each run from the request seed and the run number.
- classmethod efficiency_envelope(inputs)[source]#
Return True if the stage thins the photons by the efficiency envelope.
The option
efficiency_envelopedecides. Without it, the envelope is on for a chain whose last stage simulates the camera only, and off otherwise. Calibration chains have no envelope by default and reject an explicitqe.
- classmethod instances(inputs, label=None)[source]#
Return the atmosphere stage of the array model.
The options are declared in the software catalog. Without
seed, the seed of each run is derived from the simulation seed and the run number.
- output_file(run_number)[source]#
Return the photon stream file written when the output is not streamed.
- prepare(run_number, input_file=None, output=None)[source]#
Return the shell line that runs the atmosphere propagation.
- Parameters:
- run_numberint
Run number.
- input_filestr or Path
Input photon stream file, or
STDINwhen reading a stream.- outputStreamTo or None
Downstream command receiving the output stream; None writes the output file.
- Returns:
- list[str]
One shell line.
- runners.atmosphere_stage.run_seed(base_seed, run_number)[source]#
Return the thinning seed of one run, derived from a base seed and the run number.
Runs with different run numbers or base seeds get independent random sequences; the same base seed and run number give the same seed.
- Parameters:
- base_seedint
Base seed (the sim_telarray simulation seed of the run).
- run_numberint
Run number.
- Returns:
- int
Seed of the obdeect propagation.
Parse and validate simulation chains: ordered stages, their options and efficiency factors.
- class runners.chain_spec.SimulationChain(stages, options=<factory>)[source]#
Ordered simulation stages and their options, checked when the chain is created.
The chain is valid if each stage consumes what the stage before it produces (with its options), no efficiency factor is applied twice, and a chain ending in camera events applies every efficiency factor required for its photon source.
- Parameters:
- stagestuple of str
Stage names in chain order, including the converter stages.
- optionsdict
Checked options of each stage, with their defaults, by stage name.
- applied_factors()[source]#
Return the efficiency factors applied by each stage: a list of (stage, factors).
A stage receives the factors applied by the stages before it, so that a stage leaves a factor to an upstream stage where its catalog entry allows it.
- property generates_air_showers#
Return whether the first stage generates air showers.
- property reads_input_file#
Return whether the first stage reads an input file (it generates no photons).
- runs(implementation)[source]#
Return whether a stage of the chain is run by an implementation (a stage class).
- property software#
Return the software needed by the stages of this chain.
- property source#
Return the kind of photons the first stage generates (None if it reads an input).
- property stage_classes#
Return the stage classes in chain order.
- stage_options(stage)[source]#
Return the checked options of a stage, with their defaults (empty if it has none).
- runners.chain_spec.parse_chain(items)[source]#
Return the simulation chain of a list of stage items.
Converter stages (role
converter) may be left out: between two stages whose data products differ, the one converter that fits is inserted. A converter is listed explicitly to give it options.- Parameters:
- itemsstr or list of str
Items
STAGEorSTAGE:KEY=VALUE[,KEY=VALUE...]in chain order.
- Returns:
- SimulationChain
Checked simulation chain.
- Raises:
- ValueError
If the list is empty, a stage is unknown or listed twice, an item or an option is malformed, more than one converter fits between two stages, or the chain is invalid.
Build calibration run scripts from explicitly ordered simulation stages.
- class runners.light_emission_runner.LightArray(telescope_models, site_model, model_version, site, sim_telarray_seed)[source]#
Models of the one telescope of a light-emission simulation (as an array model).
- class runners.light_emission_runner.LightPointing(zenith_angle, azimuth_angle)[source]#
Pointing of the telescope of a light-emission simulation (degrees).
- runners.light_emission_runner.build_chain_runner(calibration, items, label=None)[source]#
Return the chain runner of a light-emission simulation.
- Parameters:
- calibrationSimulatorLightEmission
Light-emission simulation of one telescope and one light source.
- itemslist of str
Stages of the chain, each
STAGEorSTAGE:KEY=VALUE,....- labelstr, optional
Label of the stages.
- Returns:
- ChainRunner
Chain runner.
- runners.light_emission_runner.check_light_chain(chain)[source]#
Check that a chain is a chain of a calibration light source.
- Parameters:
- chainSimulationChain
Chain to check.
- Raises:
- ValueError
If the chain does not start with a light-source stage or has an air-shower stage.
- runners.light_emission_runner.script_writer_for_chain(items)[source]#
Return the run-script writer of a configured simulation chain.
- Parameters:
- itemslist of str or None
Stages of the configured chain (
simulation_software).
- Returns:
- callable or None
None for the default chain (LightEmission program, then sim_telarray), which the light-emission simulation writes itself. Otherwise a picklable callable
writer(calibration, script_file)that writes the chain script withwrite_chain_script.
- runners.light_emission_runner.stage_inputs(calibration, chain)[source]#
Return the stage inputs of a light-emission simulation.
- Parameters:
- calibrationSimulatorLightEmission
Light-emission simulation of one telescope and one light source.
- chainSimulationChain
Simulation chain.
- Returns:
- StageInputs
Inputs of the stages; the telescope of the simulation is the only array element.
- runners.light_emission_runner.write_chain_script(calibration, items, script_file)[source]#
Write the run script of the stages of a chain for a light-emission simulation.
- Parameters:
- calibrationSimulatorLightEmission
Light-emission simulation of one telescope and one light source.
- itemslist of str
Stages of the chain, each
STAGEorSTAGE:KEY=VALUE,....- script_filestr or Path
Script to write.
- Returns:
- ChainRunner
Chain runner (file lists of the stages).
Calibration light sources as photon-stream stages and sim_telarray LightEmission stages.
- class runners.light_source_stages.LightEmissionStage(calibration)[source]#
LightEmission program of sim_telarray as the first stage of a chain.
The stage runs the program of the light source type of a
SimulatorLightEmissionand checks the IACT file it writes, which is handed over to the next stage.- Parameters:
- calibrationSimulatorLightEmission
Light-emission simulation of one telescope and one light source.
- classmethod instances(inputs, label=None)[source]#
Return the stage of the light-emission simulation of the run.
- prepare(run_number, input_file=None, output=None)[source]#
Return the shell lines that run the LightEmission program and check its output.
- Parameters:
- run_numberint
Run number (the file names are those of the light-emission simulation).
- input_fileNone
The program reads no input product.
- outputNone
The program writes the IACT file (see
output_file).
- Returns:
- list of str
Shell lines.
- class runners.light_source_stages.LightSourceStage(request, work_directory, file_token='', executable=None, simulation_models_path=None, run_files=None, context=None)[source]#
Light-source stage: photons of one calibration device seen by one telescope.
The light-source type is the catalog field
light_sourceof the stage (seelight_sourcesinresources/simulation_software.yml).- Parameters:
- requestFlasherRequest or IlluminatorRequest
Request of the source type.
- work_directorystr or Path
Directory of the tables of the source.
- file_tokenstr
Suffix of the table file names of this instance.
- executablestr, optional
Program of the source type (default: the one of the source type).
- simulation_models_pathstr or Path, optional
Simulation models (for sources that read model files).
- run_filesRunnerServices, optional
File naming of the run (output file when the output is not streamed).
- contextRunContext, optional
Run context (model reader of the simulation models, used by sources that read them).
- classmethod instances(inputs, label=None)[source]#
Return the stage of a run (one telescope and one light source).
- Parameters:
- inputsStageInputs
Run inputs; the arguments and the stage options define the light-emission run.
- labelstr, optional
Label of the models.
- Returns:
- list of LightSourceStage
One stage.
- output_file(run_number)[source]#
Return the photon-stream file written when the output is not streamed.
- prepare(run_number, input_file=None, output=None)[source]#
Return the shell lines that make the photons.
- Parameters:
- run_numberint
Run number.
- input_fileNone
A light source reads no input product.
- outputStreamTo or None
One downstream command receiving the photon stream; None writes the stream file (see
output_file).
- Returns:
- list of str
Shell lines.
Optics stage of the obdeect chain: mirrors, shadowing and telescope transmission.
- class runners.optics_stage.ObdeectOpticsStage(requests, telescope_models, run_files)[source]#
Optics of the telescopes of one array model, traced by one obdeect
trace-streamprocess.Each telescope has its own optical model; the process writes one camera-frame stream with the events in input order, so the stage streams to the camera stage.
- Parameters:
- requeststuple of OpticsRequest
Optics job of each telescope, in the order of the array.
- telescope_modelstuple of TelescopeModel
Model of each telescope (its optical model is compiled from it).
- run_filesRunnerServices
File naming of the run.
- classmethod instances(inputs, label=None)[source]#
Return the optics stage of the array model, tracing all telescopes of the array.
- prepare(run_number, input_file=None, output=None)[source]#
Write the optical models and return the shell line that traces the photons.
- Parameters:
- run_numberint
Run number.
- input_filestr or Path
Photon stream file, or
STDINwhen reading a stream.- outputStreamTo or None
Downstream command receiving the camera photons; None writes the output file.
- Returns:
- list[str]
One shell line.