gammasimtools 0.26.0__py3-none-any.whl → 0.27.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.26.0.dist-info → gammasimtools-0.27.0.dist-info}/METADATA +5 -1
- {gammasimtools-0.26.0.dist-info → gammasimtools-0.27.0.dist-info}/RECORD +70 -66
- {gammasimtools-0.26.0.dist-info → gammasimtools-0.27.0.dist-info}/WHEEL +1 -1
- {gammasimtools-0.26.0.dist-info → gammasimtools-0.27.0.dist-info}/entry_points.txt +1 -1
- simtools/_version.py +2 -2
- simtools/applications/convert_geo_coordinates_of_array_elements.py +2 -1
- simtools/applications/db_get_array_layouts_from_db.py +1 -1
- simtools/applications/{calculate_incident_angles.py → derive_incident_angle.py} +16 -16
- simtools/applications/derive_mirror_rnda.py +111 -177
- simtools/applications/generate_corsika_histograms.py +38 -1
- simtools/applications/generate_regular_arrays.py +73 -36
- simtools/applications/simulate_flasher.py +3 -13
- simtools/applications/simulate_illuminator.py +2 -10
- simtools/applications/simulate_pedestals.py +1 -1
- simtools/applications/simulate_prod.py +8 -7
- simtools/applications/submit_data_from_external.py +2 -1
- simtools/applications/validate_camera_efficiency.py +28 -27
- simtools/applications/validate_cumulative_psf.py +1 -3
- simtools/applications/validate_optics.py +2 -1
- simtools/atmosphere.py +83 -0
- simtools/camera/camera_efficiency.py +171 -48
- simtools/camera/single_photon_electron_spectrum.py +6 -6
- simtools/configuration/commandline_parser.py +47 -9
- simtools/constants.py +5 -0
- simtools/corsika/corsika_config.py +88 -185
- simtools/corsika/corsika_histograms.py +246 -69
- simtools/data_model/model_data_writer.py +46 -49
- simtools/data_model/schema.py +2 -0
- simtools/db/db_handler.py +4 -2
- simtools/db/mongo_db.py +2 -2
- simtools/io/ascii_handler.py +51 -3
- simtools/io/io_handler.py +23 -12
- simtools/job_execution/job_manager.py +154 -79
- simtools/job_execution/process_pool.py +137 -0
- simtools/layout/array_layout.py +0 -1
- simtools/layout/array_layout_utils.py +143 -21
- simtools/model/array_model.py +22 -50
- simtools/model/calibration_model.py +4 -4
- simtools/model/model_parameter.py +123 -73
- simtools/model/model_utils.py +40 -1
- simtools/model/site_model.py +4 -4
- simtools/model/telescope_model.py +4 -5
- simtools/ray_tracing/incident_angles.py +87 -6
- simtools/ray_tracing/mirror_panel_psf.py +337 -217
- simtools/ray_tracing/psf_analysis.py +57 -42
- simtools/ray_tracing/psf_parameter_optimisation.py +3 -2
- simtools/ray_tracing/ray_tracing.py +37 -10
- simtools/runners/corsika_runner.py +52 -191
- simtools/runners/corsika_simtel_runner.py +74 -100
- simtools/runners/runner_services.py +214 -213
- simtools/runners/simtel_runner.py +27 -155
- simtools/runners/simtools_runner.py +9 -69
- simtools/schemas/application_workflow.metaschema.yml +8 -0
- simtools/settings.py +19 -0
- simtools/simtel/simtel_config_writer.py +0 -55
- simtools/simtel/simtel_seeds.py +184 -0
- simtools/simtel/simulator_array.py +115 -103
- simtools/simtel/simulator_camera_efficiency.py +66 -42
- simtools/simtel/simulator_light_emission.py +110 -123
- simtools/simtel/simulator_ray_tracing.py +78 -63
- simtools/simulator.py +135 -346
- simtools/testing/sim_telarray_metadata.py +13 -11
- simtools/testing/validate_output.py +87 -19
- simtools/utils/general.py +6 -17
- simtools/utils/random.py +36 -0
- simtools/visualization/plot_corsika_histograms.py +2 -0
- simtools/visualization/plot_incident_angles.py +48 -1
- simtools/visualization/plot_psf.py +160 -18
- {gammasimtools-0.26.0.dist-info → gammasimtools-0.27.0.dist-info}/licenses/LICENSE +0 -0
- {gammasimtools-0.26.0.dist-info → gammasimtools-0.27.0.dist-info}/top_level.txt +0 -0
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
import logging
|
|
4
4
|
import stat
|
|
5
|
-
from pathlib import Path
|
|
6
5
|
|
|
7
6
|
import simtools.utils.general as gen
|
|
8
7
|
from simtools import settings
|
|
9
|
-
from simtools.runners
|
|
8
|
+
from simtools.runners import corsika_runner, runner_services, simtel_runner
|
|
10
9
|
from simtools.simtel.simulator_array import SimulatorArray
|
|
11
10
|
|
|
12
11
|
|
|
@@ -24,42 +23,38 @@ class CorsikaSimtelRunner:
|
|
|
24
23
|
contain the CORSIKA configuration parameters.
|
|
25
24
|
label : str
|
|
26
25
|
Label.
|
|
27
|
-
keep_seeds : bool
|
|
28
|
-
Use seeds based on run number and primary particle. If False, use sim_telarray seeds.
|
|
29
26
|
use_multipipe : bool
|
|
30
27
|
Use multipipe to run CORSIKA and sim_telarray.
|
|
31
|
-
sim_telarray_seeds : dict
|
|
32
28
|
Dictionary with configuration for sim_telarray random instrument setup.
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
is_calibration_run : bool
|
|
30
|
+
Flag to indicate if this is a calibration run.
|
|
35
31
|
"""
|
|
36
32
|
|
|
37
33
|
def __init__(
|
|
38
34
|
self,
|
|
39
35
|
corsika_config,
|
|
40
36
|
label=None,
|
|
41
|
-
keep_seeds=False,
|
|
42
|
-
use_multipipe=False,
|
|
43
|
-
sim_telarray_seeds=None,
|
|
44
37
|
sequential=False,
|
|
45
|
-
calibration_config=None,
|
|
46
38
|
curved_atmosphere_min_zenith_angle=None,
|
|
39
|
+
is_calibration_run=False,
|
|
47
40
|
):
|
|
48
41
|
self._logger = logging.getLogger(__name__)
|
|
49
42
|
self.corsika_config = gen.ensure_iterable(corsika_config)
|
|
50
43
|
# the base corsika config is the one used to define the CORSIKA specific parameters.
|
|
51
44
|
# The others are used for the array configurations.
|
|
52
45
|
self.base_corsika_config = self.corsika_config[0]
|
|
53
|
-
self.sim_telarray_seeds = sim_telarray_seeds
|
|
54
46
|
self.label = label
|
|
55
47
|
self.sequential = "--sequential" if sequential else ""
|
|
56
48
|
|
|
57
|
-
self.
|
|
58
|
-
|
|
49
|
+
self.runner_service = runner_services.RunnerServices(
|
|
50
|
+
self.base_corsika_config, run_type="multi_pipe", label=label
|
|
51
|
+
)
|
|
52
|
+
self.file_list = None
|
|
53
|
+
|
|
54
|
+
self.corsika_runner = corsika_runner.CorsikaRunner(
|
|
59
55
|
corsika_config=self.base_corsika_config,
|
|
60
56
|
label=label,
|
|
61
|
-
|
|
62
|
-
use_multipipe=use_multipipe,
|
|
57
|
+
use_multipipe=True,
|
|
63
58
|
curved_atmosphere_min_zenith_angle=curved_atmosphere_min_zenith_angle,
|
|
64
59
|
)
|
|
65
60
|
# The simulator array should be defined for every CORSIKA configuration
|
|
@@ -70,15 +65,11 @@ class CorsikaSimtelRunner:
|
|
|
70
65
|
SimulatorArray(
|
|
71
66
|
corsika_config=_corsika_config,
|
|
72
67
|
label=label,
|
|
73
|
-
|
|
74
|
-
sim_telarray_seeds=sim_telarray_seeds,
|
|
75
|
-
calibration_config=calibration_config,
|
|
68
|
+
is_calibration_run=is_calibration_run,
|
|
76
69
|
)
|
|
77
70
|
)
|
|
78
71
|
|
|
79
|
-
def
|
|
80
|
-
self, run_number=None, input_file=None, extra_commands=None, use_pfp=False
|
|
81
|
-
):
|
|
72
|
+
def prepare_run(self, run_number=None, sub_script=None, corsika_file=None, extra_commands=None):
|
|
82
73
|
"""
|
|
83
74
|
Get the full path of the run script file for a given run number.
|
|
84
75
|
|
|
@@ -86,21 +77,24 @@ class CorsikaSimtelRunner:
|
|
|
86
77
|
----------
|
|
87
78
|
run_number: int
|
|
88
79
|
Run number.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
-------
|
|
94
|
-
Path:
|
|
95
|
-
Full path of the run script file.
|
|
80
|
+
corsika_file: str or Path
|
|
81
|
+
Path to the CORSIKA input file.
|
|
82
|
+
extra_commands: str
|
|
83
|
+
Additional commands for running simulations.
|
|
96
84
|
"""
|
|
85
|
+
self.file_list = self.runner_service.load_files(run_number=run_number)
|
|
97
86
|
self._export_multipipe_script(run_number)
|
|
98
|
-
|
|
87
|
+
self.corsika_runner.prepare_run(
|
|
99
88
|
run_number=run_number,
|
|
100
|
-
|
|
89
|
+
sub_script=sub_script,
|
|
90
|
+
corsika_file=self.runner_service.get_file_name(
|
|
91
|
+
file_type="multi_pipe_script", run_number=run_number
|
|
92
|
+
)
|
|
93
|
+
if not corsika_file
|
|
94
|
+
else corsika_file,
|
|
101
95
|
extra_commands=extra_commands,
|
|
102
|
-
use_pfp=use_pfp,
|
|
103
96
|
)
|
|
97
|
+
self.update_file_list_from_runners()
|
|
104
98
|
|
|
105
99
|
def _export_multipipe_script(self, run_number):
|
|
106
100
|
"""
|
|
@@ -116,44 +110,29 @@ class CorsikaSimtelRunner:
|
|
|
116
110
|
Path:
|
|
117
111
|
Full path of the run script file.
|
|
118
112
|
"""
|
|
119
|
-
multipipe_file =
|
|
120
|
-
|
|
113
|
+
multipipe_file = self.runner_service.get_file_name(
|
|
114
|
+
"multi_pipe_config", run_number=run_number
|
|
121
115
|
)
|
|
122
|
-
|
|
123
116
|
with open(multipipe_file, "w", encoding="utf-8") as file:
|
|
124
117
|
for simulator_array in self.simulator_array:
|
|
118
|
+
log_file = simulator_array.runner_service.get_file_name(
|
|
119
|
+
file_type="sim_telarray_log", run_number=run_number
|
|
120
|
+
)
|
|
125
121
|
run_command = simulator_array.make_run_command(
|
|
126
122
|
run_number=run_number,
|
|
127
|
-
input_file="-", # instruct sim_telarray to take input from
|
|
128
|
-
|
|
123
|
+
input_file="-", # instruct sim_telarray to take input from stdout
|
|
124
|
+
)
|
|
125
|
+
file.write(
|
|
126
|
+
f"{simtel_runner.sim_telarray_env_as_string()} "
|
|
127
|
+
+ " ".join(run_command)
|
|
128
|
+
+ f" | gzip > {log_file} 2>&1\n"
|
|
129
129
|
)
|
|
130
|
-
file.write(f"{run_command}")
|
|
131
130
|
file.write("\n")
|
|
132
|
-
self._logger.info(f"Multipipe script: {multipipe_file}")
|
|
133
|
-
self._write_multipipe_script(multipipe_file)
|
|
134
|
-
|
|
135
|
-
@staticmethod
|
|
136
|
-
def _determine_pointing_option(label):
|
|
137
|
-
"""
|
|
138
|
-
Determine the pointing option for sim_telarray.
|
|
139
131
|
|
|
140
|
-
|
|
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
|
|
132
|
+
self._logger.info(f"Multipipe script: {multipipe_file}")
|
|
133
|
+
self._write_multipipe_script(multipipe_file, run_number)
|
|
155
134
|
|
|
156
|
-
def _write_multipipe_script(self, multipipe_file):
|
|
135
|
+
def _write_multipipe_script(self, multipipe_file, run_number):
|
|
157
136
|
"""
|
|
158
137
|
Write script used to call the multipipe_corsika command.
|
|
159
138
|
|
|
@@ -161,9 +140,11 @@ class CorsikaSimtelRunner:
|
|
|
161
140
|
----------
|
|
162
141
|
multipipe_file: str or Path
|
|
163
142
|
The name of the multipipe file which contains all of the multipipe commands.
|
|
143
|
+
run_number: int
|
|
144
|
+
Run number.
|
|
164
145
|
"""
|
|
165
|
-
multipipe_script =
|
|
166
|
-
"
|
|
146
|
+
multipipe_script = self.runner_service.get_file_name(
|
|
147
|
+
"multi_pipe_script", run_number=run_number
|
|
167
148
|
)
|
|
168
149
|
with open(multipipe_script, "w", encoding="utf-8") as file:
|
|
169
150
|
multipipe_command = settings.config.sim_telarray_path.joinpath(
|
|
@@ -174,48 +155,41 @@ class CorsikaSimtelRunner:
|
|
|
174
155
|
|
|
175
156
|
multipipe_script.chmod(multipipe_script.stat().st_mode | stat.S_IEXEC)
|
|
176
157
|
|
|
177
|
-
def
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
mode=None,
|
|
183
|
-
model_version_index=0,
|
|
184
|
-
):
|
|
158
|
+
def get_resources(self, run_number=None):
|
|
159
|
+
"""Return computing resources used."""
|
|
160
|
+
return self.corsika_runner.get_resources(run_number)
|
|
161
|
+
|
|
162
|
+
def update_file_list_from_runners(self):
|
|
185
163
|
"""
|
|
186
|
-
Get
|
|
164
|
+
Get list of generated files (independent of type).
|
|
165
|
+
|
|
166
|
+
Includes file lists from all runners.
|
|
187
167
|
|
|
188
168
|
Parameters
|
|
189
169
|
----------
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
file_type: str
|
|
193
|
-
File type.
|
|
194
|
-
run_number: int
|
|
195
|
-
Run number.
|
|
196
|
-
mode: str
|
|
197
|
-
Mode to use for the file name.
|
|
198
|
-
model_version_index: int
|
|
199
|
-
Index of the model version.
|
|
200
|
-
This is used to select the correct simulator_array instance
|
|
201
|
-
in case multiple array models are simulated.
|
|
170
|
+
file_type : str
|
|
171
|
+
File type to be listed.
|
|
202
172
|
|
|
203
173
|
Returns
|
|
204
174
|
-------
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
"""
|
|
208
|
-
if simulation_software is None:
|
|
209
|
-
# preference to sim_telarray output (multipipe)
|
|
210
|
-
simulation_software = "sim_telarray" if self.simulator_array else "corsika"
|
|
211
|
-
|
|
212
|
-
runner = (
|
|
213
|
-
self.corsika_runner
|
|
214
|
-
if simulation_software == "corsika"
|
|
215
|
-
else self.simulator_array[model_version_index]
|
|
216
|
-
)
|
|
217
|
-
return runner.get_file_name(file_type=file_type, run_number=run_number, mode=mode)
|
|
175
|
+
list
|
|
176
|
+
List with the full path of all output files.
|
|
218
177
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
178
|
+
"""
|
|
179
|
+
if self.file_list is None:
|
|
180
|
+
self.file_list = self.corsika_runner.file_list
|
|
181
|
+
else:
|
|
182
|
+
self.file_list.update(self.corsika_runner.file_list)
|
|
183
|
+
|
|
184
|
+
for simulator_array in self.simulator_array:
|
|
185
|
+
_tmp_list = simulator_array.file_list
|
|
186
|
+
for key, data in _tmp_list.items():
|
|
187
|
+
if key in self.file_list:
|
|
188
|
+
# in case of multiple sim_telarray instances, make list of files
|
|
189
|
+
if not isinstance(self.file_list[key], list):
|
|
190
|
+
self.file_list[key] = [self.file_list[key]]
|
|
191
|
+
self.file_list[key].append(data)
|
|
192
|
+
else:
|
|
193
|
+
self.file_list[key] = [data]
|
|
194
|
+
|
|
195
|
+
return self.file_list
|