gammasimtools 0.6.1__py3-none-any.whl → 0.8.2__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 (355) hide show
  1. gammasimtools-0.8.2.dist-info/METADATA +173 -0
  2. gammasimtools-0.8.2.dist-info/RECORD +345 -0
  3. {gammasimtools-0.6.1.dist-info → gammasimtools-0.8.2.dist-info}/WHEEL +1 -1
  4. gammasimtools-0.8.2.dist-info/entry_points.txt +31 -0
  5. simtools/_dev_version/__init__.py +9 -0
  6. simtools/_version.py +2 -2
  7. simtools/applications/calculate_trigger_rate.py +210 -0
  8. simtools/applications/convert_all_model_parameters_from_simtel.py +372 -0
  9. simtools/applications/{print_array_elements.py → convert_geo_coordinates_of_array_elements.py} +58 -63
  10. simtools/applications/convert_model_parameter_from_simtel.py +119 -0
  11. simtools/applications/{add_file_to_db.py → db_add_file_to_db.py} +70 -60
  12. simtools/applications/db_add_model_parameters_from_repository_to_db.py +184 -0
  13. simtools/applications/db_add_value_from_json_to_db.py +105 -0
  14. simtools/applications/db_development_tools/write_array_elements_positions_to_repository.py +180 -0
  15. simtools/applications/db_get_array_layouts_from_db.py +162 -0
  16. simtools/applications/{get_file_from_db.py → db_get_file_from_db.py} +30 -34
  17. simtools/applications/db_get_parameter_from_db.py +131 -0
  18. simtools/applications/db_inspect_databases.py +52 -0
  19. simtools/applications/derive_mirror_rnda.py +39 -255
  20. simtools/applications/derive_psf_parameters.py +441 -0
  21. simtools/applications/generate_array_config.py +82 -0
  22. simtools/applications/generate_corsika_histograms.py +52 -52
  23. simtools/applications/generate_default_metadata.py +5 -8
  24. simtools/applications/generate_regular_arrays.py +117 -0
  25. simtools/applications/generate_simtel_array_histograms.py +97 -56
  26. simtools/applications/plot_array_layout.py +345 -115
  27. simtools/applications/production_generate_simulation_config.py +158 -0
  28. simtools/applications/production_scale_events.py +168 -0
  29. simtools/applications/simulate_light_emission.py +478 -0
  30. simtools/applications/simulate_prod.py +97 -175
  31. simtools/applications/submit_data_from_external.py +9 -12
  32. simtools/applications/submit_model_parameter_from_external.py +122 -0
  33. simtools/applications/validate_camera_efficiency.py +35 -102
  34. simtools/applications/validate_camera_fov.py +20 -19
  35. simtools/applications/{compare_cumulative_psf.py → validate_cumulative_psf.py} +45 -44
  36. simtools/applications/validate_file_using_schema.py +111 -47
  37. simtools/applications/validate_optics.py +17 -22
  38. simtools/camera_efficiency.py +193 -202
  39. simtools/configuration/commandline_parser.py +384 -96
  40. simtools/configuration/configurator.py +55 -71
  41. simtools/constants.py +5 -5
  42. simtools/corsika/corsika_config.py +482 -342
  43. simtools/corsika/corsika_histograms.py +226 -204
  44. simtools/corsika/corsika_histograms_visualize.py +23 -24
  45. simtools/corsika/primary_particle.py +159 -0
  46. simtools/data_model/data_reader.py +25 -20
  47. simtools/data_model/format_checkers.py +52 -0
  48. simtools/data_model/metadata_collector.py +211 -185
  49. simtools/data_model/metadata_model.py +115 -37
  50. simtools/data_model/model_data_writer.py +335 -26
  51. simtools/data_model/validate_data.py +366 -154
  52. simtools/db/db_array_elements.py +130 -0
  53. simtools/db/db_from_repo_handler.py +106 -0
  54. simtools/db/db_handler.py +1246 -0
  55. simtools/io_operations/hdf5_handler.py +3 -1
  56. simtools/io_operations/io_handler.py +32 -57
  57. simtools/job_execution/job_manager.py +82 -69
  58. simtools/layout/array_layout.py +325 -537
  59. simtools/layout/geo_coordinates.py +8 -11
  60. simtools/layout/telescope_position.py +163 -86
  61. simtools/model/array_model.py +312 -259
  62. simtools/model/calibration_model.py +50 -0
  63. simtools/model/camera.py +277 -523
  64. simtools/model/mirrors.py +68 -49
  65. simtools/model/model_parameter.py +602 -0
  66. simtools/model/model_utils.py +11 -39
  67. simtools/model/site_model.py +161 -0
  68. simtools/model/telescope_model.py +143 -633
  69. simtools/production_configuration/calculate_statistical_errors_grid_point.py +454 -0
  70. simtools/production_configuration/event_scaler.py +146 -0
  71. simtools/production_configuration/generate_simulation_config.py +193 -0
  72. simtools/production_configuration/interpolation_handler.py +197 -0
  73. simtools/ray_tracing/__init__.py +0 -0
  74. simtools/ray_tracing/mirror_panel_psf.py +280 -0
  75. simtools/{psf_analysis.py → ray_tracing/psf_analysis.py} +133 -47
  76. simtools/ray_tracing/ray_tracing.py +646 -0
  77. simtools/runners/__init__.py +0 -0
  78. simtools/runners/corsika_runner.py +240 -0
  79. simtools/runners/corsika_simtel_runner.py +225 -0
  80. simtools/runners/runner_services.py +307 -0
  81. simtools/runners/simtel_runner.py +224 -0
  82. simtools/schemas/array_elements.yml +137 -0
  83. simtools/schemas/integration_tests_config.metaschema.yml +93 -0
  84. simtools/schemas/metadata.metaschema.yml +6 -0
  85. simtools/schemas/model_parameter.metaschema.yml +78 -0
  86. simtools/schemas/{data.metaschema.yml → model_parameter_and_data_schema.metaschema.yml} +27 -44
  87. simtools/schemas/model_parameters/adjust_gain.schema.yml +37 -0
  88. simtools/schemas/model_parameters/altitude.schema.yml +37 -0
  89. simtools/schemas/model_parameters/array_coordinates.schema.yml +33 -0
  90. simtools/schemas/model_parameters/array_coordinates_UTM.schema.yml +77 -0
  91. simtools/schemas/model_parameters/array_element_position_ground.schema.yml +39 -0
  92. simtools/schemas/model_parameters/array_element_position_utm.schema.yml +39 -0
  93. simtools/schemas/model_parameters/array_layouts.schema.yml +48 -0
  94. simtools/schemas/model_parameters/array_triggers.schema.yml +93 -0
  95. simtools/schemas/model_parameters/asum_clipping.schema.yml +38 -0
  96. simtools/schemas/model_parameters/asum_offset.schema.yml +35 -0
  97. simtools/schemas/model_parameters/asum_shaping.schema.yml +35 -0
  98. simtools/schemas/model_parameters/asum_threshold.schema.yml +38 -0
  99. simtools/schemas/model_parameters/atmospheric_profile.schema.yml +32 -0
  100. simtools/schemas/model_parameters/atmospheric_transmission.schema.yml +35 -0
  101. simtools/schemas/model_parameters/axes_offsets.schema.yml +53 -0
  102. simtools/schemas/model_parameters/camera_body_diameter.schema.yml +40 -0
  103. simtools/schemas/model_parameters/camera_body_shape.schema.yml +45 -0
  104. simtools/schemas/model_parameters/camera_config_file.schema.yml +40 -0
  105. simtools/schemas/model_parameters/camera_config_rotate.schema.yml +36 -0
  106. simtools/schemas/model_parameters/camera_degraded_efficiency.schema.yml +43 -0
  107. simtools/schemas/model_parameters/camera_degraded_map.schema.yml +42 -0
  108. simtools/schemas/model_parameters/camera_depth.schema.yml +42 -0
  109. simtools/schemas/model_parameters/camera_filter.schema.yml +45 -0
  110. simtools/schemas/model_parameters/camera_filter_incidence_angle.schema.yml +29 -0
  111. simtools/schemas/model_parameters/camera_pixels.schema.yml +36 -0
  112. simtools/schemas/model_parameters/camera_transmission.schema.yml +41 -0
  113. simtools/schemas/model_parameters/channels_per_chip.schema.yml +36 -0
  114. simtools/schemas/model_parameters/correct_nsb_spectrum_to_telescope_altitude.schema.yml +35 -0
  115. simtools/schemas/model_parameters/corsika_cherenkov_photon_bunch_size.schema.yml +27 -0
  116. simtools/schemas/model_parameters/corsika_cherenkov_photon_wavelength_range.schema.yml +38 -0
  117. simtools/schemas/model_parameters/corsika_first_interaction_height.schema.yml +28 -0
  118. simtools/schemas/model_parameters/corsika_iact_io_buffer.schema.yml +23 -0
  119. simtools/schemas/model_parameters/corsika_iact_max_bunches.schema.yml +27 -0
  120. simtools/schemas/model_parameters/corsika_iact_split_auto.schema.yml +28 -0
  121. simtools/schemas/model_parameters/corsika_longitudinal_shower_development.schema.yml +27 -0
  122. simtools/schemas/model_parameters/corsika_observation_level.schema.yml +38 -0
  123. simtools/schemas/model_parameters/corsika_particle_kinetic_energy_cutoff.schema.yml +52 -0
  124. simtools/schemas/model_parameters/corsika_starting_grammage.schema.yml +27 -0
  125. simtools/schemas/model_parameters/dark_events.schema.yml +32 -0
  126. simtools/schemas/model_parameters/default_trigger.schema.yml +35 -0
  127. simtools/schemas/model_parameters/design_model.schema.yml +31 -0
  128. simtools/schemas/model_parameters/disc_ac_coupled.schema.yml +32 -0
  129. simtools/schemas/model_parameters/disc_bins.schema.yml +39 -0
  130. simtools/schemas/model_parameters/disc_start.schema.yml +41 -0
  131. simtools/schemas/model_parameters/discriminator_amplitude.schema.yml +42 -0
  132. simtools/schemas/model_parameters/discriminator_fall_time.schema.yml +41 -0
  133. simtools/schemas/model_parameters/discriminator_gate_length.schema.yml +41 -0
  134. simtools/schemas/model_parameters/discriminator_hysteresis.schema.yml +39 -0
  135. simtools/schemas/model_parameters/discriminator_output_amplitude.schema.yml +40 -0
  136. simtools/schemas/model_parameters/discriminator_output_var_percent.schema.yml +41 -0
  137. simtools/schemas/model_parameters/discriminator_pulse_shape.schema.yml +33 -0
  138. simtools/schemas/model_parameters/discriminator_rise_time.schema.yml +42 -0
  139. simtools/schemas/model_parameters/discriminator_scale_threshold.schema.yml +37 -0
  140. simtools/schemas/model_parameters/discriminator_sigsum_over_threshold.schema.yml +44 -0
  141. simtools/schemas/model_parameters/discriminator_threshold.schema.yml +36 -0
  142. simtools/schemas/model_parameters/discriminator_time_over_threshold.schema.yml +45 -0
  143. simtools/schemas/model_parameters/discriminator_var_gate_length.schema.yml +40 -0
  144. simtools/schemas/model_parameters/discriminator_var_sigsum_over_threshold.schema.yml +41 -0
  145. simtools/schemas/model_parameters/discriminator_var_threshold.schema.yml +38 -0
  146. simtools/schemas/model_parameters/discriminator_var_time_over_threshold.schema.yml +38 -0
  147. simtools/schemas/model_parameters/dish_shape_length.schema.yml +41 -0
  148. simtools/schemas/model_parameters/dsum_clipping.schema.yml +38 -0
  149. simtools/schemas/model_parameters/dsum_ignore_below.schema.yml +38 -0
  150. simtools/schemas/model_parameters/dsum_offset.schema.yml +37 -0
  151. simtools/schemas/model_parameters/dsum_pedsub.schema.yml +33 -0
  152. simtools/schemas/model_parameters/dsum_pre_clipping.schema.yml +39 -0
  153. simtools/schemas/model_parameters/dsum_prescale.schema.yml +44 -0
  154. simtools/schemas/model_parameters/dsum_presum_max.schema.yml +38 -0
  155. simtools/schemas/model_parameters/dsum_presum_shift.schema.yml +45 -0
  156. simtools/schemas/model_parameters/dsum_shaping.schema.yml +44 -0
  157. simtools/schemas/model_parameters/dsum_shaping_renormalize.schema.yml +32 -0
  158. simtools/schemas/model_parameters/dsum_threshold.schema.yml +43 -0
  159. simtools/schemas/model_parameters/dsum_zero_clip.schema.yml +42 -0
  160. simtools/schemas/model_parameters/effective_focal_length.schema.yml +61 -0
  161. simtools/schemas/model_parameters/epsg_code.schema.yml +37 -0
  162. simtools/schemas/model_parameters/fadc_ac_coupled.schema.yml +35 -0
  163. simtools/schemas/model_parameters/fadc_amplitude.schema.yml +46 -0
  164. simtools/schemas/model_parameters/fadc_bins.schema.yml +40 -0
  165. simtools/schemas/model_parameters/fadc_compensate_pedestal.schema.yml +50 -0
  166. simtools/schemas/model_parameters/fadc_dev_pedestal.schema.yml +38 -0
  167. simtools/schemas/model_parameters/fadc_err_compensate_pedestal.schema.yml +42 -0
  168. simtools/schemas/model_parameters/fadc_err_pedestal.schema.yml +49 -0
  169. simtools/schemas/model_parameters/fadc_lg_amplitude.schema.yml +47 -0
  170. simtools/schemas/model_parameters/fadc_lg_compensate_pedestal.schema.yml +51 -0
  171. simtools/schemas/model_parameters/fadc_lg_dev_pedestal.schema.yml +37 -0
  172. simtools/schemas/model_parameters/fadc_lg_err_compensate_pedestal.schema.yml +43 -0
  173. simtools/schemas/model_parameters/fadc_lg_err_pedestal.schema.yml +49 -0
  174. simtools/schemas/model_parameters/fadc_lg_max_signal.schema.yml +43 -0
  175. simtools/schemas/model_parameters/fadc_lg_max_sum.schema.yml +39 -0
  176. simtools/schemas/model_parameters/fadc_lg_noise.schema.yml +42 -0
  177. simtools/schemas/model_parameters/fadc_lg_pedestal.schema.yml +40 -0
  178. simtools/schemas/model_parameters/fadc_lg_sensitivity.schema.yml +50 -0
  179. simtools/schemas/model_parameters/fadc_lg_sysvar_pedestal.schema.yml +42 -0
  180. simtools/schemas/model_parameters/fadc_lg_var_pedestal.schema.yml +41 -0
  181. simtools/schemas/model_parameters/fadc_lg_var_sensitivity.schema.yml +42 -0
  182. simtools/schemas/model_parameters/fadc_max_signal.schema.yml +43 -0
  183. simtools/schemas/model_parameters/fadc_max_sum.schema.yml +39 -0
  184. simtools/schemas/model_parameters/fadc_mhz.schema.yml +31 -0
  185. simtools/schemas/model_parameters/fadc_noise.schema.yml +41 -0
  186. simtools/schemas/model_parameters/fadc_pedestal.schema.yml +40 -0
  187. simtools/schemas/model_parameters/fadc_pulse_shape.schema.yml +39 -0
  188. simtools/schemas/model_parameters/fadc_sensitivity.schema.yml +50 -0
  189. simtools/schemas/model_parameters/fadc_sum_bins.schema.yml +43 -0
  190. simtools/schemas/model_parameters/fadc_sum_offset.schema.yml +43 -0
  191. simtools/schemas/model_parameters/fadc_sysvar_pedestal.schema.yml +42 -0
  192. simtools/schemas/model_parameters/fadc_var_pedestal.schema.yml +41 -0
  193. simtools/schemas/model_parameters/fadc_var_sensitivity.schema.yml +42 -0
  194. simtools/schemas/model_parameters/flatfielding.schema.yml +37 -0
  195. simtools/schemas/model_parameters/focal_length.schema.yml +45 -0
  196. simtools/schemas/model_parameters/focal_surface_parameters.schema.yml +158 -0
  197. simtools/schemas/model_parameters/focal_surface_ref_radius.schema.yml +29 -0
  198. simtools/schemas/model_parameters/focus_offset.schema.yml +66 -0
  199. simtools/schemas/model_parameters/gain_variation.schema.yml +43 -0
  200. simtools/schemas/model_parameters/geomag_horizontal.schema.yml +34 -0
  201. simtools/schemas/model_parameters/geomag_rotation.schema.yml +37 -0
  202. simtools/schemas/model_parameters/geomag_vertical.schema.yml +34 -0
  203. simtools/schemas/model_parameters/hg_lg_variation.schema.yml +36 -0
  204. simtools/schemas/model_parameters/iobuf_maximum.schema.yml +34 -0
  205. simtools/schemas/model_parameters/iobuf_output_maximum.schema.yml +34 -0
  206. simtools/schemas/model_parameters/laser_events.schema.yml +36 -0
  207. simtools/schemas/model_parameters/laser_external_trigger.schema.yml +35 -0
  208. simtools/schemas/model_parameters/laser_photons.schema.yml +32 -0
  209. simtools/schemas/model_parameters/laser_pulse_exptime.schema.yml +34 -0
  210. simtools/schemas/model_parameters/laser_pulse_offset.schema.yml +34 -0
  211. simtools/schemas/model_parameters/laser_pulse_sigtime.schema.yml +33 -0
  212. simtools/schemas/model_parameters/laser_pulse_twidth.schema.yml +33 -0
  213. simtools/schemas/model_parameters/laser_var_photons.schema.yml +33 -0
  214. simtools/schemas/model_parameters/laser_wavelength.schema.yml +33 -0
  215. simtools/schemas/model_parameters/led_events.schema.yml +34 -0
  216. simtools/schemas/model_parameters/led_photons.schema.yml +34 -0
  217. simtools/schemas/model_parameters/led_pulse_offset.schema.yml +32 -0
  218. simtools/schemas/model_parameters/led_pulse_sigtime.schema.yml +33 -0
  219. simtools/schemas/model_parameters/led_var_photons.schema.yml +34 -0
  220. simtools/schemas/model_parameters/lightguide_efficiency_vs_incidence_angle.schema.yml +41 -0
  221. simtools/schemas/model_parameters/lightguide_efficiency_vs_wavelength.schema.yml +43 -0
  222. simtools/schemas/model_parameters/min_photoelectrons.schema.yml +35 -0
  223. simtools/schemas/model_parameters/min_photons.schema.yml +32 -0
  224. simtools/schemas/model_parameters/mirror_align_random_distance.schema.yml +36 -0
  225. simtools/schemas/model_parameters/mirror_align_random_horizontal.schema.yml +64 -0
  226. simtools/schemas/model_parameters/mirror_align_random_vertical.schema.yml +64 -0
  227. simtools/schemas/model_parameters/mirror_class.schema.yml +41 -0
  228. simtools/schemas/model_parameters/mirror_degraded_reflection.schema.yml +51 -0
  229. simtools/schemas/model_parameters/mirror_focal_length.schema.yml +42 -0
  230. simtools/schemas/model_parameters/mirror_list.schema.yml +38 -0
  231. simtools/schemas/model_parameters/mirror_offset.schema.yml +41 -0
  232. simtools/schemas/model_parameters/mirror_panel_2f_measurements.schema.yml +39 -0
  233. simtools/schemas/model_parameters/mirror_reflection_random_angle.schema.yml +61 -0
  234. simtools/schemas/model_parameters/mirror_reflectivity.schema.yml +40 -0
  235. simtools/schemas/model_parameters/multiplicity_offset.schema.yml +46 -0
  236. simtools/schemas/model_parameters/nsb_autoscale_airmass.schema.yml +51 -0
  237. simtools/schemas/model_parameters/nsb_gain_drop_scale.schema.yml +37 -0
  238. simtools/schemas/model_parameters/nsb_offaxis.schema.yml +79 -0
  239. simtools/schemas/model_parameters/nsb_pixel_rate.schema.yml +47 -0
  240. simtools/schemas/model_parameters/nsb_reference_spectrum.schema.yml +34 -0
  241. simtools/schemas/model_parameters/nsb_reference_value.schema.yml +33 -0
  242. simtools/schemas/model_parameters/nsb_scaling_factor.schema.yml +35 -0
  243. simtools/schemas/model_parameters/nsb_skymap.schema.yml +39 -0
  244. simtools/schemas/model_parameters/nsb_spectrum.schema.yml +50 -0
  245. simtools/schemas/model_parameters/num_gains.schema.yml +34 -0
  246. simtools/schemas/model_parameters/only_triggered_telescopes.schema.yml +33 -0
  247. simtools/schemas/model_parameters/optics_properties.schema.yml +31 -0
  248. simtools/schemas/model_parameters/parabolic_dish.schema.yml +32 -0
  249. simtools/schemas/model_parameters/pedestal_events.schema.yml +32 -0
  250. simtools/schemas/model_parameters/photon_delay.schema.yml +38 -0
  251. simtools/schemas/model_parameters/photons_per_run.schema.yml +33 -0
  252. simtools/schemas/model_parameters/pixel_cells.schema.yml +35 -0
  253. simtools/schemas/model_parameters/pixels_parallel.schema.yml +54 -0
  254. simtools/schemas/model_parameters/pixeltrg_time_step.schema.yml +40 -0
  255. simtools/schemas/model_parameters/pm_average_gain.schema.yml +34 -0
  256. simtools/schemas/model_parameters/pm_collection_efficiency.schema.yml +40 -0
  257. simtools/schemas/model_parameters/pm_gain_index.schema.yml +36 -0
  258. simtools/schemas/model_parameters/pm_photoelectron_spectrum.schema.yml +41 -0
  259. simtools/schemas/model_parameters/pm_transit_time.schema.yml +63 -0
  260. simtools/schemas/model_parameters/pm_voltage_variation.schema.yml +39 -0
  261. simtools/schemas/model_parameters/primary_mirror_degraded_map.schema.yml +42 -0
  262. simtools/schemas/model_parameters/primary_mirror_diameter.schema.yml +33 -0
  263. simtools/schemas/model_parameters/primary_mirror_hole_diameter.schema.yml +33 -0
  264. simtools/schemas/model_parameters/primary_mirror_incidence_angle.schema.yml +29 -0
  265. simtools/schemas/model_parameters/primary_mirror_parameters.schema.yml +168 -0
  266. simtools/schemas/model_parameters/primary_mirror_ref_radius.schema.yml +36 -0
  267. simtools/schemas/model_parameters/primary_mirror_segmentation.schema.yml +34 -0
  268. simtools/schemas/model_parameters/qe_variation.schema.yml +43 -0
  269. simtools/schemas/model_parameters/quantum_efficiency.schema.yml +42 -0
  270. simtools/schemas/model_parameters/random_focal_length.schema.yml +45 -0
  271. simtools/schemas/model_parameters/random_generator.schema.yml +36 -0
  272. simtools/schemas/model_parameters/reference_point_altitude.schema.yml +35 -0
  273. simtools/schemas/model_parameters/reference_point_latitude.schema.yml +36 -0
  274. simtools/schemas/model_parameters/reference_point_longitude.schema.yml +36 -0
  275. simtools/schemas/model_parameters/reference_point_utm_east.schema.yml +34 -0
  276. simtools/schemas/model_parameters/reference_point_utm_north.schema.yml +34 -0
  277. simtools/schemas/model_parameters/sampled_output.schema.yml +31 -0
  278. simtools/schemas/model_parameters/save_pe_with_amplitude.schema.yml +34 -0
  279. simtools/schemas/model_parameters/secondary_mirror_baffle.schema.yml +79 -0
  280. simtools/schemas/model_parameters/secondary_mirror_degraded_map.schema.yml +42 -0
  281. simtools/schemas/model_parameters/secondary_mirror_degraded_reflection.schema.yml +41 -0
  282. simtools/schemas/model_parameters/secondary_mirror_diameter.schema.yml +33 -0
  283. simtools/schemas/model_parameters/secondary_mirror_hole_diameter.schema.yml +36 -0
  284. simtools/schemas/model_parameters/secondary_mirror_incidence_angle.schema.yml +29 -0
  285. simtools/schemas/model_parameters/secondary_mirror_parameters.schema.yml +168 -0
  286. simtools/schemas/model_parameters/secondary_mirror_ref_radius.schema.yml +36 -0
  287. simtools/schemas/model_parameters/secondary_mirror_reflectivity.schema.yml +35 -0
  288. simtools/schemas/model_parameters/secondary_mirror_segmentation.schema.yml +37 -0
  289. simtools/schemas/model_parameters/secondary_mirror_shadow_diameter.schema.yml +40 -0
  290. simtools/schemas/model_parameters/secondary_mirror_shadow_offset.schema.yml +40 -0
  291. simtools/schemas/model_parameters/store_photoelectrons.schema.yml +41 -0
  292. simtools/schemas/model_parameters/tailcut_scale.schema.yml +40 -0
  293. simtools/schemas/model_parameters/telescope_axis_height.schema.yml +31 -0
  294. simtools/schemas/model_parameters/telescope_random_angle.schema.yml +35 -0
  295. simtools/schemas/model_parameters/telescope_random_error.schema.yml +34 -0
  296. simtools/schemas/model_parameters/telescope_sphere_radius.schema.yml +37 -0
  297. simtools/schemas/model_parameters/telescope_transmission.schema.yml +113 -0
  298. simtools/schemas/model_parameters/teltrig_min_sigsum.schema.yml +41 -0
  299. simtools/schemas/model_parameters/teltrig_min_time.schema.yml +36 -0
  300. simtools/schemas/model_parameters/transit_time_calib_error.schema.yml +36 -0
  301. simtools/schemas/model_parameters/transit_time_compensate_error.schema.yml +37 -0
  302. simtools/schemas/model_parameters/transit_time_compensate_step.schema.yml +38 -0
  303. simtools/schemas/model_parameters/transit_time_error.schema.yml +45 -0
  304. simtools/schemas/model_parameters/transit_time_jitter.schema.yml +36 -0
  305. simtools/schemas/model_parameters/trigger_current_limit.schema.yml +32 -0
  306. simtools/schemas/model_parameters/trigger_delay_compensation.schema.yml +53 -0
  307. simtools/schemas/model_parameters/trigger_pixels.schema.yml +40 -0
  308. simtools/simtel/simtel_config_reader.py +353 -0
  309. simtools/simtel/simtel_config_writer.py +244 -63
  310. simtools/simtel/{simtel_events.py → simtel_io_events.py} +26 -25
  311. simtools/simtel/simtel_io_histogram.py +661 -0
  312. simtools/simtel/simtel_io_histograms.py +569 -0
  313. simtools/simtel/simulator_array.py +145 -0
  314. simtools/simtel/{simtel_runner_camera_efficiency.py → simulator_camera_efficiency.py} +76 -52
  315. simtools/simtel/simulator_light_emission.py +473 -0
  316. simtools/simtel/simulator_ray_tracing.py +262 -0
  317. simtools/simulator.py +220 -446
  318. simtools/testing/__init__.py +0 -0
  319. simtools/testing/assertions.py +151 -0
  320. simtools/testing/configuration.py +226 -0
  321. simtools/testing/helpers.py +42 -0
  322. simtools/testing/validate_output.py +240 -0
  323. simtools/utils/general.py +340 -437
  324. simtools/utils/geometry.py +12 -12
  325. simtools/utils/names.py +257 -644
  326. simtools/utils/value_conversion.py +176 -0
  327. simtools/version.py +3 -1
  328. simtools/visualization/legend_handlers.py +135 -152
  329. simtools/visualization/plot_camera.py +379 -0
  330. simtools/visualization/visualize.py +346 -167
  331. gammasimtools-0.6.1.dist-info/METADATA +0 -180
  332. gammasimtools-0.6.1.dist-info/RECORD +0 -91
  333. gammasimtools-0.6.1.dist-info/entry_points.txt +0 -23
  334. simtools/_dev_version/scm_version.py +0 -10
  335. simtools/applications/db_development_tools/add_new_parameter_to_db.py +0 -81
  336. simtools/applications/db_development_tools/add_unit_to_parameter_in_db.py +0 -59
  337. simtools/applications/db_development_tools/mark_non_optics_parameters_non_applicable.py +0 -102
  338. simtools/applications/get_parameter.py +0 -92
  339. simtools/applications/make_regular_arrays.py +0 -160
  340. simtools/applications/produce_array_config.py +0 -136
  341. simtools/applications/production.py +0 -313
  342. simtools/applications/sim_showers_for_trigger_rates.py +0 -187
  343. simtools/applications/tune_psf.py +0 -334
  344. simtools/corsika/corsika_default_config.py +0 -282
  345. simtools/corsika/corsika_runner.py +0 -450
  346. simtools/corsika_simtel/corsika_simtel_runner.py +0 -197
  347. simtools/db_handler.py +0 -1480
  348. simtools/ray_tracing.py +0 -525
  349. simtools/simtel/simtel_histograms.py +0 -414
  350. simtools/simtel/simtel_runner.py +0 -244
  351. simtools/simtel/simtel_runner_array.py +0 -293
  352. simtools/simtel/simtel_runner_ray_tracing.py +0 -277
  353. {gammasimtools-0.6.1.dist-info → gammasimtools-0.8.2.dist-info}/LICENSE +0 -0
  354. {gammasimtools-0.6.1.dist-info → gammasimtools-0.8.2.dist-info}/top_level.txt +0 -0
  355. /simtools/{corsika_simtel → db}/__init__.py +0 -0
@@ -1,74 +1,105 @@
1
1
  #!/usr/bin/python3
2
2
 
3
3
  """
4
- Summary
5
- -------
6
- This application plots the layout array and saves into disk.
4
+ Plot array elements (array layout).
7
5
 
8
- It accepts as input the telescope list file, the name of the layout, a sequence of arguments
9
- with the telescope files or a sequence of arguments with the layout names.
6
+ Plot an array layout and save it to file (e.g., pdf). Layouts are defined in the database,
7
+ or given as command line arguments (explicit listing or telescope list file). A list of input
8
+ files is also accepted.
9
+ Layouts can be plotted in ground or UTM coordinate systems.
10
10
 
11
- A rotation angle in degrees can be passed in case the array should be rotated before plotting.
12
- A sequence of arguments for the rotation angle is also permitted, in which case all of them
13
- are plotted and saved separately.
11
+ Listing of array elements follows this logic:
14
12
 
13
+ * explicit listing: e.g., ``-array_element_list MSTN-01, MSTN05``
14
+ * listing of types: e.g, ``-array_element_list MSTN`` plots all telescopes of type MSTN.
15
15
 
16
- Command line arguments
17
- ----------------------
18
- figure_name (str, optional)
19
- File name for the pdf output.
20
- telescope_list (str, optional)
21
- The telescopes file (.ecsv) with the array information.
22
- array_layout_name (str, optional)
23
- Name of the layout array (e.g., North-TestLayout, South-TestLayout, North-4LST, etc.).
24
- rotate_angle (float, optional)
25
- Angle to rotate the array before plotting (in degrees).
26
- show_tel_label (bool, optional)
27
- Shows the telescope labels in the plot.
28
- verbosity (str, optional)
29
- Log level to print.
16
+ A rotation angle in degrees allows to rotate the array before plotting.
17
+ The typical image formats (e.g., pdf, png, jpg) are allowed for the output figures.
18
+ If no ``figure_name`` is given as output, layouts are plotted in pdf and png format.
30
19
 
31
- Example
32
- -------
33
- .. code-block:: console
20
+ Example of a layout plot:
21
+
22
+ .. _plot_array_layout_plot:
23
+ .. image:: images/plot_array_layout_example.png
24
+ :width: 49 %
25
+
26
+ Command line arguments
27
+ ----------------------
28
+ figure_name : str
29
+ File name for the output figure.
30
+ array_layout_file : str
31
+ File (astropy table compatible) with a list of array elements.
32
+ array_layout_name : str
33
+ Name of the layout array (e.g., test_layout, alpha, 4mst, etc.).
34
+ array_element_list : list
35
+ List of array elements (e.g., telescopes) to plot (e.g., ``LSTN-01 LSTN-02 MSTN``).
36
+ coordinate_system : str, optional
37
+ Coordinate system for the array layout (ground or utm).
38
+ rotate_angle : float, optional
39
+ Angle to rotate the array before plotting (in degrees).
40
+ show_labels : bool, optional
41
+ Shows the telescope labels in the plot.
42
+ axes_range : float, optional
43
+ Range of the both axes in meters.
44
+ marker_scaling : float, optional.
45
+ Scaling factor for plotting of array elements, optional.
46
+
47
+ Examples
48
+ --------
49
+ Plot layout with the name "test_layout":
50
+
51
+ .. code-block:: console
52
+
53
+ simtools-plot-layout-array --figure_name northern_array_alpha
54
+ --array_layout_name test_layout
55
+
56
+
57
+ Plot layout with 2 LSTs and all northern MSTs in UTM coordinates:
58
+
59
+ .. code-block:: console
60
+
61
+ simtools-plot-layout-array --array_element_list LSTN-01 LSTN-02 MSTN
62
+ --coordinate_system utm
63
+
64
+ Plot layout from a file with the list of telescopes:
34
65
 
35
- simtools-plot-layout-array --figure_name northern_array_alpha \
36
- --array_layout_name North-TestLayout
66
+ .. code-block:: console
37
67
 
68
+ simtools-plot-layout-array --array_element_list telescope_positions-test_layout.ecsv
38
69
  """
39
70
 
40
71
  import logging
41
72
  from pathlib import Path
42
73
 
74
+ import matplotlib as mpl
43
75
  import matplotlib.pyplot as plt
44
76
  from astropy import units as u
45
77
 
46
78
  import simtools.utils.general as gen
47
79
  from simtools.configuration import configurator
48
- from simtools.data_model import data_reader
49
80
  from simtools.io_operations import io_handler
50
- from simtools.layout.array_layout import ArrayLayout
81
+ from simtools.model.array_model import ArrayModel
82
+ from simtools.utils import names
51
83
  from simtools.visualization.visualize import plot_array
52
84
 
53
85
 
54
86
  def _parse(label, description, usage):
55
87
  """
56
- Parse command line configuration
88
+ Parse command line configuration.
57
89
 
58
90
  Parameters
59
91
  ----------
60
- label: str
92
+ label : str
61
93
  Label describing the application.
62
- description: str
94
+ description : str
63
95
  Description of the application.
64
- usage: str
96
+ usage : str
65
97
  Example on how to use the application.
66
98
 
67
99
  Returns
68
100
  -------
69
101
  CommandLineParser
70
- Command line parser object
71
-
102
+ Command line parser object.
72
103
  """
73
104
  config = configurator.Configurator(label=label, description=description, usage=usage)
74
105
 
@@ -81,110 +112,309 @@ def _parse(label, description, usage):
81
112
  )
82
113
  config.parser.add_argument(
83
114
  "--rotate_angle",
84
- help="Angle to rotate the array before plotting (in degrees).",
115
+ help="Angle to rotate the array (in degrees).",
85
116
  type=str,
86
- nargs="+",
87
117
  required=False,
88
118
  default=None,
89
119
  )
90
120
  config.parser.add_argument(
91
- "--show_tel_label",
92
- help="Shows the telescope labels in the plot.",
121
+ "--show_labels",
122
+ help="Plot array element labels.",
93
123
  action="store_true",
94
124
  required=False,
95
125
  default=False,
96
126
  )
97
- input_group = config.parser.add_mutually_exclusive_group()
98
- input_group.add_argument(
99
- "--telescope_list",
100
- help="ECSV file with the list of telescopes",
101
- nargs="+",
102
- type=str,
127
+ config.parser.add_argument(
128
+ "--marker_scaling",
129
+ help="Scaling factor for the markers.",
130
+ type=float,
103
131
  required=False,
104
- default=None,
132
+ default=1.0,
105
133
  )
106
- input_group.add_argument(
107
- "--array_layout_name",
108
- help="Name of the array layout.",
109
- nargs="+",
134
+ config.parser.add_argument(
135
+ "--coordinate_system",
136
+ help="Coordinate system for the array layout.",
110
137
  type=str,
111
138
  required=False,
139
+ default="ground",
140
+ choices=["ground", "utm"],
141
+ )
142
+ config.parser.add_argument(
143
+ "--axes_range",
144
+ help="Range of the both axes in meters.",
145
+ type=float,
146
+ required=False,
112
147
  default=None,
113
148
  )
149
+ return config.initialize(db_config=True, simulation_model=["site", "layout", "layout_file"])
150
+
151
+
152
+ def _get_site_from_telescope_list_name(telescope_list_file):
153
+ """
154
+ Get the site name from the telescope list file name.
155
+
156
+ Parameters
157
+ ----------
158
+ telescope_list_file : str
159
+ Telescope list file name.
160
+
161
+ Returns
162
+ -------
163
+ str
164
+ Site name.
165
+ """
166
+ for _site in names.site_names():
167
+ if _site in str(telescope_list_file):
168
+ return _site
169
+ return None
114
170
 
115
- return config.initialize()
171
+
172
+ def _get_list_of_plot_files(plot_file_name, output_dir):
173
+ """
174
+ Get list of output file names for plotting.
175
+
176
+ Parameters
177
+ ----------
178
+ plot_file_name : str
179
+ Name of the plot file.
180
+ output_dir : str
181
+ Output directory.
182
+
183
+ Returns
184
+ -------
185
+ list
186
+ List of output file names.
187
+
188
+ Raises
189
+ ------
190
+ NameError
191
+ If the file extension is not valid.
192
+ """
193
+ plot_file = output_dir.joinpath(plot_file_name)
194
+
195
+ if len(plot_file.suffix) == 0:
196
+ return [plot_file.with_suffix(f".{ext}") for ext in ["pdf", "png"]]
197
+
198
+ allowed_extensions = [".jpeg", ".jpg", ".png", ".tiff", ".ps", ".pdf", ".bmp"]
199
+ if plot_file.suffix in allowed_extensions:
200
+ return [plot_file]
201
+ msg = f"Extension in {plot_file} is not valid. Valid extensions are: {allowed_extensions}."
202
+ raise NameError(msg)
203
+
204
+
205
+ def _get_plot_file_name(figure_name, layout_name, site, coordinate_system, rotate_angle):
206
+ """
207
+ Generate and return the file name for plots.
208
+
209
+ Parameters
210
+ ----------
211
+ figure_name : str
212
+ Figure name given through command line.
213
+ layout_name : str
214
+ Name of the layout.
215
+ site : str
216
+ Site name.
217
+ coordinate_system : str
218
+ Coordinate system for the array layout.
219
+ rotate_angle : float
220
+ Angle to rotate the array before plotting.
221
+
222
+ Returns
223
+ -------
224
+ str
225
+ Plot file name.
226
+ """
227
+ if figure_name is not None:
228
+ return figure_name
229
+
230
+ return (
231
+ f"array_layout_{layout_name}_{site}_{coordinate_system}_"
232
+ f"{round(rotate_angle.to(u.deg).value)!s}deg"
233
+ )
234
+
235
+
236
+ def _layouts_from_array_layout_file(args_dict, db_config, rotate_angle):
237
+ """
238
+ Read array layout positions from file(s) and return a list of layouts.
239
+
240
+ Parameters
241
+ ----------
242
+ args_dict : dict
243
+ Dictionary with the command line arguments.
244
+ db_config : dict
245
+ Database configuration.
246
+ rotate_angle : float
247
+ Angle to rotate the array before plotting (in degrees).
248
+
249
+ Returns
250
+ -------
251
+ list
252
+ List of array layouts.
253
+ """
254
+ layouts = []
255
+ telescope_files = args_dict["array_layout_file"]
256
+ for one_file in telescope_files:
257
+ site = (
258
+ _get_site_from_telescope_list_name(one_file)
259
+ if args_dict["site"] is None
260
+ else args_dict["site"]
261
+ )
262
+ array_model = ArrayModel(
263
+ mongo_db_config=db_config,
264
+ model_version=args_dict["model_version"],
265
+ site=site,
266
+ array_elements=one_file,
267
+ )
268
+ layouts.append(
269
+ {
270
+ "array_elements": array_model.export_array_elements_as_table(),
271
+ "plot_file_name": _get_plot_file_name(
272
+ args_dict["figure_name"],
273
+ (Path(one_file).name).split(".")[0],
274
+ site,
275
+ args_dict["coordinate_system"],
276
+ rotate_angle,
277
+ ),
278
+ }
279
+ )
280
+ return layouts
281
+
282
+
283
+ def _layouts_from_list(args_dict, db_config, rotate_angle):
284
+ """
285
+ Read positions for a list of array elements from the database and return a list of layouts.
286
+
287
+ Parameters
288
+ ----------
289
+ args_dict : dict
290
+ Dictionary with the command line arguments.
291
+ db_config : dict
292
+ Database configuration.
293
+ rotate_angle : float
294
+ Angle to rotate the array before plotting (in degrees).
295
+
296
+ Returns
297
+ -------
298
+ list
299
+ List of array layouts.
300
+ """
301
+ site = (
302
+ names.get_site_from_array_element_name(args_dict["array_element_list"][0])
303
+ if args_dict["site"] is None
304
+ else args_dict["site"]
305
+ )
306
+ array_model = ArrayModel(
307
+ mongo_db_config=db_config,
308
+ model_version=args_dict["model_version"],
309
+ site=site,
310
+ array_elements=args_dict["array_element_list"],
311
+ )
312
+ return [
313
+ {
314
+ "array_elements": array_model.export_array_elements_as_table(
315
+ coordinate_system=args_dict["coordinate_system"]
316
+ ),
317
+ "plot_file_name": _get_plot_file_name(
318
+ args_dict["figure_name"],
319
+ "list",
320
+ site,
321
+ args_dict["coordinate_system"],
322
+ rotate_angle,
323
+ ),
324
+ }
325
+ ]
326
+
327
+
328
+ def _layouts_from_db(args_dict, db_config, rotate_angle):
329
+ """
330
+ Read array elements and their positions from data base using the layout name.
331
+
332
+ Parameters
333
+ ----------
334
+ args_dict : dict
335
+ Dictionary with the command line arguments.
336
+ db_config : dict
337
+ Database configuration.
338
+ rotate_angle : float
339
+ Angle to rotate the array before plotting (in degrees).
340
+
341
+ Returns
342
+ -------
343
+ list
344
+ List of array layouts.
345
+ """
346
+ layouts = []
347
+ array_model = ArrayModel(
348
+ mongo_db_config=db_config,
349
+ model_version=args_dict["model_version"],
350
+ site=args_dict["site"],
351
+ layout_name=args_dict["array_layout_name"],
352
+ )
353
+ layouts.append(
354
+ {
355
+ "array_elements": array_model.export_array_elements_as_table(
356
+ coordinate_system=args_dict["coordinate_system"]
357
+ ),
358
+ "plot_file_name": _get_plot_file_name(
359
+ figure_name=args_dict["figure_name"],
360
+ layout_name=args_dict["array_layout_name"],
361
+ site=args_dict["site"],
362
+ coordinate_system=args_dict["coordinate_system"],
363
+ rotate_angle=rotate_angle,
364
+ ),
365
+ }
366
+ )
367
+ return layouts
116
368
 
117
369
 
118
370
  def main():
371
+ """Plot array layout application."""
119
372
  label = Path(__file__).stem
120
- description = "Plots layout array."
121
- usage = "python applications/plot_array_layout.py --array_layout_name test_layout"
122
- args_dict, _ = _parse(label, description, usage)
373
+ args_dict, db_config = _parse(
374
+ label,
375
+ "Plots array layout.",
376
+ "python applications/plot_array_layout.py --array_layout_name test_layout",
377
+ )
378
+ logger = logging.getLogger()
379
+ logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
123
380
  io_handler_instance = io_handler.IOHandler()
124
381
 
125
- if args_dict["rotate_angle"] is None:
126
- rotate_angles = [0 * u.deg]
127
- else:
128
- rotate_angles = []
129
- for one_angle in args_dict["rotate_angle"]:
130
- rotate_angles.append(float(one_angle) * u.deg)
382
+ rotate_angle = (
383
+ 0.0 * u.deg
384
+ if args_dict["rotate_angle"] is None
385
+ else float(args_dict["rotate_angle"]) * u.deg
386
+ )
387
+
388
+ layouts = []
389
+ if args_dict["array_layout_name"] is not None:
390
+ logger.info("Plotting array from layout array name.")
391
+ layouts = _layouts_from_db(args_dict, db_config, rotate_angle)
392
+ elif args_dict["array_layout_file"] is not None:
393
+ logger.info("Plotting array from telescope list file.")
394
+ layouts = _layouts_from_array_layout_file(args_dict, db_config, rotate_angle)
395
+ elif args_dict["array_element_list"] is not None:
396
+ logger.info("Plotting array from list of array elements.")
397
+ layouts = _layouts_from_list(args_dict, db_config, rotate_angle)
131
398
 
132
- logger = logging.getLogger()
133
- logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
399
+ mpl.use("Agg")
400
+ for layout in layouts:
401
+ fig_out = plot_array(
402
+ telescopes=layout["array_elements"],
403
+ rotate_angle=rotate_angle,
404
+ show_tel_label=args_dict["show_labels"],
405
+ axes_range=args_dict["axes_range"],
406
+ marker_scaling=args_dict["marker_scaling"],
407
+ )
408
+ _plot_files = _get_list_of_plot_files(
409
+ layout["plot_file_name"],
410
+ io_handler_instance.get_output_directory(label, sub_dir="application-plots"),
411
+ )
134
412
 
135
- if args_dict["telescope_list"] is not None:
136
- logger.info("Plotting array from telescope list file(s).")
137
- telescope_file = args_dict["telescope_list"]
138
-
139
- elif args_dict["array_layout_name"] is not None:
140
- logger.info("Plotting array from layout array name(s).")
141
- telescope_file = [
142
- io_handler_instance.get_input_data_file(
143
- "layout", f"telescope_positions-{one_array}.ecsv"
144
- )
145
- for one_array in args_dict["array_layout_name"]
146
- ]
147
-
148
- for one_file in telescope_file:
149
- logger.debug(f"Processing: {one_file}.")
150
- for one_angle in rotate_angles:
151
- logger.debug(f"Processing: {one_angle}.")
152
- if args_dict["figure_name"] is None:
153
- plot_file_name = (
154
- f"plot_array_layout_{(Path(one_file).name).split('.')[0]}_"
155
- f"{str((round((one_angle.to(u.deg).value))))}deg"
156
- )
157
- else:
158
- plot_file_name = args_dict["figure_name"]
159
-
160
- telescope_table = data_reader.read_table_from_file(one_file)
161
- telescopes_dict = ArrayLayout.include_radius_into_telescope_table(telescope_table)
162
- fig_out = plot_array(
163
- telescopes_dict, rotate_angle=one_angle, show_tel_label=args_dict["show_tel_label"]
164
- )
165
- output_dir = io_handler_instance.get_output_directory(
166
- label, sub_dir="application-plots"
167
- )
168
- plot_file = output_dir.joinpath(plot_file_name)
169
-
170
- allowed_extensions = ["jpeg", "jpg", "png", "tiff", "ps", "pdf", "bmp"]
171
-
172
- splitted_plot_file_name = plot_file_name.split(".")
173
- if len(splitted_plot_file_name) > 1:
174
- if splitted_plot_file_name[-1] in allowed_extensions:
175
- logger.info(f"Saving figure as {plot_file}.")
176
- plt.savefig(plot_file, bbox_inches="tight", dpi=400)
177
- else:
178
- msg = (
179
- f"Extension in {plot_file} is not valid. Valid extensions are:"
180
- f" {allowed_extensions}."
181
- )
182
- raise NameError(msg)
183
- else:
184
- for ext in ["pdf", "png"]:
185
- logger.info(f"Saving figure to {plot_file}.{ext}.")
186
- plt.savefig(f"{str(plot_file)}.{ext}", bbox_inches="tight", dpi=400)
187
- fig_out.clf()
413
+ for file in _plot_files:
414
+ logger.info(f"Saving figure as {file}")
415
+ plt.savefig(file, bbox_inches="tight", dpi=400)
416
+ fig_out.clf()
417
+ plt.close()
188
418
 
189
419
 
190
420
  if __name__ == "__main__":
@@ -0,0 +1,158 @@
1
+ #!/usr/bin/python3
2
+
3
+ r"""
4
+ Configure a simulation based on command-line arguments.
5
+
6
+ This application configures and
7
+ generates simulation parameters for a specific grid point in a statistical uncertainty
8
+ evaluation setup.
9
+
10
+ Command line arguments
11
+ ----------------------
12
+ azimuth (float, required)
13
+ Azimuth angle in degrees.
14
+ elevation (float, required)
15
+ Elevation angle in degrees.
16
+ nsb (float, required)
17
+ Night sky background value.
18
+ ctao_data_level (str, required)
19
+ The data level for the simulation (e.g., 'A', 'B', 'C').
20
+ science_case (str, required)
21
+ The science case for the simulation.
22
+ file_path (str, required)
23
+ Path to file with MC events at CTAO DL2 data level. Used for statistical uncertainty evaluation.
24
+ file_type (str, required)
25
+ Type of the DL2 MC event file ('point-like' or 'cone').
26
+ metrics (str, optional)
27
+ Path to a YAML file containing metrics for evaluation.
28
+ site (str, required)
29
+ The observatory site (North or South).
30
+
31
+ Example
32
+ -------
33
+ To run the simulation configuration, execute the script as follows:
34
+
35
+ .. code-block:: console
36
+
37
+ simtools-production-generate-simulation-config --azimuth 60.0 --elevation 45.0 \
38
+ --nsb 0.3 --ctao_data_level "A" --science_case "high_precision" \
39
+ --file_path tests/resources/production_dl2_fits/dl2_mc_events_file.fits \
40
+ --file_type "point-like" \
41
+ --metrics_file tests/resources/production_simulation_config_metrics.yaml --site North
42
+
43
+ The output will show the configured simulation parameters.
44
+ """
45
+
46
+ import json
47
+ import logging
48
+ from pathlib import Path
49
+
50
+ import astropy.units as u
51
+
52
+ import simtools.utils.general as gen
53
+ from simtools.configuration import configurator
54
+ from simtools.io_operations import io_handler
55
+ from simtools.production_configuration.generate_simulation_config import (
56
+ SimulationConfig,
57
+ )
58
+
59
+
60
+ def _parse(label):
61
+ """Parse command-line arguments."""
62
+ config = configurator.Configurator(
63
+ label=label, description="Configure and run a simulation based on input parameters."
64
+ )
65
+ config.parser.add_argument(
66
+ "--azimuth", type=float, required=True, help="Azimuth angle in degrees."
67
+ )
68
+ config.parser.add_argument(
69
+ "--elevation", type=float, required=True, help="Elevation angle in degrees."
70
+ )
71
+ config.parser.add_argument(
72
+ "--nsb", type=float, required=True, help="Night sky background in units of 1/(sr*ns*cm**2)."
73
+ )
74
+ config.parser.add_argument(
75
+ "--ctao_data_level", type=str, required=True, help="Data level (e.g., 'A', 'B', 'C')."
76
+ )
77
+ config.parser.add_argument(
78
+ "--science_case", type=str, required=True, help="Science case for the simulation."
79
+ )
80
+ config.parser.add_argument(
81
+ "--file_path", type=str, required=True, help="Path to MC event file in DL2 format."
82
+ )
83
+ config.parser.add_argument(
84
+ "--file_type",
85
+ type=str,
86
+ required=True,
87
+ help="Type of the DL2 MC event file ('point-like' or 'cone').",
88
+ )
89
+ config.parser.add_argument(
90
+ "--metrics_file",
91
+ required=True,
92
+ type=str,
93
+ help="Path to YAML file containing metrics and required precision as values.",
94
+ )
95
+ config.parser.add_argument(
96
+ "--site",
97
+ type=str,
98
+ required=True,
99
+ help="Site location for the simulation (e.g., 'North', 'South').",
100
+ )
101
+ config.parser.add_argument(
102
+ "--output_file",
103
+ help="Name of the file to save the configured simulation parameters.",
104
+ type=str,
105
+ required=False,
106
+ default="configured_simulation_params.json",
107
+ )
108
+
109
+ return config.initialize(db_config=False)
110
+
111
+
112
+ def main():
113
+ """Run the Simulation Config application."""
114
+ label = Path(__file__).stem
115
+ args_dict, _ = _parse(label)
116
+
117
+ logger = logging.getLogger()
118
+ logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
119
+ output_path = io_handler.IOHandler().get_output_directory(label)
120
+ output_filepath = Path(output_path).joinpath(f"{args_dict['output_file']}")
121
+
122
+ grid_point_config = {
123
+ "azimuth": args_dict["azimuth"],
124
+ "elevation": args_dict["elevation"],
125
+ "night_sky_background": args_dict["nsb"],
126
+ }
127
+
128
+ metrics = (
129
+ gen.collect_data_from_file(args_dict["metrics_file"]) if "metrics_file" in args_dict else {}
130
+ )
131
+
132
+ simulation_config = SimulationConfig(
133
+ grid_point=grid_point_config,
134
+ ctao_data_level=args_dict["ctao_data_level"],
135
+ science_case=args_dict["science_case"],
136
+ file_path=args_dict["file_path"],
137
+ file_type=args_dict["file_type"],
138
+ metrics=metrics,
139
+ )
140
+
141
+ simulation_params = simulation_config.configure_simulation()
142
+
143
+ serializable_config = {}
144
+
145
+ for key, value in simulation_params.items():
146
+ if isinstance(value, u.Quantity):
147
+ serializable_config[key] = f"{value.value} {value.unit}"
148
+ else:
149
+ serializable_config[key] = value
150
+
151
+ logger.info(f"Simulation configuration: {serializable_config}")
152
+ with open(output_filepath, "w", encoding="utf-8") as f:
153
+ json.dump(serializable_config, f, indent=4)
154
+ logger.info(f"Simulation configuration saved to: {output_filepath}")
155
+
156
+
157
+ if __name__ == "__main__":
158
+ main()