gammasimtools 0.14.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.
Files changed (223) hide show
  1. {gammasimtools-0.14.0.dist-info → gammasimtools-0.16.0.dist-info}/METADATA +2 -32
  2. {gammasimtools-0.14.0.dist-info → gammasimtools-0.16.0.dist-info}/RECORD +222 -214
  3. {gammasimtools-0.14.0.dist-info → gammasimtools-0.16.0.dist-info}/WHEEL +1 -1
  4. {gammasimtools-0.14.0.dist-info → gammasimtools-0.16.0.dist-info}/entry_points.txt +5 -2
  5. simtools/_version.py +2 -2
  6. simtools/applications/calculate_trigger_rate.py +10 -10
  7. simtools/applications/convert_all_model_parameters_from_simtel.py +16 -16
  8. simtools/applications/convert_model_parameter_from_simtel.py +1 -1
  9. simtools/applications/derive_psf_parameters.py +12 -9
  10. simtools/applications/docs_produce_array_element_report.py +3 -3
  11. simtools/applications/docs_produce_calibration_reports.py +49 -0
  12. simtools/applications/docs_produce_simulation_configuration_report.py +50 -0
  13. simtools/applications/{generate_simtel_array_histograms.py → generate_sim_telarray_histograms.py} +2 -2
  14. simtools/applications/production_derive_corsika_limits.py +63 -10
  15. simtools/applications/production_derive_statistics.py +125 -0
  16. simtools/applications/production_generate_grid.py +197 -0
  17. simtools/applications/production_generate_simulation_config.py +0 -10
  18. simtools/applications/simulate_light_emission.py +5 -13
  19. simtools/applications/simulate_prod.py +16 -4
  20. simtools/applications/validate_cumulative_psf.py +6 -4
  21. simtools/applications/validate_file_using_schema.py +7 -3
  22. simtools/applications/validate_optics.py +5 -4
  23. simtools/camera/camera_efficiency.py +14 -39
  24. simtools/configuration/commandline_parser.py +4 -3
  25. simtools/configuration/configurator.py +10 -0
  26. simtools/corsika/corsika_config.py +103 -5
  27. simtools/data_model/format_checkers.py +9 -0
  28. simtools/data_model/model_data_writer.py +3 -0
  29. simtools/data_model/schema.py +27 -16
  30. simtools/data_model/validate_data.py +27 -7
  31. simtools/db/db_handler.py +10 -4
  32. simtools/layout/array_layout.py +1 -0
  33. simtools/model/array_model.py +63 -29
  34. simtools/model/model_parameter.py +76 -51
  35. simtools/model/model_utils.py +43 -1
  36. simtools/model/site_model.py +3 -2
  37. simtools/model/telescope_model.py +4 -4
  38. simtools/production_configuration/calculate_statistical_errors_grid_point.py +0 -4
  39. simtools/production_configuration/{event_scaler.py → derive_production_statistics.py} +24 -20
  40. simtools/production_configuration/derive_production_statistics_handler.py +119 -0
  41. simtools/production_configuration/generate_production_grid.py +364 -0
  42. simtools/production_configuration/generate_simulation_config.py +9 -9
  43. simtools/production_configuration/interpolation_handler.py +16 -11
  44. simtools/ray_tracing/mirror_panel_psf.py +16 -20
  45. simtools/ray_tracing/psf_analysis.py +2 -2
  46. simtools/ray_tracing/ray_tracing.py +5 -1
  47. simtools/reporting/docs_read_parameters.py +361 -58
  48. simtools/runners/corsika_runner.py +11 -1
  49. simtools/runners/corsika_simtel_runner.py +80 -89
  50. simtools/runners/runner_services.py +17 -4
  51. simtools/runners/simtel_runner.py +27 -10
  52. simtools/schemas/model_parameter.metaschema.yml +4 -0
  53. simtools/schemas/model_parameter_and_data_schema.metaschema.yml +1 -0
  54. simtools/schemas/model_parameters/adjust_gain.schema.yml +2 -2
  55. simtools/schemas/model_parameters/array_element_position_ground.schema.yml +2 -2
  56. simtools/schemas/model_parameters/array_element_position_utm.schema.yml +2 -2
  57. simtools/schemas/model_parameters/array_window.schema.yml +2 -2
  58. simtools/schemas/model_parameters/asum_offset.schema.yml +2 -2
  59. simtools/schemas/model_parameters/asum_shaping.schema.yml +2 -2
  60. simtools/schemas/model_parameters/asum_threshold.schema.yml +2 -2
  61. simtools/schemas/model_parameters/axes_offsets.schema.yml +2 -2
  62. simtools/schemas/model_parameters/camera_body_diameter.schema.yml +2 -2
  63. simtools/schemas/model_parameters/camera_body_shape.schema.yml +2 -2
  64. simtools/schemas/model_parameters/camera_config_file.schema.yml +2 -2
  65. simtools/schemas/model_parameters/camera_config_rotate.schema.yml +2 -2
  66. simtools/schemas/model_parameters/camera_degraded_efficiency.schema.yml +2 -2
  67. simtools/schemas/model_parameters/camera_degraded_map.schema.yml +2 -2
  68. simtools/schemas/model_parameters/camera_depth.schema.yml +2 -2
  69. simtools/schemas/model_parameters/camera_filter.schema.yml +2 -2
  70. simtools/schemas/model_parameters/camera_pixels.schema.yml +2 -2
  71. simtools/schemas/model_parameters/camera_transmission.schema.yml +2 -2
  72. simtools/schemas/model_parameters/channels_per_chip.schema.yml +2 -2
  73. simtools/schemas/model_parameters/correct_nsb_spectrum_to_telescope_altitude.schema.yml +2 -2
  74. simtools/schemas/model_parameters/corsika_starting_grammage.schema.yml +90 -1
  75. simtools/schemas/model_parameters/default_trigger.schema.yml +2 -2
  76. simtools/schemas/model_parameters/design_model.schema.yml +2 -2
  77. simtools/schemas/model_parameters/disc_ac_coupled.schema.yml +2 -2
  78. simtools/schemas/model_parameters/disc_bins.schema.yml +2 -2
  79. simtools/schemas/model_parameters/disc_start.schema.yml +2 -2
  80. simtools/schemas/model_parameters/discriminator_amplitude.schema.yml +2 -2
  81. simtools/schemas/model_parameters/discriminator_fall_time.schema.yml +2 -2
  82. simtools/schemas/model_parameters/discriminator_gate_length.schema.yml +2 -2
  83. simtools/schemas/model_parameters/discriminator_hysteresis.schema.yml +2 -2
  84. simtools/schemas/model_parameters/discriminator_output_amplitude.schema.yml +2 -2
  85. simtools/schemas/model_parameters/discriminator_output_var_percent.schema.yml +2 -2
  86. simtools/schemas/model_parameters/discriminator_pulse_shape.schema.yml +2 -2
  87. simtools/schemas/model_parameters/discriminator_rise_time.schema.yml +2 -2
  88. simtools/schemas/model_parameters/discriminator_scale_threshold.schema.yml +2 -2
  89. simtools/schemas/model_parameters/discriminator_sigsum_over_threshold.schema.yml +2 -2
  90. simtools/schemas/model_parameters/discriminator_threshold.schema.yml +2 -2
  91. simtools/schemas/model_parameters/discriminator_time_over_threshold.schema.yml +2 -2
  92. simtools/schemas/model_parameters/discriminator_var_gate_length.schema.yml +2 -2
  93. simtools/schemas/model_parameters/discriminator_var_sigsum_over_threshold.schema.yml +2 -2
  94. simtools/schemas/model_parameters/discriminator_var_threshold.schema.yml +2 -2
  95. simtools/schemas/model_parameters/discriminator_var_time_over_threshold.schema.yml +2 -2
  96. simtools/schemas/model_parameters/dish_shape_length.schema.yml +2 -2
  97. simtools/schemas/model_parameters/dsum_clipping.schema.yml +2 -2
  98. simtools/schemas/model_parameters/dsum_ignore_below.schema.yml +2 -2
  99. simtools/schemas/model_parameters/dsum_offset.schema.yml +2 -2
  100. simtools/schemas/model_parameters/dsum_pedsub.schema.yml +2 -2
  101. simtools/schemas/model_parameters/dsum_pre_clipping.schema.yml +2 -2
  102. simtools/schemas/model_parameters/dsum_prescale.schema.yml +2 -2
  103. simtools/schemas/model_parameters/dsum_presum_max.schema.yml +2 -2
  104. simtools/schemas/model_parameters/dsum_presum_shift.schema.yml +2 -2
  105. simtools/schemas/model_parameters/dsum_shaping.schema.yml +2 -2
  106. simtools/schemas/model_parameters/dsum_shaping_renormalize.schema.yml +2 -2
  107. simtools/schemas/model_parameters/dsum_threshold.schema.yml +3 -3
  108. simtools/schemas/model_parameters/dsum_zero_clip.schema.yml +2 -2
  109. simtools/schemas/model_parameters/effective_focal_length.schema.yml +2 -2
  110. simtools/schemas/model_parameters/fadc_ac_coupled.schema.yml +2 -2
  111. simtools/schemas/model_parameters/fadc_amplitude.schema.yml +2 -2
  112. simtools/schemas/model_parameters/fadc_bins.schema.yml +2 -2
  113. simtools/schemas/model_parameters/fadc_compensate_pedestal.schema.yml +2 -2
  114. simtools/schemas/model_parameters/fadc_err_compensate_pedestal.schema.yml +2 -2
  115. simtools/schemas/model_parameters/fadc_err_pedestal.schema.yml +2 -2
  116. simtools/schemas/model_parameters/fadc_lg_amplitude.schema.yml +2 -2
  117. simtools/schemas/model_parameters/fadc_lg_compensate_pedestal.schema.yml +2 -2
  118. simtools/schemas/model_parameters/fadc_lg_err_compensate_pedestal.schema.yml +2 -2
  119. simtools/schemas/model_parameters/fadc_lg_err_pedestal.schema.yml +2 -2
  120. simtools/schemas/model_parameters/fadc_lg_max_signal.schema.yml +2 -2
  121. simtools/schemas/model_parameters/fadc_lg_noise.schema.yml +2 -2
  122. simtools/schemas/model_parameters/fadc_lg_pedestal.schema.yml +2 -2
  123. simtools/schemas/model_parameters/fadc_lg_sensitivity.schema.yml +2 -2
  124. simtools/schemas/model_parameters/fadc_lg_sysvar_pedestal.schema.yml +2 -2
  125. simtools/schemas/model_parameters/fadc_lg_var_pedestal.schema.yml +2 -2
  126. simtools/schemas/model_parameters/fadc_lg_var_sensitivity.schema.yml +2 -2
  127. simtools/schemas/model_parameters/fadc_max_signal.schema.yml +2 -2
  128. simtools/schemas/model_parameters/fadc_mhz.schema.yml +2 -2
  129. simtools/schemas/model_parameters/fadc_noise.schema.yml +2 -2
  130. simtools/schemas/model_parameters/fadc_pedestal.schema.yml +2 -2
  131. simtools/schemas/model_parameters/fadc_pulse_shape.schema.yml +2 -2
  132. simtools/schemas/model_parameters/fadc_sensitivity.schema.yml +2 -2
  133. simtools/schemas/model_parameters/fadc_sum_bins.schema.yml +2 -2
  134. simtools/schemas/model_parameters/fadc_sum_offset.schema.yml +2 -2
  135. simtools/schemas/model_parameters/fadc_sysvar_pedestal.schema.yml +2 -2
  136. simtools/schemas/model_parameters/fadc_var_pedestal.schema.yml +2 -2
  137. simtools/schemas/model_parameters/fadc_var_sensitivity.schema.yml +2 -2
  138. simtools/schemas/model_parameters/fake_mirror_list.schema.yml +1 -1
  139. simtools/schemas/model_parameters/flatfielding.schema.yml +2 -2
  140. simtools/schemas/model_parameters/focal_length.schema.yml +2 -2
  141. simtools/schemas/model_parameters/focus_offset.schema.yml +2 -2
  142. simtools/schemas/model_parameters/gain_variation.schema.yml +2 -2
  143. simtools/schemas/model_parameters/hg_lg_variation.schema.yml +2 -2
  144. simtools/schemas/model_parameters/iobuf_maximum.schema.yml +2 -2
  145. simtools/schemas/model_parameters/iobuf_output_maximum.schema.yml +2 -2
  146. simtools/schemas/model_parameters/laser_events.schema.yml +1 -1
  147. simtools/schemas/model_parameters/lightguide_efficiency_vs_incidence_angle.schema.yml +2 -2
  148. simtools/schemas/model_parameters/lightguide_efficiency_vs_wavelength.schema.yml +2 -2
  149. simtools/schemas/model_parameters/min_photoelectrons.schema.yml +2 -2
  150. simtools/schemas/model_parameters/min_photons.schema.yml +2 -2
  151. simtools/schemas/model_parameters/mirror_align_random_distance.schema.yml +2 -2
  152. simtools/schemas/model_parameters/mirror_align_random_horizontal.schema.yml +2 -2
  153. simtools/schemas/model_parameters/mirror_align_random_vertical.schema.yml +2 -2
  154. simtools/schemas/model_parameters/mirror_class.schema.yml +2 -2
  155. simtools/schemas/model_parameters/mirror_degraded_reflection.schema.yml +2 -2
  156. simtools/schemas/model_parameters/mirror_focal_length.schema.yml +2 -2
  157. simtools/schemas/model_parameters/mirror_list.schema.yml +2 -2
  158. simtools/schemas/model_parameters/mirror_offset.schema.yml +2 -2
  159. simtools/schemas/model_parameters/mirror_reflection_random_angle.schema.yml +2 -2
  160. simtools/schemas/model_parameters/mirror_reflectivity.schema.yml +2 -2
  161. simtools/schemas/model_parameters/multiplicity_offset.schema.yml +2 -2
  162. simtools/schemas/model_parameters/muon_mono_threshold.schema.yml +2 -2
  163. simtools/schemas/model_parameters/nsb_autoscale_airmass.schema.yml +2 -2
  164. simtools/schemas/model_parameters/nsb_offaxis.schema.yml +2 -2
  165. simtools/schemas/model_parameters/nsb_pixel_rate.schema.yml +2 -2
  166. simtools/schemas/model_parameters/num_gains.schema.yml +2 -2
  167. simtools/schemas/model_parameters/only_triggered_telescopes.schema.yml +2 -2
  168. simtools/schemas/model_parameters/optics_properties.schema.yml +2 -2
  169. simtools/schemas/model_parameters/pedestal_events.schema.yml +7 -3
  170. simtools/schemas/model_parameters/photon_delay.schema.yml +2 -2
  171. simtools/schemas/model_parameters/pixeltrg_time_step.schema.yml +2 -2
  172. simtools/schemas/model_parameters/pm_average_gain.schema.yml +2 -2
  173. simtools/schemas/model_parameters/pm_collection_efficiency.schema.yml +2 -2
  174. simtools/schemas/model_parameters/pm_gain_index.schema.yml +2 -2
  175. simtools/schemas/model_parameters/pm_photoelectron_spectrum.schema.yml +2 -2
  176. simtools/schemas/model_parameters/pm_transit_time.schema.yml +2 -2
  177. simtools/schemas/model_parameters/pm_voltage_variation.schema.yml +2 -2
  178. simtools/schemas/model_parameters/primary_mirror_degraded_map.schema.yml +2 -2
  179. simtools/schemas/model_parameters/qe_variation.schema.yml +2 -2
  180. simtools/schemas/model_parameters/quantum_efficiency.schema.yml +2 -2
  181. simtools/schemas/model_parameters/random_focal_length.schema.yml +2 -2
  182. simtools/schemas/model_parameters/random_generator.schema.yml +2 -2
  183. simtools/schemas/model_parameters/random_mono_probability.schema.yml +2 -2
  184. simtools/schemas/model_parameters/sampled_output.schema.yml +2 -2
  185. simtools/schemas/model_parameters/save_pe_with_amplitude.schema.yml +2 -2
  186. simtools/schemas/model_parameters/store_photoelectrons.schema.yml +2 -2
  187. simtools/schemas/model_parameters/tailcut_scale.schema.yml +2 -2
  188. simtools/schemas/model_parameters/telescope_axis_height.schema.yml +2 -2
  189. simtools/schemas/model_parameters/telescope_random_angle.schema.yml +2 -2
  190. simtools/schemas/model_parameters/telescope_random_error.schema.yml +2 -2
  191. simtools/schemas/model_parameters/telescope_sphere_radius.schema.yml +2 -2
  192. simtools/schemas/model_parameters/telescope_transmission.schema.yml +2 -2
  193. simtools/schemas/model_parameters/teltrig_min_sigsum.schema.yml +2 -2
  194. simtools/schemas/model_parameters/teltrig_min_time.schema.yml +2 -2
  195. simtools/schemas/model_parameters/transit_time_calib_error.schema.yml +2 -2
  196. simtools/schemas/model_parameters/transit_time_compensate_error.schema.yml +2 -2
  197. simtools/schemas/model_parameters/transit_time_compensate_step.schema.yml +2 -2
  198. simtools/schemas/model_parameters/transit_time_error.schema.yml +2 -2
  199. simtools/schemas/model_parameters/transit_time_jitter.schema.yml +2 -2
  200. simtools/schemas/model_parameters/trigger_current_limit.schema.yml +2 -2
  201. simtools/schemas/model_parameters/trigger_delay_compensation.schema.yml +2 -2
  202. simtools/schemas/model_parameters/trigger_pixels.schema.yml +2 -2
  203. simtools/simtel/simtel_config_reader.py +21 -17
  204. simtools/simtel/simtel_config_writer.py +237 -65
  205. simtools/simtel/simtel_io_file_info.py +57 -0
  206. simtools/simtel/simtel_io_histogram.py +10 -14
  207. simtools/simtel/simtel_io_histograms.py +2 -2
  208. simtools/simtel/simtel_io_metadata.py +91 -0
  209. simtools/simtel/simulator_array.py +26 -12
  210. simtools/simtel/simulator_camera_efficiency.py +12 -6
  211. simtools/simtel/simulator_light_emission.py +6 -11
  212. simtools/simtel/simulator_ray_tracing.py +14 -4
  213. simtools/simulator.py +230 -66
  214. simtools/testing/configuration.py +12 -6
  215. simtools/testing/helpers.py +18 -0
  216. simtools/testing/sim_telarray_metadata.py +212 -0
  217. simtools/testing/validate_output.py +12 -5
  218. simtools/utils/general.py +18 -27
  219. simtools/utils/names.py +27 -5
  220. simtools/visualization/visualize.py +2 -2
  221. simtools/applications/production_scale_events.py +0 -185
  222. {gammasimtools-0.14.0.dist-info → gammasimtools-0.16.0.dist-info}/licenses/LICENSE +0 -0
  223. {gammasimtools-0.14.0.dist-info → gammasimtools-0.16.0.dist-info}/top_level.txt +0 -0
@@ -64,11 +64,18 @@ def _validate_output_files(config, integration_test):
64
64
 
65
65
  def _test_simtel_cfg_files(config, integration_test, from_command_line, from_config_file):
66
66
  """Test simtel cfg files."""
67
- test_simtel_cfg_file = integration_test.get("TEST_SIMTEL_CFG_FILES", {}).get(
68
- from_command_line or from_config_file
69
- )
70
- if test_simtel_cfg_file:
71
- _validate_simtel_cfg_files(config, test_simtel_cfg_file)
67
+ cfg_files = integration_test.get("TEST_SIMTEL_CFG_FILES", {})
68
+ if isinstance(from_command_line, list):
69
+ sources = from_command_line
70
+ elif isinstance(from_config_file, list):
71
+ sources = from_config_file
72
+ else:
73
+ sources = [from_command_line or from_config_file]
74
+ for version in sources:
75
+ cfg = cfg_files.get(version)
76
+ if cfg:
77
+ _validate_simtel_cfg_files(config, cfg)
78
+ break
72
79
 
73
80
 
74
81
  def _validate_reference_output_file(config, integration_test):
simtools/utils/general.py CHANGED
@@ -133,28 +133,13 @@ def collect_data_from_http(url):
133
133
  try:
134
134
  with tempfile.NamedTemporaryFile(mode="w+t") as tmp_file:
135
135
  urllib.request.urlretrieve(url, tmp_file.name)
136
- if url.endswith("yml") or url.endswith("yaml"):
137
- try:
138
- data = yaml.safe_load(tmp_file)
139
- except yaml.constructor.ConstructorError:
140
- data = _load_yaml_using_astropy(tmp_file)
141
- elif url.endswith("json"):
142
- data = json.load(tmp_file)
143
- elif url.endswith("list"):
144
- lines = tmp_file.readlines()
145
- data = [line.strip() for line in lines]
146
- else:
147
- msg = f"File extension of {url} not supported (should be json or yaml)"
148
- _logger.error(msg)
149
- raise TypeError(msg)
136
+ data = _collect_data_from_different_file_types(
137
+ tmp_file, url, Path(url).suffix.lower(), None
138
+ )
150
139
  except TypeError as exc:
151
- msg = "Invalid url {url}"
152
- _logger.error(msg)
153
- raise TypeError(msg) from exc
140
+ raise TypeError(f"Invalid url {url}") from exc
154
141
  except urllib.error.HTTPError as exc:
155
- msg = f"Failed to download file from {url}"
156
- _logger.error(msg)
157
- raise FileNotFoundError(msg) from exc
142
+ raise FileNotFoundError(f"Failed to download file from {url}") from exc
158
143
 
159
144
  _logger.debug(f"Downloaded file from {url}")
160
145
  return data
@@ -182,20 +167,26 @@ def collect_data_from_file(file_name, yaml_document=None):
182
167
  suffix = Path(file_name).suffix.lower()
183
168
  try:
184
169
  with open(file_name, encoding="utf-8") as file:
185
- if suffix == ".json":
186
- return json.load(file)
187
- if suffix == ".list":
188
- return [line.strip() for line in file.readlines()]
189
- if suffix in [".yml", ".yaml"]:
190
- return _collect_data_from_yaml_file(file, file_name, yaml_document)
170
+ return _collect_data_from_different_file_types(file, file_name, suffix, yaml_document)
191
171
  # broad exception to catch all possible errors in reading the file
192
172
  except Exception as exc: # pylint: disable=broad-except
193
173
  raise type(exc)(f"Failed to read file {file_name}: {exc}") from exc
194
174
  return None
195
175
 
196
176
 
177
+ def _collect_data_from_different_file_types(file, file_name, suffix, yaml_document):
178
+ """Collect data from different file types."""
179
+ if suffix == ".json":
180
+ return json.load(file)
181
+ if suffix == ".list":
182
+ return [line.strip() for line in file.readlines()]
183
+ if suffix in [".yml", ".yaml"]:
184
+ return _collect_data_from_yaml_file(file, file_name, yaml_document)
185
+ raise TypeError(f"File type {suffix} not supported.")
186
+
187
+
197
188
  def _collect_data_from_yaml_file(file, file_name, yaml_document):
198
- """Collect data from a yaml file."""
189
+ """Collect data from a yaml file (allow for multi-document yaml files)."""
199
190
  try:
200
191
  return yaml.safe_load(file)
201
192
  except yaml.constructor.ConstructorError:
simtools/utils/names.py CHANGED
@@ -19,7 +19,11 @@ from pathlib import Path
19
19
 
20
20
  import yaml
21
21
 
22
- from simtools.constants import MODEL_PARAMETER_SCHEMA_PATH, SCHEMA_PATH
22
+ from simtools.constants import (
23
+ MODEL_PARAMETER_DESCRIPTION_METASCHEMA,
24
+ MODEL_PARAMETER_SCHEMA_PATH,
25
+ SCHEMA_PATH,
26
+ )
23
27
 
24
28
  _logger = logging.getLogger(__name__)
25
29
 
@@ -59,6 +63,21 @@ def array_elements():
59
63
  return yaml.safe_load(file)["data"]
60
64
 
61
65
 
66
+ @cache
67
+ def simulation_software():
68
+ """
69
+ Get simulation software names from the meta schema definition.
70
+
71
+ Returns
72
+ -------
73
+ list
74
+ List of simulation software names.
75
+ """
76
+ with open(Path(MODEL_PARAMETER_DESCRIPTION_METASCHEMA), encoding="utf-8") as file:
77
+ schema = yaml.safe_load(file)
78
+ return schema["definitions"]["SimulationSoftwareName"]["enum"]
79
+
80
+
62
81
  @cache
63
82
  def site_names():
64
83
  """
@@ -129,15 +148,18 @@ def _load_model_parameters():
129
148
  """
130
149
  Get model parameters properties from schema files.
131
150
 
151
+ For schema files including multiple schemas, only the first one is returned
152
+ (as this is the most recent definition).
153
+
132
154
  Returns
133
155
  -------
134
156
  dict
135
157
  Model parameters definitions for all model parameters.
136
158
  """
137
159
  _parameters = {}
138
- for schema_file in list(Path(MODEL_PARAMETER_SCHEMA_PATH).rglob("*.yml")):
160
+ for schema_file in Path(MODEL_PARAMETER_SCHEMA_PATH).rglob("*.yml"):
139
161
  with open(schema_file, encoding="utf-8") as f:
140
- data = yaml.safe_load(f)
162
+ data = next(yaml.safe_load_all(f))
141
163
  _parameters[data["name"]] = data
142
164
  return _parameters
143
165
 
@@ -512,7 +534,7 @@ def get_collection_name_from_parameter_name(parameter_name):
512
534
 
513
535
  def get_simulation_software_name_from_parameter_name(
514
536
  parameter_name,
515
- simulation_software="sim_telarray",
537
+ software_name="sim_telarray",
516
538
  set_meta_parameter=False,
517
539
  ):
518
540
  """
@@ -541,7 +563,7 @@ def get_simulation_software_name_from_parameter_name(
541
563
 
542
564
  for software in _parameter.get("simulation_software", []):
543
565
  if (
544
- software.get("name") == simulation_software
566
+ software.get("name") == software_name
545
567
  and software.get("set_meta_parameter", False) is set_meta_parameter
546
568
  ):
547
569
  return software.get("internal_parameter_name", parameter_name)
@@ -845,12 +845,12 @@ def finalize_plot(ax, patches, x_title, y_title, axes_range):
845
845
 
846
846
  def plot_simtel_ctapipe(filename, cleaning_args, distance, return_cleaned=False):
847
847
  """
848
- Read in a simtel file and plots reconstructed photoelectrons via ctapipe.
848
+ Read in a sim_telarray file and plots reconstructed photoelectrons via ctapipe.
849
849
 
850
850
  Parameters
851
851
  ----------
852
852
  filename : str
853
- Path to the simtel file.
853
+ Path to the sim_telarray file.
854
854
  cleaning_args : tuple, optional
855
855
  Cleaning parameters as (boundary_thresh, picture_thresh, min_number_picture_neighbors).
856
856
  distance : astropy Quantity, optional
@@ -1,185 +0,0 @@
1
- #!/usr/bin/python3
2
-
3
- r"""
4
- Application to run the StatisticalErrorEvaluator and interpolate results.
5
-
6
- This application evaluates statistical uncertainties from DL2 MC event files
7
- based on input parameters like zenith angles and offsets, and performs interpolation
8
- for a specified query point.
9
-
10
- Command line arguments
11
- ----------------------
12
- base_path (str, required)
13
- Path to the directory containing the DL2 MC event file for interpolation.
14
- zeniths (list of int, required)
15
- List of zenith angles to consider.
16
- offsets (list of int, required)
17
- List of offsets in degrees.
18
- query_point (list of float, required)
19
- Query point for interpolation. The query point must contain exactly 5 values:
20
- - Energy (TeV)
21
- - Azimuth (degrees)
22
- - Zenith (degrees)
23
- - NSB (MHz)
24
- - Offset (degrees)
25
- output_file (str, optional)
26
- Output file to store the results. Default: 'interpolated_scaled_events.json'.
27
- metrics_file (str, optional)
28
- Path to the metrics definition file. Default: 'production_simulation_config_metrics.yml'.
29
- file_name_template (str, optional)
30
- Template for the file name. Default:
31
- 'prod6_LaPalma-{zenith}deg_gamma_cone.N.Am-4LSTs09MSTs_ID0_reduced.fits'.
32
-
33
- Example
34
- -------
35
- To evaluate statistical uncertainties and perform interpolation, run the command line script:
36
-
37
- .. code-block:: console
38
-
39
- simtools-production-scale-events --base_path tests/resources/production_dl2_fits/ \\
40
- --zeniths 20 40 52 60 --offsets 0 --query_point 1 180 30 0 0 \\
41
- --metrics_file "path/to/metrics.yaml" \\
42
- --output_file "output.json"
43
-
44
- The output will display the scaled events for the specified query point and save
45
- the results to the specified output file.
46
- """
47
-
48
- import itertools
49
- import json
50
- import logging
51
- from pathlib import Path
52
-
53
- import astropy.units as u
54
- import numpy as np
55
-
56
- import simtools.utils.general as gen
57
- from simtools.configuration import configurator
58
- from simtools.configuration.commandline_parser import CommandLineParser
59
- from simtools.io_operations import io_handler
60
- from simtools.production_configuration.calculate_statistical_errors_grid_point import (
61
- StatisticalErrorEvaluator,
62
- )
63
- from simtools.production_configuration.interpolation_handler import InterpolationHandler
64
-
65
-
66
- def _parse(label, description):
67
- """
68
- Parse command line arguments for the statistical error evaluator application.
69
-
70
- Returns
71
- -------
72
- argparse.Namespace
73
- Parsed command line arguments.
74
- """
75
- config = configurator.Configurator(label=label, description=description)
76
-
77
- config.parser.add_argument(
78
- "--base_path",
79
- type=str,
80
- required=True,
81
- help="Path to the DL2 MC event files for interpolation.",
82
- )
83
- config.parser.add_argument(
84
- "--zeniths",
85
- required=True,
86
- nargs="+",
87
- type=CommandLineParser.zenith_angle,
88
- help="List of zenith angles.",
89
- )
90
- config.parser.add_argument(
91
- "--offsets", required=True, nargs="+", type=float, help="List of offsets in degrees."
92
- )
93
-
94
- config.parser.add_argument(
95
- "--query_point",
96
- required=True,
97
- nargs=5,
98
- type=float,
99
- help="Grid point for interpolation (energy, azimuth, zenith, NSB, offset).",
100
- )
101
- config.parser.add_argument(
102
- "--output_file",
103
- required=False,
104
- type=str,
105
- default="interpolated_scaled_events.json",
106
- help="Output file to store the results. (default: 'interpolated_scaled_events.json').",
107
- )
108
- config.parser.add_argument(
109
- "--metrics_file",
110
- required=False,
111
- type=str,
112
- default="production_simulation_config_metrics.yml",
113
- help="Metrics definition file. (default: production_simulation_config_metrics.yml)",
114
- )
115
- config.parser.add_argument(
116
- "--file_name_template",
117
- required=False,
118
- type=str,
119
- default=("prod6_LaPalma-{zenith}deg_gamma_cone.N.Am-4LSTs09MSTs_ID0_reduced.fits"),
120
- help=(
121
- "Template for the file name. (default: "
122
- "'prod6_LaPalma-{zenith}deg_gamma_cone.N.Am-4LSTs09MSTs_ID0_reduced.fits')"
123
- ),
124
- )
125
- return config.initialize(db_config=False)
126
-
127
-
128
- def main():
129
- """Run the evaluator and interpolate."""
130
- label = Path(__file__).stem
131
- args_dict, _ = _parse(
132
- label,
133
- "Evaluate statistical uncertainties from DL2 MC event files and interpolate results.",
134
- )
135
- logger = logging.getLogger()
136
- logger.setLevel(logging.INFO)
137
- logger.info(f"args dict: {args_dict}")
138
-
139
- output_path = io_handler.IOHandler().get_output_directory(label)
140
- output_filepath = Path(output_path).joinpath(f"{args_dict['output_file']}")
141
-
142
- evaluator_instances = []
143
-
144
- metrics = gen.collect_data_from_file(args_dict["metrics_file"])
145
-
146
- if args_dict["base_path"] and args_dict["zeniths"] and args_dict["offsets"]:
147
- for zenith, offset in itertools.product(args_dict["zeniths"], args_dict["offsets"]):
148
- file_name = args_dict["file_name_template"].format(zenith=int(zenith.value))
149
- file_path = Path(args_dict["base_path"]).joinpath(file_name)
150
-
151
- if not file_path.exists():
152
- logger.warning(f"File not found: {file_path}. Skipping.")
153
- continue
154
-
155
- evaluator = StatisticalErrorEvaluator(
156
- file_path,
157
- file_type="Gamma-cone",
158
- metrics=metrics,
159
- grid_point=(1 * u.TeV, 180 * u.deg, zenith, 0, offset * u.deg),
160
- )
161
- evaluator.calculate_metrics()
162
- evaluator_instances.append(evaluator)
163
-
164
- else:
165
- logger.warning("No files read")
166
- logger.warning(f"Base Path: {args_dict['base_path']}")
167
- logger.warning(f"Zeniths: {args_dict['zeniths']}")
168
- logger.warning(f"Offsets: {args_dict['offsets']}")
169
-
170
- interpolation_handler = InterpolationHandler(evaluator_instances, metrics=metrics)
171
- query_points = np.array([args_dict["query_point"]])
172
- scaled_events = interpolation_handler.interpolate(query_points)
173
-
174
- output_data = {
175
- "query_point": args_dict["query_point"],
176
- "scaled_events": scaled_events.tolist(),
177
- }
178
- with open(output_filepath, "w", encoding="utf-8") as f:
179
- json.dump(output_data, f, indent=4)
180
- logger.info(f"Output saved to {output_filepath}")
181
- logger.info(f"Scaled events for grid point {args_dict['query_point']}: {scaled_events}")
182
-
183
-
184
- if __name__ == "__main__":
185
- main()