gammasimtools 0.21.0__py3-none-any.whl → 0.23.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 (370) hide show
  1. {gammasimtools-0.21.0.dist-info → gammasimtools-0.23.0.dist-info}/METADATA +3 -3
  2. gammasimtools-0.23.0.dist-info/RECORD +414 -0
  3. {gammasimtools-0.21.0.dist-info → gammasimtools-0.23.0.dist-info}/entry_points.txt +2 -1
  4. simtools/_version.py +2 -2
  5. simtools/application_control.py +118 -0
  6. simtools/applications/calculate_incident_angles.py +17 -25
  7. simtools/applications/convert_all_model_parameters_from_simtel.py +29 -45
  8. simtools/applications/convert_geo_coordinates_of_array_elements.py +26 -45
  9. simtools/applications/convert_model_parameter_from_simtel.py +21 -42
  10. simtools/applications/db_add_file_to_db.py +12 -13
  11. simtools/applications/db_add_simulation_model_from_repository_to_db.py +20 -33
  12. simtools/applications/db_add_value_from_json_to_db.py +28 -23
  13. simtools/applications/db_development_tools/write_array_elements_positions_to_repository.py +19 -34
  14. simtools/applications/db_generate_compound_indexes.py +12 -27
  15. simtools/applications/db_get_array_layouts_from_db.py +19 -39
  16. simtools/applications/db_get_file_from_db.py +15 -17
  17. simtools/applications/db_get_parameter_from_db.py +33 -35
  18. simtools/applications/db_inspect_databases.py +10 -11
  19. simtools/applications/db_upload_model_repository.py +104 -0
  20. simtools/applications/derive_ctao_array_layouts.py +16 -21
  21. simtools/applications/derive_mirror_rnda.py +9 -14
  22. simtools/applications/derive_photon_electron_spectrum.py +7 -10
  23. simtools/applications/derive_psf_parameters.py +24 -21
  24. simtools/applications/derive_trigger_rates.py +6 -9
  25. simtools/applications/docs_produce_array_element_report.py +22 -23
  26. simtools/applications/docs_produce_calibration_reports.py +26 -24
  27. simtools/applications/docs_produce_model_parameter_reports.py +15 -22
  28. simtools/applications/docs_produce_simulation_configuration_report.py +21 -22
  29. simtools/applications/generate_array_config.py +14 -33
  30. simtools/applications/generate_corsika_histograms.py +22 -43
  31. simtools/applications/generate_default_metadata.py +15 -36
  32. simtools/applications/generate_regular_arrays.py +11 -15
  33. simtools/applications/generate_simtel_event_data.py +23 -33
  34. simtools/applications/maintain_simulation_model_add_production.py +17 -48
  35. simtools/applications/maintain_simulation_model_compare_productions.py +10 -12
  36. simtools/applications/maintain_simulation_model_verify_production_tables.py +8 -11
  37. simtools/applications/merge_tables.py +15 -24
  38. simtools/applications/plot_array_layout.py +77 -55
  39. simtools/applications/plot_simtel_events.py +11 -13
  40. simtools/applications/plot_tabular_data.py +17 -38
  41. simtools/applications/plot_tabular_data_for_model_parameter.py +16 -23
  42. simtools/applications/print_version.py +14 -42
  43. simtools/applications/production_derive_corsika_limits.py +5 -9
  44. simtools/applications/production_derive_statistics.py +12 -26
  45. simtools/applications/production_generate_grid.py +20 -48
  46. simtools/applications/production_merge_corsika_limits.py +17 -21
  47. simtools/applications/run_application.py +12 -32
  48. simtools/applications/simulate_flasher.py +79 -81
  49. simtools/applications/simulate_illuminator.py +56 -197
  50. simtools/applications/{simulate_calibration_events.py → simulate_pedestals.py} +22 -68
  51. simtools/applications/simulate_prod.py +21 -33
  52. simtools/applications/simulate_prod_htcondor_generator.py +11 -25
  53. simtools/applications/submit_array_layouts.py +15 -18
  54. simtools/applications/submit_data_from_external.py +18 -34
  55. simtools/applications/submit_model_parameter_from_external.py +27 -41
  56. simtools/applications/validate_camera_efficiency.py +23 -22
  57. simtools/applications/validate_camera_fov.py +21 -27
  58. simtools/applications/validate_cumulative_psf.py +28 -37
  59. simtools/applications/validate_file_using_schema.py +35 -45
  60. simtools/applications/validate_optics.py +27 -33
  61. simtools/camera/camera_efficiency.py +8 -13
  62. simtools/configuration/commandline_parser.py +33 -11
  63. simtools/configuration/configurator.py +0 -7
  64. simtools/corsika/corsika_config.py +9 -16
  65. simtools/corsika/corsika_histograms.py +1 -1
  66. simtools/data_model/data_reader.py +0 -2
  67. simtools/data_model/metadata_collector.py +0 -2
  68. simtools/data_model/model_data_writer.py +87 -27
  69. simtools/data_model/schema.py +61 -2
  70. simtools/data_model/validate_data.py +1 -3
  71. simtools/db/db_handler.py +58 -39
  72. simtools/db/db_model_upload.py +210 -5
  73. simtools/io/hdf5_handler.py +0 -5
  74. simtools/io/io_handler.py +31 -83
  75. simtools/io/legacy_data_handler.py +0 -5
  76. simtools/job_execution/job_manager.py +43 -1
  77. simtools/layout/array_layout.py +0 -2
  78. simtools/layout/array_layout_utils.py +1 -5
  79. simtools/layout/telescope_position.py +0 -2
  80. simtools/model/array_model.py +95 -46
  81. simtools/model/calibration_model.py +0 -2
  82. simtools/model/camera.py +0 -2
  83. simtools/model/mirrors.py +0 -2
  84. simtools/model/model_parameter.py +50 -16
  85. simtools/model/model_repository.py +139 -106
  86. simtools/model/model_utils.py +21 -11
  87. simtools/model/site_model.py +0 -2
  88. simtools/model/telescope_model.py +20 -2
  89. simtools/production_configuration/calculate_statistical_uncertainties_grid_point.py +0 -2
  90. simtools/production_configuration/derive_corsika_limits.py +1 -1
  91. simtools/production_configuration/derive_production_statistics.py +0 -2
  92. simtools/production_configuration/interpolation_handler.py +0 -2
  93. simtools/ray_tracing/incident_angles.py +7 -7
  94. simtools/ray_tracing/mirror_panel_psf.py +1 -1
  95. simtools/ray_tracing/psf_analysis.py +0 -2
  96. simtools/ray_tracing/psf_parameter_optimisation.py +180 -73
  97. simtools/ray_tracing/ray_tracing.py +1 -5
  98. simtools/reporting/docs_auto_report_generator.py +108 -0
  99. simtools/reporting/docs_read_parameters.py +168 -104
  100. simtools/resources/array_elements.yml +26 -0
  101. simtools/runners/corsika_runner.py +0 -2
  102. simtools/runners/corsika_simtel_runner.py +11 -19
  103. simtools/runners/runner_services.py +5 -6
  104. simtools/runners/simtel_runner.py +0 -2
  105. simtools/runners/simtools_runner.py +0 -2
  106. simtools/schemas/application_workflow.metaschema.yml +1 -1
  107. simtools/schemas/common_definitions.schema.yml +39 -0
  108. simtools/schemas/model_parameter.metaschema.yml +19 -13
  109. simtools/schemas/model_parameter_and_data_schema.metaschema.yml +6 -12
  110. simtools/schemas/model_parameters/adjust_gain.schema.yml +0 -5
  111. simtools/schemas/model_parameters/altitude.schema.yml +0 -5
  112. simtools/schemas/model_parameters/array_coordinates.schema.yml +0 -5
  113. simtools/schemas/model_parameters/array_coordinates_UTM.schema.yml +0 -5
  114. simtools/schemas/model_parameters/array_element_position_ground.schema.yml +0 -7
  115. simtools/schemas/model_parameters/array_element_position_utm.schema.yml +0 -7
  116. simtools/schemas/model_parameters/array_layouts.schema.yml +0 -5
  117. simtools/schemas/model_parameters/array_triggers.schema.yml +0 -5
  118. simtools/schemas/model_parameters/array_window.schema.yml +0 -7
  119. simtools/schemas/model_parameters/asum_clipping.schema.yml +0 -3
  120. simtools/schemas/model_parameters/asum_offset.schema.yml +0 -7
  121. simtools/schemas/model_parameters/asum_shaping.schema.yml +0 -7
  122. simtools/schemas/model_parameters/asum_threshold.schema.yml +0 -7
  123. simtools/schemas/model_parameters/atmospheric_profile.schema.yml +0 -5
  124. simtools/schemas/model_parameters/atmospheric_transmission.schema.yml +0 -5
  125. simtools/schemas/model_parameters/axes_offsets.schema.yml +0 -7
  126. simtools/schemas/model_parameters/calibration_devices.schema.yml +30 -0
  127. simtools/schemas/model_parameters/camera_body_diameter.schema.yml +0 -7
  128. simtools/schemas/model_parameters/camera_body_shape.schema.yml +0 -7
  129. simtools/schemas/model_parameters/camera_config_file.schema.yml +0 -7
  130. simtools/schemas/model_parameters/camera_config_rotate.schema.yml +0 -7
  131. simtools/schemas/model_parameters/camera_degraded_efficiency.schema.yml +0 -7
  132. simtools/schemas/model_parameters/camera_degraded_map.schema.yml +0 -7
  133. simtools/schemas/model_parameters/camera_depth.schema.yml +0 -7
  134. simtools/schemas/model_parameters/camera_filter.schema.yml +0 -7
  135. simtools/schemas/model_parameters/camera_filter_incidence_angle.schema.yml +0 -3
  136. simtools/schemas/model_parameters/camera_pixels.schema.yml +0 -7
  137. simtools/schemas/model_parameters/camera_transmission.schema.yml +0 -7
  138. simtools/schemas/model_parameters/channels_per_chip.schema.yml +0 -7
  139. simtools/schemas/model_parameters/correct_nsb_spectrum_to_telescope_altitude.schema.yml +0 -7
  140. simtools/schemas/model_parameters/corsika_observation_level.schema.yml +0 -5
  141. simtools/schemas/model_parameters/dark_events.schema.yml +4 -3
  142. simtools/schemas/model_parameters/default_trigger.schema.yml +0 -7
  143. simtools/schemas/model_parameters/design_model.schema.yml +0 -7
  144. simtools/schemas/model_parameters/disc_ac_coupled.schema.yml +0 -7
  145. simtools/schemas/model_parameters/disc_bins.schema.yml +0 -7
  146. simtools/schemas/model_parameters/disc_start.schema.yml +0 -7
  147. simtools/schemas/model_parameters/discriminator_amplitude.schema.yml +0 -7
  148. simtools/schemas/model_parameters/discriminator_fall_time.schema.yml +0 -7
  149. simtools/schemas/model_parameters/discriminator_gate_length.schema.yml +0 -7
  150. simtools/schemas/model_parameters/discriminator_hysteresis.schema.yml +0 -7
  151. simtools/schemas/model_parameters/discriminator_output_amplitude.schema.yml +0 -7
  152. simtools/schemas/model_parameters/discriminator_output_var_percent.schema.yml +0 -7
  153. simtools/schemas/model_parameters/discriminator_pulse_shape.schema.yml +0 -7
  154. simtools/schemas/model_parameters/discriminator_rise_time.schema.yml +0 -7
  155. simtools/schemas/model_parameters/discriminator_scale_threshold.schema.yml +0 -7
  156. simtools/schemas/model_parameters/discriminator_sigsum_over_threshold.schema.yml +0 -7
  157. simtools/schemas/model_parameters/discriminator_threshold.schema.yml +0 -7
  158. simtools/schemas/model_parameters/discriminator_time_over_threshold.schema.yml +1 -9
  159. simtools/schemas/model_parameters/discriminator_var_gate_length.schema.yml +0 -7
  160. simtools/schemas/model_parameters/discriminator_var_sigsum_over_threshold.schema.yml +0 -7
  161. simtools/schemas/model_parameters/discriminator_var_threshold.schema.yml +0 -7
  162. simtools/schemas/model_parameters/discriminator_var_time_over_threshold.schema.yml +0 -7
  163. simtools/schemas/model_parameters/dish_shape_length.schema.yml +0 -5
  164. simtools/schemas/model_parameters/dsum_clipping.schema.yml +1 -5
  165. simtools/schemas/model_parameters/dsum_ignore_below.schema.yml +0 -3
  166. simtools/schemas/model_parameters/dsum_offset.schema.yml +0 -3
  167. simtools/schemas/model_parameters/dsum_pedsub.schema.yml +0 -3
  168. simtools/schemas/model_parameters/dsum_pre_clipping.schema.yml +0 -3
  169. simtools/schemas/model_parameters/dsum_prescale.schema.yml +0 -3
  170. simtools/schemas/model_parameters/dsum_presum_max.schema.yml +0 -3
  171. simtools/schemas/model_parameters/dsum_presum_shift.schema.yml +0 -3
  172. simtools/schemas/model_parameters/dsum_shaping.schema.yml +0 -3
  173. simtools/schemas/model_parameters/dsum_shaping_renormalize.schema.yml +0 -3
  174. simtools/schemas/model_parameters/dsum_threshold.schema.yml +2 -12
  175. simtools/schemas/model_parameters/dsum_zero_clip.schema.yml +0 -3
  176. simtools/schemas/model_parameters/effective_focal_length.schema.yml +0 -7
  177. simtools/schemas/model_parameters/epsg_code.schema.yml +0 -5
  178. simtools/schemas/model_parameters/fadc_ac_coupled.schema.yml +0 -7
  179. simtools/schemas/model_parameters/fadc_amplitude.schema.yml +2 -9
  180. simtools/schemas/model_parameters/fadc_bins.schema.yml +0 -7
  181. simtools/schemas/model_parameters/fadc_compensate_pedestal.schema.yml +0 -7
  182. simtools/schemas/model_parameters/fadc_dev_pedestal.schema.yml +0 -2
  183. simtools/schemas/model_parameters/fadc_err_compensate_pedestal.schema.yml +0 -7
  184. simtools/schemas/model_parameters/fadc_err_pedestal.schema.yml +0 -7
  185. simtools/schemas/model_parameters/fadc_lg_amplitude.schema.yml +2 -9
  186. simtools/schemas/model_parameters/fadc_lg_compensate_pedestal.schema.yml +0 -7
  187. simtools/schemas/model_parameters/fadc_lg_dev_pedestal.schema.yml +0 -2
  188. simtools/schemas/model_parameters/fadc_lg_err_compensate_pedestal.schema.yml +0 -7
  189. simtools/schemas/model_parameters/fadc_lg_err_pedestal.schema.yml +0 -7
  190. simtools/schemas/model_parameters/fadc_lg_max_signal.schema.yml +0 -7
  191. simtools/schemas/model_parameters/fadc_lg_max_sum.schema.yml +0 -2
  192. simtools/schemas/model_parameters/fadc_lg_noise.schema.yml +0 -7
  193. simtools/schemas/model_parameters/fadc_lg_pedestal.schema.yml +0 -7
  194. simtools/schemas/model_parameters/fadc_lg_sensitivity.schema.yml +0 -7
  195. simtools/schemas/model_parameters/fadc_lg_sysvar_pedestal.schema.yml +0 -7
  196. simtools/schemas/model_parameters/fadc_lg_var_pedestal.schema.yml +0 -7
  197. simtools/schemas/model_parameters/fadc_lg_var_sensitivity.schema.yml +0 -7
  198. simtools/schemas/model_parameters/fadc_long_event_threshold.schema.yml +0 -3
  199. simtools/schemas/model_parameters/fadc_long_sum_bins.schema.yml +0 -3
  200. simtools/schemas/model_parameters/fadc_long_sum_offset.schema.yml +0 -3
  201. simtools/schemas/model_parameters/fadc_max_signal.schema.yml +0 -7
  202. simtools/schemas/model_parameters/fadc_max_sum.schema.yml +0 -2
  203. simtools/schemas/model_parameters/fadc_mhz.schema.yml +0 -7
  204. simtools/schemas/model_parameters/fadc_noise.schema.yml +0 -7
  205. simtools/schemas/model_parameters/fadc_pedestal.schema.yml +0 -7
  206. simtools/schemas/model_parameters/fadc_pulse_shape.schema.yml +0 -7
  207. simtools/schemas/model_parameters/fadc_sensitivity.schema.yml +0 -7
  208. simtools/schemas/model_parameters/fadc_sum_bins.schema.yml +0 -7
  209. simtools/schemas/model_parameters/fadc_sum_offset.schema.yml +0 -7
  210. simtools/schemas/model_parameters/fadc_sysvar_pedestal.schema.yml +0 -7
  211. simtools/schemas/model_parameters/fadc_var_pedestal.schema.yml +0 -7
  212. simtools/schemas/model_parameters/fadc_var_sensitivity.schema.yml +0 -7
  213. simtools/schemas/model_parameters/fake_mirror_list.schema.yml +0 -3
  214. simtools/schemas/model_parameters/flasher_angular_distribution.schema.yml +32 -0
  215. simtools/schemas/model_parameters/flasher_angular_distribution_width.schema.yml +32 -0
  216. simtools/schemas/model_parameters/flasher_bunch_size.schema.yml +28 -0
  217. simtools/schemas/model_parameters/flasher_external_trigger.schema.yml +32 -0
  218. simtools/schemas/model_parameters/flasher_photons.schema.yml +34 -0
  219. simtools/schemas/model_parameters/flasher_position.schema.yml +43 -0
  220. simtools/schemas/model_parameters/flasher_pulse_exp_decay.schema.yml +29 -0
  221. simtools/schemas/model_parameters/flasher_pulse_offset.schema.yml +35 -0
  222. simtools/schemas/model_parameters/flasher_pulse_shape.schema.yml +30 -0
  223. simtools/schemas/model_parameters/flasher_pulse_width.schema.yml +32 -0
  224. simtools/schemas/model_parameters/flasher_type.schema.yml +28 -0
  225. simtools/schemas/model_parameters/flasher_var_photons.schema.yml +31 -0
  226. simtools/schemas/model_parameters/flasher_wavelength.schema.yml +33 -0
  227. simtools/schemas/model_parameters/flatfielding.schema.yml +0 -7
  228. simtools/schemas/model_parameters/focal_length.schema.yml +0 -7
  229. simtools/schemas/model_parameters/focal_surface_parameters.schema.yml +0 -3
  230. simtools/schemas/model_parameters/focal_surface_ref_radius.schema.yml +0 -3
  231. simtools/schemas/model_parameters/focus_offset.schema.yml +0 -7
  232. simtools/schemas/model_parameters/gain_variation.schema.yml +0 -7
  233. simtools/schemas/model_parameters/geomag_horizontal.schema.yml +2 -7
  234. simtools/schemas/model_parameters/geomag_rotation.schema.yml +2 -7
  235. simtools/schemas/model_parameters/geomag_vertical.schema.yml +2 -7
  236. simtools/schemas/model_parameters/hg_lg_variation.schema.yml +0 -5
  237. simtools/schemas/model_parameters/iobuf_maximum.schema.yml +0 -7
  238. simtools/schemas/model_parameters/iobuf_output_maximum.schema.yml +0 -7
  239. simtools/schemas/model_parameters/laser_events.schema.yml +4 -3
  240. simtools/schemas/model_parameters/laser_external_trigger.schema.yml +4 -3
  241. simtools/schemas/model_parameters/laser_photons.schema.yml +4 -3
  242. simtools/schemas/model_parameters/laser_pulse_exptime.schema.yml +4 -3
  243. simtools/schemas/model_parameters/laser_pulse_offset.schema.yml +4 -3
  244. simtools/schemas/model_parameters/laser_pulse_sigtime.schema.yml +4 -3
  245. simtools/schemas/model_parameters/laser_pulse_twidth.schema.yml +4 -3
  246. simtools/schemas/model_parameters/laser_var_photons.schema.yml +4 -3
  247. simtools/schemas/model_parameters/laser_wavelength.schema.yml +4 -3
  248. simtools/schemas/model_parameters/led_events.schema.yml +4 -3
  249. simtools/schemas/model_parameters/led_photons.schema.yml +4 -3
  250. simtools/schemas/model_parameters/led_pulse_offset.schema.yml +4 -3
  251. simtools/schemas/model_parameters/led_pulse_sigtime.schema.yml +4 -3
  252. simtools/schemas/model_parameters/led_var_photons.schema.yml +4 -3
  253. simtools/schemas/model_parameters/lightguide_efficiency_vs_incidence_angle.schema.yml +0 -7
  254. simtools/schemas/model_parameters/lightguide_efficiency_vs_wavelength.schema.yml +0 -7
  255. simtools/schemas/model_parameters/min_photoelectrons.schema.yml +0 -7
  256. simtools/schemas/model_parameters/min_photons.schema.yml +0 -7
  257. simtools/schemas/model_parameters/mirror_align_random_distance.schema.yml +0 -5
  258. simtools/schemas/model_parameters/mirror_align_random_horizontal.schema.yml +0 -7
  259. simtools/schemas/model_parameters/mirror_align_random_vertical.schema.yml +0 -7
  260. simtools/schemas/model_parameters/mirror_class.schema.yml +2 -9
  261. simtools/schemas/model_parameters/mirror_degraded_reflection.schema.yml +0 -7
  262. simtools/schemas/model_parameters/mirror_focal_length.schema.yml +0 -5
  263. simtools/schemas/model_parameters/mirror_list.schema.yml +0 -7
  264. simtools/schemas/model_parameters/mirror_offset.schema.yml +0 -7
  265. simtools/schemas/model_parameters/mirror_reflection_random_angle.schema.yml +0 -7
  266. simtools/schemas/model_parameters/mirror_reflectivity.schema.yml +0 -7
  267. simtools/schemas/model_parameters/multiplicity_offset.schema.yml +0 -7
  268. simtools/schemas/model_parameters/muon_mono_threshold.schema.yml +0 -7
  269. simtools/schemas/model_parameters/nsb_autoscale_airmass.schema.yml +0 -7
  270. simtools/schemas/model_parameters/nsb_gain_drop_scale.schema.yml +0 -3
  271. simtools/schemas/model_parameters/nsb_offaxis.schema.yml +0 -7
  272. simtools/schemas/model_parameters/nsb_pixel_rate.schema.yml +0 -7
  273. simtools/schemas/model_parameters/nsb_reference_spectrum.schema.yml +0 -5
  274. simtools/schemas/model_parameters/nsb_reference_value.schema.yml +0 -5
  275. simtools/schemas/model_parameters/nsb_scaling_factor.schema.yml +0 -5
  276. simtools/schemas/model_parameters/nsb_sky_map.schema.yml +0 -5
  277. simtools/schemas/model_parameters/nsb_spectrum.schema.yml +0 -5
  278. simtools/schemas/model_parameters/num_gains.schema.yml +0 -7
  279. simtools/schemas/model_parameters/only_triggered_telescopes.schema.yml +0 -7
  280. simtools/schemas/model_parameters/optics_properties.schema.yml +0 -7
  281. simtools/schemas/model_parameters/parabolic_dish.schema.yml +0 -3
  282. simtools/schemas/model_parameters/pedestal_events.schema.yml +4 -7
  283. simtools/schemas/model_parameters/photon_delay.schema.yml +0 -7
  284. simtools/schemas/model_parameters/photons_per_run.schema.yml +4 -4
  285. simtools/schemas/model_parameters/pixel_cells.schema.yml +0 -3
  286. simtools/schemas/model_parameters/pixels_parallel.schema.yml +0 -3
  287. simtools/schemas/model_parameters/pixeltrg_time_step.schema.yml +0 -7
  288. simtools/schemas/model_parameters/pm_average_gain.schema.yml +0 -5
  289. simtools/schemas/model_parameters/pm_collection_efficiency.schema.yml +0 -5
  290. simtools/schemas/model_parameters/pm_gain_index.schema.yml +0 -5
  291. simtools/schemas/model_parameters/pm_photoelectron_spectrum.schema.yml +0 -7
  292. simtools/schemas/model_parameters/pm_transit_time.schema.yml +4 -9
  293. simtools/schemas/model_parameters/pm_voltage_variation.schema.yml +0 -5
  294. simtools/schemas/model_parameters/primary_mirror_degraded_map.schema.yml +0 -7
  295. simtools/schemas/model_parameters/primary_mirror_diameter.schema.yml +0 -3
  296. simtools/schemas/model_parameters/primary_mirror_hole_diameter.schema.yml +0 -3
  297. simtools/schemas/model_parameters/primary_mirror_incidence_angle.schema.yml +0 -3
  298. simtools/schemas/model_parameters/primary_mirror_parameters.schema.yml +0 -3
  299. simtools/schemas/model_parameters/primary_mirror_ref_radius.schema.yml +0 -3
  300. simtools/schemas/model_parameters/primary_mirror_segmentation.schema.yml +0 -3
  301. simtools/schemas/model_parameters/qe_variation.schema.yml +0 -7
  302. simtools/schemas/model_parameters/quantum_efficiency.schema.yml +0 -7
  303. simtools/schemas/model_parameters/random_focal_length.schema.yml +2 -7
  304. simtools/schemas/model_parameters/random_generator.schema.yml +0 -7
  305. simtools/schemas/model_parameters/random_mono_probability.schema.yml +0 -7
  306. simtools/schemas/model_parameters/reference_point_altitude.schema.yml +0 -5
  307. simtools/schemas/model_parameters/reference_point_latitude.schema.yml +0 -5
  308. simtools/schemas/model_parameters/reference_point_longitude.schema.yml +0 -5
  309. simtools/schemas/model_parameters/reference_point_utm_east.schema.yml +0 -5
  310. simtools/schemas/model_parameters/reference_point_utm_north.schema.yml +0 -5
  311. simtools/schemas/model_parameters/sampled_output.schema.yml +0 -7
  312. simtools/schemas/model_parameters/save_pe_with_amplitude.schema.yml +0 -7
  313. simtools/schemas/model_parameters/secondary_mirror_baffle.schema.yml +0 -3
  314. simtools/schemas/model_parameters/secondary_mirror_degraded_map.schema.yml +0 -3
  315. simtools/schemas/model_parameters/secondary_mirror_degraded_reflection.schema.yml +0 -3
  316. simtools/schemas/model_parameters/secondary_mirror_diameter.schema.yml +0 -3
  317. simtools/schemas/model_parameters/secondary_mirror_hole_diameter.schema.yml +0 -3
  318. simtools/schemas/model_parameters/secondary_mirror_incidence_angle.schema.yml +0 -3
  319. simtools/schemas/model_parameters/secondary_mirror_parameters.schema.yml +0 -3
  320. simtools/schemas/model_parameters/secondary_mirror_ref_radius.schema.yml +0 -3
  321. simtools/schemas/model_parameters/secondary_mirror_reflectivity.schema.yml +0 -3
  322. simtools/schemas/model_parameters/secondary_mirror_segmentation.schema.yml +0 -3
  323. simtools/schemas/model_parameters/secondary_mirror_shadow_diameter.schema.yml +0 -3
  324. simtools/schemas/model_parameters/secondary_mirror_shadow_offset.schema.yml +0 -3
  325. simtools/schemas/model_parameters/stars.schema.yml +0 -5
  326. simtools/schemas/model_parameters/store_photoelectrons.schema.yml +0 -7
  327. simtools/schemas/model_parameters/tailcut_scale.schema.yml +0 -7
  328. simtools/schemas/model_parameters/telescope_axis_height.schema.yml +0 -7
  329. simtools/schemas/model_parameters/telescope_random_angle.schema.yml +0 -7
  330. simtools/schemas/model_parameters/telescope_random_error.schema.yml +0 -7
  331. simtools/schemas/model_parameters/telescope_sphere_radius.schema.yml +0 -7
  332. simtools/schemas/model_parameters/telescope_transmission.schema.yml +0 -7
  333. simtools/schemas/model_parameters/teltrig_min_sigsum.schema.yml +0 -7
  334. simtools/schemas/model_parameters/teltrig_min_time.schema.yml +0 -7
  335. simtools/schemas/model_parameters/transit_time_calib_error.schema.yml +0 -7
  336. simtools/schemas/model_parameters/transit_time_compensate_error.schema.yml +0 -7
  337. simtools/schemas/model_parameters/transit_time_compensate_step.schema.yml +0 -7
  338. simtools/schemas/model_parameters/transit_time_error.schema.yml +0 -7
  339. simtools/schemas/model_parameters/transit_time_jitter.schema.yml +0 -7
  340. simtools/schemas/model_parameters/transit_time_random.schema.yml +29 -0
  341. simtools/schemas/model_parameters/trigger_current_limit.schema.yml +0 -7
  342. simtools/schemas/model_parameters/trigger_delay_compensation.schema.yml +0 -7
  343. simtools/schemas/model_parameters/trigger_pixels.schema.yml +0 -7
  344. simtools/schemas/production_tables.schema.yml +8 -8
  345. simtools/schemas/simulation_models_info.schema.yml +78 -0
  346. simtools/simtel/simtel_config_reader.py +0 -2
  347. simtools/simtel/simtel_config_writer.py +118 -26
  348. simtools/simtel/simtel_io_metadata.py +3 -3
  349. simtools/simtel/simulator_array.py +43 -85
  350. simtools/simtel/simulator_camera_efficiency.py +0 -2
  351. simtools/simtel/simulator_light_emission.py +336 -631
  352. simtools/simtel/simulator_ray_tracing.py +2 -4
  353. simtools/simulator.py +45 -19
  354. simtools/testing/assertions.py +2 -2
  355. simtools/testing/configuration.py +21 -6
  356. simtools/testing/sim_telarray_metadata.py +4 -4
  357. simtools/utils/general.py +5 -13
  358. simtools/utils/geometry.py +34 -5
  359. simtools/utils/names.py +1 -13
  360. simtools/version.py +83 -0
  361. simtools/visualization/plot_array_layout.py +129 -23
  362. simtools/visualization/plot_incident_angles.py +0 -2
  363. simtools/visualization/plot_psf.py +163 -61
  364. simtools/visualization/plot_simtel_events.py +1 -12
  365. simtools/visualization/visualize.py +0 -12
  366. gammasimtools-0.21.0.dist-info/RECORD +0 -396
  367. simtools/model/flasher_model.py +0 -106
  368. {gammasimtools-0.21.0.dist-info → gammasimtools-0.23.0.dist-info}/WHEEL +0 -0
  369. {gammasimtools-0.21.0.dist-info → gammasimtools-0.23.0.dist-info}/licenses/LICENSE +0 -0
  370. {gammasimtools-0.21.0.dist-info → gammasimtools-0.23.0.dist-info}/top_level.txt +0 -0
@@ -15,8 +15,6 @@ from simtools.data_model import schema
15
15
  from simtools.io import ascii_handler
16
16
  from simtools.utils import names, value_conversion
17
17
 
18
- __all__ = ["DataValidator"]
19
-
20
18
 
21
19
  class DataValidator:
22
20
  """
@@ -232,7 +230,7 @@ class DataValidator:
232
230
  else:
233
231
  self._check_data_type(np.array(value).dtype, index, value)
234
232
 
235
- if self.data_dict.get("type") not in ("string", "dict", "file"):
233
+ if self._get_data_description(index).get("type", None) not in ("string", "dict", "file"):
236
234
  self._check_for_not_a_number(value, index)
237
235
  value, unit = self._check_and_convert_units(value, unit, index)
238
236
  for range_type in ("allowed_range", "required_range"):
simtools/db/db_handler.py CHANGED
@@ -11,7 +11,6 @@ import gridfs
11
11
  import jsonschema
12
12
  from astropy.table import Table
13
13
  from bson.objectid import ObjectId
14
- from packaging.version import Version
15
14
  from pymongo import MongoClient
16
15
 
17
16
  from simtools.data_model import validate_data
@@ -20,8 +19,6 @@ from simtools.simtel import simtel_table_reader
20
19
  from simtools.utils import names, value_conversion
21
20
  from simtools.version import resolve_version_to_latest_patch
22
21
 
23
- __all__ = ["DatabaseHandler"]
24
-
25
22
  logging.getLogger("pymongo").setLevel(logging.WARNING)
26
23
 
27
24
 
@@ -100,7 +97,6 @@ class DatabaseHandler:
100
97
  self.list_of_collections = {}
101
98
 
102
99
  self._set_up_connection()
103
- self._find_latest_simulation_model_db()
104
100
  self.db_name = (
105
101
  self.get_db_name(
106
102
  db_simulation_model_version=self.mongo_db_config.get("db_simulation_model_version"),
@@ -127,6 +123,34 @@ class DatabaseHandler:
127
123
  return None
128
124
  return None if (db_simulation_model_version or model_name) else self.db_name
129
125
 
126
+ def print_connection_info(self):
127
+ """Print the connection information."""
128
+ if self.mongo_db_config:
129
+ self._logger.info(
130
+ f"Connected to MongoDB at {self.mongo_db_config['db_server']}:"
131
+ f"{self.mongo_db_config['db_api_port']} "
132
+ f"using database: {self.db_name}"
133
+ )
134
+ else:
135
+ self._logger.info("No MongoDB configuration provided.")
136
+
137
+ def is_remote_database(self):
138
+ """
139
+ Check if the database is remote.
140
+
141
+ Check for domain pattern like "cta-simpipe-protodb.zeuthen.desy.de"
142
+
143
+ Returns
144
+ -------
145
+ bool
146
+ True if the database is remote, False otherwise.
147
+ """
148
+ if self.mongo_db_config:
149
+ db_server = self.mongo_db_config["db_server"]
150
+ domain_pattern = r"^([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$"
151
+ return bool(re.match(domain_pattern, db_server))
152
+ return False
153
+
130
154
  def _validate_mongo_db_config(self, mongo_db_config):
131
155
  """Validate the MongoDB configuration."""
132
156
  if mongo_db_config is None or all(value is None for value in mongo_db_config.values()):
@@ -171,50 +195,45 @@ class DatabaseHandler:
171
195
  tlsallowinvalidcertificates=True,
172
196
  )
173
197
 
174
- def _find_latest_simulation_model_db(self):
198
+ def generate_compound_indexes_for_databases(
199
+ self, db_name, db_simulation_model, db_simulation_model_version
200
+ ):
175
201
  """
176
- Find the latest released version of the simulation model and update the DB config.
202
+ Generate compound indexes for several databases.
177
203
 
178
- This is indicated by "LATEST" to the simulation model data base version.
179
- Only released versions are considered, pre-releases are ignored.
204
+ Parameters
205
+ ----------
206
+ db_name: str
207
+ Name of the database.
208
+ db_simulation_model: str
209
+ Name of the simulation model.
210
+ db_simulation_model_version: str
211
+ Version of the simulation model.
180
212
 
181
213
  Raises
182
214
  ------
183
215
  ValueError
184
- If the "LATEST" version is requested but no versions are found in the DB.
216
+ If the requested database is not found.
185
217
 
186
218
  """
187
- try:
188
- db_simulation_model_version = self.mongo_db_config["db_simulation_model_version"]
189
- db_simulation_model = self.mongo_db_config["db_simulation_model"]
190
- if db_simulation_model_version != "LATEST":
191
- return
192
- except TypeError: # db_simulation_model_version is None
193
- return
194
-
195
- list_of_db_names = self.db_client.list_database_names()
196
- filtered_list_of_db_names = [
197
- s for s in list_of_db_names if s.startswith(db_simulation_model)
219
+ databases = [
220
+ d for d in self.db_client.list_database_names() if d not in ("config", "admin", "local")
198
221
  ]
199
- pattern = re.compile(rf"{re.escape(db_simulation_model)}-v(\d+)-(\d+)-(\d+)(?:-(.+))?$")
200
-
201
- versioned_strings = []
202
- for s in filtered_list_of_db_names:
203
- m = pattern.match(s)
204
- if m:
205
- # skip pre-releases (have suffix)
206
- if m.group(4) is None:
207
- version_str = f"{m.group(1)}.{m.group(2)}.{m.group(3)}"
208
- versioned_strings.append((s, Version(version_str)))
209
-
210
- if versioned_strings:
211
- latest_string, _ = max(versioned_strings, key=lambda x: x[1])
212
- self.mongo_db_config["db_simulation_model"] = latest_string
213
- self._logger.info(
214
- f"Updated the DB simulation model to the latest version {latest_string}"
222
+ requested = self.get_db_name(
223
+ db_name=db_name,
224
+ db_simulation_model_version=db_simulation_model_version,
225
+ model_name=db_simulation_model,
226
+ )
227
+ if requested != "all" and requested not in databases:
228
+ raise ValueError(
229
+ f"Requested database '{requested}' not found. "
230
+ f"Following databases are available: {', '.join(databases)}"
215
231
  )
216
- else:
217
- raise ValueError("LATEST requested but no released versions found in DB.")
232
+
233
+ databases = databases if requested == "all" else [requested]
234
+ for dbs in databases:
235
+ self._logger.info(f"Generating compound indexes for database: {dbs}")
236
+ self.generate_compound_indexes(db_name=dbs)
218
237
 
219
238
  def generate_compound_indexes(self, db_name=None):
220
239
  """
@@ -875,7 +894,7 @@ class DatabaseHandler:
875
894
  """
876
895
  db_name = db_name or self.db_name
877
896
  collection = self.get_collection("production_tables", db_name=db_name or self.db_name)
878
- self._logger.debug(f"Adding production for {production_table.get('collection')} to to DB")
897
+ self._logger.debug(f"Adding production for {production_table.get('collection')} to the DB")
879
898
  collection.insert_one(production_table)
880
899
  DatabaseHandler.production_table_cached.clear()
881
900
  DatabaseHandler.model_versions_cached.clear()
@@ -1,16 +1,85 @@
1
1
  """Upload a simulation model (parameters and production tables) to the database."""
2
2
 
3
3
  import logging
4
+ import shutil
4
5
  from pathlib import Path
5
6
 
6
7
  from packaging.version import Version
7
8
 
8
9
  from simtools.io import ascii_handler
10
+ from simtools.job_execution.job_manager import retry_command
9
11
  from simtools.utils import names
10
12
 
11
13
  logger = logging.getLogger(__name__)
12
14
 
13
15
 
16
+ def add_complete_model(
17
+ tmp_dir,
18
+ db,
19
+ db_simulation_model,
20
+ db_simulation_model_version,
21
+ repository_url,
22
+ repository_branch=None,
23
+ ):
24
+ """
25
+ Upload a complete model including model parameters and production tables to the database.
26
+
27
+ Generate compound indexes for the new database.
28
+
29
+ Parameters
30
+ ----------
31
+ tmp_dir : Path or str
32
+ Temporary directory to use for cloning the repository.
33
+ db : DatabaseHandler
34
+ Database handler object.
35
+ db_simulation_model : str
36
+ Name of the simulation model in the database.
37
+ db_simulation_model_version : str
38
+ Version of the simulation model in the database.
39
+ repository_url : str
40
+ URL of the simulation model repository to clone.
41
+ repository_branch : str, optional
42
+ Branch of the repository to use. If None, the default branch is used.
43
+
44
+ Returns
45
+ -------
46
+ None
47
+ This function does not return a value.
48
+ """
49
+ if not _confirm_remote_database_upload(db):
50
+ return
51
+
52
+ repository_dir = None
53
+ try:
54
+ repository_dir = clone_simulation_model_repository(
55
+ tmp_dir,
56
+ repository_url,
57
+ db_simulation_model_version=db_simulation_model_version,
58
+ repository_branch=repository_branch,
59
+ )
60
+
61
+ add_model_parameters_to_db(
62
+ input_path=repository_dir / "simulation-models" / "model_parameters", db=db
63
+ )
64
+
65
+ add_production_tables_to_db(
66
+ input_path=repository_dir / "simulation-models" / "productions", db=db
67
+ )
68
+
69
+ db.generate_compound_indexes_for_databases(
70
+ db_name=None,
71
+ db_simulation_model=db_simulation_model,
72
+ db_simulation_model_version=db_simulation_model_version,
73
+ )
74
+ except Exception as exc:
75
+ raise RuntimeError(f"Upload of simulation model failed: {exc}") from exc
76
+ finally:
77
+ if repository_dir is not None and repository_dir.exists():
78
+ shutil.rmtree(repository_dir)
79
+
80
+ logger.info("Upload of simulation model completed successfully")
81
+
82
+
14
83
  def add_values_from_json_to_db(file, collection, db, file_prefix):
15
84
  """
16
85
  Upload new model parameter from json files to db.
@@ -86,13 +155,16 @@ def add_production_tables_to_db(input_path, db):
86
155
  input_path = Path(input_path)
87
156
  logger.info(f"Reading production tables from repository path {input_path}")
88
157
 
89
- for model in filter(Path.is_dir, input_path.iterdir()):
158
+ for model in sorted(filter(Path.is_dir, input_path.iterdir())):
90
159
  logger.info(f"Reading production tables for model version {model.name}")
91
160
  model_dict = _read_production_tables(model)
92
161
 
93
162
  for collection, data in model_dict.items():
94
163
  if data["parameters"]:
95
- logger.info(f"Adding production table for {collection} to the database")
164
+ logger.info(
165
+ f"Adding production table for {collection} "
166
+ f"(model version {model.name}) to the database"
167
+ )
96
168
  db.add_production_table(production_table=data)
97
169
  else:
98
170
  logger.info(f"No production table for {collection} in model version {model.name}")
@@ -103,7 +175,7 @@ def _read_production_tables(model_path):
103
175
  Read production tables from a directory.
104
176
 
105
177
  Take into account that some productions include patch updates only. Read in this cases
106
- the base models first.
178
+ all models from the model version history, starting with the earliest one.
107
179
 
108
180
  Parameters
109
181
  ----------
@@ -121,6 +193,12 @@ def _read_production_tables(model_path):
121
193
  for file in sorted((model_path.parent / model).rglob("*json")):
122
194
  _read_production_table(model_dict, file, model)
123
195
 
196
+ # ensure that the for patch updates the model version is set correctly
197
+ for table in model_dict.values():
198
+ table["model_version"] = model_path.name
199
+
200
+ _remove_deprecated_model_parameters(model_dict)
201
+
124
202
  return model_dict
125
203
 
126
204
 
@@ -135,10 +213,14 @@ def _read_production_table(model_dict, file, model_name):
135
213
  "model_version": model_name,
136
214
  "parameters": {},
137
215
  "design_model": {},
216
+ "deprecated_parameters": [],
138
217
  },
139
218
  )
140
219
  parameter_dict = ascii_handler.collect_data_from_file(file_name=file)
141
- logger.debug(f"Reading production table for {array_element} (collection {collection})")
220
+ logger.debug(
221
+ f"Reading production table for {array_element} "
222
+ f"(model_version {model_name}, collection {collection})"
223
+ )
142
224
  try:
143
225
  if array_element in ("configuration_corsika", "configuration_sim_telarray"):
144
226
  model_dict[collection]["parameters"] = parameter_dict["parameters"]
@@ -146,10 +228,10 @@ def _read_production_table(model_dict, file, model_name):
146
228
  model_dict[collection]["parameters"].setdefault(array_element, {}).update(
147
229
  parameter_dict["parameters"][array_element]
148
230
  )
149
-
150
231
  except KeyError as exc:
151
232
  logger.error(f"KeyError: {exc}")
152
233
  raise
234
+
153
235
  try:
154
236
  model_dict[collection]["design_model"][array_element] = parameter_dict["design_model"][
155
237
  array_element
@@ -157,4 +239,127 @@ def _read_production_table(model_dict, file, model_name):
157
239
  except KeyError:
158
240
  pass
159
241
 
242
+ try:
243
+ model_dict[collection]["deprecated_parameters"] = parameter_dict["deprecated_parameters"]
244
+ except KeyError:
245
+ pass
246
+
160
247
  model_dict[collection]["model_version"] = model_name
248
+
249
+
250
+ def _remove_deprecated_model_parameters(model_dict):
251
+ """
252
+ Remove deprecated parameters from all tables in a model dictionary.
253
+
254
+ Parameters
255
+ ----------
256
+ model_dict : dict
257
+ Production tables for a specific model version.
258
+ """
259
+ for table in model_dict.values():
260
+ for params in table.get("parameters", {}).values():
261
+ for param in table.get("deprecated_parameters", []):
262
+ if param in params:
263
+ logger.info(
264
+ f"Deprecated parameter {param} in production table {table['collection']}"
265
+ )
266
+ params.pop(param)
267
+
268
+
269
+ def _confirm_remote_database_upload(db):
270
+ """
271
+ Confirm with the user that they want to upload to a remote database.
272
+
273
+ Returns True if the user confirms, False otherwise. Returns also True
274
+ if the database is not remote.
275
+
276
+ Parameters
277
+ ----------
278
+ db : DatabaseHandler
279
+ Database handler object.
280
+
281
+ Returns
282
+ -------
283
+ bool
284
+ True if user confirms upload, False otherwise.
285
+ """
286
+ abort_message = "Operation aborted."
287
+
288
+ if not db.is_remote_database():
289
+ return True
290
+
291
+ db_config = db.mongo_db_config
292
+ db_server = db_config.get("db_server", "unknown server") if db_config else "unknown server"
293
+
294
+ try:
295
+ # First confirmation
296
+ user_input = input(
297
+ f"Do you really want to upload to remote DB {db_server}? Type 'yes' to confirm: "
298
+ )
299
+ if user_input != "yes":
300
+ logger.info(abort_message)
301
+ return False
302
+
303
+ # Second confirmation
304
+ user_input = input(
305
+ f"Let be sure: do you really want to upload to remote DB {db_server}? "
306
+ "Type 'yes' to confirm: "
307
+ )
308
+ if user_input != "yes":
309
+ logger.info(abort_message)
310
+ return False
311
+
312
+ return True
313
+
314
+ except (EOFError, KeyboardInterrupt):
315
+ logger.info(abort_message)
316
+ return False
317
+
318
+
319
+ def clone_simulation_model_repository(
320
+ target_dir, repository_url, db_simulation_model_version, repository_branch
321
+ ):
322
+ """
323
+ Clone a git repository containing simulation model parameters and production tables.
324
+
325
+ Parameters
326
+ ----------
327
+ target_dir : Path or str
328
+ Target directory to clone the repository into.
329
+ repository_url : str
330
+ URL of the git repository to clone.
331
+ db_simulation_model_version : str
332
+ Version tag of the simulation model to checkout.
333
+ repository_branch : str, optional
334
+ Branch of the repository to use. If None, the version tag is used.
335
+
336
+ Returns
337
+ -------
338
+ Path
339
+ Path to the cloned repository.
340
+ """
341
+ if repository_branch:
342
+ logger.info(f"Using branch: {repository_branch}")
343
+ else:
344
+ logger.info(f"Using version tag: {db_simulation_model_version}")
345
+
346
+ target_dir = Path(target_dir)
347
+ target_dir = target_dir if target_dir.is_absolute() else Path.cwd() / target_dir
348
+
349
+ if target_dir.exists():
350
+ shutil.rmtree(target_dir)
351
+
352
+ logger.info(f"Cloning model parameters from {repository_url}")
353
+
354
+ if repository_branch:
355
+ command = f'git clone --depth=1 -b "{repository_branch}" "{repository_url}" "{target_dir}"'
356
+ else:
357
+ # Use version tag with detached head (generates warning but that's fine)
358
+ command = (
359
+ f'git clone --branch "{db_simulation_model_version}" '
360
+ f'--depth 1 "{repository_url}" "{target_dir}"'
361
+ )
362
+
363
+ retry_command(command)
364
+
365
+ return target_dir
@@ -10,11 +10,6 @@ from ctapipe.io import read_table
10
10
 
11
11
  from simtools.utils.names import sanitize_name
12
12
 
13
- __all__ = [
14
- "fill_hdf5_table",
15
- "read_hdf5",
16
- ]
17
-
18
13
  _logger = logging.getLogger(__name__)
19
14
 
20
15
 
simtools/io/io_handler.py CHANGED
@@ -1,15 +1,8 @@
1
- """Handle input and output paths."""
1
+ """Handle input and output directories and file paths."""
2
2
 
3
- import datetime
4
3
  import logging
5
4
  from pathlib import Path
6
5
 
7
- __all__ = ["IOHandler", "IOHandlerSingleton"]
8
-
9
-
10
- class IncompleteIOHandlerInitError(Exception):
11
- """Exception raised when IOHandler is not initialized."""
12
-
13
6
 
14
7
  class IOHandlerSingleton(type):
15
8
  """Singleton base class."""
@@ -17,32 +10,24 @@ class IOHandlerSingleton(type):
17
10
  _instances = {}
18
11
 
19
12
  def __call__(cls, *args, **kwargs):
20
- """
21
- Ensure a single instance of the IOHandlerSingleton class.
22
-
23
- Creates a new instance if it doesn't exist, otherwise returns the existing instance.
24
- """
13
+ """Create a new instance if it doesn't exist, otherwise returns the existing instance."""
25
14
  if cls not in cls._instances:
26
15
  cls._instances[cls] = super().__call__(*args, **kwargs)
27
16
  return cls._instances[cls]
28
17
 
29
18
 
30
19
  class IOHandler(metaclass=IOHandlerSingleton):
31
- """Handle input and output paths."""
20
+ """Handle input and output directories and file paths."""
32
21
 
33
22
  def __init__(self):
34
23
  """Initialize IOHandler."""
35
- self._logger = logging.getLogger(__name__)
36
- self._logger.debug("Init IOHandler")
24
+ self.logger = logging.getLogger(__name__)
25
+ self.logger.debug("Init IOHandler")
37
26
 
38
27
  self.output_path = None
39
- self.use_plain_output_path = False
40
- self.data_path = None
41
28
  self.model_path = None
42
29
 
43
- def set_paths(
44
- self, output_path=None, data_path=None, model_path=None, use_plain_output_path=False
45
- ):
30
+ def set_paths(self, output_path=None, model_path=None):
46
31
  """
47
32
  Set paths for input and output.
48
33
 
@@ -50,28 +35,19 @@ class IOHandler(metaclass=IOHandlerSingleton):
50
35
  ----------
51
36
  output_path: str or Path
52
37
  Path pointing to the output directory.
53
- data_path: str or Path
54
- Path pointing to the data files (e.g., CORSIKA or sim_telarray output).
55
38
  model_path: str or Path
56
39
  Path pointing to the model file directory.
57
- use_plain_output_path: bool
58
- Use plain output path without adding tool name and date
59
-
60
40
  """
61
41
  self.output_path = output_path
62
- self.use_plain_output_path = use_plain_output_path
63
- self.data_path = data_path
64
42
  self.model_path = model_path
65
43
 
66
- def get_output_directory(self, label=None, sub_dir=None):
44
+ def get_output_directory(self, sub_dir=None):
67
45
  """
68
- Return path to output directory.
46
+ Create and get path of an output directory.
69
47
 
70
48
  Parameters
71
49
  ----------
72
- label: str
73
- Instance label.
74
- sub_dir: str
50
+ sub_dir: str or list of str, optional
75
51
  Name of the subdirectory (ray_tracing, model etc)
76
52
 
77
53
  Returns
@@ -81,34 +57,24 @@ class IOHandler(metaclass=IOHandlerSingleton):
81
57
  Raises
82
58
  ------
83
59
  FileNotFoundError
84
- if error creating directory
85
- TypeError
86
- raised for errors while creating directory name
60
+ if the directory cannot be created
87
61
  """
88
- path = Path(self.output_path)
89
- if not self.use_plain_output_path:
90
- path = (
91
- path
92
- if str(self.output_path).endswith("-output")
93
- else path.joinpath("simtools-output")
94
- )
95
- label_dir = label if label is not None else "d-" + str(datetime.date.today())
96
- path = (
97
- path.joinpath(label_dir) if sub_dir is None else path.joinpath(label_dir, sub_dir)
98
- )
99
-
100
- return self._mkdir(path)
101
-
102
- def _mkdir(self, path):
103
- """Create a directory and return path."""
62
+ if sub_dir is None:
63
+ parts = []
64
+ elif isinstance(sub_dir, list | tuple):
65
+ parts = sub_dir
66
+ else:
67
+ parts = [sub_dir]
68
+ path = Path(self.output_path, *parts)
69
+
104
70
  try:
105
71
  path.mkdir(parents=True, exist_ok=True)
106
72
  except FileNotFoundError as exc:
107
73
  raise FileNotFoundError(f"Error creating directory {path!s}") from exc
108
74
 
109
- return path.absolute()
75
+ return path.resolve()
110
76
 
111
- def get_output_file(self, file_name, label=None, sub_dir=None):
77
+ def get_output_file(self, file_name, sub_dir=None):
112
78
  """
113
79
  Get path of an output file.
114
80
 
@@ -116,51 +82,31 @@ class IOHandler(metaclass=IOHandlerSingleton):
116
82
  ----------
117
83
  files_name: str
118
84
  File name.
119
- label: str
120
- Instance label.
121
- sub_dir: str
85
+ sub_dir: sub_dir: str or list of str, optional
122
86
  Name of the subdirectory (ray_tracing, model etc)
123
87
 
124
88
  Returns
125
89
  -------
126
90
  Path
127
91
  """
128
- return (
129
- self.get_output_directory(label=label, sub_dir=sub_dir).joinpath(file_name).absolute()
130
- )
92
+ return self.get_output_directory(sub_dir).joinpath(file_name).absolute()
131
93
 
132
- def get_input_data_file(self, parent_dir=None, file_name=None, test=False):
94
+ def get_test_data_file(self, file_name=None):
133
95
  """
134
- Get path of a data file, using data_path.
96
+ Get path of a data file in the test resources directory.
135
97
 
136
98
  Parameters
137
99
  ----------
138
- parent_dir: str
139
- Parent directory of the file.
140
100
  files_name: str
141
101
  File name.
142
- test: bool
143
- If true, return test resources location
144
102
 
145
103
  Returns
146
104
  -------
147
105
  Path
148
-
149
- Raises
150
- ------
151
- IncompleteIOHandlerInitError
152
- if data_path is not set
153
-
154
106
  """
155
- if test:
156
- file_prefix = Path("tests/resources/")
157
- elif self.data_path is not None:
158
- file_prefix = Path(self.data_path).joinpath(parent_dir)
159
- else:
160
- raise IncompleteIOHandlerInitError
161
- return file_prefix.joinpath(file_name).absolute()
107
+ return Path("tests/resources", file_name).resolve()
162
108
 
163
- def get_model_configuration_directory(self, label, model_version):
109
+ def get_model_configuration_directory(self, model_version, sub_dir=None):
164
110
  """
165
111
  Get path of the simulation model configuration directory.
166
112
 
@@ -168,13 +114,15 @@ class IOHandler(metaclass=IOHandlerSingleton):
168
114
 
169
115
  Parameters
170
116
  ----------
171
- label: str
172
- Instance label.
173
117
  model_version: str
174
118
  Model version.
119
+ sub_dir: str
120
+ subdirectory
175
121
 
176
122
  Returns
177
123
  -------
178
124
  Path
179
125
  """
180
- return self._mkdir(self.get_output_directory(label=label).joinpath("model", model_version))
126
+ return self.get_output_directory(
127
+ sub_dir=[sub_dir, "model", model_version] if sub_dir else ["model", model_version]
128
+ )
@@ -5,11 +5,6 @@ import logging
5
5
 
6
6
  from astropy.table import Table
7
7
 
8
- __all__ = [
9
- "read_legacy_data_as_table",
10
- "read_legacy_lst_single_pe",
11
- ]
12
-
13
8
  logger = logging.getLogger(__name__)
14
9
 
15
10