Simulator#

Base modules for calling external simulation software.

simulator#

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

exception simulator.InvalidRunsToSimulateError[source]#

Exception for invalid runs to simulate.

class simulator.Simulator(simulation_software, simulator_source_path, config_data, label=None, submit_command=None, extra_commands=None, mongo_db_config=None, model_version=None, test=False)[source]#

Simulator is responsible for managing simulation of showers and array of telescopes.

It interfaces with simulation software-specific packages, like CORSIKA or sim_telarray.

The configuration is set as a dict config_data or a yaml file config_file.

Example of config_data for shower simulations:

config_data = {
    'data_directory': '.',
    'site': 'South',
    'layout_name': 'Prod5',
    'run_range': [1, 100],
    'nshow': 10,
    'primary': 'gamma',
    'erange': [100 * u.GeV, 1 * u.TeV],
    'eslope': -2,
    'zenith': 20 * u.deg,
    'azimuth': 0 * u.deg,
    'viewcone': 0 * u.deg,
    'cscat': [10, 1500 * u.m, 0]
}

Example of config_data for array simulations:

config_data = {
    'data_directory': '(..)/data',
    'primary': 'gamma',
    'zenith': 20 * u.deg,
    'azimuth': 0 * u.deg,
    'viewcone': 0 * u.deg,
    # ArrayModel
    'site': 'North',
    'layout_name': '1LST',
    'model_version': 'Prod5',
    'default': {
        'LST': '1'
    },
    'MST-01': 'FlashCam-D'
}
Parameters:
simulation_software: str

Simulation software to be used (choices: [corsika, simtel, corsika_simtel])

simulator_source_path: str or Path

Location of executables for simulation software (e.g. path with CORSIKA or sim_telarray)

label: str

Instance label.

config_data: dict

Simulator configuration data.

submit_command: str

Job submission command.

extra_commands: str or list of str

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

mongo_db_config: dict

MongoDB configuration.

model_version: str

Simulation model version.

test: bool

If True, no jobs are submitted; only run scripts are prepared

file_list(input_file_list=None)[source]#

List output files obtained with simulation run.

Parameters:
input_file_list: str or list of str

Single file or list of files of shower simulations.

get_list_of_histogram_files()[source]#

Get list of histogram files.

(not applicable to all simulation types)

Returns:
list

List with the full path of all the histogram files.

get_list_of_input_files()[source]#

Get list of input files.

Returns:
list

List with the full path of all the input files.

get_list_of_log_files()[source]#

Get list of log files.

Returns:
list

List with the full path of all the log files.

get_list_of_output_files(run_list=None, run_range=None)[source]#

Get list of output files.

Parameters:
run_list: list

List of run numbers.

run_range: list

List of len 2 with the limits of the range of the run numbers.

Returns:
list

List with the full path of all the output files.

print_list_of_histogram_files()[source]#

Print list of histogram files.

print_list_of_input_files()[source]#

Print list of output files.

print_list_of_log_files()[source]#

Print list of log files.

print_list_of_output_files()[source]#

Print list of output files.

resources(input_file_list=None)[source]#

Print a simple report on computing resources used.

Includes run time per run only at this point.

Parameters:
input_file_list: str or list of str

Single file or list of files of shower simulations.

simulate(input_file_list=None)[source]#

Submit a run script as a job.

Parameters:
input_file_list: str or list of str

Single file or list of files of shower simulations.

property simulation_software#

The attribute simulation_software