gammasimtools 0.6.0__py3-none-any.whl → 0.8.1__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 (353) hide show
  1. gammasimtools-0.8.1.dist-info/METADATA +172 -0
  2. gammasimtools-0.8.1.dist-info/RECORD +346 -0
  3. {gammasimtools-0.6.0.dist-info → gammasimtools-0.8.1.dist-info}/WHEEL +1 -1
  4. gammasimtools-0.8.1.dist-info/entry_points.txt +31 -0
  5. simtools/_version.py +2 -2
  6. simtools/applications/calculate_trigger_rate.py +210 -0
  7. simtools/applications/convert_all_model_parameters_from_simtel.py +372 -0
  8. simtools/applications/{print_array_elements.py → convert_geo_coordinates_of_array_elements.py} +58 -63
  9. simtools/applications/convert_model_parameter_from_simtel.py +119 -0
  10. simtools/applications/{add_file_to_db.py → db_add_file_to_db.py} +70 -60
  11. simtools/applications/db_add_model_parameters_from_repository_to_db.py +184 -0
  12. simtools/applications/db_add_value_from_json_to_db.py +105 -0
  13. simtools/applications/db_development_tools/write_array_elements_positions_to_repository.py +180 -0
  14. simtools/applications/db_get_array_layouts_from_db.py +162 -0
  15. simtools/applications/{get_file_from_db.py → db_get_file_from_db.py} +30 -34
  16. simtools/applications/db_get_parameter_from_db.py +131 -0
  17. simtools/applications/db_inspect_databases.py +52 -0
  18. simtools/applications/derive_mirror_rnda.py +39 -255
  19. simtools/applications/derive_psf_parameters.py +441 -0
  20. simtools/applications/generate_array_config.py +82 -0
  21. simtools/applications/generate_corsika_histograms.py +52 -52
  22. simtools/applications/generate_default_metadata.py +5 -8
  23. simtools/applications/generate_regular_arrays.py +117 -0
  24. simtools/applications/generate_simtel_array_histograms.py +97 -56
  25. simtools/applications/plot_array_layout.py +345 -115
  26. simtools/applications/production_generate_simulation_config.py +158 -0
  27. simtools/applications/production_scale_events.py +168 -0
  28. simtools/applications/simulate_light_emission.py +478 -0
  29. simtools/applications/simulate_prod.py +97 -175
  30. simtools/applications/submit_data_from_external.py +9 -12
  31. simtools/applications/submit_model_parameter_from_external.py +122 -0
  32. simtools/applications/validate_camera_efficiency.py +35 -102
  33. simtools/applications/validate_camera_fov.py +20 -19
  34. simtools/applications/{compare_cumulative_psf.py → validate_cumulative_psf.py} +45 -44
  35. simtools/applications/validate_file_using_schema.py +113 -47
  36. simtools/applications/validate_optics.py +17 -22
  37. simtools/camera_efficiency.py +193 -202
  38. simtools/configuration/commandline_parser.py +384 -96
  39. simtools/configuration/configurator.py +55 -71
  40. simtools/constants.py +5 -5
  41. simtools/corsika/corsika_config.py +482 -342
  42. simtools/corsika/corsika_histograms.py +226 -204
  43. simtools/corsika/corsika_histograms_visualize.py +23 -24
  44. simtools/corsika/primary_particle.py +159 -0
  45. simtools/data_model/data_reader.py +25 -20
  46. simtools/data_model/format_checkers.py +52 -0
  47. simtools/data_model/metadata_collector.py +210 -184
  48. simtools/data_model/metadata_model.py +115 -37
  49. simtools/data_model/model_data_writer.py +335 -26
  50. simtools/data_model/validate_data.py +366 -154
  51. simtools/db/db_array_elements.py +130 -0
  52. simtools/db/db_from_repo_handler.py +106 -0
  53. simtools/db/db_handler.py +1246 -0
  54. simtools/io_operations/hdf5_handler.py +3 -1
  55. simtools/io_operations/io_handler.py +32 -57
  56. simtools/job_execution/job_manager.py +82 -69
  57. simtools/layout/array_layout.py +329 -533
  58. simtools/layout/geo_coordinates.py +8 -11
  59. simtools/layout/telescope_position.py +163 -86
  60. simtools/model/array_model.py +305 -256
  61. simtools/model/calibration_model.py +50 -0
  62. simtools/model/camera.py +233 -496
  63. simtools/model/mirrors.py +61 -44
  64. simtools/model/model_parameter.py +602 -0
  65. simtools/model/model_utils.py +7 -103
  66. simtools/model/site_model.py +161 -0
  67. simtools/model/telescope_model.py +127 -621
  68. simtools/production_configuration/calculate_statistical_errors_grid_point.py +454 -0
  69. simtools/production_configuration/event_scaler.py +146 -0
  70. simtools/production_configuration/generate_simulation_config.py +193 -0
  71. simtools/production_configuration/interpolation_handler.py +197 -0
  72. simtools/ray_tracing/__init__.py +0 -0
  73. simtools/ray_tracing/mirror_panel_psf.py +280 -0
  74. simtools/{psf_analysis.py → ray_tracing/psf_analysis.py} +133 -47
  75. simtools/ray_tracing/ray_tracing.py +646 -0
  76. simtools/runners/__init__.py +0 -0
  77. simtools/runners/corsika_runner.py +240 -0
  78. simtools/runners/corsika_simtel_runner.py +225 -0
  79. simtools/runners/runner_services.py +307 -0
  80. simtools/runners/simtel_runner.py +224 -0
  81. simtools/schemas/array_elements.yml +137 -0
  82. simtools/schemas/integration_tests_config.metaschema.yml +93 -0
  83. simtools/schemas/metadata.metaschema.yml +6 -0
  84. simtools/schemas/model_parameter.metaschema.yml +78 -0
  85. simtools/schemas/{data.metaschema.yml → model_parameter_and_data_schema.metaschema.yml} +27 -44
  86. simtools/schemas/model_parameters/adjust_gain.schema.yml +37 -0
  87. simtools/schemas/model_parameters/altitude.schema.yml +37 -0
  88. simtools/schemas/model_parameters/array_coordinates.schema.yml +33 -0
  89. simtools/schemas/model_parameters/array_coordinates_UTM.schema.yml +77 -0
  90. simtools/schemas/model_parameters/array_element_position_ground.schema.yml +39 -0
  91. simtools/schemas/model_parameters/array_element_position_utm.schema.yml +39 -0
  92. simtools/schemas/model_parameters/array_layouts.schema.yml +48 -0
  93. simtools/schemas/model_parameters/array_triggers.schema.yml +93 -0
  94. simtools/schemas/model_parameters/asum_clipping.schema.yml +38 -0
  95. simtools/schemas/model_parameters/asum_offset.schema.yml +35 -0
  96. simtools/schemas/model_parameters/asum_shaping.schema.yml +35 -0
  97. simtools/schemas/model_parameters/asum_threshold.schema.yml +38 -0
  98. simtools/schemas/model_parameters/atmospheric_profile.schema.yml +32 -0
  99. simtools/schemas/model_parameters/atmospheric_transmission.schema.yml +35 -0
  100. simtools/schemas/model_parameters/axes_offsets.schema.yml +53 -0
  101. simtools/schemas/model_parameters/camera_body_diameter.schema.yml +40 -0
  102. simtools/schemas/model_parameters/camera_body_shape.schema.yml +45 -0
  103. simtools/schemas/model_parameters/camera_config_file.schema.yml +40 -0
  104. simtools/schemas/model_parameters/camera_config_rotate.schema.yml +36 -0
  105. simtools/schemas/model_parameters/camera_degraded_efficiency.schema.yml +43 -0
  106. simtools/schemas/model_parameters/camera_degraded_map.schema.yml +42 -0
  107. simtools/schemas/model_parameters/camera_depth.schema.yml +42 -0
  108. simtools/schemas/model_parameters/camera_filter.schema.yml +45 -0
  109. simtools/schemas/model_parameters/camera_filter_incidence_angle.schema.yml +29 -0
  110. simtools/schemas/model_parameters/camera_pixels.schema.yml +36 -0
  111. simtools/schemas/model_parameters/camera_transmission.schema.yml +41 -0
  112. simtools/schemas/model_parameters/channels_per_chip.schema.yml +36 -0
  113. simtools/schemas/model_parameters/correct_nsb_spectrum_to_telescope_altitude.schema.yml +35 -0
  114. simtools/schemas/model_parameters/corsika_cherenkov_photon_bunch_size.schema.yml +27 -0
  115. simtools/schemas/model_parameters/corsika_cherenkov_photon_wavelength_range.schema.yml +38 -0
  116. simtools/schemas/model_parameters/corsika_first_interaction_height.schema.yml +28 -0
  117. simtools/schemas/model_parameters/corsika_iact_io_buffer.schema.yml +23 -0
  118. simtools/schemas/model_parameters/corsika_iact_max_bunches.schema.yml +27 -0
  119. simtools/schemas/model_parameters/corsika_iact_split_auto.schema.yml +28 -0
  120. simtools/schemas/model_parameters/corsika_longitudinal_shower_development.schema.yml +27 -0
  121. simtools/schemas/model_parameters/corsika_observation_level.schema.yml +38 -0
  122. simtools/schemas/model_parameters/corsika_particle_kinetic_energy_cutoff.schema.yml +52 -0
  123. simtools/schemas/model_parameters/corsika_starting_grammage.schema.yml +27 -0
  124. simtools/schemas/model_parameters/dark_events.schema.yml +32 -0
  125. simtools/schemas/model_parameters/default_trigger.schema.yml +35 -0
  126. simtools/schemas/model_parameters/design_model.schema.yml +31 -0
  127. simtools/schemas/model_parameters/disc_ac_coupled.schema.yml +32 -0
  128. simtools/schemas/model_parameters/disc_bins.schema.yml +39 -0
  129. simtools/schemas/model_parameters/disc_start.schema.yml +41 -0
  130. simtools/schemas/model_parameters/discriminator_amplitude.schema.yml +42 -0
  131. simtools/schemas/model_parameters/discriminator_fall_time.schema.yml +41 -0
  132. simtools/schemas/model_parameters/discriminator_gate_length.schema.yml +41 -0
  133. simtools/schemas/model_parameters/discriminator_hysteresis.schema.yml +39 -0
  134. simtools/schemas/model_parameters/discriminator_output_amplitude.schema.yml +40 -0
  135. simtools/schemas/model_parameters/discriminator_output_var_percent.schema.yml +41 -0
  136. simtools/schemas/model_parameters/discriminator_pulse_shape.schema.yml +33 -0
  137. simtools/schemas/model_parameters/discriminator_rise_time.schema.yml +42 -0
  138. simtools/schemas/model_parameters/discriminator_scale_threshold.schema.yml +37 -0
  139. simtools/schemas/model_parameters/discriminator_sigsum_over_threshold.schema.yml +44 -0
  140. simtools/schemas/model_parameters/discriminator_threshold.schema.yml +36 -0
  141. simtools/schemas/model_parameters/discriminator_time_over_threshold.schema.yml +45 -0
  142. simtools/schemas/model_parameters/discriminator_var_gate_length.schema.yml +40 -0
  143. simtools/schemas/model_parameters/discriminator_var_sigsum_over_threshold.schema.yml +41 -0
  144. simtools/schemas/model_parameters/discriminator_var_threshold.schema.yml +38 -0
  145. simtools/schemas/model_parameters/discriminator_var_time_over_threshold.schema.yml +38 -0
  146. simtools/schemas/model_parameters/dish_shape_length.schema.yml +41 -0
  147. simtools/schemas/model_parameters/dsum_clipping.schema.yml +38 -0
  148. simtools/schemas/model_parameters/dsum_ignore_below.schema.yml +38 -0
  149. simtools/schemas/model_parameters/dsum_offset.schema.yml +37 -0
  150. simtools/schemas/model_parameters/dsum_pedsub.schema.yml +33 -0
  151. simtools/schemas/model_parameters/dsum_pre_clipping.schema.yml +39 -0
  152. simtools/schemas/model_parameters/dsum_prescale.schema.yml +44 -0
  153. simtools/schemas/model_parameters/dsum_presum_max.schema.yml +38 -0
  154. simtools/schemas/model_parameters/dsum_presum_shift.schema.yml +45 -0
  155. simtools/schemas/model_parameters/dsum_shaping.schema.yml +44 -0
  156. simtools/schemas/model_parameters/dsum_shaping_renormalize.schema.yml +32 -0
  157. simtools/schemas/model_parameters/dsum_threshold.schema.yml +43 -0
  158. simtools/schemas/model_parameters/dsum_zero_clip.schema.yml +42 -0
  159. simtools/schemas/model_parameters/effective_focal_length.schema.yml +61 -0
  160. simtools/schemas/model_parameters/epsg_code.schema.yml +37 -0
  161. simtools/schemas/model_parameters/fadc_ac_coupled.schema.yml +35 -0
  162. simtools/schemas/model_parameters/fadc_amplitude.schema.yml +46 -0
  163. simtools/schemas/model_parameters/fadc_bins.schema.yml +40 -0
  164. simtools/schemas/model_parameters/fadc_compensate_pedestal.schema.yml +50 -0
  165. simtools/schemas/model_parameters/fadc_dev_pedestal.schema.yml +38 -0
  166. simtools/schemas/model_parameters/fadc_err_compensate_pedestal.schema.yml +42 -0
  167. simtools/schemas/model_parameters/fadc_err_pedestal.schema.yml +49 -0
  168. simtools/schemas/model_parameters/fadc_lg_amplitude.schema.yml +47 -0
  169. simtools/schemas/model_parameters/fadc_lg_compensate_pedestal.schema.yml +51 -0
  170. simtools/schemas/model_parameters/fadc_lg_dev_pedestal.schema.yml +37 -0
  171. simtools/schemas/model_parameters/fadc_lg_err_compensate_pedestal.schema.yml +43 -0
  172. simtools/schemas/model_parameters/fadc_lg_err_pedestal.schema.yml +49 -0
  173. simtools/schemas/model_parameters/fadc_lg_max_signal.schema.yml +43 -0
  174. simtools/schemas/model_parameters/fadc_lg_max_sum.schema.yml +39 -0
  175. simtools/schemas/model_parameters/fadc_lg_noise.schema.yml +42 -0
  176. simtools/schemas/model_parameters/fadc_lg_pedestal.schema.yml +40 -0
  177. simtools/schemas/model_parameters/fadc_lg_sensitivity.schema.yml +50 -0
  178. simtools/schemas/model_parameters/fadc_lg_sysvar_pedestal.schema.yml +42 -0
  179. simtools/schemas/model_parameters/fadc_lg_var_pedestal.schema.yml +41 -0
  180. simtools/schemas/model_parameters/fadc_lg_var_sensitivity.schema.yml +42 -0
  181. simtools/schemas/model_parameters/fadc_max_signal.schema.yml +43 -0
  182. simtools/schemas/model_parameters/fadc_max_sum.schema.yml +39 -0
  183. simtools/schemas/model_parameters/fadc_mhz.schema.yml +31 -0
  184. simtools/schemas/model_parameters/fadc_noise.schema.yml +41 -0
  185. simtools/schemas/model_parameters/fadc_pedestal.schema.yml +40 -0
  186. simtools/schemas/model_parameters/fadc_pulse_shape.schema.yml +39 -0
  187. simtools/schemas/model_parameters/fadc_sensitivity.schema.yml +50 -0
  188. simtools/schemas/model_parameters/fadc_sum_bins.schema.yml +43 -0
  189. simtools/schemas/model_parameters/fadc_sum_offset.schema.yml +43 -0
  190. simtools/schemas/model_parameters/fadc_sysvar_pedestal.schema.yml +42 -0
  191. simtools/schemas/model_parameters/fadc_var_pedestal.schema.yml +41 -0
  192. simtools/schemas/model_parameters/fadc_var_sensitivity.schema.yml +42 -0
  193. simtools/schemas/model_parameters/flatfielding.schema.yml +37 -0
  194. simtools/schemas/model_parameters/focal_length.schema.yml +45 -0
  195. simtools/schemas/model_parameters/focal_surface_parameters.schema.yml +158 -0
  196. simtools/schemas/model_parameters/focal_surface_ref_radius.schema.yml +29 -0
  197. simtools/schemas/model_parameters/focus_offset.schema.yml +66 -0
  198. simtools/schemas/model_parameters/gain_variation.schema.yml +43 -0
  199. simtools/schemas/model_parameters/geomag_horizontal.schema.yml +34 -0
  200. simtools/schemas/model_parameters/geomag_rotation.schema.yml +37 -0
  201. simtools/schemas/model_parameters/geomag_vertical.schema.yml +34 -0
  202. simtools/schemas/model_parameters/hg_lg_variation.schema.yml +36 -0
  203. simtools/schemas/model_parameters/iobuf_maximum.schema.yml +34 -0
  204. simtools/schemas/model_parameters/iobuf_output_maximum.schema.yml +34 -0
  205. simtools/schemas/model_parameters/laser_events.schema.yml +36 -0
  206. simtools/schemas/model_parameters/laser_external_trigger.schema.yml +35 -0
  207. simtools/schemas/model_parameters/laser_photons.schema.yml +32 -0
  208. simtools/schemas/model_parameters/laser_pulse_exptime.schema.yml +34 -0
  209. simtools/schemas/model_parameters/laser_pulse_offset.schema.yml +34 -0
  210. simtools/schemas/model_parameters/laser_pulse_sigtime.schema.yml +33 -0
  211. simtools/schemas/model_parameters/laser_pulse_twidth.schema.yml +33 -0
  212. simtools/schemas/model_parameters/laser_var_photons.schema.yml +33 -0
  213. simtools/schemas/model_parameters/laser_wavelength.schema.yml +33 -0
  214. simtools/schemas/model_parameters/led_events.schema.yml +34 -0
  215. simtools/schemas/model_parameters/led_photons.schema.yml +34 -0
  216. simtools/schemas/model_parameters/led_pulse_offset.schema.yml +32 -0
  217. simtools/schemas/model_parameters/led_pulse_sigtime.schema.yml +33 -0
  218. simtools/schemas/model_parameters/led_var_photons.schema.yml +34 -0
  219. simtools/schemas/model_parameters/lightguide_efficiency_vs_incidence_angle.schema.yml +41 -0
  220. simtools/schemas/model_parameters/lightguide_efficiency_vs_wavelength.schema.yml +43 -0
  221. simtools/schemas/model_parameters/min_photoelectrons.schema.yml +35 -0
  222. simtools/schemas/model_parameters/min_photons.schema.yml +32 -0
  223. simtools/schemas/model_parameters/mirror_align_random_distance.schema.yml +36 -0
  224. simtools/schemas/model_parameters/mirror_align_random_horizontal.schema.yml +64 -0
  225. simtools/schemas/model_parameters/mirror_align_random_vertical.schema.yml +64 -0
  226. simtools/schemas/model_parameters/mirror_class.schema.yml +41 -0
  227. simtools/schemas/model_parameters/mirror_degraded_reflection.schema.yml +51 -0
  228. simtools/schemas/model_parameters/mirror_focal_length.schema.yml +42 -0
  229. simtools/schemas/model_parameters/mirror_list.schema.yml +38 -0
  230. simtools/schemas/model_parameters/mirror_offset.schema.yml +41 -0
  231. simtools/schemas/model_parameters/mirror_panel_2f_measurements.schema.yml +39 -0
  232. simtools/schemas/model_parameters/mirror_reflection_random_angle.schema.yml +61 -0
  233. simtools/schemas/model_parameters/mirror_reflectivity.schema.yml +40 -0
  234. simtools/schemas/model_parameters/multiplicity_offset.schema.yml +46 -0
  235. simtools/schemas/model_parameters/nsb_autoscale_airmass.schema.yml +51 -0
  236. simtools/schemas/model_parameters/nsb_gain_drop_scale.schema.yml +37 -0
  237. simtools/schemas/model_parameters/nsb_offaxis.schema.yml +79 -0
  238. simtools/schemas/model_parameters/nsb_pixel_rate.schema.yml +47 -0
  239. simtools/schemas/model_parameters/nsb_reference_spectrum.schema.yml +34 -0
  240. simtools/schemas/model_parameters/nsb_reference_value.schema.yml +33 -0
  241. simtools/schemas/model_parameters/nsb_scaling_factor.schema.yml +35 -0
  242. simtools/schemas/model_parameters/nsb_skymap.schema.yml +39 -0
  243. simtools/schemas/model_parameters/nsb_spectrum.schema.yml +50 -0
  244. simtools/schemas/model_parameters/num_gains.schema.yml +34 -0
  245. simtools/schemas/model_parameters/only_triggered_telescopes.schema.yml +33 -0
  246. simtools/schemas/model_parameters/optics_properties.schema.yml +31 -0
  247. simtools/schemas/model_parameters/parabolic_dish.schema.yml +32 -0
  248. simtools/schemas/model_parameters/pedestal_events.schema.yml +32 -0
  249. simtools/schemas/model_parameters/photon_delay.schema.yml +38 -0
  250. simtools/schemas/model_parameters/photons_per_run.schema.yml +33 -0
  251. simtools/schemas/model_parameters/pixel_cells.schema.yml +35 -0
  252. simtools/schemas/model_parameters/pixels_parallel.schema.yml +54 -0
  253. simtools/schemas/model_parameters/pixeltrg_time_step.schema.yml +40 -0
  254. simtools/schemas/model_parameters/pm_average_gain.schema.yml +34 -0
  255. simtools/schemas/model_parameters/pm_collection_efficiency.schema.yml +40 -0
  256. simtools/schemas/model_parameters/pm_gain_index.schema.yml +36 -0
  257. simtools/schemas/model_parameters/pm_photoelectron_spectrum.schema.yml +41 -0
  258. simtools/schemas/model_parameters/pm_transit_time.schema.yml +63 -0
  259. simtools/schemas/model_parameters/pm_voltage_variation.schema.yml +39 -0
  260. simtools/schemas/model_parameters/primary_mirror_degraded_map.schema.yml +42 -0
  261. simtools/schemas/model_parameters/primary_mirror_diameter.schema.yml +33 -0
  262. simtools/schemas/model_parameters/primary_mirror_hole_diameter.schema.yml +33 -0
  263. simtools/schemas/model_parameters/primary_mirror_incidence_angle.schema.yml +29 -0
  264. simtools/schemas/model_parameters/primary_mirror_parameters.schema.yml +168 -0
  265. simtools/schemas/model_parameters/primary_mirror_ref_radius.schema.yml +36 -0
  266. simtools/schemas/model_parameters/primary_mirror_segmentation.schema.yml +34 -0
  267. simtools/schemas/model_parameters/qe_variation.schema.yml +43 -0
  268. simtools/schemas/model_parameters/quantum_efficiency.schema.yml +42 -0
  269. simtools/schemas/model_parameters/random_focal_length.schema.yml +45 -0
  270. simtools/schemas/model_parameters/random_generator.schema.yml +36 -0
  271. simtools/schemas/model_parameters/reference_point_altitude.schema.yml +35 -0
  272. simtools/schemas/model_parameters/reference_point_latitude.schema.yml +36 -0
  273. simtools/schemas/model_parameters/reference_point_longitude.schema.yml +36 -0
  274. simtools/schemas/model_parameters/reference_point_utm_east.schema.yml +34 -0
  275. simtools/schemas/model_parameters/reference_point_utm_north.schema.yml +34 -0
  276. simtools/schemas/model_parameters/sampled_output.schema.yml +31 -0
  277. simtools/schemas/model_parameters/save_pe_with_amplitude.schema.yml +34 -0
  278. simtools/schemas/model_parameters/secondary_mirror_baffle.schema.yml +79 -0
  279. simtools/schemas/model_parameters/secondary_mirror_degraded_map.schema.yml +42 -0
  280. simtools/schemas/model_parameters/secondary_mirror_degraded_reflection.schema.yml +41 -0
  281. simtools/schemas/model_parameters/secondary_mirror_diameter.schema.yml +33 -0
  282. simtools/schemas/model_parameters/secondary_mirror_hole_diameter.schema.yml +36 -0
  283. simtools/schemas/model_parameters/secondary_mirror_incidence_angle.schema.yml +29 -0
  284. simtools/schemas/model_parameters/secondary_mirror_parameters.schema.yml +168 -0
  285. simtools/schemas/model_parameters/secondary_mirror_ref_radius.schema.yml +36 -0
  286. simtools/schemas/model_parameters/secondary_mirror_reflectivity.schema.yml +35 -0
  287. simtools/schemas/model_parameters/secondary_mirror_segmentation.schema.yml +37 -0
  288. simtools/schemas/model_parameters/secondary_mirror_shadow_diameter.schema.yml +40 -0
  289. simtools/schemas/model_parameters/secondary_mirror_shadow_offset.schema.yml +40 -0
  290. simtools/schemas/model_parameters/store_photoelectrons.schema.yml +41 -0
  291. simtools/schemas/model_parameters/tailcut_scale.schema.yml +40 -0
  292. simtools/schemas/model_parameters/telescope_axis_height.schema.yml +31 -0
  293. simtools/schemas/model_parameters/telescope_random_angle.schema.yml +35 -0
  294. simtools/schemas/model_parameters/telescope_random_error.schema.yml +34 -0
  295. simtools/schemas/model_parameters/telescope_sphere_radius.schema.yml +37 -0
  296. simtools/schemas/model_parameters/telescope_transmission.schema.yml +113 -0
  297. simtools/schemas/model_parameters/teltrig_min_sigsum.schema.yml +41 -0
  298. simtools/schemas/model_parameters/teltrig_min_time.schema.yml +36 -0
  299. simtools/schemas/model_parameters/transit_time_calib_error.schema.yml +36 -0
  300. simtools/schemas/model_parameters/transit_time_compensate_error.schema.yml +37 -0
  301. simtools/schemas/model_parameters/transit_time_compensate_step.schema.yml +38 -0
  302. simtools/schemas/model_parameters/transit_time_error.schema.yml +45 -0
  303. simtools/schemas/model_parameters/transit_time_jitter.schema.yml +36 -0
  304. simtools/schemas/model_parameters/trigger_current_limit.schema.yml +32 -0
  305. simtools/schemas/model_parameters/trigger_delay_compensation.schema.yml +53 -0
  306. simtools/schemas/model_parameters/trigger_pixels.schema.yml +40 -0
  307. simtools/simtel/simtel_config_reader.py +353 -0
  308. simtools/simtel/simtel_config_writer.py +244 -63
  309. simtools/simtel/{simtel_events.py → simtel_io_events.py} +26 -25
  310. simtools/simtel/simtel_io_histogram.py +661 -0
  311. simtools/simtel/simtel_io_histograms.py +569 -0
  312. simtools/simtel/simulator_array.py +145 -0
  313. simtools/simtel/{simtel_runner_camera_efficiency.py → simulator_camera_efficiency.py} +76 -52
  314. simtools/simtel/simulator_light_emission.py +473 -0
  315. simtools/simtel/simulator_ray_tracing.py +262 -0
  316. simtools/simulator.py +220 -446
  317. simtools/testing/__init__.py +0 -0
  318. simtools/testing/assertions.py +151 -0
  319. simtools/testing/configuration.py +226 -0
  320. simtools/testing/helpers.py +42 -0
  321. simtools/testing/validate_output.py +240 -0
  322. simtools/utils/general.py +340 -437
  323. simtools/utils/geometry.py +12 -12
  324. simtools/utils/names.py +266 -568
  325. simtools/utils/value_conversion.py +176 -0
  326. simtools/version.py +2 -0
  327. simtools/visualization/legend_handlers.py +135 -152
  328. simtools/visualization/plot_camera.py +379 -0
  329. simtools/visualization/visualize.py +346 -167
  330. gammasimtools-0.6.0.dist-info/METADATA +0 -180
  331. gammasimtools-0.6.0.dist-info/RECORD +0 -91
  332. gammasimtools-0.6.0.dist-info/entry_points.txt +0 -23
  333. simtools/applications/db_development_tools/add_new_parameter_to_db.py +0 -81
  334. simtools/applications/db_development_tools/add_unit_to_parameter_in_db.py +0 -59
  335. simtools/applications/db_development_tools/mark_non_optics_parameters_non_applicable.py +0 -102
  336. simtools/applications/get_parameter.py +0 -92
  337. simtools/applications/make_regular_arrays.py +0 -160
  338. simtools/applications/produce_array_config.py +0 -136
  339. simtools/applications/production.py +0 -313
  340. simtools/applications/sim_showers_for_trigger_rates.py +0 -187
  341. simtools/applications/tune_psf.py +0 -334
  342. simtools/corsika/corsika_default_config.py +0 -282
  343. simtools/corsika/corsika_runner.py +0 -450
  344. simtools/corsika_simtel/corsika_simtel_runner.py +0 -197
  345. simtools/db_handler.py +0 -1481
  346. simtools/ray_tracing.py +0 -525
  347. simtools/simtel/simtel_histograms.py +0 -414
  348. simtools/simtel/simtel_runner.py +0 -244
  349. simtools/simtel/simtel_runner_array.py +0 -293
  350. simtools/simtel/simtel_runner_ray_tracing.py +0 -277
  351. {gammasimtools-0.6.0.dist-info → gammasimtools-0.8.1.dist-info}/LICENSE +0 -0
  352. {gammasimtools-0.6.0.dist-info → gammasimtools-0.8.1.dist-info}/top_level.txt +0 -0
  353. /simtools/{corsika_simtel → db}/__init__.py +0 -0
@@ -1,21 +1,21 @@
1
1
  #!/usr/bin/python3
2
2
 
3
- """
4
- Summary
5
- -------
6
- This application produces a set of histograms of the distribution of Cherenkov photons on the
7
- ground (at observation level) read from the CORSIKA IACT output file provided as input.
3
+ r"""
4
+ Generates a set of histograms Cherenkov photon distributions from CORSIKA output.
5
+
6
+ The Cherenkov photons (from observation level) are read from a CORSIKA IACT
7
+ output file provided as input.
8
8
 
9
9
  The histograms can be saved both into pdfs and in a hdf5 file.
10
10
 
11
- The following 2D histograms are produced:
11
+ The following 2D histograms are generated:
12
12
  - Number of Cherenkov photons on the ground;
13
13
  - Density of Cherenkov photons on the ground;
14
14
  - Incoming direction (directive cosines) of the Cherenkov photons;
15
15
  - Time of arrival (ns) vs altitude of production (km);
16
16
  - Number of Cherenkov photons per event per telescope.
17
17
 
18
- The following 1D histograms are produced:
18
+ The following 1D histograms are generated:
19
19
  - Wavelength;
20
20
  - Counts;
21
21
  - Density;
@@ -25,7 +25,7 @@
25
25
  - Number of photons per event.
26
26
 
27
27
  Histograms for the distribution of CORSIKA event header elements can also be generated by using
28
- the `--event_1d_histograms` and `--event_2d_histograms` arguments. The accepted arguments (keys)
28
+ the --event_1d_histograms and --event_2d_histograms arguments. The accepted arguments (keys)
29
29
  are to be found in the CORSIKA manual, e.g., "total_energy", "zenith", "azimuth".
30
30
 
31
31
  Command line arguments
@@ -65,7 +65,7 @@
65
65
  bins: 100
66
66
  scale: linear
67
67
  start: !astropy.units.Quantity
68
- unit: &id001 !astropy.units.Unit {unit: m}
68
+ unit: &id001 m
69
69
  value: -1000.0
70
70
  stop: &id002 !astropy.units.Quantity
71
71
  unit: *id001
@@ -81,7 +81,7 @@
81
81
  bins: 80
82
82
  scale: linear
83
83
  start: !astropy.units.Quantity
84
- unit: &id003 !astropy.units.Unit {unit: nm}
84
+ unit: nm
85
85
  value: 200.0
86
86
  stop: !astropy.units.Quantity
87
87
  unit: *id003
@@ -91,7 +91,7 @@
91
91
  bins: 100
92
92
  scale: linear
93
93
  start: !astropy.units.Quantity
94
- unit: &id004 !astropy.units.Unit {unit: ns}
94
+ unit: ns
95
95
  value: -2000.0
96
96
  stop: !astropy.units.Quantity
97
97
  unit: *id004
@@ -100,7 +100,7 @@
100
100
  bins: 100
101
101
  scale: linear
102
102
  start: !astropy.units.Quantity
103
- unit: &id005 !astropy.units.Unit {unit: km}
103
+ unit: km
104
104
  value: 120.0
105
105
  stop: !astropy.units.Quantity
106
106
  unit: *id005
@@ -110,10 +110,10 @@
110
110
  pdf (bool, optional)
111
111
  If set, histograms are saved into pdf files.
112
112
  One pdf file contains all the histograms for the Cherenkov photons.
113
- The name of the file is controlled via `hdf5_file_name`.
113
+ The name of the file is controlled via hdf5_file_name.
114
114
  If event_1d_histograms and event_2d_histograms are used, two separate pdf files might be
115
115
  created to accommodate the histograms for the CORSIKA event header elements. The core names
116
- of these output pdf files are also given by `hdf5_file_name` argument with the addition of
116
+ of these output pdf files are also given by hdf5_file_name argument with the addition of
117
117
  'event_1d_histograms' and 'event_2d_histograms'.
118
118
 
119
119
 
@@ -122,28 +122,28 @@
122
122
 
123
123
  hdf5_file_name (str, optional)
124
124
  The name of the output hdf5 data (without the path).
125
- It requires the `--hdf5` flag.
126
- If not given, `hdf5_file_name` takes the name from the input IACT file (`input_file`).
127
- If the output `hdf5_file_name` file already exists, the tables associated to the chosen
128
- flags (e.g. `hdf5`, `event_1d_histograms`, `event_2d_histograms`) will be overwritten. The
125
+ It requires the --hdf5 flag.
126
+ If not given, hdf5_file_name takes the name from the input IACT file (input_file).
127
+ If the output hdf5_file_name file already exists, the tables associated to the chosen
128
+ flags (e.g. hdf5, event_1d_histograms, event_2d_histograms) will be overwritten. The
129
129
  remaining tables, if any, will stay untouched.
130
130
 
131
131
 
132
132
  event_1d_histograms (str, optional)
133
- Produce 1D histograms for elements given in `--event_1d_histograms` from the CORSIKA event
133
+ Generate 1D histograms for elements given in --event_1d_histograms from the CORSIKA event
134
134
  header and save into hdf5/pdf files.
135
135
  It allows more than one argument, separated by simple spaces.
136
- Usage: `--event_1d_histograms first_interaction_height total_energy`.
136
+ Usage: --event_1d_histograms first_interaction_height total_energy.
137
137
 
138
138
  event_2d_histograms (str, optional)
139
- Produce 2D histograms for elements given in `--event_2d_histograms` from the CORSIKA event
139
+ Generate 2D histograms for elements given in --event_2d_histograms from the CORSIKA event
140
140
  header and save into hdf5/pdf files.
141
141
  It allows more than one argument, separated by simple spaces.
142
- The elements are grouped into pairs and the 2D histograms are produced always for two
142
+ The elements are grouped into pairs and the 2D histograms are generated always for two
143
143
  subsequent elements.
144
- For example, `--event_2d_histograms first_interaction_height total_energy zenith azimuth`
145
- will produce one 2D histogram for `first_interaction_height` `total_energy` and another 2D
146
- histogram for `zenith` and `azimuth`.
144
+ For example, --event_2d_histograms first_interaction_height total_energy zenith azimuth
145
+ will generate one 2D histogram for first_interaction_height total_energy and another 2D
146
+ histogram for zenith and azimuth.
147
147
 
148
148
  Example
149
149
  -------
@@ -151,11 +151,11 @@
151
151
 
152
152
  .. code-block:: console
153
153
 
154
- simtools-generate-corsika-histograms --iact_file /workdir/external/simtools/tests/\
155
- resources/tel_output_10GeV-2-gamma-20deg-CTAO-South.corsikaio --pdf --hdf5
154
+ simtools-generate-corsika-histograms --iact_file /workdir/external/simtools/\\
155
+ testsresources/tel_output_10GeV-2-gamma-20deg-CTAO-South.corsikaio \\
156
+ --pdf --hdf5 \\
156
157
  --event_2d_histograms zenith azimuth --event_1d_histograms total_energy
157
158
 
158
-
159
159
  Expected final print-out message:
160
160
 
161
161
  .. code-block:: console
@@ -182,7 +182,7 @@ logger = logging.getLogger()
182
182
 
183
183
  def _parse(label, description):
184
184
  """
185
- Parse command line configuration
185
+ Parse command line configuration.
186
186
 
187
187
  Parameters
188
188
  ----------
@@ -251,7 +251,7 @@ def _parse(label, description):
251
251
  config.parser.add_argument(
252
252
  "--event_1d_histograms",
253
253
  help="The keys from the CORSIKA event header to be used for the generation of 1D "
254
- "histograms. The available choices can been found in the `all_event_keys` attribute of"
254
+ "histograms. The available choices can been found in the all_event_keys attribute of"
255
255
  "the CorsikaHistograms.",
256
256
  required=False,
257
257
  default=None,
@@ -261,7 +261,7 @@ def _parse(label, description):
261
261
  config.parser.add_argument(
262
262
  "--event_2d_histograms",
263
263
  help="The keys from the CORSIKA event header to be used for the generation of 2D "
264
- "histograms. The available choices can been found in the `all_event_keys` attribute of"
264
+ "histograms. The available choices can been found in the all_event_keys attribute of"
265
265
  "the CorsikaHistograms.",
266
266
  required=False,
267
267
  default=None,
@@ -270,16 +270,16 @@ def _parse(label, description):
270
270
 
271
271
  config_parser, _ = config.initialize(db_config=False, paths=True)
272
272
 
273
- if not config_parser["pdf"]:
274
- if (
275
- not config_parser["hdf5"]
276
- and not config_parser["event_1d_histograms"]
277
- and not config_parser["event_2d_histograms"]
278
- ):
279
- config.parser.error(
280
- "At least one argument is required: `--pdf`, `--hdf5`, `--event_1d_histograms`, or "
281
- "`--event_2d_histograms`."
282
- )
273
+ if (
274
+ not config_parser["pdf"]
275
+ and not config_parser["hdf5"]
276
+ and not config_parser["event_1d_histograms"]
277
+ and not config_parser["event_2d_histograms"]
278
+ ):
279
+ config.parser.error(
280
+ "At least one argument is required: --pdf, --hdf5, --event_1d_histograms, or "
281
+ "--event_2d_histograms."
282
+ )
283
283
 
284
284
  return config_parser, _
285
285
 
@@ -290,12 +290,11 @@ def _plot_figures(corsika_histograms_instance, test=False):
290
290
 
291
291
  Parameters
292
292
  ----------
293
- corsika_histograms_instance: `CorsikaHistograms` instance.
293
+ corsika_histograms_instance: CorsikaHistograms instance.
294
294
  The CorsikaHistograms instance created in main.
295
295
  test: bool
296
296
  If true plots the figures for the first two functions only.
297
297
  """
298
-
299
298
  plot_function_names = [
300
299
  plotting_method
301
300
  for plotting_method in dir(corsika_histograms_visualize)
@@ -307,8 +306,8 @@ def _plot_figures(corsika_histograms_instance, test=False):
307
306
 
308
307
  figure_list = []
309
308
  for function_name in plot_function_names:
310
- function = getattr(corsika_histograms_visualize, function_name)
311
- figures = function(corsika_histograms_instance)
309
+ plot_function = getattr(corsika_histograms_visualize, function_name)
310
+ figures = plot_function(corsika_histograms_instance)
312
311
  for fig in figures:
313
312
  figure_list.append(fig)
314
313
 
@@ -326,10 +325,10 @@ def _derive_event_1d_histograms(
326
325
 
327
326
  Parameters
328
327
  ----------
329
- corsika_histograms_instance: `CorsikaHistograms` instance.
328
+ corsika_histograms_instance: CorsikaHistograms instance.
330
329
  The CorsikaHistograms instance created in main.
331
330
  event_1d_header_keys: str
332
- Produce 1D histograms for elements given in `event_1d_header_keys` from the CORSIKA event
331
+ Generate 1D histograms for elements given in event_1d_header_keys from the CORSIKA event
333
332
  header and save into hdf5/pdf files.
334
333
  pdf: bool
335
334
  If true, histograms are saved into a pdf file.
@@ -362,14 +361,15 @@ def _derive_event_2d_histograms(
362
361
  ):
363
362
  """
364
363
  Auxiliary function to derive the histograms for the arguments given by event_1d_histograms.
364
+
365
365
  If an odd number of event header keys are given, the last one is discarded.
366
366
 
367
367
  Parameters
368
368
  ----------
369
- corsika_histograms_instance: `CorsikaHistograms` instance.
369
+ corsika_histograms_instance: CorsikaHistograms instance.
370
370
  The CorsikaHistograms instance created in main.
371
371
  event_2d_header_keys: str
372
- Produce 1D histograms for elements given in `event_1d_header_keys` from the CORSIKA event
372
+ Generate 1D histograms for elements given in event_1d_header_keys from the CORSIKA event
373
373
  header and save into hdf5/pdf files.
374
374
  pdf: bool
375
375
  If true, histograms are saved into a pdf file.
@@ -384,7 +384,7 @@ def _derive_event_2d_histograms(
384
384
 
385
385
  if len(event_2d_header_keys) % 2 == 1: # if odd number of keys
386
386
  msg = (
387
- "An odd number of keys was passed to produce 2D histograms."
387
+ "An odd number of keys was passed to generate 2D histograms."
388
388
  "The last key is being ignored."
389
389
  )
390
390
  logger.warning(msg)
@@ -412,7 +412,7 @@ def _derive_event_2d_histograms(
412
412
  corsika_histograms_visualize.save_figs_to_pdf(figures_list, output_file_name)
413
413
 
414
414
 
415
- def main():
415
+ def main(): # noqa: D103
416
416
  label = Path(__file__).stem
417
417
  description = "Generate histograms for the Cherenkov photons saved in the CORSIKA IACT file."
418
418
  io_handler_instance = io_handler.IOHandler()
@@ -433,7 +433,7 @@ def main():
433
433
  except ValueError:
434
434
  msg = (
435
435
  f"{args_dict['telescope_indices']} not a valid input. "
436
- f"Please use integer numbers for `telescope_indices`"
436
+ f"Please use integer numbers for telescope_indices"
437
437
  )
438
438
  logger.error(msg)
439
439
  raise
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/python3
2
- """
3
- Summary
4
- -------
2
+ r"""
5
3
  Generate a default simtools metadata file from a json schema.
6
4
 
7
5
  Command line arguments
@@ -16,8 +14,8 @@
16
14
  -------
17
15
  .. code-block:: console
18
16
 
19
- simtools-generate-default-metadata
20
- --schema simtools/schemas/metadata.metaschema.yml
17
+ simtools-generate-default-metadata \\
18
+ --schema simtools/schemas/metadata.metaschema.yml \\
21
19
  --output_file default_metadata.yml
22
20
 
23
21
 
@@ -37,7 +35,7 @@ from simtools.io_operations import io_handler
37
35
 
38
36
  def _parse(label, description):
39
37
  """
40
- Parse command line configuration
38
+ Parse command line configuration.
41
39
 
42
40
  Parameters
43
41
  ----------
@@ -52,7 +50,6 @@ def _parse(label, description):
52
50
  Command line parser object
53
51
 
54
52
  """
55
-
56
53
  config = configurator.Configurator(label=label, description=description)
57
54
 
58
55
  config.parser.add_argument(
@@ -71,7 +68,7 @@ def _parse(label, description):
71
68
  return config.initialize(output=False, require_command_line=True)
72
69
 
73
70
 
74
- def main():
71
+ def main(): # noqa: D103
75
72
  label = Path(__file__).stem
76
73
  args_dict, _ = _parse(
77
74
  label, description="Generate a default simtools metadata file from a json schema."
@@ -0,0 +1,117 @@
1
+ #!/usr/bin/python3
2
+
3
+ """
4
+ Make a regular array of telescopes and save it as astropy table.
5
+
6
+ The arrays consist of one telescope at the center of the array and or of 4 telescopes
7
+ in a square grid. These arrays are used for trigger rate simulations.
8
+
9
+ The array layout files created will be available at the data/layout directory.
10
+
11
+ Command line arguments
12
+ ----------------------
13
+ site (str, required)
14
+ observatory site (e.g., North or South).
15
+ model_version (str, optional)
16
+ Model version to use (e.g., 6.0.0). If not provided, the latest version is used.
17
+
18
+ Example
19
+ -------
20
+ Runtime < 10 s.
21
+
22
+ .. code-block:: console
23
+
24
+ simtools-generate-regular-arrays --site=North
25
+ """
26
+
27
+ import logging
28
+ import os
29
+ from pathlib import Path
30
+
31
+ import astropy.units as u
32
+ from astropy.table import QTable
33
+
34
+ import simtools.data_model.model_data_writer as writer
35
+ import simtools.utils.general as gen
36
+ from simtools.configuration import configurator
37
+ from simtools.utils import names
38
+
39
+ # Telescope distances for 4 tel square arrays
40
+ # !HARDCODED
41
+ telescope_distance = {"LST": 57.5 * u.m, "MST": 70 * u.m, "SST": 80 * u.m}
42
+
43
+
44
+ def _parse():
45
+ config = configurator.Configurator(
46
+ label=Path(__file__).stem,
47
+ description=(
48
+ "Generate a regular array of telescope and save as astropy table.\n"
49
+ "Default telescope distances for 4 telescope square arrays are: \n"
50
+ f" LST: {telescope_distance['LST']}\n"
51
+ f" MST: {telescope_distance['MST']}\n"
52
+ f" SST: {telescope_distance['SST']}\n"
53
+ ),
54
+ )
55
+ return config.initialize(db_config=False, simulation_model="site", output=True)
56
+
57
+
58
+ def main():
59
+ """Create layout array files (ecsv) of regular arrays."""
60
+ args_dict, _ = _parse()
61
+
62
+ logger = logging.getLogger()
63
+ logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
64
+
65
+ if args_dict["site"] == "South":
66
+ array_list = ["1SST", "4SST", "1MST", "4MST", "1LST", "4LST"]
67
+ else:
68
+ array_list = ["1MST", "4MST", "1LST", "4LST"]
69
+
70
+ for array_name in array_list:
71
+ logger.info(f"Processing array {array_name}")
72
+
73
+ tel_name, pos_x, pos_y, pos_z = [], [], [], []
74
+ tel_size = array_name[1:4]
75
+
76
+ # Single telescope at the center
77
+ if array_name[0] == "1":
78
+ tel_name.append(
79
+ names.get_array_element_name_from_type_site_id(tel_size, args_dict["site"], "01")
80
+ )
81
+ pos_x.append(0 * u.m)
82
+ pos_y.append(0 * u.m)
83
+ pos_z.append(0 * u.m)
84
+ # 4 telescopes in a regular square grid
85
+ else:
86
+ for i in range(1, 5):
87
+ tel_name.append(
88
+ names.get_array_element_name_from_type_site_id(
89
+ tel_size, args_dict["site"], f"0{i}"
90
+ )
91
+ )
92
+ pos_x.append(telescope_distance[tel_size] * (-1) ** (i // 2))
93
+ pos_y.append(telescope_distance[tel_size] * (-1) ** (i % 2))
94
+ pos_z.append(0 * u.m)
95
+
96
+ table = QTable(meta={"array_name": array_name, "site": args_dict["site"]})
97
+ table["telescope_name"] = tel_name
98
+ table["position_x"] = pos_x
99
+ table["position_y"] = pos_y
100
+ table["position_z"] = pos_z
101
+ table.sort("telescope_name")
102
+ table.pprint()
103
+
104
+ output_file = args_dict.get("output_file", None)
105
+ if output_file is not None:
106
+ base_name, file_extension = os.path.splitext(output_file)
107
+ output_file = f"{base_name}-{args_dict['site']}-{array_name}{file_extension}"
108
+ writer.ModelDataWriter.dump(
109
+ args_dict=args_dict,
110
+ output_file=output_file,
111
+ metadata=None,
112
+ product_data=table,
113
+ )
114
+
115
+
116
+ if __name__ == "__main__":
117
+ main()
@@ -1,9 +1,8 @@
1
1
  #!/usr/bin/python3
2
2
 
3
- """
4
- Summary
5
- -------
6
- This application allows to write sim_telarray histograms into pdf and hdf5 files.
3
+ r"""
4
+ Write sim_telarray histograms into pdf and hdf5 files.
5
+
7
6
  It accepts multiple lists of histograms files, a single list or a histogram file.
8
7
  Each histogram is plotted in a page of the pdf file if the --pdf option is activated.
9
8
 
@@ -19,31 +18,29 @@
19
18
  pdf (bool, optional)
20
19
  If set, histograms are saved into pdf files.
21
20
  One pdf file contains all the histograms found in the file.
22
- The name of the file is controlled via `output_file_name`.
21
+ The name of the file is controlled via output_file_name.
23
22
  hdf5: bool
24
23
  If true, histograms are saved into hdf5 files.
25
- At least one of `pdf` and `hdf5` has to be activated.
24
+ At least one of pdf and hdf5 has to be activated.
26
25
  output_file_name (str, optional)
27
26
  The name of the output hdf5 (and/or pdf) files (without the path).
28
- If not given, `output_file_name` takes the name from the (first) input file
29
- (`hist_file_names`).
30
- If the output `output_file_name.hdf5` file already exists and `hdf5` is set, the tables
31
- associated to `hdf5` will be overwritten. The remaining tables, if any, will stay
27
+ If not given, output_file_name takes the name from the (first) input file
28
+ (hist_file_names).
29
+ If the output output_file_name.hdf5 file already exists and hdf5 is set, the tables
30
+ associated to hdf5 will be overwritten. The remaining tables, if any, will stay
32
31
  untouched.
33
- verbosity (str, optional)
34
- Log level to print.
35
32
 
36
33
  Raises
37
34
  ------
38
35
  TypeError:
39
- if argument passed through `hist_file_names` is not a file.
36
+ if argument passed through hist_file_names is not a file.
40
37
 
41
38
  Example
42
39
  -------
43
40
  .. code-block:: console
44
41
 
45
- simtools-generate-simtel-array-histograms --hist_file_names tests/resources/
46
- run2_gamma_za20deg_azm0deg-North-Prod5_test-production-5.hdata.zst
42
+ simtools-generate-simtel-array-histograms --hist_file_names tests/resources/ \\
43
+ run2_gamma_za20deg_azm0deg-North-Prod5_test-production-5.hdata.zst \\
47
44
  --output_file_name test_hist_hdata --hdf5 --pdf
48
45
 
49
46
  """
@@ -57,12 +54,12 @@ from matplotlib.backends.backend_pdf import PdfPages
57
54
  import simtools.utils.general as gen
58
55
  from simtools.configuration import configurator
59
56
  from simtools.io_operations import io_handler
60
- from simtools.simtel.simtel_histograms import SimtelHistograms
57
+ from simtools.simtel.simtel_io_histograms import SimtelIOHistograms
61
58
 
62
59
 
63
60
  def _parse(label, description):
64
61
  """
65
- Parse command line configuration
62
+ Parse command line configuration.
66
63
 
67
64
  Parameters
68
65
  ----------
@@ -105,88 +102,132 @@ def _parse(label, description):
105
102
  )
106
103
 
107
104
  config_parser, _ = config.initialize(db_config=False, paths=True)
108
- if not config_parser["pdf"]:
109
- if not config_parser["hdf5"]:
110
- config.parser.error("At least one argument is required: `--pdf` or `--hdf5`.")
105
+ if not config_parser["pdf"] and not config_parser["hdf5"]:
106
+ config.parser.error("At least one argument is required: --pdf or --hdf5.")
111
107
 
112
108
  return config_parser
113
109
 
114
110
 
115
- def main():
116
- label = Path(__file__).stem
117
- description = "Display the simtel_array histograms."
118
- io_handler_instance = io_handler.IOHandler()
119
- config_parser = _parse(label, description)
120
- output_path = io_handler_instance.get_output_directory(label, sub_dir="application-plots")
121
- logger = logging.getLogger()
122
- logger.setLevel(gen.get_log_level_from_user(config_parser["log_level"]))
123
- logger.info("Starting the application.")
111
+ def build_histogram_files(config_parser, logger):
112
+ """
113
+ Build a list of histogram files from command line arguments.
124
114
 
125
- # Building list of histograms from the input files
115
+ Parameters
116
+ ----------
117
+ config_parser: dict
118
+ Parsed command line arguments.
119
+ logger: logging.Logger
120
+ Logger object for logging messages.
121
+
122
+ Returns
123
+ -------
124
+ list
125
+ List of histogram file paths.
126
+ """
126
127
  histogram_files = []
127
128
  for one_file in config_parser["hist_file_names"]:
128
129
  try:
129
130
  if Path(one_file).suffix in [".zst", ".simtel", ".hdata"]:
130
131
  histogram_files.append(one_file)
131
132
  else:
132
- # Collecting hist files
133
133
  with open(one_file, encoding="utf-8") as file:
134
134
  for line in file:
135
- # Removing '\n' from filename, in case it is left there.
136
- histogram_files.append(line.replace("\n", ""))
135
+ histogram_files.append(line.strip())
137
136
  except FileNotFoundError as exc:
138
137
  msg = f"{one_file} is not a file."
139
138
  logger.error(msg)
140
139
  raise FileNotFoundError from exc
140
+ return histogram_files
141
141
 
142
- # If no output name is passed, the tool gets the name of the first histogram of the list
143
- if config_parser["output_file_name"] is None:
144
- config_parser["output_file_name"] = Path(histogram_files[0]).absolute().name
145
- output_file_name = Path(output_path).joinpath(f"{config_parser['output_file_name']}")
146
142
 
147
- # If the hdf5 output file already exists, it is overwritten
148
- if (Path(f"{config_parser['output_file_name']}.hdf5").exists()) and (config_parser["hdf5"]):
143
+ def check_and_log_overwrite(config_parser, logger):
144
+ """
145
+ Check if the output hdf5 file already exists and log a warning if it does.
146
+
147
+ Parameters
148
+ ----------
149
+ config_parser: dict
150
+ Parsed command line arguments.
151
+ logger: logging.Logger
152
+ Logger object for logging messages.
153
+
154
+ Returns
155
+ -------
156
+ bool
157
+ True if the hdf5 file exists and should be overwritten, False otherwise.
158
+ """
159
+ if Path(f"{config_parser['output_file_name']}.hdf5").exists() and config_parser["hdf5"]:
149
160
  msg = (
150
161
  f"Output hdf5 file {config_parser['output_file_name']}.hdf5 already exists. "
151
162
  f"Overwriting it."
152
163
  )
153
164
  logger.warning(msg)
154
- overwrite = True
155
- else:
156
- overwrite = False
165
+ return True
166
+ return False
157
167
 
158
- # Building SimtelHistograms
159
- simtel_histograms = SimtelHistograms(histogram_files)
160
168
 
169
+ def create_pdf(simtel_histograms, output_file_name, config_parser, logger):
170
+ """
171
+ Create a PDF file containing histograms.
172
+
173
+ Parameters
174
+ ----------
175
+ simtel_histograms: SimtelIOHistograms
176
+ SimtelIOHistograms object containing histograms to plot.
177
+ output_file_name: str
178
+ Base name for the output PDF file.
179
+ config_parser: dict
180
+ Parsed command line arguments.
181
+ logger: logging.Logger
182
+ Logger object for logging messages.
183
+ """
161
184
  if config_parser["pdf"]:
162
185
  logger.debug(f"Creating the pdf file {output_file_name}.pdf")
163
186
  pdf_pages = PdfPages(f"{output_file_name}.pdf")
164
-
165
- if config_parser["test"]:
166
- number_of_histograms = 2
167
- else:
168
- number_of_histograms = simtel_histograms.number_of_histograms
169
-
187
+ number_of_histograms = 2 if config_parser["test"] else len(simtel_histograms.combined_hists)
170
188
  for i_hist in range(number_of_histograms):
171
- title = simtel_histograms.get_histogram_title(i_hist)
172
-
173
- logger.debug(f"Processing: {title}")
174
-
189
+ logger.debug(f"Processing: {i_hist + 1} histogram.")
175
190
  fig, ax = plt.subplots(1, 1, figsize=(6, 6))
176
191
  simtel_histograms.plot_one_histogram(i_hist, ax)
177
-
178
192
  plt.tight_layout()
179
193
  pdf_pages.savefig(fig)
180
194
  plt.clf()
181
-
182
195
  plt.close()
183
196
  pdf_pages.close()
184
197
  logger.info(f"Wrote histograms to the pdf file {output_file_name}.pdf")
185
198
 
199
+
200
+ def export_to_hdf5(simtel_histograms, output_file_name, overwrite, config_parser, logger):
201
+ """Export histograms to an HDF5 file."""
186
202
  if config_parser["hdf5"]:
187
203
  logger.info(f"Wrote histograms to the hdf5 file {output_file_name}.hdf5")
188
204
  simtel_histograms.export_histograms(f"{output_file_name}.hdf5", overwrite=overwrite)
189
205
 
190
206
 
207
+ def main(): # noqa: D103
208
+ label = Path(__file__).stem
209
+ description = "Display the simtel_array histograms."
210
+ io_handler_instance = io_handler.IOHandler()
211
+ config_parser = _parse(label, description)
212
+ output_path = io_handler_instance.get_output_directory(label, sub_dir="application-plots")
213
+ logger = logging.getLogger()
214
+ logger.setLevel(gen.get_log_level_from_user(config_parser["log_level"]))
215
+ logger.info("Starting the application.")
216
+
217
+ histogram_files = build_histogram_files(config_parser, logger)
218
+
219
+ # If no output name is passed, the tool gets the name of the first histogram of the list
220
+ if config_parser["output_file_name"] is None:
221
+ config_parser["output_file_name"] = Path(histogram_files[0]).absolute().name
222
+ output_file_name = Path(output_path).joinpath(f"{config_parser['output_file_name']}")
223
+
224
+ # If the hdf5 output file already exists, it is overwritten
225
+ overwrite = check_and_log_overwrite(config_parser, logger)
226
+
227
+ simtel_histograms = SimtelIOHistograms(histogram_files)
228
+ create_pdf(simtel_histograms, output_file_name, config_parser, logger)
229
+ export_to_hdf5(simtel_histograms, output_file_name, overwrite, config_parser, logger)
230
+
231
+
191
232
  if __name__ == "__main__":
192
233
  main()