gammasimtools 0.15.0__py3-none-any.whl → 0.16.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {gammasimtools-0.15.0.dist-info → gammasimtools-0.16.0.dist-info}/METADATA +2 -32
- {gammasimtools-0.15.0.dist-info → gammasimtools-0.16.0.dist-info}/RECORD +222 -214
- {gammasimtools-0.15.0.dist-info → gammasimtools-0.16.0.dist-info}/WHEEL +1 -1
- {gammasimtools-0.15.0.dist-info → gammasimtools-0.16.0.dist-info}/entry_points.txt +5 -2
- simtools/_version.py +2 -2
- simtools/applications/calculate_trigger_rate.py +10 -10
- simtools/applications/convert_all_model_parameters_from_simtel.py +16 -16
- simtools/applications/convert_model_parameter_from_simtel.py +1 -1
- simtools/applications/derive_psf_parameters.py +12 -9
- simtools/applications/docs_produce_array_element_report.py +3 -3
- simtools/applications/docs_produce_calibration_reports.py +49 -0
- simtools/applications/docs_produce_simulation_configuration_report.py +50 -0
- simtools/applications/{generate_simtel_array_histograms.py → generate_sim_telarray_histograms.py} +2 -2
- simtools/applications/production_derive_corsika_limits.py +63 -10
- simtools/applications/production_derive_statistics.py +125 -0
- simtools/applications/production_generate_grid.py +197 -0
- simtools/applications/production_generate_simulation_config.py +0 -10
- simtools/applications/simulate_light_emission.py +5 -13
- simtools/applications/simulate_prod.py +16 -4
- simtools/applications/validate_cumulative_psf.py +6 -4
- simtools/applications/validate_file_using_schema.py +7 -3
- simtools/applications/validate_optics.py +5 -4
- simtools/camera/camera_efficiency.py +14 -39
- simtools/configuration/commandline_parser.py +4 -3
- simtools/configuration/configurator.py +10 -0
- simtools/corsika/corsika_config.py +103 -5
- simtools/data_model/format_checkers.py +9 -0
- simtools/data_model/model_data_writer.py +3 -0
- simtools/data_model/schema.py +27 -16
- simtools/data_model/validate_data.py +27 -7
- simtools/db/db_handler.py +10 -4
- simtools/layout/array_layout.py +1 -0
- simtools/model/array_model.py +63 -29
- simtools/model/model_parameter.py +76 -51
- simtools/model/model_utils.py +43 -1
- simtools/model/site_model.py +3 -2
- simtools/model/telescope_model.py +4 -4
- simtools/production_configuration/calculate_statistical_errors_grid_point.py +0 -4
- simtools/production_configuration/{event_scaler.py → derive_production_statistics.py} +24 -20
- simtools/production_configuration/derive_production_statistics_handler.py +119 -0
- simtools/production_configuration/generate_production_grid.py +364 -0
- simtools/production_configuration/generate_simulation_config.py +9 -9
- simtools/production_configuration/interpolation_handler.py +16 -11
- simtools/ray_tracing/mirror_panel_psf.py +16 -20
- simtools/ray_tracing/psf_analysis.py +2 -2
- simtools/ray_tracing/ray_tracing.py +5 -1
- simtools/reporting/docs_read_parameters.py +361 -58
- simtools/runners/corsika_runner.py +11 -1
- simtools/runners/corsika_simtel_runner.py +80 -89
- simtools/runners/runner_services.py +17 -4
- simtools/runners/simtel_runner.py +27 -10
- simtools/schemas/model_parameter.metaschema.yml +4 -0
- simtools/schemas/model_parameter_and_data_schema.metaschema.yml +1 -0
- simtools/schemas/model_parameters/adjust_gain.schema.yml +2 -2
- simtools/schemas/model_parameters/array_element_position_ground.schema.yml +2 -2
- simtools/schemas/model_parameters/array_element_position_utm.schema.yml +2 -2
- simtools/schemas/model_parameters/array_window.schema.yml +2 -2
- simtools/schemas/model_parameters/asum_offset.schema.yml +2 -2
- simtools/schemas/model_parameters/asum_shaping.schema.yml +2 -2
- simtools/schemas/model_parameters/asum_threshold.schema.yml +2 -2
- simtools/schemas/model_parameters/axes_offsets.schema.yml +2 -2
- simtools/schemas/model_parameters/camera_body_diameter.schema.yml +2 -2
- simtools/schemas/model_parameters/camera_body_shape.schema.yml +2 -2
- simtools/schemas/model_parameters/camera_config_file.schema.yml +2 -2
- simtools/schemas/model_parameters/camera_config_rotate.schema.yml +2 -2
- simtools/schemas/model_parameters/camera_degraded_efficiency.schema.yml +2 -2
- simtools/schemas/model_parameters/camera_degraded_map.schema.yml +2 -2
- simtools/schemas/model_parameters/camera_depth.schema.yml +2 -2
- simtools/schemas/model_parameters/camera_filter.schema.yml +2 -2
- simtools/schemas/model_parameters/camera_pixels.schema.yml +2 -2
- simtools/schemas/model_parameters/camera_transmission.schema.yml +2 -2
- simtools/schemas/model_parameters/channels_per_chip.schema.yml +2 -2
- simtools/schemas/model_parameters/correct_nsb_spectrum_to_telescope_altitude.schema.yml +2 -2
- simtools/schemas/model_parameters/corsika_starting_grammage.schema.yml +90 -1
- simtools/schemas/model_parameters/default_trigger.schema.yml +2 -2
- simtools/schemas/model_parameters/design_model.schema.yml +2 -2
- simtools/schemas/model_parameters/disc_ac_coupled.schema.yml +2 -2
- simtools/schemas/model_parameters/disc_bins.schema.yml +2 -2
- simtools/schemas/model_parameters/disc_start.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_amplitude.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_fall_time.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_gate_length.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_hysteresis.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_output_amplitude.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_output_var_percent.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_pulse_shape.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_rise_time.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_scale_threshold.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_sigsum_over_threshold.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_threshold.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_time_over_threshold.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_var_gate_length.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_var_sigsum_over_threshold.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_var_threshold.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_var_time_over_threshold.schema.yml +2 -2
- simtools/schemas/model_parameters/dish_shape_length.schema.yml +2 -2
- simtools/schemas/model_parameters/dsum_clipping.schema.yml +2 -2
- simtools/schemas/model_parameters/dsum_ignore_below.schema.yml +2 -2
- simtools/schemas/model_parameters/dsum_offset.schema.yml +2 -2
- simtools/schemas/model_parameters/dsum_pedsub.schema.yml +2 -2
- simtools/schemas/model_parameters/dsum_pre_clipping.schema.yml +2 -2
- simtools/schemas/model_parameters/dsum_prescale.schema.yml +2 -2
- simtools/schemas/model_parameters/dsum_presum_max.schema.yml +2 -2
- simtools/schemas/model_parameters/dsum_presum_shift.schema.yml +2 -2
- simtools/schemas/model_parameters/dsum_shaping.schema.yml +2 -2
- simtools/schemas/model_parameters/dsum_shaping_renormalize.schema.yml +2 -2
- simtools/schemas/model_parameters/dsum_threshold.schema.yml +3 -3
- simtools/schemas/model_parameters/dsum_zero_clip.schema.yml +2 -2
- simtools/schemas/model_parameters/effective_focal_length.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_ac_coupled.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_amplitude.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_bins.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_compensate_pedestal.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_err_compensate_pedestal.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_err_pedestal.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_lg_amplitude.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_lg_compensate_pedestal.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_lg_err_compensate_pedestal.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_lg_err_pedestal.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_lg_max_signal.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_lg_noise.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_lg_pedestal.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_lg_sensitivity.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_lg_sysvar_pedestal.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_lg_var_pedestal.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_lg_var_sensitivity.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_max_signal.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_mhz.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_noise.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_pedestal.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_pulse_shape.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_sensitivity.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_sum_bins.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_sum_offset.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_sysvar_pedestal.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_var_pedestal.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_var_sensitivity.schema.yml +2 -2
- simtools/schemas/model_parameters/fake_mirror_list.schema.yml +1 -1
- simtools/schemas/model_parameters/flatfielding.schema.yml +2 -2
- simtools/schemas/model_parameters/focal_length.schema.yml +2 -2
- simtools/schemas/model_parameters/focus_offset.schema.yml +2 -2
- simtools/schemas/model_parameters/gain_variation.schema.yml +2 -2
- simtools/schemas/model_parameters/hg_lg_variation.schema.yml +2 -2
- simtools/schemas/model_parameters/iobuf_maximum.schema.yml +2 -2
- simtools/schemas/model_parameters/iobuf_output_maximum.schema.yml +2 -2
- simtools/schemas/model_parameters/laser_events.schema.yml +1 -1
- simtools/schemas/model_parameters/lightguide_efficiency_vs_incidence_angle.schema.yml +2 -2
- simtools/schemas/model_parameters/lightguide_efficiency_vs_wavelength.schema.yml +2 -2
- simtools/schemas/model_parameters/min_photoelectrons.schema.yml +2 -2
- simtools/schemas/model_parameters/min_photons.schema.yml +2 -2
- simtools/schemas/model_parameters/mirror_align_random_distance.schema.yml +2 -2
- simtools/schemas/model_parameters/mirror_align_random_horizontal.schema.yml +2 -2
- simtools/schemas/model_parameters/mirror_align_random_vertical.schema.yml +2 -2
- simtools/schemas/model_parameters/mirror_class.schema.yml +2 -2
- simtools/schemas/model_parameters/mirror_degraded_reflection.schema.yml +2 -2
- simtools/schemas/model_parameters/mirror_focal_length.schema.yml +2 -2
- simtools/schemas/model_parameters/mirror_list.schema.yml +2 -2
- simtools/schemas/model_parameters/mirror_offset.schema.yml +2 -2
- simtools/schemas/model_parameters/mirror_reflection_random_angle.schema.yml +2 -2
- simtools/schemas/model_parameters/mirror_reflectivity.schema.yml +2 -2
- simtools/schemas/model_parameters/multiplicity_offset.schema.yml +2 -2
- simtools/schemas/model_parameters/muon_mono_threshold.schema.yml +2 -2
- simtools/schemas/model_parameters/nsb_autoscale_airmass.schema.yml +2 -2
- simtools/schemas/model_parameters/nsb_offaxis.schema.yml +2 -2
- simtools/schemas/model_parameters/nsb_pixel_rate.schema.yml +2 -2
- simtools/schemas/model_parameters/num_gains.schema.yml +2 -2
- simtools/schemas/model_parameters/only_triggered_telescopes.schema.yml +2 -2
- simtools/schemas/model_parameters/optics_properties.schema.yml +2 -2
- simtools/schemas/model_parameters/pedestal_events.schema.yml +7 -3
- simtools/schemas/model_parameters/photon_delay.schema.yml +2 -2
- simtools/schemas/model_parameters/pixeltrg_time_step.schema.yml +2 -2
- simtools/schemas/model_parameters/pm_average_gain.schema.yml +2 -2
- simtools/schemas/model_parameters/pm_collection_efficiency.schema.yml +2 -2
- simtools/schemas/model_parameters/pm_gain_index.schema.yml +2 -2
- simtools/schemas/model_parameters/pm_photoelectron_spectrum.schema.yml +2 -2
- simtools/schemas/model_parameters/pm_transit_time.schema.yml +2 -2
- simtools/schemas/model_parameters/pm_voltage_variation.schema.yml +2 -2
- simtools/schemas/model_parameters/primary_mirror_degraded_map.schema.yml +2 -2
- simtools/schemas/model_parameters/qe_variation.schema.yml +2 -2
- simtools/schemas/model_parameters/quantum_efficiency.schema.yml +2 -2
- simtools/schemas/model_parameters/random_focal_length.schema.yml +2 -2
- simtools/schemas/model_parameters/random_generator.schema.yml +2 -2
- simtools/schemas/model_parameters/random_mono_probability.schema.yml +2 -2
- simtools/schemas/model_parameters/sampled_output.schema.yml +2 -2
- simtools/schemas/model_parameters/save_pe_with_amplitude.schema.yml +2 -2
- simtools/schemas/model_parameters/store_photoelectrons.schema.yml +2 -2
- simtools/schemas/model_parameters/tailcut_scale.schema.yml +2 -2
- simtools/schemas/model_parameters/telescope_axis_height.schema.yml +2 -2
- simtools/schemas/model_parameters/telescope_random_angle.schema.yml +2 -2
- simtools/schemas/model_parameters/telescope_random_error.schema.yml +2 -2
- simtools/schemas/model_parameters/telescope_sphere_radius.schema.yml +2 -2
- simtools/schemas/model_parameters/telescope_transmission.schema.yml +2 -2
- simtools/schemas/model_parameters/teltrig_min_sigsum.schema.yml +2 -2
- simtools/schemas/model_parameters/teltrig_min_time.schema.yml +2 -2
- simtools/schemas/model_parameters/transit_time_calib_error.schema.yml +2 -2
- simtools/schemas/model_parameters/transit_time_compensate_error.schema.yml +2 -2
- simtools/schemas/model_parameters/transit_time_compensate_step.schema.yml +2 -2
- simtools/schemas/model_parameters/transit_time_error.schema.yml +2 -2
- simtools/schemas/model_parameters/transit_time_jitter.schema.yml +2 -2
- simtools/schemas/model_parameters/trigger_current_limit.schema.yml +2 -2
- simtools/schemas/model_parameters/trigger_delay_compensation.schema.yml +2 -2
- simtools/schemas/model_parameters/trigger_pixels.schema.yml +2 -2
- simtools/simtel/simtel_config_reader.py +21 -17
- simtools/simtel/simtel_config_writer.py +237 -65
- simtools/simtel/simtel_io_file_info.py +57 -0
- simtools/simtel/simtel_io_histogram.py +10 -14
- simtools/simtel/simtel_io_histograms.py +2 -2
- simtools/simtel/simtel_io_metadata.py +91 -0
- simtools/simtel/simulator_array.py +26 -12
- simtools/simtel/simulator_camera_efficiency.py +12 -6
- simtools/simtel/simulator_light_emission.py +6 -11
- simtools/simtel/simulator_ray_tracing.py +14 -4
- simtools/simulator.py +230 -66
- simtools/testing/configuration.py +5 -0
- simtools/testing/helpers.py +18 -0
- simtools/testing/sim_telarray_metadata.py +212 -0
- simtools/testing/validate_output.py +12 -5
- simtools/utils/general.py +18 -27
- simtools/utils/names.py +27 -5
- simtools/visualization/visualize.py +2 -2
- simtools/applications/production_scale_events.py +0 -185
- {gammasimtools-0.15.0.dist-info → gammasimtools-0.16.0.dist-info}/licenses/LICENSE +0 -0
- {gammasimtools-0.15.0.dist-info → gammasimtools-0.16.0.dist-info}/top_level.txt +0 -0
|
@@ -6,7 +6,6 @@ from pathlib import Path
|
|
|
6
6
|
|
|
7
7
|
from simtools.runners.corsika_runner import CorsikaRunner
|
|
8
8
|
from simtools.simtel.simulator_array import SimulatorArray
|
|
9
|
-
from simtools.utils.general import clear_default_sim_telarray_cfg_directories
|
|
10
9
|
|
|
11
10
|
__all__ = ["CorsikaSimtelRunner"]
|
|
12
11
|
|
|
@@ -20,8 +19,9 @@ class CorsikaSimtelRunner:
|
|
|
20
19
|
|
|
21
20
|
Parameters
|
|
22
21
|
----------
|
|
23
|
-
corsika_config : CorsikaConfig
|
|
24
|
-
|
|
22
|
+
corsika_config : CorsikaConfig or list of CorsikaConfig
|
|
23
|
+
A list of "CorsikaConfig" instances which
|
|
24
|
+
contain the CORSIKA configuration parameters.
|
|
25
25
|
simtel_path : str or Path
|
|
26
26
|
Location of the sim_telarray package.
|
|
27
27
|
label : str
|
|
@@ -30,6 +30,8 @@ class CorsikaSimtelRunner:
|
|
|
30
30
|
Use seeds based on run number and primary particle. If False, use sim_telarray seeds.
|
|
31
31
|
use_multipipe : bool
|
|
32
32
|
Use multipipe to run CORSIKA and sim_telarray.
|
|
33
|
+
sim_telarray_seeds : dict
|
|
34
|
+
Dictionary with configuration for sim_telarray random instrument setup.
|
|
33
35
|
"""
|
|
34
36
|
|
|
35
37
|
def __init__(
|
|
@@ -42,26 +44,37 @@ class CorsikaSimtelRunner:
|
|
|
42
44
|
sim_telarray_seeds=None,
|
|
43
45
|
):
|
|
44
46
|
self._logger = logging.getLogger(__name__)
|
|
45
|
-
self.corsika_config =
|
|
47
|
+
self.corsika_config = (
|
|
48
|
+
corsika_config if isinstance(corsika_config, list) else [corsika_config]
|
|
49
|
+
)
|
|
50
|
+
# the base corsika config is the one used to define the CORSIKA specific parameters.
|
|
51
|
+
# The others are used for the array configurations.
|
|
52
|
+
self.base_corsika_config = self.corsika_config[0]
|
|
46
53
|
self._simtel_path = simtel_path
|
|
47
54
|
self.sim_telarray_seeds = sim_telarray_seeds
|
|
48
55
|
self.label = label
|
|
49
56
|
|
|
50
|
-
self.
|
|
57
|
+
self.base_corsika_config.set_output_file_and_directory(use_multipipe)
|
|
51
58
|
self.corsika_runner = CorsikaRunner(
|
|
52
|
-
corsika_config=
|
|
59
|
+
corsika_config=self.base_corsika_config,
|
|
53
60
|
simtel_path=simtel_path,
|
|
54
61
|
label=label,
|
|
55
62
|
keep_seeds=keep_seeds,
|
|
56
63
|
use_multipipe=use_multipipe,
|
|
57
64
|
)
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
# The simulator array should be defined for every CORSIKA configuration
|
|
66
|
+
# because it allows to define multiple sim_telarray instances
|
|
67
|
+
self.simulator_array = []
|
|
68
|
+
for _corsika_config in self.corsika_config:
|
|
69
|
+
self.simulator_array.append(
|
|
70
|
+
SimulatorArray(
|
|
71
|
+
corsika_config=_corsika_config,
|
|
72
|
+
simtel_path=simtel_path,
|
|
73
|
+
label=label,
|
|
74
|
+
use_multipipe=use_multipipe,
|
|
75
|
+
sim_telarray_seeds=sim_telarray_seeds,
|
|
76
|
+
)
|
|
77
|
+
)
|
|
65
78
|
|
|
66
79
|
def prepare_run_script(
|
|
67
80
|
self, run_number=None, input_file=None, extra_commands=None, use_pfp=False
|
|
@@ -103,18 +116,43 @@ class CorsikaSimtelRunner:
|
|
|
103
116
|
Path:
|
|
104
117
|
Full path of the run script file.
|
|
105
118
|
"""
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
input_file="-", # instruct sim_telarray to take input from standard output
|
|
109
|
-
)
|
|
110
|
-
multipipe_file = Path(self.corsika_config.config_file_path.parent).joinpath(
|
|
111
|
-
self.corsika_config.get_corsika_config_file_name("multipipe")
|
|
119
|
+
multipipe_file = Path(self.base_corsika_config.config_file_path.parent).joinpath(
|
|
120
|
+
self.base_corsika_config.get_corsika_config_file_name("multipipe")
|
|
112
121
|
)
|
|
122
|
+
|
|
113
123
|
with open(multipipe_file, "w", encoding="utf-8") as file:
|
|
114
|
-
|
|
124
|
+
for simulator_array in self.simulator_array:
|
|
125
|
+
run_command = simulator_array.make_run_command(
|
|
126
|
+
run_number=run_number,
|
|
127
|
+
input_file="-", # instruct sim_telarray to take input from standard output
|
|
128
|
+
weak_pointing=self._determine_pointing_option(self.label),
|
|
129
|
+
)
|
|
130
|
+
file.write(f"{run_command}")
|
|
131
|
+
file.write("\n")
|
|
115
132
|
self._logger.info(f"Multipipe script: {multipipe_file}")
|
|
116
133
|
self._write_multipipe_script(multipipe_file)
|
|
117
134
|
|
|
135
|
+
@staticmethod
|
|
136
|
+
def _determine_pointing_option(label):
|
|
137
|
+
"""
|
|
138
|
+
Determine the pointing option for sim_telarray.
|
|
139
|
+
|
|
140
|
+
Parameters
|
|
141
|
+
----------
|
|
142
|
+
label: str
|
|
143
|
+
Label of the simulation.
|
|
144
|
+
|
|
145
|
+
Returns
|
|
146
|
+
-------
|
|
147
|
+
str:
|
|
148
|
+
Pointing option.
|
|
149
|
+
"""
|
|
150
|
+
try:
|
|
151
|
+
return any(pointing in label for pointing in ["divergent", "convergent"])
|
|
152
|
+
except TypeError: # allow for pointing_option to be None
|
|
153
|
+
pass
|
|
154
|
+
return False
|
|
155
|
+
|
|
118
156
|
def _write_multipipe_script(self, multipipe_file):
|
|
119
157
|
"""
|
|
120
158
|
Write script used to call the multipipe_corsika command.
|
|
@@ -124,7 +162,7 @@ class CorsikaSimtelRunner:
|
|
|
124
162
|
multipipe_file: str or Path
|
|
125
163
|
The name of the multipipe file which contains all of the multipipe commands.
|
|
126
164
|
"""
|
|
127
|
-
multipipe_script = Path(self.
|
|
165
|
+
multipipe_script = Path(self.base_corsika_config.config_file_path.parent).joinpath(
|
|
128
166
|
"run_cta_multipipe"
|
|
129
167
|
)
|
|
130
168
|
with open(multipipe_script, "w", encoding="utf-8") as file:
|
|
@@ -135,71 +173,14 @@ class CorsikaSimtelRunner:
|
|
|
135
173
|
|
|
136
174
|
multipipe_script.chmod(multipipe_script.stat().st_mode | stat.S_IEXEC)
|
|
137
175
|
|
|
138
|
-
def
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
input_file: str
|
|
147
|
-
Full path of the input CORSIKA file.
|
|
148
|
-
Use '-' to tell sim_telarray to read from standard output
|
|
149
|
-
|
|
150
|
-
Returns
|
|
151
|
-
-------
|
|
152
|
-
str:
|
|
153
|
-
Command to run sim_telarray.
|
|
154
|
-
"""
|
|
155
|
-
try:
|
|
156
|
-
weak_pointing = any(pointing in self.label for pointing in ["divergent", "convergent"])
|
|
157
|
-
except TypeError: # allow for self.label to be None
|
|
158
|
-
weak_pointing = False
|
|
159
|
-
|
|
160
|
-
command = str(self._simtel_path.joinpath("sim_telarray/bin/sim_telarray"))
|
|
161
|
-
command += f" -c {self.corsika_config.array_model.get_config_file()}"
|
|
162
|
-
command += f" -I{self.corsika_config.array_model.get_config_directory()}"
|
|
163
|
-
command += self.simulator_array.get_config_option(
|
|
164
|
-
"telescope_theta", self.corsika_config.zenith_angle, weak_option=weak_pointing
|
|
165
|
-
)
|
|
166
|
-
command += self.simulator_array.get_config_option(
|
|
167
|
-
"telescope_phi", self.corsika_config.azimuth_angle, weak_option=weak_pointing
|
|
168
|
-
)
|
|
169
|
-
command += self.simulator_array.get_config_option(
|
|
170
|
-
"power_law",
|
|
171
|
-
SimulatorArray.get_power_law_for_sim_telarray_histograms(
|
|
172
|
-
self.corsika_config.primary_particle
|
|
173
|
-
),
|
|
174
|
-
)
|
|
175
|
-
command += self.simulator_array.get_config_option(
|
|
176
|
-
"histogram_file",
|
|
177
|
-
self.get_file_name(
|
|
178
|
-
simulation_software="simtel", file_type="histogram", run_number=run_number
|
|
179
|
-
),
|
|
180
|
-
)
|
|
181
|
-
command += self.simulator_array.get_config_option("random_state", "none")
|
|
182
|
-
if self.sim_telarray_seeds:
|
|
183
|
-
command += self.simulator_array.get_config_option(
|
|
184
|
-
"random_seed", self.sim_telarray_seeds
|
|
185
|
-
)
|
|
186
|
-
command += self.simulator_array.get_config_option("show", "all")
|
|
187
|
-
command += self.simulator_array.get_config_option(
|
|
188
|
-
"output_file",
|
|
189
|
-
self.simulator_array.get_file_name(
|
|
190
|
-
simulation_software="simtel", file_type="output", run_number=run_number
|
|
191
|
-
),
|
|
192
|
-
)
|
|
193
|
-
command += f" {input_file}"
|
|
194
|
-
_log_file = self.simulator_array.get_file_name(
|
|
195
|
-
simulation_software="simtel", file_type="log", run_number=run_number
|
|
196
|
-
)
|
|
197
|
-
command += f" | gzip > {_log_file} 2>&1 || exit"
|
|
198
|
-
|
|
199
|
-
# Remove the default sim_telarray configuration directories
|
|
200
|
-
return clear_default_sim_telarray_cfg_directories(command)
|
|
201
|
-
|
|
202
|
-
def get_file_name(self, simulation_software=None, file_type=None, run_number=None, mode=None):
|
|
176
|
+
def get_file_name(
|
|
177
|
+
self,
|
|
178
|
+
simulation_software=None,
|
|
179
|
+
file_type=None,
|
|
180
|
+
run_number=None,
|
|
181
|
+
mode=None,
|
|
182
|
+
model_version_index=0,
|
|
183
|
+
):
|
|
203
184
|
"""
|
|
204
185
|
Get the full path of a file for a given run number.
|
|
205
186
|
|
|
@@ -211,6 +192,12 @@ class CorsikaSimtelRunner:
|
|
|
211
192
|
File type.
|
|
212
193
|
run_number: int
|
|
213
194
|
Run number.
|
|
195
|
+
mode: str
|
|
196
|
+
Mode to use for the file name.
|
|
197
|
+
model_version_index: int
|
|
198
|
+
Index of the model version.
|
|
199
|
+
This is used to select the correct simulator_array instance
|
|
200
|
+
in case multiple array models are simulated.
|
|
214
201
|
|
|
215
202
|
Returns
|
|
216
203
|
-------
|
|
@@ -218,8 +205,12 @@ class CorsikaSimtelRunner:
|
|
|
218
205
|
File name with full path.
|
|
219
206
|
"""
|
|
220
207
|
if simulation_software is None:
|
|
221
|
-
# preference to
|
|
222
|
-
simulation_software = "
|
|
208
|
+
# preference to sim_telarray output (multipipe)
|
|
209
|
+
simulation_software = "sim_telarray" if self.simulator_array else "corsika"
|
|
223
210
|
|
|
224
|
-
runner =
|
|
211
|
+
runner = (
|
|
212
|
+
self.corsika_runner
|
|
213
|
+
if simulation_software == "corsika"
|
|
214
|
+
else self.simulator_array[model_version_index]
|
|
215
|
+
)
|
|
225
216
|
return runner.get_file_name(file_type=file_type, run_number=run_number, mode=mode)
|
|
@@ -52,6 +52,7 @@ class RunnerServices:
|
|
|
52
52
|
"array_name": self.corsika_config.array_model.layout_name,
|
|
53
53
|
"site": self.corsika_config.array_model.site,
|
|
54
54
|
"label": self.label,
|
|
55
|
+
"model_version": self.corsika_config.array_model.model_version,
|
|
55
56
|
"zenith": self.corsika_config.zenith_angle,
|
|
56
57
|
"azimuth": self.corsika_config.azimuth_angle,
|
|
57
58
|
}
|
|
@@ -70,8 +71,8 @@ class RunnerServices:
|
|
|
70
71
|
"""
|
|
71
72
|
software_map = {
|
|
72
73
|
"corsika": ["corsika"],
|
|
73
|
-
"
|
|
74
|
-
"
|
|
74
|
+
"sim_telarray": ["sim_telarray"],
|
|
75
|
+
"corsika_sim_telarray": ["corsika", "sim_telarray"],
|
|
75
76
|
}
|
|
76
77
|
return software_map.get(simulation_software.lower(), [])
|
|
77
78
|
|
|
@@ -141,7 +142,8 @@ class RunnerServices:
|
|
|
141
142
|
return (
|
|
142
143
|
f"{run_dir}_{info_for_file_name['primary']}_"
|
|
143
144
|
f"za{round(zenith):02}deg_azm{azimuth:03}deg_"
|
|
144
|
-
f"{info_for_file_name['site']}_{info_for_file_name['array_name']}
|
|
145
|
+
f"{info_for_file_name['site']}_{info_for_file_name['array_name']}_"
|
|
146
|
+
f"{info_for_file_name['model_version']}{file_label}"
|
|
145
147
|
)
|
|
146
148
|
|
|
147
149
|
def _get_log_file_path(self, file_type, file_name):
|
|
@@ -220,7 +222,13 @@ class RunnerServices:
|
|
|
220
222
|
sub_log_file_dir.mkdir(parents=True, exist_ok=True)
|
|
221
223
|
return sub_log_file_dir.joinpath(f"sub_{file_name}{suffix}")
|
|
222
224
|
|
|
223
|
-
def get_file_name(
|
|
225
|
+
def get_file_name(
|
|
226
|
+
self,
|
|
227
|
+
file_type,
|
|
228
|
+
run_number=None,
|
|
229
|
+
mode=None,
|
|
230
|
+
_model_version_index=0,
|
|
231
|
+
): # pylint: disable=unused-argument
|
|
224
232
|
"""
|
|
225
233
|
Get a CORSIKA/sim_telarray style file name for various log and data file types.
|
|
226
234
|
|
|
@@ -232,6 +240,11 @@ class RunnerServices:
|
|
|
232
240
|
Run number.
|
|
233
241
|
mode: str
|
|
234
242
|
out or err (optional, relevant only for sub_log).
|
|
243
|
+
model_version_index: int
|
|
244
|
+
Index of the model version.
|
|
245
|
+
This is not used here, but in other implementations of this function is
|
|
246
|
+
used to select the correct simulator_array instance in case
|
|
247
|
+
multiple array models are simulated.
|
|
235
248
|
|
|
236
249
|
Returns
|
|
237
250
|
-------
|
|
@@ -12,7 +12,7 @@ __all__ = ["InvalidOutputFileError", "SimtelExecutionError", "SimtelRunner"]
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
class SimtelExecutionError(Exception):
|
|
15
|
-
"""Exception for
|
|
15
|
+
"""Exception for sim_telarray execution error."""
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
class InvalidOutputFileError(Exception):
|
|
@@ -21,7 +21,10 @@ class InvalidOutputFileError(Exception):
|
|
|
21
21
|
|
|
22
22
|
class SimtelRunner:
|
|
23
23
|
"""
|
|
24
|
-
Base class for running sim_telarray
|
|
24
|
+
Base class for running simulations based on the sim_telarray software stack.
|
|
25
|
+
|
|
26
|
+
The sim_telarray software stack includes sim_telarray itself and e.g., testeff,
|
|
27
|
+
LightEmission, and other software packages.
|
|
25
28
|
|
|
26
29
|
Parameters
|
|
27
30
|
----------
|
|
@@ -29,6 +32,10 @@ class SimtelRunner:
|
|
|
29
32
|
Location of sim_telarray installation.
|
|
30
33
|
label: str
|
|
31
34
|
Instance label. Important for output file naming.
|
|
35
|
+
corsika_config: CorsikaConfig
|
|
36
|
+
CORSIKA configuration.
|
|
37
|
+
use_multipipe: bool
|
|
38
|
+
Use multipipe to run CORSIKA and sim_telarray.
|
|
32
39
|
"""
|
|
33
40
|
|
|
34
41
|
def __init__(self, simtel_path, label=None, corsika_config=None, use_multipipe=False):
|
|
@@ -43,7 +50,7 @@ class SimtelRunner:
|
|
|
43
50
|
|
|
44
51
|
self.runner_service = RunnerServices(corsika_config, label)
|
|
45
52
|
self._directory = self.runner_service.load_data_directories(
|
|
46
|
-
"
|
|
53
|
+
"corsika_sim_telarray" if use_multipipe else "sim_telarray"
|
|
47
54
|
)
|
|
48
55
|
|
|
49
56
|
def __repr__(self):
|
|
@@ -70,12 +77,8 @@ class SimtelRunner:
|
|
|
70
77
|
Path
|
|
71
78
|
Full path of the run script.
|
|
72
79
|
"""
|
|
73
|
-
self._logger.debug("Creating run bash script")
|
|
74
|
-
|
|
75
80
|
script_file_path = self.get_file_name(file_type="sub_script", run_number=run_number)
|
|
76
|
-
|
|
77
81
|
self._logger.debug(f"Run bash script - {script_file_path}")
|
|
78
|
-
|
|
79
82
|
self._logger.debug(f"Extra commands to be added to the run script {extra_commands}")
|
|
80
83
|
|
|
81
84
|
command = self._make_run_command(run_number=run_number, input_file=input_file)
|
|
@@ -216,7 +219,14 @@ class SimtelRunner:
|
|
|
216
219
|
"""Return computing resources used."""
|
|
217
220
|
return self.runner_service.get_resources(run_number)
|
|
218
221
|
|
|
219
|
-
def get_file_name(
|
|
222
|
+
def get_file_name(
|
|
223
|
+
self,
|
|
224
|
+
simulation_software="sim_telarray",
|
|
225
|
+
file_type=None,
|
|
226
|
+
run_number=None,
|
|
227
|
+
mode="",
|
|
228
|
+
model_version_index=0,
|
|
229
|
+
):
|
|
220
230
|
"""
|
|
221
231
|
Get the full path of a file for a given run number.
|
|
222
232
|
|
|
@@ -228,16 +238,23 @@ class SimtelRunner:
|
|
|
228
238
|
File type.
|
|
229
239
|
run_number: int
|
|
230
240
|
Run number.
|
|
241
|
+
model_version_index: int
|
|
242
|
+
Index of the model version.
|
|
243
|
+
This is used to select the correct simulator_array instance in case
|
|
244
|
+
multiple array models are simulated.
|
|
231
245
|
|
|
232
246
|
Returns
|
|
233
247
|
-------
|
|
234
248
|
str
|
|
235
249
|
File name with full path.
|
|
236
250
|
"""
|
|
237
|
-
if simulation_software.lower() != "
|
|
251
|
+
if simulation_software.lower() != "sim_telarray":
|
|
238
252
|
raise ValueError(
|
|
239
253
|
f"simulation_software ({simulation_software}) is not supported in SimulatorArray"
|
|
240
254
|
)
|
|
241
255
|
return self.runner_service.get_file_name(
|
|
242
|
-
file_type=file_type,
|
|
256
|
+
file_type=file_type,
|
|
257
|
+
run_number=run_number,
|
|
258
|
+
mode=mode,
|
|
259
|
+
_model_version_index=model_version_index,
|
|
243
260
|
)
|