gammasimtools 0.8.2__py3-none-any.whl → 0.10.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 (122) hide show
  1. {gammasimtools-0.8.2.dist-info → gammasimtools-0.10.0.dist-info}/METADATA +4 -4
  2. {gammasimtools-0.8.2.dist-info → gammasimtools-0.10.0.dist-info}/RECORD +119 -105
  3. {gammasimtools-0.8.2.dist-info → gammasimtools-0.10.0.dist-info}/WHEEL +1 -1
  4. {gammasimtools-0.8.2.dist-info → gammasimtools-0.10.0.dist-info}/entry_points.txt +4 -1
  5. simtools/_version.py +2 -2
  6. simtools/applications/calculate_trigger_rate.py +15 -38
  7. simtools/applications/convert_all_model_parameters_from_simtel.py +9 -28
  8. simtools/applications/convert_geo_coordinates_of_array_elements.py +54 -53
  9. simtools/applications/convert_model_parameter_from_simtel.py +2 -2
  10. simtools/applications/db_add_file_to_db.py +1 -2
  11. simtools/applications/db_add_simulation_model_from_repository_to_db.py +110 -0
  12. simtools/applications/db_add_value_from_json_to_db.py +2 -11
  13. simtools/applications/db_development_tools/write_array_elements_positions_to_repository.py +6 -6
  14. simtools/applications/db_get_array_layouts_from_db.py +3 -1
  15. simtools/applications/db_get_file_from_db.py +11 -12
  16. simtools/applications/db_get_parameter_from_db.py +44 -32
  17. simtools/applications/derive_mirror_rnda.py +10 -1
  18. simtools/applications/derive_photon_electron_spectrum.py +99 -0
  19. simtools/applications/derive_psf_parameters.py +1 -1
  20. simtools/applications/generate_array_config.py +18 -22
  21. simtools/applications/generate_regular_arrays.py +24 -21
  22. simtools/applications/generate_simtel_array_histograms.py +11 -48
  23. simtools/applications/plot_array_layout.py +3 -1
  24. simtools/applications/plot_tabular_data.py +84 -0
  25. simtools/applications/production_generate_simulation_config.py +25 -7
  26. simtools/applications/production_scale_events.py +3 -4
  27. simtools/applications/simulate_light_emission.py +2 -2
  28. simtools/applications/simulate_prod.py +25 -60
  29. simtools/applications/simulate_prod_htcondor_generator.py +95 -0
  30. simtools/applications/submit_data_from_external.py +12 -4
  31. simtools/applications/submit_model_parameter_from_external.py +8 -6
  32. simtools/applications/validate_camera_efficiency.py +3 -3
  33. simtools/applications/validate_camera_fov.py +3 -7
  34. simtools/applications/validate_cumulative_psf.py +3 -7
  35. simtools/applications/validate_file_using_schema.py +38 -24
  36. simtools/applications/validate_optics.py +3 -4
  37. simtools/{camera_efficiency.py → camera/camera_efficiency.py} +1 -4
  38. simtools/camera/single_photon_electron_spectrum.py +168 -0
  39. simtools/configuration/commandline_parser.py +14 -13
  40. simtools/configuration/configurator.py +6 -19
  41. simtools/constants.py +10 -3
  42. simtools/corsika/corsika_config.py +8 -7
  43. simtools/corsika/corsika_histograms.py +1 -1
  44. simtools/data_model/data_reader.py +0 -3
  45. simtools/data_model/metadata_collector.py +21 -4
  46. simtools/data_model/metadata_model.py +8 -111
  47. simtools/data_model/model_data_writer.py +18 -64
  48. simtools/data_model/schema.py +213 -0
  49. simtools/data_model/validate_data.py +73 -51
  50. simtools/db/db_handler.py +395 -790
  51. simtools/db/db_model_upload.py +139 -0
  52. simtools/io_operations/hdf5_handler.py +54 -24
  53. simtools/io_operations/legacy_data_handler.py +61 -0
  54. simtools/job_execution/htcondor_script_generator.py +133 -0
  55. simtools/job_execution/job_manager.py +77 -50
  56. simtools/layout/array_layout.py +33 -28
  57. simtools/model/array_model.py +13 -7
  58. simtools/model/camera.py +4 -2
  59. simtools/model/model_parameter.py +61 -63
  60. simtools/model/site_model.py +3 -3
  61. simtools/production_configuration/calculate_statistical_errors_grid_point.py +119 -144
  62. simtools/production_configuration/event_scaler.py +7 -17
  63. simtools/production_configuration/generate_simulation_config.py +5 -32
  64. simtools/production_configuration/interpolation_handler.py +8 -11
  65. simtools/ray_tracing/mirror_panel_psf.py +47 -27
  66. simtools/runners/corsika_runner.py +14 -3
  67. simtools/runners/corsika_simtel_runner.py +3 -1
  68. simtools/runners/runner_services.py +3 -3
  69. simtools/runners/simtel_runner.py +27 -8
  70. simtools/schemas/input/MST_mirror_2f_measurements.schema.yml +39 -0
  71. simtools/schemas/input/single_pe_spectrum.schema.yml +38 -0
  72. simtools/schemas/integration_tests_config.metaschema.yml +23 -3
  73. simtools/schemas/model_parameter.metaschema.yml +95 -2
  74. simtools/schemas/model_parameter_and_data_schema.metaschema.yml +2 -0
  75. simtools/schemas/model_parameters/array_element_position_utm.schema.yml +1 -1
  76. simtools/schemas/model_parameters/array_window.schema.yml +37 -0
  77. simtools/schemas/model_parameters/asum_clipping.schema.yml +0 -4
  78. simtools/schemas/model_parameters/channels_per_chip.schema.yml +1 -1
  79. simtools/schemas/model_parameters/corsika_iact_io_buffer.schema.yml +2 -2
  80. simtools/schemas/model_parameters/dsum_clipping.schema.yml +0 -2
  81. simtools/schemas/model_parameters/dsum_ignore_below.schema.yml +0 -2
  82. simtools/schemas/model_parameters/dsum_offset.schema.yml +0 -2
  83. simtools/schemas/model_parameters/dsum_pedsub.schema.yml +0 -2
  84. simtools/schemas/model_parameters/dsum_pre_clipping.schema.yml +0 -2
  85. simtools/schemas/model_parameters/dsum_prescale.schema.yml +0 -2
  86. simtools/schemas/model_parameters/dsum_presum_max.schema.yml +0 -2
  87. simtools/schemas/model_parameters/dsum_presum_shift.schema.yml +0 -2
  88. simtools/schemas/model_parameters/dsum_shaping.schema.yml +0 -2
  89. simtools/schemas/model_parameters/dsum_shaping_renormalize.schema.yml +0 -2
  90. simtools/schemas/model_parameters/dsum_threshold.schema.yml +0 -2
  91. simtools/schemas/model_parameters/dsum_zero_clip.schema.yml +0 -2
  92. simtools/schemas/model_parameters/effective_focal_length.schema.yml +31 -1
  93. simtools/schemas/model_parameters/fadc_compensate_pedestal.schema.yml +1 -1
  94. simtools/schemas/model_parameters/fadc_lg_compensate_pedestal.schema.yml +1 -1
  95. simtools/schemas/model_parameters/fadc_noise.schema.yml +3 -3
  96. simtools/schemas/model_parameters/fake_mirror_list.schema.yml +33 -0
  97. simtools/schemas/model_parameters/laser_photons.schema.yml +2 -2
  98. simtools/schemas/model_parameters/secondary_mirror_degraded_reflection.schema.yml +1 -1
  99. simtools/schemas/production_configuration_metrics.schema.yml +68 -0
  100. simtools/schemas/production_tables.schema.yml +41 -0
  101. simtools/simtel/simtel_config_writer.py +5 -6
  102. simtools/simtel/simtel_io_histogram.py +32 -67
  103. simtools/simtel/simtel_io_histograms.py +15 -30
  104. simtools/simtel/simtel_table_reader.py +410 -0
  105. simtools/simtel/simulator_array.py +2 -1
  106. simtools/simtel/simulator_camera_efficiency.py +11 -4
  107. simtools/simtel/simulator_light_emission.py +5 -3
  108. simtools/simtel/simulator_ray_tracing.py +2 -2
  109. simtools/simulator.py +80 -33
  110. simtools/testing/configuration.py +12 -8
  111. simtools/testing/helpers.py +9 -16
  112. simtools/testing/validate_output.py +152 -68
  113. simtools/utils/general.py +149 -12
  114. simtools/utils/names.py +25 -21
  115. simtools/utils/value_conversion.py +9 -1
  116. simtools/visualization/plot_tables.py +106 -0
  117. simtools/visualization/visualize.py +43 -5
  118. simtools/applications/db_add_model_parameters_from_repository_to_db.py +0 -184
  119. simtools/db/db_array_elements.py +0 -130
  120. simtools/db/db_from_repo_handler.py +0 -106
  121. {gammasimtools-0.8.2.dist-info → gammasimtools-0.10.0.dist-info}/LICENSE +0 -0
  122. {gammasimtools-0.8.2.dist-info → gammasimtools-0.10.0.dist-info}/top_level.txt +0 -0
@@ -8,7 +8,7 @@ meta_schema_version: 0.1.0
8
8
  name: fadc_compensate_pedestal
9
9
  description: |-
10
10
  Emulate FADC pedestal compensation (as e.g., done in camera firmware using FPGAs)
11
- to homogenise significant pixel-to-pixel variations of raw pedestals values
11
+ to homogenize significant pixel-to-pixel variations of raw pedestals values
12
12
  (for high-gain channel for dual-gain readout).
13
13
  The resulting values are still unsigned integers and no rescaling takes place
14
14
  (pure integer pedestal offset). No compensation takes place for the default value
@@ -8,7 +8,7 @@ meta_schema_version: 0.1.0
8
8
  name: fadc_lg_compensate_pedestal
9
9
  description: |-
10
10
  Emulate FADC pedestal compensation (as e.g., done in camera firmware using FPGAs)
11
- to homogenise significant pixel-to-pixel variations of raw pedestals values
11
+ to homogenize significant pixel-to-pixel variations of raw pedestals values
12
12
  (for low-gain channel for dual-gain readout).
13
13
  The resulting values are still unsigned integers and no rescaling takes place
14
14
  (pure integer pedestal offset). No compensation takes place for the default value
@@ -7,13 +7,13 @@ meta_schema_url: https://raw.githubusercontent.com/gammasim/simtools/main/src/si
7
7
  meta_schema_version: 0.1.0
8
8
  name: fadc_noise
9
9
  description: |-
10
- Gaussian r.m.s. spread of white noise per time bin in digitisation
10
+ Gaussian r.m.s. spread of white noise per time bin in digitization
11
11
  (for high-gain channel, if different gains are used).
12
- short_description: Gaussian r.m.s. spread of white noise per time bin in digitisation.
12
+ short_description: Gaussian r.m.s. spread of white noise per time bin in digitization.
13
13
  data:
14
14
  - type: double
15
15
  description: |-
16
- Gaussian r.m.s. spread of white noise per time bin in digitisation
16
+ Gaussian r.m.s. spread of white noise per time bin in digitization
17
17
  (for high-gain channel in case of dual-readout chain)
18
18
  unit: count
19
19
  default: 4.0
@@ -0,0 +1,33 @@
1
+ %YAML 1.2
2
+ ---
3
+ title: Schema for fake_mirror_list model parameter
4
+ version: 0.1.0
5
+ meta_schema: simpipe-schema
6
+ meta_schema_url: https://raw.githubusercontent.com/gammasim/simtools/main/src/simtools/schemas/model_parameter_and_data_schema.metaschema.yml
7
+ meta_schema_version: 0.1.0
8
+ developer_note: To be replaced by a data table
9
+ name: fake_mirror_list
10
+ short_description: Fake mirror list to be used for camera efficiency calculations ('testeff' program).
11
+ description: |-
12
+ Fake mirror list to be used for camera efficiency calculations ('testeff' program).
13
+ Allows to obtain realistic distributions of the photon incidence angles on the camera plan.
14
+ Not to be used for actual simulations.
15
+ data:
16
+ - type: file
17
+ unit: dimensionless
18
+ default: None
19
+ instrument:
20
+ class: Structure
21
+ type:
22
+ - SSTS
23
+ - SCTS
24
+ activity:
25
+ setting:
26
+ - SetParameterFromExternal
27
+ validation:
28
+ - ValidateParameterByExpert
29
+ - ValidateCameraEfficiency
30
+ source:
31
+ - Initial instrument setup
32
+ simulation_software:
33
+ - name: sim_telarray
@@ -7,9 +7,9 @@ meta_schema_url: https://raw.githubusercontent.com/gammasim/simtools/main/src/si
7
7
  meta_schema_version: 0.1.0
8
8
  name: laser_photons
9
9
  description: |-
10
- Number of laser photons at each photodetector.
10
+ Number of laser photons at each photo detector.
11
11
  short_description: |-
12
- Number of laser photons at each photodetector.
12
+ Number of laser photons at each photo detector.
13
13
  data:
14
14
  - type: double
15
15
  unit: dimensionless
@@ -10,7 +10,7 @@ description: |-
10
10
  Mirror degradation factor for the secondary mirror (wavelength independent).
11
11
  Strictly interpreted as being for reflection on the secondary mirror of a
12
12
  dual-mirror telescope, and still gets applied in simulations where only
13
- the reflection on the primary mirror is bypassd (for example a
13
+ the reflection on the primary mirror is bypassed (for example a
14
14
  flat-fielding light source illuminating the camera via reflection on the
15
15
  secondary).
16
16
  short_description: |-
@@ -0,0 +1,68 @@
1
+ ---
2
+ $schema: http://json-schema.org/draft-06/schema#
3
+ $ref: '#/definitions/ErrorMetrics'
4
+ title: Statistical Error Metrics Schema
5
+ description: |
6
+ YAML representation of simulation production configuration
7
+ metrics.
8
+ version: 0.1.0
9
+ name: production_configuration_metrics.metaschema
10
+ type: object
11
+ additionalProperties: false
12
+
13
+ definitions:
14
+ ErrorMetrics:
15
+ type: object
16
+ description: Definition of error metrics and validity ranges.
17
+ additionalProperties: false
18
+ properties:
19
+ uncertainty_effective_area:
20
+ $ref: '#/definitions/ErrorMetric'
21
+ energy_estimate:
22
+ $ref: '#/definitions/ErrorMetric'
23
+
24
+ ErrorMetric:
25
+ type: object
26
+ description: Error metric definition.
27
+ additionalProperties: false
28
+ properties:
29
+ description:
30
+ type: string
31
+ description: Description of the error metric.
32
+ target_error:
33
+ $ref: '#/definitions/TargetError'
34
+ energy_range:
35
+ $ref: '#/definitions/EnergyRange'
36
+ required:
37
+ - target_error
38
+ - energy_range
39
+
40
+ TargetError:
41
+ type: object
42
+ description: Target error specification.
43
+ additionalProperties: false
44
+ properties:
45
+ value:
46
+ type: number
47
+ description: Target error value.
48
+ required:
49
+ - value
50
+
51
+ EnergyRange:
52
+ type: object
53
+ description: Energy range specification.
54
+ additionalProperties: false
55
+ properties:
56
+ value:
57
+ type: array
58
+ description: Energy range values.
59
+ items:
60
+ type: number
61
+ minItems: 2
62
+ maxItems: 2
63
+ unit:
64
+ type: string
65
+ description: Energy unit.
66
+ required:
67
+ - value
68
+ - unit
@@ -0,0 +1,41 @@
1
+ ---
2
+ $schema: http://json-schema.org/draft-06/schema#
3
+ $ref: '#/definitions/ProductionModelTable'
4
+ title: SimPipe DB Production Model Metaschema
5
+ description: |
6
+ YAML representation of DB production model metaschema
7
+ (based on simulation model DB).
8
+ version: 0.1.0
9
+ name: production_table.metaschema
10
+ type: object
11
+ additionalProperties: false
12
+
13
+ definitions:
14
+ ProductionModelTable:
15
+ properties:
16
+ model_version:
17
+ type: string
18
+ description: Model version.
19
+ pattern: '^\d+\.\d+\.\d+$'
20
+ parameters:
21
+ type: object
22
+ description: Model parameters.
23
+ additionalProperties:
24
+ type: object
25
+ description: Model parameter.
26
+ additionalProperties:
27
+ type: string
28
+ description: Parameter version (semantical versioning).
29
+ pattern: '^\d+\.\d+\.\d+$'
30
+ propertyNames:
31
+ description: Allowed parameter name patterns.
32
+ pattern: '^([A-Za-z](ST|LL)[N,S,x]-\d{2,3}|[A-Za-z](ST|LL)[N,S,x]-design|OBS-(North|South)|Dummy-Telescope)$'
33
+ design_model:
34
+ type: object
35
+ description: Design models.
36
+ additionalProperties:
37
+ type: string
38
+ description: Design model of a telescope
39
+ required:
40
+ - model_version
41
+ - parameters
@@ -78,8 +78,10 @@ class SimtelConfigWriter:
78
78
  file.write("#endif\n\n")
79
79
 
80
80
  for _simtel_name, value in parameters.items():
81
- if _simtel_name.startswith("array_trigger"):
82
- continue # array trigger is a site parameter, not a telescope parameter
81
+ # array trigger is a site parameter, not a telescope parameter
82
+ # fake_mirror_list is not a sim_telarray parameter (used for testeff only)
83
+ if _simtel_name.startswith("array_trigger") or _simtel_name == "fake_mirror_list":
84
+ continue
83
85
  if _simtel_name:
84
86
  file.write(f"{_simtel_name} = {self._get_value_string_for_simtel(value)}\n")
85
87
  _config_meta = self._get_simtel_metadata("telescope")
@@ -294,10 +296,7 @@ class SimtelConfigWriter:
294
296
  _site_parameters = site_model.get_simtel_parameters()
295
297
  for par, value in _site_parameters.items():
296
298
  _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,
299
+ par, simulation_software="sim_telarray"
301
300
  )
302
301
  _simtel_name, value = self._convert_model_parameters_to_simtel_format(
303
302
  _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
- # Try to find configuration from .simtel file. If .hdata, config will be None
146
- for obj in f:
147
- if isinstance(obj, MCRunHeader):
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 total_num_simulated_events(self):
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
- Returns the total number of triggered events.
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
- _, trigger_histogram = self.fill_event_histogram_dicts()
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(f"Number of total triggered showers: {self._total_num_triggered_events}")
186
- return self._total_num_triggered_events
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
- # Save the appropriate histograms to variables
205
- found_simulated_events_hist = False
206
- found_triggered_events_hist = False
207
- events_histogram = None
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):
@@ -521,11 +484,11 @@ class SimtelIOHistogram:
521
484
  """
522
485
  Get the particle distribution function.
523
486
 
524
- This depends on whether one wants the reference CR distribution or the distribution
487
+ This depends on whether one wants the reference CR distribution or the distribution
525
488
  used in the simulation. This is controlled by label.
526
489
  By using label="reference", one gets the distribution function according to a pre-defined CR
527
490
  distribution, while by using label="simulation", the spectral index of the distribution
528
- function from the simulation is used. Naturally, label="simulation" only works when the
491
+ function from the simulation is used. The label="simulation" works only when the
529
492
  input file is a .simtel file and not a .hdata file.
530
493
 
531
494
  Parameters
@@ -603,7 +566,8 @@ class SimtelIOHistogram:
603
566
  self.energy_range[1],
604
567
  )
605
568
  if stacked_num_simulated_events is None:
606
- return (self.total_num_simulated_events / first_estimate) * u.s
569
+ _simulated_events, _ = self.total_number_of_events
570
+ return (_simulated_events / first_estimate) * u.s
607
571
  return (stacked_num_simulated_events / first_estimate) * u.s
608
572
 
609
573
  def estimate_trigger_rate_uncertainty(
@@ -648,13 +612,14 @@ class SimtelIOHistogram:
648
612
  dict:
649
613
  Dictionary with the information, e.g., view angle, energy range, etc.
650
614
  """
615
+ _simulated, _triggered = self.total_number_of_events
651
616
  info_dict = {
652
617
  "view_cone": self.view_cone,
653
618
  "solid_angle": self.solid_angle,
654
619
  "total_area": self.total_area,
655
620
  "energy_range": self.energy_range,
656
- "total_num_simulated_events": self.total_num_simulated_events,
657
- "total_num_triggered_events": self.total_num_triggered_events,
621
+ "total_num_simulated_events": _simulated,
622
+ "total_num_triggered_events": _triggered,
658
623
  }
659
624
  if mode != "silent":
660
625
  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
- stacked_num_simulated_events += simtel_hist_instance.total_num_simulated_events
196
- stacked_num_triggered_events += simtel_hist_instance.total_num_triggered_events
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):
@@ -245,7 +240,7 @@ class SimtelIOHistograms:
245
240
  logging.info(
246
241
  f"System trigger event rate for stacked files: "
247
242
  # pylint: disable=E1101
248
- f"{triggered_event_rate.value:.4e} \u00B1 "
243
+ f"{triggered_event_rate.value:.4e} \u00b1 "
249
244
  # pylint: disable=E1101
250
245
  f"{triggered_event_rate_uncertainty.value:.4e} Hz"
251
246
  )
@@ -282,24 +277,17 @@ class SimtelIOHistograms:
282
277
  if print_info:
283
278
  simtel_hist_instance.print_info()
284
279
 
280
+ _simulated_events, _triggered_events = simtel_hist_instance.total_number_of_events
285
281
  logging.info(f"Histogram {i_file + 1}:")
286
- logging.info(
287
- "Total number of simulated events: "
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
- )
282
+ logging.info(f"Total number of simulated events: {_simulated_events} events")
283
+ logging.info(f"Total number of triggered events: {_triggered_events} events")
294
284
 
295
- obs_time = simtel_hist_instance.estimate_observation_time(
296
- simtel_hist_instance.total_num_simulated_events
297
- )
285
+ obs_time = simtel_hist_instance.estimate_observation_time(_simulated_events)
298
286
  logging.info(
299
287
  f"Estimated equivalent observation time corresponding to the number of "
300
288
  f"events simulated: {obs_time.value} s"
301
289
  )
302
- sim_event_rate = simtel_hist_instance.total_num_simulated_events / obs_time
290
+ sim_event_rate = _simulated_events / obs_time
303
291
  sim_event_rates.append(sim_event_rate)
304
292
  logging.info(f"Simulated event rate: {sim_event_rate.value:.4e} Hz")
305
293
 
@@ -310,7 +298,7 @@ class SimtelIOHistograms:
310
298
  logging.info(
311
299
  f"System trigger event rate: "
312
300
  # pylint: disable=E1101
313
- f"{triggered_event_rate.value:.4e} \u00B1 "
301
+ f"{triggered_event_rate.value:.4e} \u00b1 "
314
302
  # pylint: disable=E1101
315
303
  f"{triggered_event_rate_uncertainty.value:.4e} Hz"
316
304
  )
@@ -515,15 +503,16 @@ class SimtelIOHistograms:
515
503
 
516
504
  def export_histograms(self, hdf5_file_name, overwrite=False):
517
505
  """
518
- Export the histograms to hdf5 files.
506
+ Export sim_telarray histograms to hdf5 files.
519
507
 
520
508
  Parameters
521
509
  ----------
522
510
  hdf5_file_name: str
523
511
  Name of the file to be saved with the hdf5 tables.
524
512
  overwrite: bool
525
- If True overwrites the histograms already saved in the hdf5 file.
513
+ If True overwrites histograms already saved in the hdf5 file.
526
514
  """
515
+ self._logger.info(f"Exporting histograms to {hdf5_file_name}.")
527
516
  for histogram in self.combined_hists:
528
517
  x_bin_edges_list = np.linspace(
529
518
  histogram["lower_x"],
@@ -556,14 +545,10 @@ class SimtelIOHistograms:
556
545
  f"Writing histogram with name {self._meta_dict['Title']} to {hdf5_file_name}."
557
546
  )
558
547
  # overwrite takes precedence over append
559
- if overwrite is True:
560
- append = False
561
- else:
562
- append = True
563
548
  write_table(
564
549
  table,
565
550
  hdf5_file_name,
566
551
  f"/{self._meta_dict['Title']}",
567
- append=append,
552
+ append=not overwrite,
568
553
  overwrite=overwrite,
569
554
  )