Simulator#

Base modules for calling external simulation software.

simulator#

Simulator class for managing simulations of showers and array of telescopes.

class simulator.Simulator(label=None, extra_commands=None, model_reader=None, context=None)[source]#

Simulation of showers and of the array of telescopes.

Interface with the simulation software packages (e.g., CORSIKA or sim_telarray). A single run is simulated per instance, possibly for multiple model versions.

Parameters:
label: str

Instance label.

extra_commands: str or list of str

Extra commands to be added to the run script before the run command.

get_files(file_type)[source]#

Get file(s) generated by simulations (empty list for an unknown file type).

Parameters:
file_typestr

File type to be listed.

Returns:
Path or list[Path]:

Full path(s) of the output files of the given file type.

pack_for_register(directory_for_grid_upload=None)[source]#

Prepare simulation output files for registering on the grid.

Parameters:
directory_for_grid_uploadstr or pathlib.Path or None, optional

Output directory; defaults to the directory_for_grid_upload subdirectory.

report()[source]#

Report on the simulations and the computing resources used.

save_file_lists()[source]#

Save file lists for output and log files.

save_reduced_event_lists()[source]#

Save reduced event lists with event data on simulated and triggered events.

The files are saved using the configured simulation file list entries.

simulate()[source]#

Prepare and submit the run script as a job, then collect generated files.

classmethod simulate_direct_injection_sequence(label=None, context=None)[source]#

Run direct-injection simulations for one or several intensity settings.

This method supports filter-wheel-like sequences by allowing number_of_events and flasher_photons to be provided as either scalars or sequences. For multi-step runs, one value can be broadcast to all steps, or one value per step can be provided explicitly.

Parameters:
labelstr or None, optional

Simulation label passed to the simulator instance of each sequence step.

property simulation_software#

The attribute simulation_software.

update_file_lists()[source]#

Update file lists with the data, log, histogram and submission files.

validate_simulations()[source]#

Validate data, log and metadata of CORSIKA, sim_telarray and reduced event lists.

static write_reduced_event_lists(input_files=None, output_path=None, output_files=None, input_file_list=None, files_per_reduced_event_file=1, max_workers=1, backend='local', backend_config=None, wait_for_completion=True, array_models=None, input_file_list_pattern=None, file_format='eventio', context=None)[source]#

Write reduced event lists using the selected simulation-file reader.

Input files are passed directly or read from text files (one file per line), processed in batches with one output file written per batch.

Parameters:
input_fileslist

Simulation files in the selected input format.

output_pathstr or Path, optional

Output directory (default: the directory of each input file).

output_fileslist, optional

Explicit output files, zipped with the input file batches.

input_file_liststr or Path, optional

Text file containing one simulation file per line.

files_per_reduced_event_fileint, optional

Number of input files combined into each output file (default 1).

max_workersint, optional

Output-file worker processes (None: 60% of CPUs, 0: all CPUs, 1: serial).

array_modelslist, optional

ArrayModel instances exported into the simulation metadata.

input_file_list_patternstr, optional

Glob pattern of text files with one simulation file per line; each list is processed independently, all jobs share one execution submission.

backendstr, optional

Execution backend (default "local").

backend_configdict, optional

Backend-specific execution settings.

wait_for_completionbool, optional

Wait for all backend jobs; submit-only mode suits asynchronous backends.

contextRunContext, optional

Run context; its arguments build the embedded standard metadata.

Returns:
SubmissionHandle or None

Handle for submit-only execution; blocking execution returns None.

Raises:
ValueError

If the input parameters or number of explicit output files are invalid.