gammasimtools 0.21.0__py3-none-any.whl → 0.22.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 (312) hide show
  1. {gammasimtools-0.21.0.dist-info → gammasimtools-0.22.0.dist-info}/METADATA +2 -3
  2. {gammasimtools-0.21.0.dist-info → gammasimtools-0.22.0.dist-info}/RECORD +311 -295
  3. {gammasimtools-0.21.0.dist-info → gammasimtools-0.22.0.dist-info}/entry_points.txt +2 -1
  4. simtools/_version.py +2 -2
  5. simtools/applications/calculate_incident_angles.py +1 -4
  6. simtools/applications/convert_all_model_parameters_from_simtel.py +1 -2
  7. simtools/applications/convert_model_parameter_from_simtel.py +0 -1
  8. simtools/applications/db_generate_compound_indexes.py +3 -16
  9. simtools/applications/db_upload_model_repository.py +122 -0
  10. simtools/applications/derive_psf_parameters.py +13 -3
  11. simtools/applications/docs_produce_array_element_report.py +1 -1
  12. simtools/applications/docs_produce_calibration_reports.py +1 -1
  13. simtools/applications/docs_produce_model_parameter_reports.py +1 -1
  14. simtools/applications/docs_produce_simulation_configuration_report.py +1 -1
  15. simtools/applications/generate_corsika_histograms.py +1 -1
  16. simtools/applications/maintain_simulation_model_add_production.py +7 -31
  17. simtools/applications/merge_tables.py +1 -1
  18. simtools/applications/plot_array_layout.py +1 -2
  19. simtools/applications/print_version.py +1 -1
  20. simtools/applications/production_derive_statistics.py +1 -2
  21. simtools/applications/production_generate_grid.py +1 -1
  22. simtools/applications/simulate_flasher.py +74 -72
  23. simtools/applications/simulate_illuminator.py +52 -186
  24. simtools/applications/{simulate_calibration_events.py → simulate_pedestals.py} +9 -55
  25. simtools/applications/submit_model_parameter_from_external.py +0 -1
  26. simtools/applications/validate_camera_efficiency.py +0 -1
  27. simtools/applications/validate_camera_fov.py +1 -2
  28. simtools/applications/validate_cumulative_psf.py +2 -3
  29. simtools/applications/validate_file_using_schema.py +20 -12
  30. simtools/applications/validate_optics.py +2 -2
  31. simtools/camera/camera_efficiency.py +8 -11
  32. simtools/configuration/commandline_parser.py +1 -7
  33. simtools/configuration/configurator.py +0 -2
  34. simtools/corsika/corsika_config.py +9 -11
  35. simtools/corsika/corsika_histograms.py +1 -1
  36. simtools/data_model/model_data_writer.py +87 -25
  37. simtools/data_model/schema.py +61 -2
  38. simtools/data_model/validate_data.py +1 -1
  39. simtools/db/db_handler.py +58 -37
  40. simtools/db/db_model_upload.py +210 -5
  41. simtools/io/io_handler.py +31 -83
  42. simtools/job_execution/job_manager.py +45 -0
  43. simtools/layout/array_layout_utils.py +1 -5
  44. simtools/model/array_model.py +93 -42
  45. simtools/model/model_parameter.py +20 -9
  46. simtools/model/model_repository.py +139 -106
  47. simtools/model/model_utils.py +21 -6
  48. simtools/model/telescope_model.py +20 -0
  49. simtools/production_configuration/derive_corsika_limits.py +1 -1
  50. simtools/ray_tracing/incident_angles.py +7 -7
  51. simtools/ray_tracing/mirror_panel_psf.py +1 -1
  52. simtools/ray_tracing/psf_parameter_optimisation.py +180 -73
  53. simtools/ray_tracing/ray_tracing.py +1 -3
  54. simtools/reporting/docs_read_parameters.py +171 -101
  55. simtools/resources/array_elements.yml +26 -0
  56. simtools/runners/corsika_simtel_runner.py +11 -17
  57. simtools/runners/runner_services.py +5 -6
  58. simtools/runners/simtools_runner.py +0 -2
  59. simtools/schemas/application_workflow.metaschema.yml +1 -1
  60. simtools/schemas/common_definitions.schema.yml +39 -0
  61. simtools/schemas/model_parameter.metaschema.yml +19 -13
  62. simtools/schemas/model_parameter_and_data_schema.metaschema.yml +6 -12
  63. simtools/schemas/model_parameters/adjust_gain.schema.yml +0 -5
  64. simtools/schemas/model_parameters/altitude.schema.yml +0 -5
  65. simtools/schemas/model_parameters/array_coordinates.schema.yml +0 -5
  66. simtools/schemas/model_parameters/array_coordinates_UTM.schema.yml +0 -5
  67. simtools/schemas/model_parameters/array_element_position_ground.schema.yml +0 -7
  68. simtools/schemas/model_parameters/array_element_position_utm.schema.yml +0 -7
  69. simtools/schemas/model_parameters/array_layouts.schema.yml +0 -5
  70. simtools/schemas/model_parameters/array_triggers.schema.yml +0 -5
  71. simtools/schemas/model_parameters/array_window.schema.yml +0 -7
  72. simtools/schemas/model_parameters/asum_clipping.schema.yml +0 -3
  73. simtools/schemas/model_parameters/asum_offset.schema.yml +0 -7
  74. simtools/schemas/model_parameters/asum_shaping.schema.yml +0 -7
  75. simtools/schemas/model_parameters/asum_threshold.schema.yml +0 -7
  76. simtools/schemas/model_parameters/atmospheric_profile.schema.yml +0 -5
  77. simtools/schemas/model_parameters/atmospheric_transmission.schema.yml +0 -5
  78. simtools/schemas/model_parameters/axes_offsets.schema.yml +0 -7
  79. simtools/schemas/model_parameters/calibration_devices.schema.yml +30 -0
  80. simtools/schemas/model_parameters/camera_body_diameter.schema.yml +0 -7
  81. simtools/schemas/model_parameters/camera_body_shape.schema.yml +0 -7
  82. simtools/schemas/model_parameters/camera_config_file.schema.yml +0 -7
  83. simtools/schemas/model_parameters/camera_config_rotate.schema.yml +0 -7
  84. simtools/schemas/model_parameters/camera_degraded_efficiency.schema.yml +0 -7
  85. simtools/schemas/model_parameters/camera_degraded_map.schema.yml +0 -7
  86. simtools/schemas/model_parameters/camera_depth.schema.yml +0 -7
  87. simtools/schemas/model_parameters/camera_filter.schema.yml +0 -7
  88. simtools/schemas/model_parameters/camera_filter_incidence_angle.schema.yml +0 -3
  89. simtools/schemas/model_parameters/camera_pixels.schema.yml +0 -7
  90. simtools/schemas/model_parameters/camera_transmission.schema.yml +0 -7
  91. simtools/schemas/model_parameters/channels_per_chip.schema.yml +0 -7
  92. simtools/schemas/model_parameters/correct_nsb_spectrum_to_telescope_altitude.schema.yml +0 -7
  93. simtools/schemas/model_parameters/corsika_observation_level.schema.yml +0 -5
  94. simtools/schemas/model_parameters/dark_events.schema.yml +4 -3
  95. simtools/schemas/model_parameters/default_trigger.schema.yml +0 -7
  96. simtools/schemas/model_parameters/design_model.schema.yml +0 -7
  97. simtools/schemas/model_parameters/disc_ac_coupled.schema.yml +0 -7
  98. simtools/schemas/model_parameters/disc_bins.schema.yml +0 -7
  99. simtools/schemas/model_parameters/disc_start.schema.yml +0 -7
  100. simtools/schemas/model_parameters/discriminator_amplitude.schema.yml +0 -7
  101. simtools/schemas/model_parameters/discriminator_fall_time.schema.yml +0 -7
  102. simtools/schemas/model_parameters/discriminator_gate_length.schema.yml +0 -7
  103. simtools/schemas/model_parameters/discriminator_hysteresis.schema.yml +0 -7
  104. simtools/schemas/model_parameters/discriminator_output_amplitude.schema.yml +0 -7
  105. simtools/schemas/model_parameters/discriminator_output_var_percent.schema.yml +0 -7
  106. simtools/schemas/model_parameters/discriminator_pulse_shape.schema.yml +0 -7
  107. simtools/schemas/model_parameters/discriminator_rise_time.schema.yml +0 -7
  108. simtools/schemas/model_parameters/discriminator_scale_threshold.schema.yml +0 -7
  109. simtools/schemas/model_parameters/discriminator_sigsum_over_threshold.schema.yml +0 -7
  110. simtools/schemas/model_parameters/discriminator_threshold.schema.yml +0 -7
  111. simtools/schemas/model_parameters/discriminator_time_over_threshold.schema.yml +1 -9
  112. simtools/schemas/model_parameters/discriminator_var_gate_length.schema.yml +0 -7
  113. simtools/schemas/model_parameters/discriminator_var_sigsum_over_threshold.schema.yml +0 -7
  114. simtools/schemas/model_parameters/discriminator_var_threshold.schema.yml +0 -7
  115. simtools/schemas/model_parameters/discriminator_var_time_over_threshold.schema.yml +0 -7
  116. simtools/schemas/model_parameters/dish_shape_length.schema.yml +0 -5
  117. simtools/schemas/model_parameters/dsum_clipping.schema.yml +1 -5
  118. simtools/schemas/model_parameters/dsum_ignore_below.schema.yml +0 -3
  119. simtools/schemas/model_parameters/dsum_offset.schema.yml +0 -3
  120. simtools/schemas/model_parameters/dsum_pedsub.schema.yml +0 -3
  121. simtools/schemas/model_parameters/dsum_pre_clipping.schema.yml +0 -3
  122. simtools/schemas/model_parameters/dsum_prescale.schema.yml +0 -3
  123. simtools/schemas/model_parameters/dsum_presum_max.schema.yml +0 -3
  124. simtools/schemas/model_parameters/dsum_presum_shift.schema.yml +0 -3
  125. simtools/schemas/model_parameters/dsum_shaping.schema.yml +0 -3
  126. simtools/schemas/model_parameters/dsum_shaping_renormalize.schema.yml +0 -3
  127. simtools/schemas/model_parameters/dsum_threshold.schema.yml +2 -12
  128. simtools/schemas/model_parameters/dsum_zero_clip.schema.yml +0 -3
  129. simtools/schemas/model_parameters/effective_focal_length.schema.yml +0 -7
  130. simtools/schemas/model_parameters/epsg_code.schema.yml +0 -5
  131. simtools/schemas/model_parameters/fadc_ac_coupled.schema.yml +0 -7
  132. simtools/schemas/model_parameters/fadc_amplitude.schema.yml +2 -9
  133. simtools/schemas/model_parameters/fadc_bins.schema.yml +0 -7
  134. simtools/schemas/model_parameters/fadc_compensate_pedestal.schema.yml +0 -7
  135. simtools/schemas/model_parameters/fadc_dev_pedestal.schema.yml +0 -2
  136. simtools/schemas/model_parameters/fadc_err_compensate_pedestal.schema.yml +0 -7
  137. simtools/schemas/model_parameters/fadc_err_pedestal.schema.yml +0 -7
  138. simtools/schemas/model_parameters/fadc_lg_amplitude.schema.yml +2 -9
  139. simtools/schemas/model_parameters/fadc_lg_compensate_pedestal.schema.yml +0 -7
  140. simtools/schemas/model_parameters/fadc_lg_dev_pedestal.schema.yml +0 -2
  141. simtools/schemas/model_parameters/fadc_lg_err_compensate_pedestal.schema.yml +0 -7
  142. simtools/schemas/model_parameters/fadc_lg_err_pedestal.schema.yml +0 -7
  143. simtools/schemas/model_parameters/fadc_lg_max_signal.schema.yml +0 -7
  144. simtools/schemas/model_parameters/fadc_lg_max_sum.schema.yml +0 -2
  145. simtools/schemas/model_parameters/fadc_lg_noise.schema.yml +0 -7
  146. simtools/schemas/model_parameters/fadc_lg_pedestal.schema.yml +0 -7
  147. simtools/schemas/model_parameters/fadc_lg_sensitivity.schema.yml +0 -7
  148. simtools/schemas/model_parameters/fadc_lg_sysvar_pedestal.schema.yml +0 -7
  149. simtools/schemas/model_parameters/fadc_lg_var_pedestal.schema.yml +0 -7
  150. simtools/schemas/model_parameters/fadc_lg_var_sensitivity.schema.yml +0 -7
  151. simtools/schemas/model_parameters/fadc_long_event_threshold.schema.yml +0 -3
  152. simtools/schemas/model_parameters/fadc_long_sum_bins.schema.yml +0 -3
  153. simtools/schemas/model_parameters/fadc_long_sum_offset.schema.yml +0 -3
  154. simtools/schemas/model_parameters/fadc_max_signal.schema.yml +0 -7
  155. simtools/schemas/model_parameters/fadc_max_sum.schema.yml +0 -2
  156. simtools/schemas/model_parameters/fadc_mhz.schema.yml +0 -7
  157. simtools/schemas/model_parameters/fadc_noise.schema.yml +0 -7
  158. simtools/schemas/model_parameters/fadc_pedestal.schema.yml +0 -7
  159. simtools/schemas/model_parameters/fadc_pulse_shape.schema.yml +0 -7
  160. simtools/schemas/model_parameters/fadc_sensitivity.schema.yml +0 -7
  161. simtools/schemas/model_parameters/fadc_sum_bins.schema.yml +0 -7
  162. simtools/schemas/model_parameters/fadc_sum_offset.schema.yml +0 -7
  163. simtools/schemas/model_parameters/fadc_sysvar_pedestal.schema.yml +0 -7
  164. simtools/schemas/model_parameters/fadc_var_pedestal.schema.yml +0 -7
  165. simtools/schemas/model_parameters/fadc_var_sensitivity.schema.yml +0 -7
  166. simtools/schemas/model_parameters/fake_mirror_list.schema.yml +0 -3
  167. simtools/schemas/model_parameters/flasher_angular_distribution.schema.yml +32 -0
  168. simtools/schemas/model_parameters/flasher_angular_distribution_width.schema.yml +32 -0
  169. simtools/schemas/model_parameters/flasher_bunch_size.schema.yml +28 -0
  170. simtools/schemas/model_parameters/flasher_external_trigger.schema.yml +32 -0
  171. simtools/schemas/model_parameters/flasher_photons.schema.yml +34 -0
  172. simtools/schemas/model_parameters/flasher_position.schema.yml +43 -0
  173. simtools/schemas/model_parameters/flasher_pulse_exp_decay.schema.yml +29 -0
  174. simtools/schemas/model_parameters/flasher_pulse_offset.schema.yml +35 -0
  175. simtools/schemas/model_parameters/flasher_pulse_shape.schema.yml +30 -0
  176. simtools/schemas/model_parameters/flasher_pulse_width.schema.yml +32 -0
  177. simtools/schemas/model_parameters/flasher_type.schema.yml +28 -0
  178. simtools/schemas/model_parameters/flasher_var_photons.schema.yml +31 -0
  179. simtools/schemas/model_parameters/flasher_wavelength.schema.yml +33 -0
  180. simtools/schemas/model_parameters/flatfielding.schema.yml +0 -7
  181. simtools/schemas/model_parameters/focal_length.schema.yml +0 -7
  182. simtools/schemas/model_parameters/focal_surface_parameters.schema.yml +0 -3
  183. simtools/schemas/model_parameters/focal_surface_ref_radius.schema.yml +0 -3
  184. simtools/schemas/model_parameters/focus_offset.schema.yml +0 -7
  185. simtools/schemas/model_parameters/gain_variation.schema.yml +0 -7
  186. simtools/schemas/model_parameters/geomag_horizontal.schema.yml +2 -7
  187. simtools/schemas/model_parameters/geomag_rotation.schema.yml +2 -7
  188. simtools/schemas/model_parameters/geomag_vertical.schema.yml +2 -7
  189. simtools/schemas/model_parameters/hg_lg_variation.schema.yml +0 -5
  190. simtools/schemas/model_parameters/iobuf_maximum.schema.yml +0 -7
  191. simtools/schemas/model_parameters/iobuf_output_maximum.schema.yml +0 -7
  192. simtools/schemas/model_parameters/laser_events.schema.yml +4 -3
  193. simtools/schemas/model_parameters/laser_external_trigger.schema.yml +4 -3
  194. simtools/schemas/model_parameters/laser_photons.schema.yml +4 -3
  195. simtools/schemas/model_parameters/laser_pulse_exptime.schema.yml +4 -3
  196. simtools/schemas/model_parameters/laser_pulse_offset.schema.yml +4 -3
  197. simtools/schemas/model_parameters/laser_pulse_sigtime.schema.yml +4 -3
  198. simtools/schemas/model_parameters/laser_pulse_twidth.schema.yml +4 -3
  199. simtools/schemas/model_parameters/laser_var_photons.schema.yml +4 -3
  200. simtools/schemas/model_parameters/laser_wavelength.schema.yml +4 -3
  201. simtools/schemas/model_parameters/led_events.schema.yml +4 -3
  202. simtools/schemas/model_parameters/led_photons.schema.yml +4 -3
  203. simtools/schemas/model_parameters/led_pulse_offset.schema.yml +4 -3
  204. simtools/schemas/model_parameters/led_pulse_sigtime.schema.yml +4 -3
  205. simtools/schemas/model_parameters/led_var_photons.schema.yml +4 -3
  206. simtools/schemas/model_parameters/lightguide_efficiency_vs_incidence_angle.schema.yml +0 -7
  207. simtools/schemas/model_parameters/lightguide_efficiency_vs_wavelength.schema.yml +0 -7
  208. simtools/schemas/model_parameters/min_photoelectrons.schema.yml +0 -7
  209. simtools/schemas/model_parameters/min_photons.schema.yml +0 -7
  210. simtools/schemas/model_parameters/mirror_align_random_distance.schema.yml +0 -5
  211. simtools/schemas/model_parameters/mirror_align_random_horizontal.schema.yml +0 -7
  212. simtools/schemas/model_parameters/mirror_align_random_vertical.schema.yml +0 -7
  213. simtools/schemas/model_parameters/mirror_class.schema.yml +2 -9
  214. simtools/schemas/model_parameters/mirror_degraded_reflection.schema.yml +0 -7
  215. simtools/schemas/model_parameters/mirror_focal_length.schema.yml +0 -5
  216. simtools/schemas/model_parameters/mirror_list.schema.yml +0 -7
  217. simtools/schemas/model_parameters/mirror_offset.schema.yml +0 -7
  218. simtools/schemas/model_parameters/mirror_reflection_random_angle.schema.yml +0 -7
  219. simtools/schemas/model_parameters/mirror_reflectivity.schema.yml +0 -7
  220. simtools/schemas/model_parameters/multiplicity_offset.schema.yml +0 -7
  221. simtools/schemas/model_parameters/muon_mono_threshold.schema.yml +0 -7
  222. simtools/schemas/model_parameters/nsb_autoscale_airmass.schema.yml +0 -7
  223. simtools/schemas/model_parameters/nsb_gain_drop_scale.schema.yml +0 -3
  224. simtools/schemas/model_parameters/nsb_offaxis.schema.yml +0 -7
  225. simtools/schemas/model_parameters/nsb_pixel_rate.schema.yml +0 -7
  226. simtools/schemas/model_parameters/nsb_reference_spectrum.schema.yml +0 -5
  227. simtools/schemas/model_parameters/nsb_reference_value.schema.yml +0 -5
  228. simtools/schemas/model_parameters/nsb_scaling_factor.schema.yml +0 -5
  229. simtools/schemas/model_parameters/nsb_sky_map.schema.yml +0 -5
  230. simtools/schemas/model_parameters/nsb_spectrum.schema.yml +0 -5
  231. simtools/schemas/model_parameters/num_gains.schema.yml +0 -7
  232. simtools/schemas/model_parameters/only_triggered_telescopes.schema.yml +0 -7
  233. simtools/schemas/model_parameters/optics_properties.schema.yml +0 -7
  234. simtools/schemas/model_parameters/parabolic_dish.schema.yml +0 -3
  235. simtools/schemas/model_parameters/pedestal_events.schema.yml +4 -7
  236. simtools/schemas/model_parameters/photon_delay.schema.yml +0 -7
  237. simtools/schemas/model_parameters/photons_per_run.schema.yml +4 -4
  238. simtools/schemas/model_parameters/pixel_cells.schema.yml +0 -3
  239. simtools/schemas/model_parameters/pixels_parallel.schema.yml +0 -3
  240. simtools/schemas/model_parameters/pixeltrg_time_step.schema.yml +0 -7
  241. simtools/schemas/model_parameters/pm_average_gain.schema.yml +0 -5
  242. simtools/schemas/model_parameters/pm_collection_efficiency.schema.yml +0 -5
  243. simtools/schemas/model_parameters/pm_gain_index.schema.yml +0 -5
  244. simtools/schemas/model_parameters/pm_photoelectron_spectrum.schema.yml +0 -7
  245. simtools/schemas/model_parameters/pm_transit_time.schema.yml +4 -9
  246. simtools/schemas/model_parameters/pm_voltage_variation.schema.yml +0 -5
  247. simtools/schemas/model_parameters/primary_mirror_degraded_map.schema.yml +0 -7
  248. simtools/schemas/model_parameters/primary_mirror_diameter.schema.yml +0 -3
  249. simtools/schemas/model_parameters/primary_mirror_hole_diameter.schema.yml +0 -3
  250. simtools/schemas/model_parameters/primary_mirror_incidence_angle.schema.yml +0 -3
  251. simtools/schemas/model_parameters/primary_mirror_parameters.schema.yml +0 -3
  252. simtools/schemas/model_parameters/primary_mirror_ref_radius.schema.yml +0 -3
  253. simtools/schemas/model_parameters/primary_mirror_segmentation.schema.yml +0 -3
  254. simtools/schemas/model_parameters/qe_variation.schema.yml +0 -7
  255. simtools/schemas/model_parameters/quantum_efficiency.schema.yml +0 -7
  256. simtools/schemas/model_parameters/random_focal_length.schema.yml +2 -7
  257. simtools/schemas/model_parameters/random_generator.schema.yml +0 -7
  258. simtools/schemas/model_parameters/random_mono_probability.schema.yml +0 -7
  259. simtools/schemas/model_parameters/reference_point_altitude.schema.yml +0 -5
  260. simtools/schemas/model_parameters/reference_point_latitude.schema.yml +0 -5
  261. simtools/schemas/model_parameters/reference_point_longitude.schema.yml +0 -5
  262. simtools/schemas/model_parameters/reference_point_utm_east.schema.yml +0 -5
  263. simtools/schemas/model_parameters/reference_point_utm_north.schema.yml +0 -5
  264. simtools/schemas/model_parameters/sampled_output.schema.yml +0 -7
  265. simtools/schemas/model_parameters/save_pe_with_amplitude.schema.yml +0 -7
  266. simtools/schemas/model_parameters/secondary_mirror_baffle.schema.yml +0 -3
  267. simtools/schemas/model_parameters/secondary_mirror_degraded_map.schema.yml +0 -3
  268. simtools/schemas/model_parameters/secondary_mirror_degraded_reflection.schema.yml +0 -3
  269. simtools/schemas/model_parameters/secondary_mirror_diameter.schema.yml +0 -3
  270. simtools/schemas/model_parameters/secondary_mirror_hole_diameter.schema.yml +0 -3
  271. simtools/schemas/model_parameters/secondary_mirror_incidence_angle.schema.yml +0 -3
  272. simtools/schemas/model_parameters/secondary_mirror_parameters.schema.yml +0 -3
  273. simtools/schemas/model_parameters/secondary_mirror_ref_radius.schema.yml +0 -3
  274. simtools/schemas/model_parameters/secondary_mirror_reflectivity.schema.yml +0 -3
  275. simtools/schemas/model_parameters/secondary_mirror_segmentation.schema.yml +0 -3
  276. simtools/schemas/model_parameters/secondary_mirror_shadow_diameter.schema.yml +0 -3
  277. simtools/schemas/model_parameters/secondary_mirror_shadow_offset.schema.yml +0 -3
  278. simtools/schemas/model_parameters/stars.schema.yml +0 -5
  279. simtools/schemas/model_parameters/store_photoelectrons.schema.yml +0 -7
  280. simtools/schemas/model_parameters/tailcut_scale.schema.yml +0 -7
  281. simtools/schemas/model_parameters/telescope_axis_height.schema.yml +0 -7
  282. simtools/schemas/model_parameters/telescope_random_angle.schema.yml +0 -7
  283. simtools/schemas/model_parameters/telescope_random_error.schema.yml +0 -7
  284. simtools/schemas/model_parameters/telescope_sphere_radius.schema.yml +0 -7
  285. simtools/schemas/model_parameters/telescope_transmission.schema.yml +0 -7
  286. simtools/schemas/model_parameters/teltrig_min_sigsum.schema.yml +0 -7
  287. simtools/schemas/model_parameters/teltrig_min_time.schema.yml +0 -7
  288. simtools/schemas/model_parameters/transit_time_calib_error.schema.yml +0 -7
  289. simtools/schemas/model_parameters/transit_time_compensate_error.schema.yml +0 -7
  290. simtools/schemas/model_parameters/transit_time_compensate_step.schema.yml +0 -7
  291. simtools/schemas/model_parameters/transit_time_error.schema.yml +0 -7
  292. simtools/schemas/model_parameters/transit_time_jitter.schema.yml +0 -7
  293. simtools/schemas/model_parameters/trigger_current_limit.schema.yml +0 -7
  294. simtools/schemas/model_parameters/trigger_delay_compensation.schema.yml +0 -7
  295. simtools/schemas/model_parameters/trigger_pixels.schema.yml +0 -7
  296. simtools/schemas/production_tables.schema.yml +8 -8
  297. simtools/schemas/simulation_models_info.schema.yml +78 -0
  298. simtools/simtel/simtel_config_writer.py +87 -13
  299. simtools/simtel/simulator_array.py +44 -74
  300. simtools/simtel/simulator_light_emission.py +336 -629
  301. simtools/simtel/simulator_ray_tracing.py +2 -2
  302. simtools/simulator.py +45 -14
  303. simtools/testing/configuration.py +4 -2
  304. simtools/testing/sim_telarray_metadata.py +4 -4
  305. simtools/utils/geometry.py +34 -0
  306. simtools/version.py +22 -0
  307. simtools/visualization/plot_psf.py +163 -61
  308. simtools/visualization/plot_simtel_events.py +1 -1
  309. simtools/model/flasher_model.py +0 -106
  310. {gammasimtools-0.21.0.dist-info → gammasimtools-0.22.0.dist-info}/WHEEL +0 -0
  311. {gammasimtools-0.21.0.dist-info → gammasimtools-0.22.0.dist-info}/licenses/LICENSE +0 -0
  312. {gammasimtools-0.21.0.dist-info → gammasimtools-0.22.0.dist-info}/top_level.txt +0 -0
@@ -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
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
+ )
@@ -2,6 +2,7 @@
2
2
 
3
3
  import logging
4
4
  import subprocess
5
+ import time
5
6
  from pathlib import Path
6
7
 
7
8
  import simtools.utils.general as gen
@@ -9,10 +10,54 @@ import simtools.utils.general as gen
9
10
  __all__ = ["JobExecutionError", "JobManager"]
10
11
 
11
12
 
13
+ logger = logging.getLogger(__name__)
14
+
15
+
12
16
  class JobExecutionError(Exception):
13
17
  """Job execution error."""
14
18
 
15
19
 
20
+ def retry_command(command, max_attempts=3, delay=10):
21
+ """
22
+ Execute a shell command with retry logic for network-related failures.
23
+
24
+ Parameters
25
+ ----------
26
+ command : str
27
+ Shell command to execute.
28
+ max_attempts : int
29
+ Maximum number of retry attempts (default: 3).
30
+ delay : int
31
+ Delay in seconds between attempts (default: 10).
32
+
33
+ Returns
34
+ -------
35
+ bool
36
+ True if command succeeded, False if all attempts failed.
37
+
38
+ Raises
39
+ ------
40
+ subprocess.CalledProcessError
41
+ If command fails after all retry attempts.
42
+ """
43
+ for attempt in range(1, max_attempts + 1):
44
+ logger.info(f"Attempt {attempt} of {max_attempts}: {command}")
45
+ try:
46
+ subprocess.run(command, shell=True, check=True, text=True)
47
+ logger.info(f"Command succeeded on attempt {attempt}")
48
+ return True
49
+ except subprocess.CalledProcessError as exc:
50
+ logger.warning(f"Command failed on attempt {attempt}")
51
+ if attempt < max_attempts:
52
+ logger.info(f"Waiting {delay}s before retry...")
53
+ time.sleep(delay)
54
+ else:
55
+ logger.error(f"Command failed after {max_attempts} attempts")
56
+ raise exc from None
57
+
58
+ return False
59
+
60
+
16
61
  class JobManager:
17
62
  """
18
63
  Job manager for submitting jobs to a compute node.
@@ -154,10 +154,7 @@ def write_array_layouts(array_layouts, args_dict, db_config):
154
154
  _logger.info(f"Writing updated array layouts to the database for site {site}.")
155
155
 
156
156
  io_handler_instance = io_handler.IOHandler()
157
- io_handler_instance.set_paths(
158
- output_path=args_dict["output_path"],
159
- use_plain_output_path=args_dict["use_plain_output_path"],
160
- )
157
+ io_handler_instance.set_paths(output_path=args_dict["output_path"])
161
158
  output_file = io_handler_instance.get_output_file(
162
159
  f"array-layouts-{args_dict['updated_parameter_version']}.json"
163
160
  )
@@ -168,7 +165,6 @@ def write_array_layouts(array_layouts, args_dict, db_config):
168
165
  instrument=site,
169
166
  parameter_version=args_dict.get("updated_parameter_version"),
170
167
  output_file=output_file,
171
- use_plain_output_path=args_dict["use_plain_output_path"],
172
168
  db_config=db_config,
173
169
  )
174
170
  MetadataCollector.dump(