gammasimtools 0.9.0__py3-none-any.whl → 0.11.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.9.0.dist-info → gammasimtools-0.11.0.dist-info}/METADATA +4 -2
- {gammasimtools-0.9.0.dist-info → gammasimtools-0.11.0.dist-info}/RECORD +133 -117
- {gammasimtools-0.9.0.dist-info → gammasimtools-0.11.0.dist-info}/WHEEL +1 -1
- {gammasimtools-0.9.0.dist-info → gammasimtools-0.11.0.dist-info}/entry_points.txt +6 -1
- simtools/_version.py +9 -4
- simtools/applications/calculate_trigger_rate.py +15 -38
- simtools/applications/convert_all_model_parameters_from_simtel.py +9 -29
- simtools/applications/convert_geo_coordinates_of_array_elements.py +47 -45
- simtools/applications/convert_model_parameter_from_simtel.py +2 -3
- simtools/applications/db_add_file_to_db.py +1 -3
- simtools/applications/db_add_simulation_model_from_repository_to_db.py +110 -0
- simtools/applications/db_add_value_from_json_to_db.py +1 -2
- simtools/applications/db_development_tools/write_array_elements_positions_to_repository.py +6 -6
- simtools/applications/db_get_file_from_db.py +11 -12
- simtools/applications/db_get_parameter_from_db.py +26 -35
- simtools/applications/derive_mirror_rnda.py +1 -2
- simtools/applications/derive_photon_electron_spectrum.py +99 -0
- simtools/applications/derive_psf_parameters.py +1 -0
- simtools/applications/docs_produce_array_element_report.py +71 -0
- simtools/applications/docs_produce_model_parameter_reports.py +63 -0
- simtools/applications/generate_array_config.py +17 -17
- simtools/applications/generate_corsika_histograms.py +2 -2
- simtools/applications/generate_regular_arrays.py +19 -17
- simtools/applications/generate_simtel_array_histograms.py +11 -48
- simtools/applications/production_derive_limits.py +95 -0
- simtools/applications/production_generate_simulation_config.py +37 -33
- simtools/applications/production_scale_events.py +4 -9
- simtools/applications/run_application.py +165 -0
- simtools/applications/simulate_light_emission.py +0 -4
- simtools/applications/simulate_prod.py +1 -1
- simtools/applications/simulate_prod_htcondor_generator.py +26 -26
- simtools/applications/submit_data_from_external.py +12 -4
- simtools/applications/submit_model_parameter_from_external.py +18 -11
- simtools/applications/validate_camera_efficiency.py +2 -2
- simtools/applications/validate_file_using_schema.py +26 -22
- simtools/camera/single_photon_electron_spectrum.py +168 -0
- simtools/configuration/commandline_parser.py +37 -1
- simtools/configuration/configurator.py +8 -10
- simtools/constants.py +10 -3
- simtools/corsika/corsika_config.py +19 -17
- simtools/corsika/corsika_histograms.py +5 -7
- simtools/corsika/corsika_histograms_visualize.py +2 -4
- simtools/data_model/data_reader.py +0 -3
- simtools/data_model/metadata_collector.py +20 -12
- simtools/data_model/metadata_model.py +8 -124
- simtools/data_model/model_data_writer.py +81 -75
- simtools/data_model/schema.py +220 -0
- simtools/data_model/validate_data.py +79 -68
- simtools/db/db_handler.py +350 -492
- simtools/db/db_model_upload.py +139 -0
- simtools/dependencies.py +112 -0
- simtools/io_operations/hdf5_handler.py +54 -24
- simtools/layout/array_layout.py +38 -32
- simtools/model/array_model.py +13 -7
- simtools/model/model_parameter.py +55 -54
- simtools/model/site_model.py +2 -2
- simtools/production_configuration/calculate_statistical_errors_grid_point.py +119 -145
- simtools/production_configuration/event_scaler.py +9 -35
- simtools/production_configuration/generate_simulation_config.py +9 -44
- simtools/production_configuration/interpolation_handler.py +9 -15
- simtools/production_configuration/limits_calculation.py +202 -0
- simtools/reporting/docs_read_parameters.py +310 -0
- simtools/runners/corsika_simtel_runner.py +4 -4
- simtools/schemas/{integration_tests_config.metaschema.yml → application_workflow.metaschema.yml} +61 -27
- simtools/schemas/array_elements.yml +8 -0
- simtools/schemas/input/MST_mirror_2f_measurements.schema.yml +39 -0
- simtools/schemas/input/single_pe_spectrum.schema.yml +38 -0
- simtools/schemas/model_parameter.metaschema.yml +103 -2
- simtools/schemas/model_parameter_and_data_schema.metaschema.yml +4 -1
- simtools/schemas/model_parameters/array_element_position_utm.schema.yml +1 -1
- simtools/schemas/model_parameters/array_window.schema.yml +37 -0
- simtools/schemas/model_parameters/asum_clipping.schema.yml +0 -4
- simtools/schemas/model_parameters/channels_per_chip.schema.yml +1 -1
- simtools/schemas/model_parameters/correct_nsb_spectrum_to_telescope_altitude.schema.yml +1 -1
- simtools/schemas/model_parameters/corsika_cherenkov_photon_bunch_size.schema.yml +2 -0
- simtools/schemas/model_parameters/corsika_cherenkov_photon_wavelength_range.schema.yml +2 -0
- simtools/schemas/model_parameters/corsika_first_interaction_height.schema.yml +2 -0
- simtools/schemas/model_parameters/corsika_iact_io_buffer.schema.yml +4 -2
- simtools/schemas/model_parameters/corsika_iact_max_bunches.schema.yml +2 -0
- simtools/schemas/model_parameters/corsika_iact_split_auto.schema.yml +2 -0
- simtools/schemas/model_parameters/corsika_longitudinal_shower_development.schema.yml +2 -0
- simtools/schemas/model_parameters/corsika_particle_kinetic_energy_cutoff.schema.yml +2 -0
- simtools/schemas/model_parameters/corsika_starting_grammage.schema.yml +2 -0
- simtools/schemas/model_parameters/dsum_clipping.schema.yml +0 -2
- simtools/schemas/model_parameters/dsum_ignore_below.schema.yml +0 -2
- simtools/schemas/model_parameters/dsum_offset.schema.yml +0 -2
- simtools/schemas/model_parameters/dsum_pedsub.schema.yml +0 -2
- simtools/schemas/model_parameters/dsum_pre_clipping.schema.yml +0 -2
- simtools/schemas/model_parameters/dsum_prescale.schema.yml +0 -2
- simtools/schemas/model_parameters/dsum_presum_max.schema.yml +0 -2
- simtools/schemas/model_parameters/dsum_presum_shift.schema.yml +0 -2
- simtools/schemas/model_parameters/dsum_shaping.schema.yml +0 -2
- simtools/schemas/model_parameters/dsum_shaping_renormalize.schema.yml +0 -2
- simtools/schemas/model_parameters/dsum_threshold.schema.yml +0 -2
- simtools/schemas/model_parameters/dsum_zero_clip.schema.yml +0 -2
- simtools/schemas/model_parameters/fadc_compensate_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_lg_compensate_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_noise.schema.yml +3 -3
- simtools/schemas/model_parameters/fake_mirror_list.schema.yml +33 -0
- simtools/schemas/model_parameters/iobuf_maximum.schema.yml +1 -1
- simtools/schemas/model_parameters/iobuf_output_maximum.schema.yml +1 -1
- simtools/schemas/model_parameters/laser_photons.schema.yml +2 -2
- simtools/schemas/model_parameters/lightguide_efficiency_vs_incidence_angle.schema.yml +1 -1
- simtools/schemas/model_parameters/lightguide_efficiency_vs_wavelength.schema.yml +1 -1
- simtools/schemas/model_parameters/min_photoelectrons.schema.yml +1 -1
- simtools/schemas/model_parameters/min_photons.schema.yml +1 -1
- simtools/schemas/model_parameters/random_generator.schema.yml +1 -1
- simtools/schemas/model_parameters/sampled_output.schema.yml +1 -1
- simtools/schemas/model_parameters/save_pe_with_amplitude.schema.yml +1 -1
- simtools/schemas/model_parameters/secondary_mirror_degraded_reflection.schema.yml +1 -1
- simtools/schemas/model_parameters/store_photoelectrons.schema.yml +1 -1
- simtools/schemas/model_parameters/tailcut_scale.schema.yml +1 -1
- simtools/schemas/production_configuration_metrics.schema.yml +68 -0
- simtools/schemas/production_tables.schema.yml +41 -0
- simtools/simtel/simtel_config_reader.py +1 -2
- simtools/simtel/simtel_config_writer.py +6 -8
- simtools/simtel/simtel_io_histogram.py +32 -68
- simtools/simtel/simtel_io_histograms.py +17 -34
- simtools/simtel/simulator_array.py +2 -1
- simtools/simtel/simulator_camera_efficiency.py +6 -3
- simtools/simtel/simulator_light_emission.py +5 -6
- simtools/simtel/simulator_ray_tracing.py +3 -4
- simtools/testing/configuration.py +2 -1
- simtools/testing/helpers.py +6 -13
- simtools/testing/validate_output.py +141 -47
- simtools/utils/general.py +114 -14
- simtools/utils/names.py +299 -157
- simtools/utils/value_conversion.py +17 -13
- simtools/version.py +2 -2
- simtools/visualization/legend_handlers.py +2 -0
- simtools/applications/db_add_model_parameters_from_repository_to_db.py +0 -176
- simtools/db/db_array_elements.py +0 -130
- {gammasimtools-0.9.0.dist-info → gammasimtools-0.11.0.dist-info}/LICENSE +0 -0
- {gammasimtools-0.9.0.dist-info → gammasimtools-0.11.0.dist-info}/top_level.txt +0 -0
- /simtools/{camera_efficiency.py → camera/camera_efficiency.py} +0 -0
|
@@ -72,14 +72,15 @@ class SimtelConfigWriter:
|
|
|
72
72
|
|
|
73
73
|
file.write("#ifdef TELESCOPE\n")
|
|
74
74
|
file.write(
|
|
75
|
-
f" echo Configuration for {self._telescope_model_name}"
|
|
76
|
-
" - TELESCOPE $(TELESCOPE)\n"
|
|
75
|
+
f" echo Configuration for {self._telescope_model_name} - TELESCOPE $(TELESCOPE)\n"
|
|
77
76
|
)
|
|
78
77
|
file.write("#endif\n\n")
|
|
79
78
|
|
|
80
79
|
for _simtel_name, value in parameters.items():
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
# array trigger is a site parameter, not a telescope parameter
|
|
81
|
+
# fake_mirror_list is not a sim_telarray parameter (used for testeff only)
|
|
82
|
+
if _simtel_name.startswith("array_trigger") or _simtel_name == "fake_mirror_list":
|
|
83
|
+
continue
|
|
83
84
|
if _simtel_name:
|
|
84
85
|
file.write(f"{_simtel_name} = {self._get_value_string_for_simtel(value)}\n")
|
|
85
86
|
_config_meta = self._get_simtel_metadata("telescope")
|
|
@@ -294,10 +295,7 @@ class SimtelConfigWriter:
|
|
|
294
295
|
_site_parameters = site_model.get_simtel_parameters()
|
|
295
296
|
for par, value in _site_parameters.items():
|
|
296
297
|
_simtel_name = names.get_simulation_software_name_from_parameter_name(
|
|
297
|
-
par,
|
|
298
|
-
simulation_software="sim_telarray",
|
|
299
|
-
search_telescope_parameters=False,
|
|
300
|
-
search_site_parameters=True,
|
|
298
|
+
par, simulation_software="sim_telarray"
|
|
301
299
|
)
|
|
302
300
|
_simtel_name, value = self._convert_model_parameters_to_simtel_format(
|
|
303
301
|
_simtel_name, value, model_path, telescope_model
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Reads the content of either a single histogram (.hdata) or a single simtel_array output (.simtel).
|
|
3
|
-
|
|
4
|
-
Files can be zst compressed.
|
|
5
|
-
"""
|
|
1
|
+
"""Reads the content of either a single histogram or simtel_array output file."""
|
|
6
2
|
|
|
7
3
|
import copy
|
|
8
4
|
import logging
|
|
@@ -81,9 +77,9 @@ class SimtelIOHistogram:
|
|
|
81
77
|
self._config = None
|
|
82
78
|
self._total_area = None
|
|
83
79
|
self._solid_angle = None
|
|
80
|
+
self._histogram = None
|
|
84
81
|
self._total_num_simulated_events = None
|
|
85
82
|
self._total_num_triggered_events = None
|
|
86
|
-
self._histogram = None
|
|
87
83
|
self._initialize_histogram()
|
|
88
84
|
self.trigger_rate = None
|
|
89
85
|
self.trigger_rate_uncertainty = None
|
|
@@ -134,56 +130,39 @@ class SimtelIOHistogram:
|
|
|
134
130
|
"""
|
|
135
131
|
Return information about the input parameters for the simulation.
|
|
136
132
|
|
|
133
|
+
If the file is a .hdata or .hdata.zst, config will be None.
|
|
134
|
+
|
|
137
135
|
Returns
|
|
138
136
|
-------
|
|
139
137
|
dict:
|
|
140
138
|
dictionary with information about the simulation (pyeventio MCRunHeader object).
|
|
141
139
|
"""
|
|
142
140
|
if self._config is None:
|
|
143
|
-
# If the file is a .hdata or .hdata.zst, config will continue to be None.
|
|
144
141
|
with EventIOFile(self.histogram_file) as f:
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
self._config = obj.parse()
|
|
149
|
-
|
|
142
|
+
self._config = next(
|
|
143
|
+
(obj.parse() for obj in f if isinstance(obj, MCRunHeader)), None
|
|
144
|
+
)
|
|
150
145
|
return self._config
|
|
151
146
|
|
|
152
147
|
@property
|
|
153
|
-
def
|
|
154
|
-
"""
|
|
155
|
-
Return the total number of simulated events the histograms.
|
|
156
|
-
|
|
157
|
-
Returns
|
|
158
|
-
-------
|
|
159
|
-
int:
|
|
160
|
-
total number of simulated events.
|
|
161
|
-
"""
|
|
162
|
-
if self._total_num_simulated_events is None:
|
|
163
|
-
events_histogram, _ = self.fill_event_histogram_dicts()
|
|
164
|
-
self._total_num_simulated_events = np.sum(events_histogram["data"])
|
|
165
|
-
logging.debug(f"Number of total simulated showers: {self._total_num_simulated_events}")
|
|
166
|
-
return self._total_num_simulated_events
|
|
167
|
-
|
|
168
|
-
@property
|
|
169
|
-
def total_num_triggered_events(self):
|
|
148
|
+
def total_number_of_events(self):
|
|
170
149
|
"""
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
Please note that this value is not supposed to match the trigger rate x estimated
|
|
174
|
-
observation time, as the simulation is optimized for computational time and the energy
|
|
175
|
-
distribution assumed is not necessarily the reference cosmic-ray spectra.
|
|
150
|
+
Return the total number of simulated and triggered events in the histograms.
|
|
176
151
|
|
|
177
152
|
Returns
|
|
178
153
|
-------
|
|
179
|
-
int:
|
|
180
|
-
total number of simulated events.
|
|
154
|
+
int, int:
|
|
155
|
+
total number of simulated and triggered events.
|
|
181
156
|
"""
|
|
182
|
-
if self._total_num_triggered_events is None:
|
|
183
|
-
|
|
157
|
+
if self._total_num_simulated_events is None or self._total_num_triggered_events is None:
|
|
158
|
+
simulated_histogram, trigger_histogram = self.fill_event_histogram_dicts()
|
|
159
|
+
self._total_num_simulated_events = np.sum(simulated_histogram["data"])
|
|
184
160
|
self._total_num_triggered_events = np.sum(trigger_histogram["data"])
|
|
185
|
-
logging.debug(
|
|
186
|
-
|
|
161
|
+
logging.debug(
|
|
162
|
+
"Number of total simulated / triggered events: "
|
|
163
|
+
f"{self._total_num_simulated_events} / {self._total_num_triggered_events}"
|
|
164
|
+
)
|
|
165
|
+
return self._total_num_simulated_events, self._total_num_triggered_events
|
|
187
166
|
|
|
188
167
|
def fill_event_histogram_dicts(self):
|
|
189
168
|
"""
|
|
@@ -191,34 +170,18 @@ class SimtelIOHistogram:
|
|
|
191
170
|
|
|
192
171
|
Returns
|
|
193
172
|
-------
|
|
194
|
-
dict:
|
|
195
|
-
Information about the histograms with simulated events.
|
|
196
|
-
dict:
|
|
197
|
-
Information about the histograms with triggered events.
|
|
173
|
+
tuple(dict, dict):
|
|
174
|
+
Information about the histograms with simulated and triggered events.
|
|
198
175
|
|
|
199
176
|
Raises
|
|
200
177
|
------
|
|
201
178
|
HistogramIdNotFoundError:
|
|
202
179
|
if histogram ids not found. Problem with the file.
|
|
203
180
|
"""
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
triggered_events_histogram = None
|
|
209
|
-
for hist in self.histogram:
|
|
210
|
-
if hist["id"] == 1:
|
|
211
|
-
events_histogram = hist
|
|
212
|
-
found_simulated_events_hist = True
|
|
213
|
-
elif hist["id"] == 2:
|
|
214
|
-
triggered_events_histogram = hist
|
|
215
|
-
found_triggered_events_hist = True
|
|
216
|
-
if found_simulated_events_hist * found_triggered_events_hist:
|
|
217
|
-
if "triggered_events_histogram" in locals():
|
|
218
|
-
return events_histogram, triggered_events_histogram
|
|
219
|
-
msg = "Histograms ids not found. Please check your files."
|
|
220
|
-
|
|
221
|
-
self._logger.error(msg)
|
|
181
|
+
histograms = {hist["id"]: hist for hist in self.histogram if hist["id"] in {1, 2}}
|
|
182
|
+
if 1 in histograms and 2 in histograms:
|
|
183
|
+
return histograms[1], histograms[2]
|
|
184
|
+
self._logger.error("Histograms ids not found. Please check your files.")
|
|
222
185
|
raise HistogramIdNotFoundError
|
|
223
186
|
|
|
224
187
|
def _set_view_cone(self, view_cone):
|
|
@@ -456,7 +419,6 @@ class SimtelIOHistogram:
|
|
|
456
419
|
return {
|
|
457
420
|
"simtel_array_file": self.histogram_file,
|
|
458
421
|
"simulation_input": self.print_info(mode="silent"),
|
|
459
|
-
# pylint: disable=E1101
|
|
460
422
|
"system_trigger_rate (Hz)": self.trigger_rate.value,
|
|
461
423
|
}
|
|
462
424
|
|
|
@@ -521,11 +483,11 @@ class SimtelIOHistogram:
|
|
|
521
483
|
"""
|
|
522
484
|
Get the particle distribution function.
|
|
523
485
|
|
|
524
|
-
This depends
|
|
486
|
+
This depends on whether one wants the reference CR distribution or the distribution
|
|
525
487
|
used in the simulation. This is controlled by label.
|
|
526
488
|
By using label="reference", one gets the distribution function according to a pre-defined CR
|
|
527
489
|
distribution, while by using label="simulation", the spectral index of the distribution
|
|
528
|
-
function from the simulation is used.
|
|
490
|
+
function from the simulation is used. The label="simulation" works only when the
|
|
529
491
|
input file is a .simtel file and not a .hdata file.
|
|
530
492
|
|
|
531
493
|
Parameters
|
|
@@ -603,7 +565,8 @@ class SimtelIOHistogram:
|
|
|
603
565
|
self.energy_range[1],
|
|
604
566
|
)
|
|
605
567
|
if stacked_num_simulated_events is None:
|
|
606
|
-
|
|
568
|
+
_simulated_events, _ = self.total_number_of_events
|
|
569
|
+
return (_simulated_events / first_estimate) * u.s
|
|
607
570
|
return (stacked_num_simulated_events / first_estimate) * u.s
|
|
608
571
|
|
|
609
572
|
def estimate_trigger_rate_uncertainty(
|
|
@@ -648,13 +611,14 @@ class SimtelIOHistogram:
|
|
|
648
611
|
dict:
|
|
649
612
|
Dictionary with the information, e.g., view angle, energy range, etc.
|
|
650
613
|
"""
|
|
614
|
+
_simulated, _triggered = self.total_number_of_events
|
|
651
615
|
info_dict = {
|
|
652
616
|
"view_cone": self.view_cone,
|
|
653
617
|
"solid_angle": self.solid_angle,
|
|
654
618
|
"total_area": self.total_area,
|
|
655
619
|
"energy_range": self.energy_range,
|
|
656
|
-
"total_num_simulated_events":
|
|
657
|
-
"total_num_triggered_events":
|
|
620
|
+
"total_num_simulated_events": _simulated,
|
|
621
|
+
"total_num_triggered_events": _triggered,
|
|
658
622
|
}
|
|
659
623
|
if mode != "silent":
|
|
660
624
|
print(info_dict)
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Reads the content of multiples files from sim_telarray.
|
|
3
|
-
|
|
4
|
-
Reads the content of either multiple histogram (.hdata, or .hdata.zst) or
|
|
5
|
-
simtel_array output files (.simtel or .simtel.zst). The module is built on top of the
|
|
6
|
-
simtel_io_histogram module and uses its class (SimtelIOHistogram) to read the individual files.
|
|
7
|
-
"""
|
|
1
|
+
"""Reads the content of multiples files from sim_telarray."""
|
|
8
2
|
|
|
9
3
|
import copy
|
|
10
4
|
import logging
|
|
@@ -192,8 +186,9 @@ class SimtelIOHistograms:
|
|
|
192
186
|
energy_range=self.energy_range,
|
|
193
187
|
view_cone=self.view_cone,
|
|
194
188
|
)
|
|
195
|
-
|
|
196
|
-
|
|
189
|
+
_simulated, _triggered = simtel_hist_instance.total_number_of_events
|
|
190
|
+
stacked_num_simulated_events += _simulated
|
|
191
|
+
stacked_num_triggered_events += _triggered
|
|
197
192
|
return stacked_num_simulated_events, stacked_num_triggered_events
|
|
198
193
|
|
|
199
194
|
def _rates_for_stacked_files(self):
|
|
@@ -224,8 +219,8 @@ class SimtelIOHistograms:
|
|
|
224
219
|
)
|
|
225
220
|
|
|
226
221
|
stacked_num_simulated_events, stacked_num_triggered_events = self.get_stacked_num_events()
|
|
227
|
-
logging.info("Total number of simulated events:
|
|
228
|
-
logging.info("Total number of triggered events:
|
|
222
|
+
logging.info(f"Total number of simulated events: {stacked_num_simulated_events} events")
|
|
223
|
+
logging.info(f"Total number of triggered events: {stacked_num_triggered_events} events")
|
|
229
224
|
obs_time = simtel_hist_instance.estimate_observation_time(stacked_num_simulated_events)
|
|
230
225
|
logging.info(
|
|
231
226
|
"Estimated equivalent observation time corresponding to the number of"
|
|
@@ -244,9 +239,7 @@ class SimtelIOHistograms:
|
|
|
244
239
|
)
|
|
245
240
|
logging.info(
|
|
246
241
|
f"System trigger event rate for stacked files: "
|
|
247
|
-
|
|
248
|
-
f"{triggered_event_rate.value:.4e} \u00B1 "
|
|
249
|
-
# pylint: disable=E1101
|
|
242
|
+
f"{triggered_event_rate.value:.4e} \u00b1 "
|
|
250
243
|
f"{triggered_event_rate_uncertainty.value:.4e} Hz"
|
|
251
244
|
)
|
|
252
245
|
return (
|
|
@@ -282,24 +275,17 @@ class SimtelIOHistograms:
|
|
|
282
275
|
if print_info:
|
|
283
276
|
simtel_hist_instance.print_info()
|
|
284
277
|
|
|
278
|
+
_simulated_events, _triggered_events = simtel_hist_instance.total_number_of_events
|
|
285
279
|
logging.info(f"Histogram {i_file + 1}:")
|
|
286
|
-
logging.info(
|
|
287
|
-
|
|
288
|
-
f"{simtel_hist_instance.total_num_simulated_events} events"
|
|
289
|
-
)
|
|
290
|
-
logging.info(
|
|
291
|
-
"Total number of triggered events: "
|
|
292
|
-
f"{simtel_hist_instance.total_num_triggered_events} events"
|
|
293
|
-
)
|
|
280
|
+
logging.info(f"Total number of simulated events: {_simulated_events} events")
|
|
281
|
+
logging.info(f"Total number of triggered events: {_triggered_events} events")
|
|
294
282
|
|
|
295
|
-
obs_time = simtel_hist_instance.estimate_observation_time(
|
|
296
|
-
simtel_hist_instance.total_num_simulated_events
|
|
297
|
-
)
|
|
283
|
+
obs_time = simtel_hist_instance.estimate_observation_time(_simulated_events)
|
|
298
284
|
logging.info(
|
|
299
285
|
f"Estimated equivalent observation time corresponding to the number of "
|
|
300
286
|
f"events simulated: {obs_time.value} s"
|
|
301
287
|
)
|
|
302
|
-
sim_event_rate =
|
|
288
|
+
sim_event_rate = _simulated_events / obs_time
|
|
303
289
|
sim_event_rates.append(sim_event_rate)
|
|
304
290
|
logging.info(f"Simulated event rate: {sim_event_rate.value:.4e} Hz")
|
|
305
291
|
|
|
@@ -310,7 +296,7 @@ class SimtelIOHistograms:
|
|
|
310
296
|
logging.info(
|
|
311
297
|
f"System trigger event rate: "
|
|
312
298
|
# pylint: disable=E1101
|
|
313
|
-
f"{triggered_event_rate.value:.4e} \
|
|
299
|
+
f"{triggered_event_rate.value:.4e} \u00b1 "
|
|
314
300
|
# pylint: disable=E1101
|
|
315
301
|
f"{triggered_event_rate_uncertainty.value:.4e} Hz"
|
|
316
302
|
)
|
|
@@ -515,15 +501,16 @@ class SimtelIOHistograms:
|
|
|
515
501
|
|
|
516
502
|
def export_histograms(self, hdf5_file_name, overwrite=False):
|
|
517
503
|
"""
|
|
518
|
-
Export
|
|
504
|
+
Export sim_telarray histograms to hdf5 files.
|
|
519
505
|
|
|
520
506
|
Parameters
|
|
521
507
|
----------
|
|
522
508
|
hdf5_file_name: str
|
|
523
509
|
Name of the file to be saved with the hdf5 tables.
|
|
524
510
|
overwrite: bool
|
|
525
|
-
If True overwrites
|
|
511
|
+
If True overwrites histograms already saved in the hdf5 file.
|
|
526
512
|
"""
|
|
513
|
+
self._logger.info(f"Exporting histograms to {hdf5_file_name}.")
|
|
527
514
|
for histogram in self.combined_hists:
|
|
528
515
|
x_bin_edges_list = np.linspace(
|
|
529
516
|
histogram["lower_x"],
|
|
@@ -556,14 +543,10 @@ class SimtelIOHistograms:
|
|
|
556
543
|
f"Writing histogram with name {self._meta_dict['Title']} to {hdf5_file_name}."
|
|
557
544
|
)
|
|
558
545
|
# overwrite takes precedence over append
|
|
559
|
-
if overwrite is True:
|
|
560
|
-
append = False
|
|
561
|
-
else:
|
|
562
|
-
append = True
|
|
563
546
|
write_table(
|
|
564
547
|
table,
|
|
565
548
|
hdf5_file_name,
|
|
566
549
|
f"/{self._meta_dict['Title']}",
|
|
567
|
-
append=
|
|
550
|
+
append=not overwrite,
|
|
568
551
|
overwrite=overwrite,
|
|
569
552
|
)
|
|
@@ -4,6 +4,7 @@ import logging
|
|
|
4
4
|
|
|
5
5
|
from simtools.io_operations import io_handler
|
|
6
6
|
from simtools.runners.simtel_runner import InvalidOutputFileError, SimtelRunner
|
|
7
|
+
from simtools.utils.general import clear_default_sim_telarray_cfg_directories
|
|
7
8
|
|
|
8
9
|
__all__ = ["SimulatorArray"]
|
|
9
10
|
|
|
@@ -88,7 +89,7 @@ class SimulatorArray(SimtelRunner):
|
|
|
88
89
|
command += f" {input_file}"
|
|
89
90
|
command += f" > {self._log_file} 2>&1 || exit"
|
|
90
91
|
|
|
91
|
-
return command
|
|
92
|
+
return clear_default_sim_telarray_cfg_directories(command)
|
|
92
93
|
|
|
93
94
|
def _check_run_result(self, run_number=None):
|
|
94
95
|
"""
|
|
@@ -72,9 +72,7 @@ class SimulatorCameraEfficiency(SimtelRunner):
|
|
|
72
72
|
/ Path(self._telescope_model.get_parameter_value("nsb_reference_spectrum")).name
|
|
73
73
|
)
|
|
74
74
|
|
|
75
|
-
def _make_run_command(
|
|
76
|
-
self, run_number=None, input_file=None
|
|
77
|
-
): # pylint: disable=unused-argument
|
|
75
|
+
def _make_run_command(self, run_number=None, input_file=None): # pylint: disable=unused-argument
|
|
78
76
|
"""Prepare the command used to run testeff."""
|
|
79
77
|
self._logger.debug("Preparing the command to run testeff")
|
|
80
78
|
|
|
@@ -135,6 +133,8 @@ class SimulatorCameraEfficiency(SimtelRunner):
|
|
|
135
133
|
command += f" {pixel_shape_cmd} {pixel_diameter}"
|
|
136
134
|
if mirror_class == 0:
|
|
137
135
|
command += f" -fmir {self._telescope_model.get_parameter_value('mirror_list')}"
|
|
136
|
+
if mirror_class == 2:
|
|
137
|
+
command += f" -fmir {self._telescope_model.get_parameter_value('fake_mirror_list')}"
|
|
138
138
|
command += f" -fref {mirror_reflectivity}"
|
|
139
139
|
if mirror_class == 2:
|
|
140
140
|
command += " -m2"
|
|
@@ -155,6 +155,9 @@ class SimulatorCameraEfficiency(SimtelRunner):
|
|
|
155
155
|
command += f" {self._telescope_model.get_parameter_value('atmospheric_profile')}"
|
|
156
156
|
command += f" {self.zenith_angle}"
|
|
157
157
|
|
|
158
|
+
# Remove the default sim_telarray configuration directories
|
|
159
|
+
command = general.clear_default_sim_telarray_cfg_directories(command)
|
|
160
|
+
|
|
158
161
|
return (
|
|
159
162
|
f"cd {self._simtel_path.joinpath('sim_telarray')} && {command}",
|
|
160
163
|
self._file_simtel,
|
|
@@ -9,6 +9,7 @@ import numpy as np
|
|
|
9
9
|
|
|
10
10
|
from simtools.io_operations import io_handler
|
|
11
11
|
from simtools.runners.simtel_runner import SimtelRunner
|
|
12
|
+
from simtools.utils.general import clear_default_sim_telarray_cfg_directories
|
|
12
13
|
|
|
13
14
|
__all__ = ["SimulatorLightEmission"]
|
|
14
15
|
|
|
@@ -233,7 +234,6 @@ class SimulatorLightEmission(SimtelRunner):
|
|
|
233
234
|
command += f"/{self.le_application[0]}"
|
|
234
235
|
|
|
235
236
|
if self.light_source_type == "led":
|
|
236
|
-
|
|
237
237
|
if self.le_application[1] == "variable":
|
|
238
238
|
command += f" -x {self.default_le_config['x_pos']['default'].to(u.cm).value}"
|
|
239
239
|
command += f" -y {self.default_le_config['y_pos']['default'].to(u.cm).value}"
|
|
@@ -244,7 +244,6 @@ class SimulatorLightEmission(SimtelRunner):
|
|
|
244
244
|
command += f" -n {self.photons_per_run}"
|
|
245
245
|
|
|
246
246
|
elif self.le_application[1] == "layout":
|
|
247
|
-
|
|
248
247
|
x_origin = x_cal - x_tel
|
|
249
248
|
y_origin = y_cal - y_tel
|
|
250
249
|
z_origin = z_cal - z_tel
|
|
@@ -290,7 +289,7 @@ class SimulatorLightEmission(SimtelRunner):
|
|
|
290
289
|
|
|
291
290
|
command += f" --telescope-theta {angle_theta}"
|
|
292
291
|
command += f" --telescope-phi {angle_phi}"
|
|
293
|
-
command += f" --laser-theta {90-angles[2]}"
|
|
292
|
+
command += f" --laser-theta {90 - angles[2]}"
|
|
294
293
|
command += f" --laser-phi {angles[3]}" # convention north (x) towards east (-y)
|
|
295
294
|
command += f" --atmosphere {_model_directory}/"
|
|
296
295
|
command += f"{self._telescope_model.get_parameter_value('atmospheric_profile')}"
|
|
@@ -351,8 +350,7 @@ class SimulatorLightEmission(SimtelRunner):
|
|
|
351
350
|
)
|
|
352
351
|
command += super().get_config_option(
|
|
353
352
|
"output_file",
|
|
354
|
-
f"{self.output_directory}/"
|
|
355
|
-
f"{self.le_application[0]}_{self.le_application[1]}.simtel.gz",
|
|
353
|
+
f"{self.output_directory}/{self.le_application[0]}_{self.le_application[1]}.simtel.gz",
|
|
356
354
|
)
|
|
357
355
|
command += super().get_config_option(
|
|
358
356
|
"histogram_file",
|
|
@@ -360,7 +358,8 @@ class SimulatorLightEmission(SimtelRunner):
|
|
|
360
358
|
f"{self.le_application[0]}_{self.le_application[1]}.ctsim.hdata\n",
|
|
361
359
|
)
|
|
362
360
|
|
|
363
|
-
|
|
361
|
+
# Remove the default sim_telarray configuration directories
|
|
362
|
+
return clear_default_sim_telarray_cfg_directories(command)
|
|
364
363
|
|
|
365
364
|
def _remove_line_from_config(self, file_path, line_prefix):
|
|
366
365
|
"""
|
|
@@ -8,6 +8,7 @@ import astropy.units as u
|
|
|
8
8
|
from simtools.io_operations import io_handler
|
|
9
9
|
from simtools.runners.simtel_runner import SimtelRunner
|
|
10
10
|
from simtools.utils import names
|
|
11
|
+
from simtools.utils.general import clear_default_sim_telarray_cfg_directories
|
|
11
12
|
|
|
12
13
|
__all__ = ["SimulatorRayTracing"]
|
|
13
14
|
|
|
@@ -135,9 +136,7 @@ class SimulatorRayTracing(SimtelRunner):
|
|
|
135
136
|
self._logger.debug("For single mirror mode, need to prepare the single pixel camera.")
|
|
136
137
|
self._write_out_single_pixel_camera_file()
|
|
137
138
|
|
|
138
|
-
def _make_run_command(
|
|
139
|
-
self, run_number=None, input_file=None
|
|
140
|
-
): # pylint: disable=unused-argument
|
|
139
|
+
def _make_run_command(self, run_number=None, input_file=None): # pylint: disable=unused-argument
|
|
141
140
|
"""Generate simtel_array run command."""
|
|
142
141
|
if self.config.single_mirror_mode:
|
|
143
142
|
# Note: no mirror length defined for dual-mirror telescopes
|
|
@@ -192,7 +191,7 @@ class SimulatorRayTracing(SimtelRunner):
|
|
|
192
191
|
command += super().get_config_option("mirror_align_random_vertical", "0.,28.,0.,0.")
|
|
193
192
|
command += " " + str(self._corsika_file)
|
|
194
193
|
|
|
195
|
-
return command, self._log_file, self._log_file
|
|
194
|
+
return clear_default_sim_telarray_cfg_directories(command), self._log_file, self._log_file
|
|
196
195
|
|
|
197
196
|
def _check_run_result(self, run_number=None): # pylint: disable=unused-argument
|
|
198
197
|
"""
|
|
@@ -71,7 +71,8 @@ def _read_configs_from_files(config_files):
|
|
|
71
71
|
_dict = gen.remove_substring_recursively_from_dict(
|
|
72
72
|
gen.collect_data_from_file(file_name=config_file), substring="\n"
|
|
73
73
|
)
|
|
74
|
-
|
|
74
|
+
for application in _dict.get("CTA_SIMPIPE", {}).get("APPLICATIONS", []):
|
|
75
|
+
configs.append(application)
|
|
75
76
|
return configs
|
|
76
77
|
|
|
77
78
|
|
simtools/testing/helpers.py
CHANGED
|
@@ -6,19 +6,12 @@ from pathlib import Path
|
|
|
6
6
|
|
|
7
7
|
def skip_camera_efficiency(config):
|
|
8
8
|
"""Skip camera efficiency tests if the old version of testeff is used."""
|
|
9
|
-
if "camera-efficiency" in config["APPLICATION"]:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
)
|
|
16
|
-
full_test_name = f"{config['APPLICATION']}_{config['TEST_NAME']}"
|
|
17
|
-
if "simtools-validate-camera-efficiency_SSTS" == full_test_name:
|
|
18
|
-
return (
|
|
19
|
-
"The test simtools-validate-camera-efficiency_SSTS is skipped "
|
|
20
|
-
"since the fake SST mirrors are not yet implemented (#1155)"
|
|
21
|
-
)
|
|
9
|
+
if "camera-efficiency" in config["APPLICATION"] and not _new_testeff_version():
|
|
10
|
+
return (
|
|
11
|
+
"Any applications calling the old version of testeff are skipped "
|
|
12
|
+
"due to a limitation of the old testeff not allowing to specify "
|
|
13
|
+
"the include directory. Please update your sim_telarray tarball."
|
|
14
|
+
)
|
|
22
15
|
return None
|
|
23
16
|
|
|
24
17
|
|