gammasimtools 0.15.0__py3-none-any.whl → 0.17.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.17.0.dist-info}/METADATA +5 -33
- {gammasimtools-0.15.0.dist-info → gammasimtools-0.17.0.dist-info}/RECORD +243 -229
- {gammasimtools-0.15.0.dist-info → gammasimtools-0.17.0.dist-info}/WHEEL +1 -1
- {gammasimtools-0.15.0.dist-info → gammasimtools-0.17.0.dist-info}/entry_points.txt +8 -3
- 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_ctao_array_layouts.py +5 -5
- 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/generate_simtel_event_data.py +36 -46
- simtools/applications/merge_tables.py +104 -0
- simtools/applications/plot_array_layout.py +145 -258
- simtools/applications/production_derive_corsika_limits.py +35 -167
- simtools/applications/production_derive_statistics.py +159 -0
- simtools/applications/production_generate_grid.py +197 -0
- simtools/applications/simulate_light_emission.py +6 -13
- simtools/applications/simulate_prod.py +45 -21
- simtools/applications/simulate_prod_htcondor_generator.py +0 -1
- simtools/applications/submit_array_layouts.py +93 -0
- 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/applications/verify_simulation_model_production_tables.py +52 -0
- simtools/camera/camera_efficiency.py +17 -42
- simtools/configuration/commandline_parser.py +32 -37
- simtools/configuration/configurator.py +10 -4
- simtools/corsika/corsika_config.py +120 -17
- simtools/corsika/primary_particle.py +46 -13
- simtools/data_model/format_checkers.py +9 -0
- simtools/data_model/metadata_collector.py +7 -3
- 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 +21 -15
- simtools/db/db_model_upload.py +2 -2
- simtools/io_operations/io_handler.py +2 -2
- simtools/io_operations/io_table_handler.py +345 -0
- simtools/job_execution/htcondor_script_generator.py +2 -2
- simtools/job_execution/job_manager.py +7 -121
- simtools/layout/array_layout.py +1 -0
- simtools/layout/array_layout_utils.py +385 -0
- simtools/model/array_model.py +68 -29
- simtools/model/model_parameter.py +76 -51
- simtools/model/model_repository.py +134 -0
- 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 → calculate_statistical_uncertainties_grid_point.py} +101 -116
- simtools/production_configuration/derive_corsika_limits.py +239 -111
- simtools/production_configuration/derive_corsika_limits_grid.py +189 -0
- simtools/production_configuration/derive_production_statistics.py +155 -0
- simtools/production_configuration/derive_production_statistics_handler.py +152 -0
- simtools/production_configuration/generate_production_grid.py +364 -0
- simtools/production_configuration/interpolation_handler.py +303 -96
- simtools/ray_tracing/mirror_panel_psf.py +16 -20
- simtools/ray_tracing/psf_analysis.py +2 -2
- simtools/ray_tracing/ray_tracing.py +12 -7
- simtools/reporting/docs_read_parameters.py +426 -81
- simtools/runners/corsika_runner.py +11 -1
- simtools/runners/corsika_simtel_runner.py +84 -90
- simtools/runners/runner_services.py +22 -8
- 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 +44 -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/schemas/production_configuration_metrics.schema.yml +2 -2
- simtools/simtel/simtel_config_reader.py +21 -17
- simtools/simtel/simtel_config_writer.py +258 -66
- simtools/simtel/simtel_io_event_reader.py +301 -194
- simtools/simtel/simtel_io_event_writer.py +207 -227
- simtools/simtel/simtel_io_file_info.py +62 -0
- simtools/simtel/simtel_io_histogram.py +10 -14
- simtools/simtel/simtel_io_histograms.py +2 -2
- simtools/simtel/simtel_io_metadata.py +106 -0
- simtools/simtel/simulator_array.py +28 -14
- simtools/simtel/simulator_camera_efficiency.py +12 -6
- simtools/simtel/simulator_light_emission.py +85 -45
- simtools/simtel/simulator_ray_tracing.py +16 -6
- simtools/simulator.py +286 -89
- 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 +16 -6
- simtools/utils/general.py +18 -27
- simtools/utils/names.py +32 -10
- simtools/visualization/plot_array_layout.py +242 -0
- simtools/visualization/plot_pixels.py +681 -0
- simtools/visualization/visualize.py +5 -221
- simtools/applications/production_generate_simulation_config.py +0 -162
- simtools/applications/production_scale_events.py +0 -185
- simtools/layout/ctao_array_layouts.py +0 -172
- simtools/production_configuration/event_scaler.py +0 -120
- simtools/production_configuration/generate_simulation_config.py +0 -158
- {gammasimtools-0.15.0.dist-info → gammasimtools-0.17.0.dist-info}/licenses/LICENSE +0 -0
- {gammasimtools-0.15.0.dist-info → gammasimtools-0.17.0.dist-info}/top_level.txt +0 -0
|
@@ -24,7 +24,8 @@ class ModelParameter:
|
|
|
24
24
|
"""
|
|
25
25
|
Base class for simulation model parameters.
|
|
26
26
|
|
|
27
|
-
Provides methods to read and manipulate parameters from DB
|
|
27
|
+
Provides methods to read and manipulate parameters from DB and to write
|
|
28
|
+
sim_telarray configuration files.
|
|
28
29
|
|
|
29
30
|
Parameters
|
|
30
31
|
----------
|
|
@@ -64,7 +65,7 @@ class ModelParameter:
|
|
|
64
65
|
)
|
|
65
66
|
|
|
66
67
|
self._parameters = {}
|
|
67
|
-
self._simulation_config_parameters = {
|
|
68
|
+
self._simulation_config_parameters = {sw: {} for sw in names.simulation_software()}
|
|
68
69
|
self.collection = collection
|
|
69
70
|
self.label = label
|
|
70
71
|
self.model_version = model_version
|
|
@@ -86,6 +87,34 @@ class ModelParameter:
|
|
|
86
87
|
self._is_config_file_up_to_date = False
|
|
87
88
|
self._is_exported_model_files_up_to_date = False
|
|
88
89
|
|
|
90
|
+
@property
|
|
91
|
+
def model_version(self):
|
|
92
|
+
"""Model version."""
|
|
93
|
+
return self._model_version
|
|
94
|
+
|
|
95
|
+
@model_version.setter
|
|
96
|
+
def model_version(self, model_version):
|
|
97
|
+
"""
|
|
98
|
+
Set model version.
|
|
99
|
+
|
|
100
|
+
Parameters
|
|
101
|
+
----------
|
|
102
|
+
model_version: str or list
|
|
103
|
+
Model version (e.g., "6.0.0").
|
|
104
|
+
If a list is passed, it must contain exactly one element,
|
|
105
|
+
and only that element will be used.
|
|
106
|
+
|
|
107
|
+
Raises
|
|
108
|
+
------
|
|
109
|
+
ValueError
|
|
110
|
+
If more than one model version is passed.
|
|
111
|
+
"""
|
|
112
|
+
if isinstance(model_version, list):
|
|
113
|
+
raise ValueError(
|
|
114
|
+
f"Only one model version can be passed to {self.__class__.__name__}, not a list."
|
|
115
|
+
)
|
|
116
|
+
self._model_version = model_version
|
|
117
|
+
|
|
89
118
|
@property
|
|
90
119
|
def parameters(self):
|
|
91
120
|
"""
|
|
@@ -279,7 +308,7 @@ class ModelParameter:
|
|
|
279
308
|
return
|
|
280
309
|
|
|
281
310
|
self._config_file_directory = self.io_handler.get_output_directory(
|
|
282
|
-
label=self.label, sub_dir="model"
|
|
311
|
+
label=self.label, sub_dir=f"model/{self.model_version}"
|
|
283
312
|
)
|
|
284
313
|
|
|
285
314
|
# Setting file name and the location
|
|
@@ -322,32 +351,19 @@ class ModelParameter:
|
|
|
322
351
|
simulation_software=simulation_software,
|
|
323
352
|
)
|
|
324
353
|
)
|
|
325
|
-
except ValueError
|
|
326
|
-
|
|
327
|
-
f"No {simulation_software} parameters found for "
|
|
328
|
-
f"{self.site}, {self.name} (model version {self.model_version}). "
|
|
329
|
-
f" (Query {exc})"
|
|
330
|
-
)
|
|
354
|
+
except ValueError:
|
|
355
|
+
pass
|
|
331
356
|
|
|
332
357
|
def _load_parameters_from_db(self):
|
|
333
358
|
"""Read parameters from DB and store them in _parameters."""
|
|
334
359
|
if self.db is None:
|
|
335
360
|
return
|
|
336
361
|
|
|
337
|
-
if self.name:
|
|
362
|
+
if self.name or self.site:
|
|
338
363
|
self._parameters = self.db.get_model_parameters(
|
|
339
364
|
self.site, self.name, self.collection, self.model_version
|
|
340
365
|
)
|
|
341
366
|
|
|
342
|
-
if self.site:
|
|
343
|
-
self._parameters.update(
|
|
344
|
-
self.db.get_model_parameters(
|
|
345
|
-
self.site,
|
|
346
|
-
None,
|
|
347
|
-
"sites",
|
|
348
|
-
self.model_version,
|
|
349
|
-
)
|
|
350
|
-
)
|
|
351
367
|
self._load_simulation_software_parameter()
|
|
352
368
|
|
|
353
369
|
@property
|
|
@@ -446,37 +462,66 @@ class ModelParameter:
|
|
|
446
462
|
file_path: str
|
|
447
463
|
Path of the file to be added to the config file directory.
|
|
448
464
|
"""
|
|
449
|
-
|
|
450
|
-
self._added_parameter_files = []
|
|
465
|
+
self._added_parameter_files = self._added_parameter_files or []
|
|
451
466
|
self._added_parameter_files.append(par_name)
|
|
452
467
|
shutil.copy(file_path, self.config_file_directory)
|
|
453
468
|
|
|
454
|
-
def export_model_files(self):
|
|
455
|
-
"""
|
|
469
|
+
def export_model_files(self, destination_path=None, update_if_necessary=False):
|
|
470
|
+
"""
|
|
471
|
+
Export the model files into the config file directory.
|
|
472
|
+
|
|
473
|
+
Parameters
|
|
474
|
+
----------
|
|
475
|
+
destination_path: str
|
|
476
|
+
Path to the directory where the model files should be exported.
|
|
477
|
+
If None, the config file directory is used.
|
|
478
|
+
update_if_necessary: bool
|
|
479
|
+
If True, the model files are only exported if they are not up to date.
|
|
480
|
+
"""
|
|
481
|
+
if self._is_exported_model_files_up_to_date and update_if_necessary:
|
|
482
|
+
self._logger.debug(
|
|
483
|
+
f"Model files for {self.name} are already exported to {self.config_file_directory}"
|
|
484
|
+
)
|
|
485
|
+
return
|
|
456
486
|
# Removing parameter files added manually (which are not in DB)
|
|
457
487
|
pars_from_db = copy(self.parameters)
|
|
458
488
|
if self._added_parameter_files is not None:
|
|
459
489
|
for par in self._added_parameter_files:
|
|
460
490
|
pars_from_db.pop(par)
|
|
461
491
|
|
|
462
|
-
self.db.export_model_files(
|
|
492
|
+
self.db.export_model_files(
|
|
493
|
+
parameters=pars_from_db,
|
|
494
|
+
dest=destination_path or self.config_file_directory,
|
|
495
|
+
)
|
|
463
496
|
self._is_exported_model_files_up_to_date = True
|
|
464
497
|
|
|
465
|
-
def
|
|
466
|
-
"""
|
|
467
|
-
|
|
468
|
-
|
|
498
|
+
def write_sim_telarray_config_file(self, additional_model=None):
|
|
499
|
+
"""
|
|
500
|
+
Write the sim_telarray configuration file.
|
|
501
|
+
|
|
502
|
+
Parameters
|
|
503
|
+
----------
|
|
504
|
+
additional_model: TelescopeModel or SiteModel
|
|
505
|
+
Model object for additional parameter to be written to the config file.
|
|
506
|
+
"""
|
|
507
|
+
self.parameters.update(self._simulation_config_parameters.get("sim_telarray", {}))
|
|
508
|
+
self.export_model_files(update_if_necessary=True)
|
|
509
|
+
|
|
510
|
+
if additional_model:
|
|
511
|
+
self.parameters.update(additional_model.parameters)
|
|
512
|
+
additional_model.export_model_files(
|
|
513
|
+
self.config_file_directory, update_if_necessary=True
|
|
514
|
+
)
|
|
469
515
|
|
|
470
516
|
self._load_simtel_config_writer()
|
|
471
517
|
self.simtel_config_writer.write_telescope_config_file(
|
|
472
518
|
config_file_path=self.config_file_path,
|
|
473
519
|
parameters=self.parameters,
|
|
474
|
-
config_parameters=self._simulation_config_parameters["simtel"],
|
|
475
520
|
)
|
|
476
521
|
|
|
477
522
|
@property
|
|
478
523
|
def config_file_directory(self):
|
|
479
|
-
"""Directory for
|
|
524
|
+
"""Directory for configuration files. Configure if not yet set."""
|
|
480
525
|
if self._config_file_directory is None:
|
|
481
526
|
self._set_config_file_directory_and_name()
|
|
482
527
|
return self._config_file_directory
|
|
@@ -488,26 +533,6 @@ class ModelParameter:
|
|
|
488
533
|
self._set_config_file_directory_and_name()
|
|
489
534
|
return self._config_file_path
|
|
490
535
|
|
|
491
|
-
def get_config_file(self, no_export=False):
|
|
492
|
-
"""
|
|
493
|
-
Get the path of the config file for sim_telarray.
|
|
494
|
-
|
|
495
|
-
The config file is produced if the file is not up to date.
|
|
496
|
-
|
|
497
|
-
Parameters
|
|
498
|
-
----------
|
|
499
|
-
no_export: bool
|
|
500
|
-
Turn it on if you do not want the file to be exported.
|
|
501
|
-
|
|
502
|
-
Returns
|
|
503
|
-
-------
|
|
504
|
-
Path
|
|
505
|
-
Path of the exported config file for sim_telarray.
|
|
506
|
-
"""
|
|
507
|
-
if not self._is_config_file_up_to_date and not no_export:
|
|
508
|
-
self.export_config_file()
|
|
509
|
-
return self.config_file_path
|
|
510
|
-
|
|
511
536
|
def _load_simtel_config_writer(self):
|
|
512
537
|
"""Load the SimtelConfigWriter object."""
|
|
513
538
|
if self.simtel_config_writer is None:
|
|
@@ -535,7 +560,7 @@ class ModelParameter:
|
|
|
535
560
|
self.db.export_model_files(
|
|
536
561
|
parameters={
|
|
537
562
|
"nsb_spectrum_at_2200m": {
|
|
538
|
-
"value": self._simulation_config_parameters["
|
|
563
|
+
"value": self._simulation_config_parameters["sim_telarray"][
|
|
539
564
|
"correct_nsb_spectrum_to_telescope_altitude"
|
|
540
565
|
]["value"],
|
|
541
566
|
"file": True,
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"""Utilities for managing the simulation models repository.
|
|
2
|
+
|
|
3
|
+
Simulation model parameters and production tables are managed through
|
|
4
|
+
a gitlab repository ('SimulationModels'). This module provides service
|
|
5
|
+
functions to interact with and verify the repository.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import logging
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
from simtools.utils import general as gen
|
|
12
|
+
from simtools.utils import names
|
|
13
|
+
|
|
14
|
+
_logger = logging.getLogger(__name__)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def verify_simulation_model_production_tables(simulation_models_path):
|
|
18
|
+
"""
|
|
19
|
+
Verify the simulation model production tables in the specified path.
|
|
20
|
+
|
|
21
|
+
Checks that all model parameters defined in the production tables are
|
|
22
|
+
present in the simulation models repository.
|
|
23
|
+
|
|
24
|
+
Parameters
|
|
25
|
+
----------
|
|
26
|
+
simulation_models_path : str
|
|
27
|
+
Path to the simulation models repository.
|
|
28
|
+
|
|
29
|
+
Returns
|
|
30
|
+
-------
|
|
31
|
+
bool
|
|
32
|
+
True if all parameters found, False if any missing.
|
|
33
|
+
"""
|
|
34
|
+
productions_path = Path(simulation_models_path) / "simulation-models" / "productions"
|
|
35
|
+
production_files = list(productions_path.rglob("*.json"))
|
|
36
|
+
|
|
37
|
+
_logger.info(
|
|
38
|
+
f"Verifying {len(production_files)} simulation model production "
|
|
39
|
+
f"tables in {simulation_models_path}"
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
missing_files = []
|
|
43
|
+
total_checked = 0
|
|
44
|
+
|
|
45
|
+
for production_file in production_files:
|
|
46
|
+
file_missing, file_checked = _verify_model_parameters_for_production(
|
|
47
|
+
simulation_models_path, production_file
|
|
48
|
+
)
|
|
49
|
+
missing_files.extend(file_missing)
|
|
50
|
+
total_checked += file_checked
|
|
51
|
+
|
|
52
|
+
_logger.info(f"Checked {total_checked} parameters, {len(missing_files)} missing")
|
|
53
|
+
|
|
54
|
+
if missing_files:
|
|
55
|
+
for missing_file in missing_files:
|
|
56
|
+
_logger.error(f"Missing: {missing_file}")
|
|
57
|
+
return False
|
|
58
|
+
|
|
59
|
+
_logger.info("Verification passed: All parameters found")
|
|
60
|
+
return True
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _verify_model_parameters_for_production(simulation_models_path, production_file):
|
|
64
|
+
"""
|
|
65
|
+
Verify that model parameters defined in the production tables exist.
|
|
66
|
+
|
|
67
|
+
Parameters
|
|
68
|
+
----------
|
|
69
|
+
simulation_models_path : str
|
|
70
|
+
Path to the simulation models repository.
|
|
71
|
+
production_file : Path
|
|
72
|
+
Path to the production file.
|
|
73
|
+
|
|
74
|
+
Returns
|
|
75
|
+
-------
|
|
76
|
+
tuple
|
|
77
|
+
(missing_files_list, total_checked_count)
|
|
78
|
+
"""
|
|
79
|
+
production_table = gen.collect_data_from_file(production_file)
|
|
80
|
+
missing_files = []
|
|
81
|
+
total_checked = 0
|
|
82
|
+
|
|
83
|
+
parameters = production_table.get("parameters", {})
|
|
84
|
+
for array_element, par_dict in parameters.items():
|
|
85
|
+
if isinstance(par_dict, dict):
|
|
86
|
+
for param_name, param_version in par_dict.items():
|
|
87
|
+
total_checked += 1
|
|
88
|
+
parameter_file = _get_model_parameter_file_path(
|
|
89
|
+
simulation_models_path, array_element, param_name, param_version
|
|
90
|
+
)
|
|
91
|
+
if parameter_file and not parameter_file.exists():
|
|
92
|
+
missing_files.append(str(parameter_file))
|
|
93
|
+
|
|
94
|
+
return missing_files, total_checked
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def _get_model_parameter_file_path(
|
|
98
|
+
simulation_models_path, array_element, parameter_name, parameter_version
|
|
99
|
+
):
|
|
100
|
+
"""
|
|
101
|
+
Get the file path for a model parameter.
|
|
102
|
+
|
|
103
|
+
Take into account path structure based on collections and array elements.
|
|
104
|
+
|
|
105
|
+
Parameters
|
|
106
|
+
----------
|
|
107
|
+
simulation_models_path : str
|
|
108
|
+
Path to the simulation models repository.
|
|
109
|
+
array_element : str
|
|
110
|
+
Name of the array element (e.g., 'telescope').
|
|
111
|
+
parameter_name : str
|
|
112
|
+
Name of the parameter.
|
|
113
|
+
parameter_version : str
|
|
114
|
+
Version of the parameter.
|
|
115
|
+
|
|
116
|
+
Returns
|
|
117
|
+
-------
|
|
118
|
+
Path
|
|
119
|
+
The file path to the model parameter JSON file.
|
|
120
|
+
"""
|
|
121
|
+
collection = names.get_collection_name_from_parameter_name(parameter_name)
|
|
122
|
+
return (
|
|
123
|
+
Path(simulation_models_path)
|
|
124
|
+
/ "simulation-models"
|
|
125
|
+
/ "model_parameters"
|
|
126
|
+
/ (
|
|
127
|
+
collection
|
|
128
|
+
if collection in ("configuration_sim_telarray", "configuration_corsika")
|
|
129
|
+
else ""
|
|
130
|
+
)
|
|
131
|
+
/ (array_element if collection != "configuration_corsika" else "")
|
|
132
|
+
/ parameter_name
|
|
133
|
+
/ f"{parameter_name}-{parameter_version}.json"
|
|
134
|
+
)
|
simtools/model/model_utils.py
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/python3
|
|
2
|
-
"""Helper functions
|
|
2
|
+
"""Helper functions related to model parameters."""
|
|
3
3
|
|
|
4
4
|
import math
|
|
5
5
|
|
|
6
|
+
from simtools.model.site_model import SiteModel
|
|
7
|
+
from simtools.model.telescope_model import TelescopeModel
|
|
6
8
|
from simtools.utils import names
|
|
7
9
|
|
|
8
10
|
__all__ = [
|
|
@@ -11,6 +13,46 @@ __all__ = [
|
|
|
11
13
|
]
|
|
12
14
|
|
|
13
15
|
|
|
16
|
+
def initialize_simulation_models(label, db_config, site, telescope_name, model_version):
|
|
17
|
+
"""
|
|
18
|
+
Initialize simulation models for a single telescope and site model.
|
|
19
|
+
|
|
20
|
+
Parameters
|
|
21
|
+
----------
|
|
22
|
+
label: str
|
|
23
|
+
Label for the simulation.
|
|
24
|
+
db_config: dict
|
|
25
|
+
Database configuration.
|
|
26
|
+
site: str
|
|
27
|
+
Name of the site.
|
|
28
|
+
telescope_name: str
|
|
29
|
+
Name of the telescope.
|
|
30
|
+
model_version: str
|
|
31
|
+
Version of the simulation model
|
|
32
|
+
|
|
33
|
+
Returns
|
|
34
|
+
-------
|
|
35
|
+
Tuple
|
|
36
|
+
Tuple containing the telescope model and site model.
|
|
37
|
+
"""
|
|
38
|
+
tel_model = TelescopeModel(
|
|
39
|
+
site=site,
|
|
40
|
+
telescope_name=telescope_name,
|
|
41
|
+
mongo_db_config=db_config,
|
|
42
|
+
model_version=model_version,
|
|
43
|
+
label=label,
|
|
44
|
+
)
|
|
45
|
+
site_model = SiteModel(
|
|
46
|
+
site=site,
|
|
47
|
+
model_version=model_version,
|
|
48
|
+
mongo_db_config=db_config,
|
|
49
|
+
label=label,
|
|
50
|
+
)
|
|
51
|
+
for model in tel_model, site_model:
|
|
52
|
+
model.export_model_files()
|
|
53
|
+
return tel_model, site_model
|
|
54
|
+
|
|
55
|
+
|
|
14
56
|
def compute_telescope_transmission(pars: list[float], off_axis: float) -> float:
|
|
15
57
|
"""
|
|
16
58
|
Compute telescope transmission (0 < T < 1) for a given off-axis angle.
|
simtools/model/site_model.py
CHANGED
|
@@ -19,8 +19,8 @@ class SiteModel(ModelParameter):
|
|
|
19
19
|
Site name (e.g., South or North).
|
|
20
20
|
mongo_db_config: dict
|
|
21
21
|
MongoDB configuration.
|
|
22
|
-
model_version: str
|
|
23
|
-
Model version.
|
|
22
|
+
model_version: str or list
|
|
23
|
+
Model version or list of model versions (in which case only the first one is used).
|
|
24
24
|
label: str, optional
|
|
25
25
|
Instance label. Important for output file naming.
|
|
26
26
|
"""
|
|
@@ -41,6 +41,7 @@ class SiteModel(ModelParameter):
|
|
|
41
41
|
model_version=model_version,
|
|
42
42
|
db=None,
|
|
43
43
|
label=label,
|
|
44
|
+
collection="sites",
|
|
44
45
|
)
|
|
45
46
|
|
|
46
47
|
def get_reference_point(self) -> dict:
|
|
@@ -220,8 +220,8 @@ class TelescopeModel(ModelParameter):
|
|
|
220
220
|
"""
|
|
221
221
|
try:
|
|
222
222
|
file_name = self.get_parameter_value(par)
|
|
223
|
-
except
|
|
224
|
-
logging.
|
|
223
|
+
except InvalidModelParameterError:
|
|
224
|
+
logging.warning(f"Parameter {par} does not exist")
|
|
225
225
|
return False
|
|
226
226
|
|
|
227
227
|
file = self.config_file_directory.joinpath(file_name)
|
|
@@ -269,11 +269,11 @@ class TelescopeModel(ModelParameter):
|
|
|
269
269
|
self.config_file_directory.joinpath(self.get_parameter_value("optics_properties"))
|
|
270
270
|
)
|
|
271
271
|
if not np.isclose(ray_tracing_data["Off-axis angle"][0], 0):
|
|
272
|
-
|
|
272
|
+
msg = (
|
|
273
273
|
f"No value for the on-axis effective optical area exists."
|
|
274
274
|
f" The minimum off-axis angle is {ray_tracing_data['Off-axis angle'][0]}"
|
|
275
275
|
)
|
|
276
|
-
raise ValueError
|
|
276
|
+
raise ValueError(msg)
|
|
277
277
|
return ray_tracing_data["eff_area"][0]
|
|
278
278
|
|
|
279
279
|
def read_incidence_angle_distribution(self, incidence_angle_dist_file: str) -> Table:
|