gammasimtools 0.6.0__py3-none-any.whl → 0.8.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (353) hide show
  1. gammasimtools-0.8.1.dist-info/METADATA +172 -0
  2. gammasimtools-0.8.1.dist-info/RECORD +346 -0
  3. {gammasimtools-0.6.0.dist-info → gammasimtools-0.8.1.dist-info}/WHEEL +1 -1
  4. gammasimtools-0.8.1.dist-info/entry_points.txt +31 -0
  5. simtools/_version.py +2 -2
  6. simtools/applications/calculate_trigger_rate.py +210 -0
  7. simtools/applications/convert_all_model_parameters_from_simtel.py +372 -0
  8. simtools/applications/{print_array_elements.py → convert_geo_coordinates_of_array_elements.py} +58 -63
  9. simtools/applications/convert_model_parameter_from_simtel.py +119 -0
  10. simtools/applications/{add_file_to_db.py → db_add_file_to_db.py} +70 -60
  11. simtools/applications/db_add_model_parameters_from_repository_to_db.py +184 -0
  12. simtools/applications/db_add_value_from_json_to_db.py +105 -0
  13. simtools/applications/db_development_tools/write_array_elements_positions_to_repository.py +180 -0
  14. simtools/applications/db_get_array_layouts_from_db.py +162 -0
  15. simtools/applications/{get_file_from_db.py → db_get_file_from_db.py} +30 -34
  16. simtools/applications/db_get_parameter_from_db.py +131 -0
  17. simtools/applications/db_inspect_databases.py +52 -0
  18. simtools/applications/derive_mirror_rnda.py +39 -255
  19. simtools/applications/derive_psf_parameters.py +441 -0
  20. simtools/applications/generate_array_config.py +82 -0
  21. simtools/applications/generate_corsika_histograms.py +52 -52
  22. simtools/applications/generate_default_metadata.py +5 -8
  23. simtools/applications/generate_regular_arrays.py +117 -0
  24. simtools/applications/generate_simtel_array_histograms.py +97 -56
  25. simtools/applications/plot_array_layout.py +345 -115
  26. simtools/applications/production_generate_simulation_config.py +158 -0
  27. simtools/applications/production_scale_events.py +168 -0
  28. simtools/applications/simulate_light_emission.py +478 -0
  29. simtools/applications/simulate_prod.py +97 -175
  30. simtools/applications/submit_data_from_external.py +9 -12
  31. simtools/applications/submit_model_parameter_from_external.py +122 -0
  32. simtools/applications/validate_camera_efficiency.py +35 -102
  33. simtools/applications/validate_camera_fov.py +20 -19
  34. simtools/applications/{compare_cumulative_psf.py → validate_cumulative_psf.py} +45 -44
  35. simtools/applications/validate_file_using_schema.py +113 -47
  36. simtools/applications/validate_optics.py +17 -22
  37. simtools/camera_efficiency.py +193 -202
  38. simtools/configuration/commandline_parser.py +384 -96
  39. simtools/configuration/configurator.py +55 -71
  40. simtools/constants.py +5 -5
  41. simtools/corsika/corsika_config.py +482 -342
  42. simtools/corsika/corsika_histograms.py +226 -204
  43. simtools/corsika/corsika_histograms_visualize.py +23 -24
  44. simtools/corsika/primary_particle.py +159 -0
  45. simtools/data_model/data_reader.py +25 -20
  46. simtools/data_model/format_checkers.py +52 -0
  47. simtools/data_model/metadata_collector.py +210 -184
  48. simtools/data_model/metadata_model.py +115 -37
  49. simtools/data_model/model_data_writer.py +335 -26
  50. simtools/data_model/validate_data.py +366 -154
  51. simtools/db/db_array_elements.py +130 -0
  52. simtools/db/db_from_repo_handler.py +106 -0
  53. simtools/db/db_handler.py +1246 -0
  54. simtools/io_operations/hdf5_handler.py +3 -1
  55. simtools/io_operations/io_handler.py +32 -57
  56. simtools/job_execution/job_manager.py +82 -69
  57. simtools/layout/array_layout.py +329 -533
  58. simtools/layout/geo_coordinates.py +8 -11
  59. simtools/layout/telescope_position.py +163 -86
  60. simtools/model/array_model.py +305 -256
  61. simtools/model/calibration_model.py +50 -0
  62. simtools/model/camera.py +233 -496
  63. simtools/model/mirrors.py +61 -44
  64. simtools/model/model_parameter.py +602 -0
  65. simtools/model/model_utils.py +7 -103
  66. simtools/model/site_model.py +161 -0
  67. simtools/model/telescope_model.py +127 -621
  68. simtools/production_configuration/calculate_statistical_errors_grid_point.py +454 -0
  69. simtools/production_configuration/event_scaler.py +146 -0
  70. simtools/production_configuration/generate_simulation_config.py +193 -0
  71. simtools/production_configuration/interpolation_handler.py +197 -0
  72. simtools/ray_tracing/__init__.py +0 -0
  73. simtools/ray_tracing/mirror_panel_psf.py +280 -0
  74. simtools/{psf_analysis.py → ray_tracing/psf_analysis.py} +133 -47
  75. simtools/ray_tracing/ray_tracing.py +646 -0
  76. simtools/runners/__init__.py +0 -0
  77. simtools/runners/corsika_runner.py +240 -0
  78. simtools/runners/corsika_simtel_runner.py +225 -0
  79. simtools/runners/runner_services.py +307 -0
  80. simtools/runners/simtel_runner.py +224 -0
  81. simtools/schemas/array_elements.yml +137 -0
  82. simtools/schemas/integration_tests_config.metaschema.yml +93 -0
  83. simtools/schemas/metadata.metaschema.yml +6 -0
  84. simtools/schemas/model_parameter.metaschema.yml +78 -0
  85. simtools/schemas/{data.metaschema.yml → model_parameter_and_data_schema.metaschema.yml} +27 -44
  86. simtools/schemas/model_parameters/adjust_gain.schema.yml +37 -0
  87. simtools/schemas/model_parameters/altitude.schema.yml +37 -0
  88. simtools/schemas/model_parameters/array_coordinates.schema.yml +33 -0
  89. simtools/schemas/model_parameters/array_coordinates_UTM.schema.yml +77 -0
  90. simtools/schemas/model_parameters/array_element_position_ground.schema.yml +39 -0
  91. simtools/schemas/model_parameters/array_element_position_utm.schema.yml +39 -0
  92. simtools/schemas/model_parameters/array_layouts.schema.yml +48 -0
  93. simtools/schemas/model_parameters/array_triggers.schema.yml +93 -0
  94. simtools/schemas/model_parameters/asum_clipping.schema.yml +38 -0
  95. simtools/schemas/model_parameters/asum_offset.schema.yml +35 -0
  96. simtools/schemas/model_parameters/asum_shaping.schema.yml +35 -0
  97. simtools/schemas/model_parameters/asum_threshold.schema.yml +38 -0
  98. simtools/schemas/model_parameters/atmospheric_profile.schema.yml +32 -0
  99. simtools/schemas/model_parameters/atmospheric_transmission.schema.yml +35 -0
  100. simtools/schemas/model_parameters/axes_offsets.schema.yml +53 -0
  101. simtools/schemas/model_parameters/camera_body_diameter.schema.yml +40 -0
  102. simtools/schemas/model_parameters/camera_body_shape.schema.yml +45 -0
  103. simtools/schemas/model_parameters/camera_config_file.schema.yml +40 -0
  104. simtools/schemas/model_parameters/camera_config_rotate.schema.yml +36 -0
  105. simtools/schemas/model_parameters/camera_degraded_efficiency.schema.yml +43 -0
  106. simtools/schemas/model_parameters/camera_degraded_map.schema.yml +42 -0
  107. simtools/schemas/model_parameters/camera_depth.schema.yml +42 -0
  108. simtools/schemas/model_parameters/camera_filter.schema.yml +45 -0
  109. simtools/schemas/model_parameters/camera_filter_incidence_angle.schema.yml +29 -0
  110. simtools/schemas/model_parameters/camera_pixels.schema.yml +36 -0
  111. simtools/schemas/model_parameters/camera_transmission.schema.yml +41 -0
  112. simtools/schemas/model_parameters/channels_per_chip.schema.yml +36 -0
  113. simtools/schemas/model_parameters/correct_nsb_spectrum_to_telescope_altitude.schema.yml +35 -0
  114. simtools/schemas/model_parameters/corsika_cherenkov_photon_bunch_size.schema.yml +27 -0
  115. simtools/schemas/model_parameters/corsika_cherenkov_photon_wavelength_range.schema.yml +38 -0
  116. simtools/schemas/model_parameters/corsika_first_interaction_height.schema.yml +28 -0
  117. simtools/schemas/model_parameters/corsika_iact_io_buffer.schema.yml +23 -0
  118. simtools/schemas/model_parameters/corsika_iact_max_bunches.schema.yml +27 -0
  119. simtools/schemas/model_parameters/corsika_iact_split_auto.schema.yml +28 -0
  120. simtools/schemas/model_parameters/corsika_longitudinal_shower_development.schema.yml +27 -0
  121. simtools/schemas/model_parameters/corsika_observation_level.schema.yml +38 -0
  122. simtools/schemas/model_parameters/corsika_particle_kinetic_energy_cutoff.schema.yml +52 -0
  123. simtools/schemas/model_parameters/corsika_starting_grammage.schema.yml +27 -0
  124. simtools/schemas/model_parameters/dark_events.schema.yml +32 -0
  125. simtools/schemas/model_parameters/default_trigger.schema.yml +35 -0
  126. simtools/schemas/model_parameters/design_model.schema.yml +31 -0
  127. simtools/schemas/model_parameters/disc_ac_coupled.schema.yml +32 -0
  128. simtools/schemas/model_parameters/disc_bins.schema.yml +39 -0
  129. simtools/schemas/model_parameters/disc_start.schema.yml +41 -0
  130. simtools/schemas/model_parameters/discriminator_amplitude.schema.yml +42 -0
  131. simtools/schemas/model_parameters/discriminator_fall_time.schema.yml +41 -0
  132. simtools/schemas/model_parameters/discriminator_gate_length.schema.yml +41 -0
  133. simtools/schemas/model_parameters/discriminator_hysteresis.schema.yml +39 -0
  134. simtools/schemas/model_parameters/discriminator_output_amplitude.schema.yml +40 -0
  135. simtools/schemas/model_parameters/discriminator_output_var_percent.schema.yml +41 -0
  136. simtools/schemas/model_parameters/discriminator_pulse_shape.schema.yml +33 -0
  137. simtools/schemas/model_parameters/discriminator_rise_time.schema.yml +42 -0
  138. simtools/schemas/model_parameters/discriminator_scale_threshold.schema.yml +37 -0
  139. simtools/schemas/model_parameters/discriminator_sigsum_over_threshold.schema.yml +44 -0
  140. simtools/schemas/model_parameters/discriminator_threshold.schema.yml +36 -0
  141. simtools/schemas/model_parameters/discriminator_time_over_threshold.schema.yml +45 -0
  142. simtools/schemas/model_parameters/discriminator_var_gate_length.schema.yml +40 -0
  143. simtools/schemas/model_parameters/discriminator_var_sigsum_over_threshold.schema.yml +41 -0
  144. simtools/schemas/model_parameters/discriminator_var_threshold.schema.yml +38 -0
  145. simtools/schemas/model_parameters/discriminator_var_time_over_threshold.schema.yml +38 -0
  146. simtools/schemas/model_parameters/dish_shape_length.schema.yml +41 -0
  147. simtools/schemas/model_parameters/dsum_clipping.schema.yml +38 -0
  148. simtools/schemas/model_parameters/dsum_ignore_below.schema.yml +38 -0
  149. simtools/schemas/model_parameters/dsum_offset.schema.yml +37 -0
  150. simtools/schemas/model_parameters/dsum_pedsub.schema.yml +33 -0
  151. simtools/schemas/model_parameters/dsum_pre_clipping.schema.yml +39 -0
  152. simtools/schemas/model_parameters/dsum_prescale.schema.yml +44 -0
  153. simtools/schemas/model_parameters/dsum_presum_max.schema.yml +38 -0
  154. simtools/schemas/model_parameters/dsum_presum_shift.schema.yml +45 -0
  155. simtools/schemas/model_parameters/dsum_shaping.schema.yml +44 -0
  156. simtools/schemas/model_parameters/dsum_shaping_renormalize.schema.yml +32 -0
  157. simtools/schemas/model_parameters/dsum_threshold.schema.yml +43 -0
  158. simtools/schemas/model_parameters/dsum_zero_clip.schema.yml +42 -0
  159. simtools/schemas/model_parameters/effective_focal_length.schema.yml +61 -0
  160. simtools/schemas/model_parameters/epsg_code.schema.yml +37 -0
  161. simtools/schemas/model_parameters/fadc_ac_coupled.schema.yml +35 -0
  162. simtools/schemas/model_parameters/fadc_amplitude.schema.yml +46 -0
  163. simtools/schemas/model_parameters/fadc_bins.schema.yml +40 -0
  164. simtools/schemas/model_parameters/fadc_compensate_pedestal.schema.yml +50 -0
  165. simtools/schemas/model_parameters/fadc_dev_pedestal.schema.yml +38 -0
  166. simtools/schemas/model_parameters/fadc_err_compensate_pedestal.schema.yml +42 -0
  167. simtools/schemas/model_parameters/fadc_err_pedestal.schema.yml +49 -0
  168. simtools/schemas/model_parameters/fadc_lg_amplitude.schema.yml +47 -0
  169. simtools/schemas/model_parameters/fadc_lg_compensate_pedestal.schema.yml +51 -0
  170. simtools/schemas/model_parameters/fadc_lg_dev_pedestal.schema.yml +37 -0
  171. simtools/schemas/model_parameters/fadc_lg_err_compensate_pedestal.schema.yml +43 -0
  172. simtools/schemas/model_parameters/fadc_lg_err_pedestal.schema.yml +49 -0
  173. simtools/schemas/model_parameters/fadc_lg_max_signal.schema.yml +43 -0
  174. simtools/schemas/model_parameters/fadc_lg_max_sum.schema.yml +39 -0
  175. simtools/schemas/model_parameters/fadc_lg_noise.schema.yml +42 -0
  176. simtools/schemas/model_parameters/fadc_lg_pedestal.schema.yml +40 -0
  177. simtools/schemas/model_parameters/fadc_lg_sensitivity.schema.yml +50 -0
  178. simtools/schemas/model_parameters/fadc_lg_sysvar_pedestal.schema.yml +42 -0
  179. simtools/schemas/model_parameters/fadc_lg_var_pedestal.schema.yml +41 -0
  180. simtools/schemas/model_parameters/fadc_lg_var_sensitivity.schema.yml +42 -0
  181. simtools/schemas/model_parameters/fadc_max_signal.schema.yml +43 -0
  182. simtools/schemas/model_parameters/fadc_max_sum.schema.yml +39 -0
  183. simtools/schemas/model_parameters/fadc_mhz.schema.yml +31 -0
  184. simtools/schemas/model_parameters/fadc_noise.schema.yml +41 -0
  185. simtools/schemas/model_parameters/fadc_pedestal.schema.yml +40 -0
  186. simtools/schemas/model_parameters/fadc_pulse_shape.schema.yml +39 -0
  187. simtools/schemas/model_parameters/fadc_sensitivity.schema.yml +50 -0
  188. simtools/schemas/model_parameters/fadc_sum_bins.schema.yml +43 -0
  189. simtools/schemas/model_parameters/fadc_sum_offset.schema.yml +43 -0
  190. simtools/schemas/model_parameters/fadc_sysvar_pedestal.schema.yml +42 -0
  191. simtools/schemas/model_parameters/fadc_var_pedestal.schema.yml +41 -0
  192. simtools/schemas/model_parameters/fadc_var_sensitivity.schema.yml +42 -0
  193. simtools/schemas/model_parameters/flatfielding.schema.yml +37 -0
  194. simtools/schemas/model_parameters/focal_length.schema.yml +45 -0
  195. simtools/schemas/model_parameters/focal_surface_parameters.schema.yml +158 -0
  196. simtools/schemas/model_parameters/focal_surface_ref_radius.schema.yml +29 -0
  197. simtools/schemas/model_parameters/focus_offset.schema.yml +66 -0
  198. simtools/schemas/model_parameters/gain_variation.schema.yml +43 -0
  199. simtools/schemas/model_parameters/geomag_horizontal.schema.yml +34 -0
  200. simtools/schemas/model_parameters/geomag_rotation.schema.yml +37 -0
  201. simtools/schemas/model_parameters/geomag_vertical.schema.yml +34 -0
  202. simtools/schemas/model_parameters/hg_lg_variation.schema.yml +36 -0
  203. simtools/schemas/model_parameters/iobuf_maximum.schema.yml +34 -0
  204. simtools/schemas/model_parameters/iobuf_output_maximum.schema.yml +34 -0
  205. simtools/schemas/model_parameters/laser_events.schema.yml +36 -0
  206. simtools/schemas/model_parameters/laser_external_trigger.schema.yml +35 -0
  207. simtools/schemas/model_parameters/laser_photons.schema.yml +32 -0
  208. simtools/schemas/model_parameters/laser_pulse_exptime.schema.yml +34 -0
  209. simtools/schemas/model_parameters/laser_pulse_offset.schema.yml +34 -0
  210. simtools/schemas/model_parameters/laser_pulse_sigtime.schema.yml +33 -0
  211. simtools/schemas/model_parameters/laser_pulse_twidth.schema.yml +33 -0
  212. simtools/schemas/model_parameters/laser_var_photons.schema.yml +33 -0
  213. simtools/schemas/model_parameters/laser_wavelength.schema.yml +33 -0
  214. simtools/schemas/model_parameters/led_events.schema.yml +34 -0
  215. simtools/schemas/model_parameters/led_photons.schema.yml +34 -0
  216. simtools/schemas/model_parameters/led_pulse_offset.schema.yml +32 -0
  217. simtools/schemas/model_parameters/led_pulse_sigtime.schema.yml +33 -0
  218. simtools/schemas/model_parameters/led_var_photons.schema.yml +34 -0
  219. simtools/schemas/model_parameters/lightguide_efficiency_vs_incidence_angle.schema.yml +41 -0
  220. simtools/schemas/model_parameters/lightguide_efficiency_vs_wavelength.schema.yml +43 -0
  221. simtools/schemas/model_parameters/min_photoelectrons.schema.yml +35 -0
  222. simtools/schemas/model_parameters/min_photons.schema.yml +32 -0
  223. simtools/schemas/model_parameters/mirror_align_random_distance.schema.yml +36 -0
  224. simtools/schemas/model_parameters/mirror_align_random_horizontal.schema.yml +64 -0
  225. simtools/schemas/model_parameters/mirror_align_random_vertical.schema.yml +64 -0
  226. simtools/schemas/model_parameters/mirror_class.schema.yml +41 -0
  227. simtools/schemas/model_parameters/mirror_degraded_reflection.schema.yml +51 -0
  228. simtools/schemas/model_parameters/mirror_focal_length.schema.yml +42 -0
  229. simtools/schemas/model_parameters/mirror_list.schema.yml +38 -0
  230. simtools/schemas/model_parameters/mirror_offset.schema.yml +41 -0
  231. simtools/schemas/model_parameters/mirror_panel_2f_measurements.schema.yml +39 -0
  232. simtools/schemas/model_parameters/mirror_reflection_random_angle.schema.yml +61 -0
  233. simtools/schemas/model_parameters/mirror_reflectivity.schema.yml +40 -0
  234. simtools/schemas/model_parameters/multiplicity_offset.schema.yml +46 -0
  235. simtools/schemas/model_parameters/nsb_autoscale_airmass.schema.yml +51 -0
  236. simtools/schemas/model_parameters/nsb_gain_drop_scale.schema.yml +37 -0
  237. simtools/schemas/model_parameters/nsb_offaxis.schema.yml +79 -0
  238. simtools/schemas/model_parameters/nsb_pixel_rate.schema.yml +47 -0
  239. simtools/schemas/model_parameters/nsb_reference_spectrum.schema.yml +34 -0
  240. simtools/schemas/model_parameters/nsb_reference_value.schema.yml +33 -0
  241. simtools/schemas/model_parameters/nsb_scaling_factor.schema.yml +35 -0
  242. simtools/schemas/model_parameters/nsb_skymap.schema.yml +39 -0
  243. simtools/schemas/model_parameters/nsb_spectrum.schema.yml +50 -0
  244. simtools/schemas/model_parameters/num_gains.schema.yml +34 -0
  245. simtools/schemas/model_parameters/only_triggered_telescopes.schema.yml +33 -0
  246. simtools/schemas/model_parameters/optics_properties.schema.yml +31 -0
  247. simtools/schemas/model_parameters/parabolic_dish.schema.yml +32 -0
  248. simtools/schemas/model_parameters/pedestal_events.schema.yml +32 -0
  249. simtools/schemas/model_parameters/photon_delay.schema.yml +38 -0
  250. simtools/schemas/model_parameters/photons_per_run.schema.yml +33 -0
  251. simtools/schemas/model_parameters/pixel_cells.schema.yml +35 -0
  252. simtools/schemas/model_parameters/pixels_parallel.schema.yml +54 -0
  253. simtools/schemas/model_parameters/pixeltrg_time_step.schema.yml +40 -0
  254. simtools/schemas/model_parameters/pm_average_gain.schema.yml +34 -0
  255. simtools/schemas/model_parameters/pm_collection_efficiency.schema.yml +40 -0
  256. simtools/schemas/model_parameters/pm_gain_index.schema.yml +36 -0
  257. simtools/schemas/model_parameters/pm_photoelectron_spectrum.schema.yml +41 -0
  258. simtools/schemas/model_parameters/pm_transit_time.schema.yml +63 -0
  259. simtools/schemas/model_parameters/pm_voltage_variation.schema.yml +39 -0
  260. simtools/schemas/model_parameters/primary_mirror_degraded_map.schema.yml +42 -0
  261. simtools/schemas/model_parameters/primary_mirror_diameter.schema.yml +33 -0
  262. simtools/schemas/model_parameters/primary_mirror_hole_diameter.schema.yml +33 -0
  263. simtools/schemas/model_parameters/primary_mirror_incidence_angle.schema.yml +29 -0
  264. simtools/schemas/model_parameters/primary_mirror_parameters.schema.yml +168 -0
  265. simtools/schemas/model_parameters/primary_mirror_ref_radius.schema.yml +36 -0
  266. simtools/schemas/model_parameters/primary_mirror_segmentation.schema.yml +34 -0
  267. simtools/schemas/model_parameters/qe_variation.schema.yml +43 -0
  268. simtools/schemas/model_parameters/quantum_efficiency.schema.yml +42 -0
  269. simtools/schemas/model_parameters/random_focal_length.schema.yml +45 -0
  270. simtools/schemas/model_parameters/random_generator.schema.yml +36 -0
  271. simtools/schemas/model_parameters/reference_point_altitude.schema.yml +35 -0
  272. simtools/schemas/model_parameters/reference_point_latitude.schema.yml +36 -0
  273. simtools/schemas/model_parameters/reference_point_longitude.schema.yml +36 -0
  274. simtools/schemas/model_parameters/reference_point_utm_east.schema.yml +34 -0
  275. simtools/schemas/model_parameters/reference_point_utm_north.schema.yml +34 -0
  276. simtools/schemas/model_parameters/sampled_output.schema.yml +31 -0
  277. simtools/schemas/model_parameters/save_pe_with_amplitude.schema.yml +34 -0
  278. simtools/schemas/model_parameters/secondary_mirror_baffle.schema.yml +79 -0
  279. simtools/schemas/model_parameters/secondary_mirror_degraded_map.schema.yml +42 -0
  280. simtools/schemas/model_parameters/secondary_mirror_degraded_reflection.schema.yml +41 -0
  281. simtools/schemas/model_parameters/secondary_mirror_diameter.schema.yml +33 -0
  282. simtools/schemas/model_parameters/secondary_mirror_hole_diameter.schema.yml +36 -0
  283. simtools/schemas/model_parameters/secondary_mirror_incidence_angle.schema.yml +29 -0
  284. simtools/schemas/model_parameters/secondary_mirror_parameters.schema.yml +168 -0
  285. simtools/schemas/model_parameters/secondary_mirror_ref_radius.schema.yml +36 -0
  286. simtools/schemas/model_parameters/secondary_mirror_reflectivity.schema.yml +35 -0
  287. simtools/schemas/model_parameters/secondary_mirror_segmentation.schema.yml +37 -0
  288. simtools/schemas/model_parameters/secondary_mirror_shadow_diameter.schema.yml +40 -0
  289. simtools/schemas/model_parameters/secondary_mirror_shadow_offset.schema.yml +40 -0
  290. simtools/schemas/model_parameters/store_photoelectrons.schema.yml +41 -0
  291. simtools/schemas/model_parameters/tailcut_scale.schema.yml +40 -0
  292. simtools/schemas/model_parameters/telescope_axis_height.schema.yml +31 -0
  293. simtools/schemas/model_parameters/telescope_random_angle.schema.yml +35 -0
  294. simtools/schemas/model_parameters/telescope_random_error.schema.yml +34 -0
  295. simtools/schemas/model_parameters/telescope_sphere_radius.schema.yml +37 -0
  296. simtools/schemas/model_parameters/telescope_transmission.schema.yml +113 -0
  297. simtools/schemas/model_parameters/teltrig_min_sigsum.schema.yml +41 -0
  298. simtools/schemas/model_parameters/teltrig_min_time.schema.yml +36 -0
  299. simtools/schemas/model_parameters/transit_time_calib_error.schema.yml +36 -0
  300. simtools/schemas/model_parameters/transit_time_compensate_error.schema.yml +37 -0
  301. simtools/schemas/model_parameters/transit_time_compensate_step.schema.yml +38 -0
  302. simtools/schemas/model_parameters/transit_time_error.schema.yml +45 -0
  303. simtools/schemas/model_parameters/transit_time_jitter.schema.yml +36 -0
  304. simtools/schemas/model_parameters/trigger_current_limit.schema.yml +32 -0
  305. simtools/schemas/model_parameters/trigger_delay_compensation.schema.yml +53 -0
  306. simtools/schemas/model_parameters/trigger_pixels.schema.yml +40 -0
  307. simtools/simtel/simtel_config_reader.py +353 -0
  308. simtools/simtel/simtel_config_writer.py +244 -63
  309. simtools/simtel/{simtel_events.py → simtel_io_events.py} +26 -25
  310. simtools/simtel/simtel_io_histogram.py +661 -0
  311. simtools/simtel/simtel_io_histograms.py +569 -0
  312. simtools/simtel/simulator_array.py +145 -0
  313. simtools/simtel/{simtel_runner_camera_efficiency.py → simulator_camera_efficiency.py} +76 -52
  314. simtools/simtel/simulator_light_emission.py +473 -0
  315. simtools/simtel/simulator_ray_tracing.py +262 -0
  316. simtools/simulator.py +220 -446
  317. simtools/testing/__init__.py +0 -0
  318. simtools/testing/assertions.py +151 -0
  319. simtools/testing/configuration.py +226 -0
  320. simtools/testing/helpers.py +42 -0
  321. simtools/testing/validate_output.py +240 -0
  322. simtools/utils/general.py +340 -437
  323. simtools/utils/geometry.py +12 -12
  324. simtools/utils/names.py +266 -568
  325. simtools/utils/value_conversion.py +176 -0
  326. simtools/version.py +2 -0
  327. simtools/visualization/legend_handlers.py +135 -152
  328. simtools/visualization/plot_camera.py +379 -0
  329. simtools/visualization/visualize.py +346 -167
  330. gammasimtools-0.6.0.dist-info/METADATA +0 -180
  331. gammasimtools-0.6.0.dist-info/RECORD +0 -91
  332. gammasimtools-0.6.0.dist-info/entry_points.txt +0 -23
  333. simtools/applications/db_development_tools/add_new_parameter_to_db.py +0 -81
  334. simtools/applications/db_development_tools/add_unit_to_parameter_in_db.py +0 -59
  335. simtools/applications/db_development_tools/mark_non_optics_parameters_non_applicable.py +0 -102
  336. simtools/applications/get_parameter.py +0 -92
  337. simtools/applications/make_regular_arrays.py +0 -160
  338. simtools/applications/produce_array_config.py +0 -136
  339. simtools/applications/production.py +0 -313
  340. simtools/applications/sim_showers_for_trigger_rates.py +0 -187
  341. simtools/applications/tune_psf.py +0 -334
  342. simtools/corsika/corsika_default_config.py +0 -282
  343. simtools/corsika/corsika_runner.py +0 -450
  344. simtools/corsika_simtel/corsika_simtel_runner.py +0 -197
  345. simtools/db_handler.py +0 -1481
  346. simtools/ray_tracing.py +0 -525
  347. simtools/simtel/simtel_histograms.py +0 -414
  348. simtools/simtel/simtel_runner.py +0 -244
  349. simtools/simtel/simtel_runner_array.py +0 -293
  350. simtools/simtel/simtel_runner_ray_tracing.py +0 -277
  351. {gammasimtools-0.6.0.dist-info → gammasimtools-0.8.1.dist-info}/LICENSE +0 -0
  352. {gammasimtools-0.6.0.dist-info → gammasimtools-0.8.1.dist-info}/top_level.txt +0 -0
  353. /simtools/{corsika_simtel → db}/__init__.py +0 -0
simtools/utils/names.py CHANGED
@@ -1,473 +1,411 @@
1
+ """Validation of names."""
2
+
3
+ import glob
1
4
  import logging
2
5
  import re
6
+ from functools import cache
7
+ from pathlib import Path
8
+
9
+ import yaml
3
10
 
4
11
  _logger = logging.getLogger(__name__)
5
12
 
6
13
  __all__ = [
7
- "camera_efficiency_log_file_name",
8
- "camera_efficiency_results_file_name",
9
- "camera_efficiency_simtel_file_name",
10
- "convert_telescope_model_name_to_yaml",
11
- "get_site_from_telescope_name",
12
- "get_telescope_type",
13
- "is_valid_name",
14
+ "generate_file_name",
15
+ "get_array_element_type_from_name",
16
+ "get_site_from_array_element_name",
14
17
  "layout_telescope_list_file_name",
15
- "ray_tracing_file_name",
16
- "ray_tracing_plot_file_name",
17
- "ray_tracing_results_file_name",
18
- "simtel_array_config_file_name",
19
- "simtel_telescope_config_file_name",
20
- "simtools_instrument_name",
21
- "split_telescope_model_name",
22
- "validate_camera_name",
23
- "validate_array_layout_name",
24
- "validate_model_version_name",
25
- "validate_name",
26
- "validate_simtel_mode_name",
18
+ "sanitize_name",
19
+ "simtel_config_file_name",
20
+ "simtel_single_mirror_list_file_name",
21
+ "validate_array_element_id_name",
22
+ "validate_array_element_name",
27
23
  "validate_site_name",
28
- "validate_sub_system_name",
29
- "validate_telescope_id_name",
30
- "validate_telescope_model_name",
31
- "validate_telescope_name_db",
32
24
  ]
33
25
 
34
- lst = "LST"
35
- mst = "MST"
36
- sct = "SCT"
37
- sst = "SST"
38
- hess = "HESS"
39
- magic = "MAGIC"
40
- veritas = "VERITAS"
41
-
42
- all_telescope_class_names = {
43
- lst: ["lst"],
44
- mst: ["mst"],
45
- sct: ["sct"],
46
- sst: ["sst"],
47
- hess: ["hess"],
48
- magic: ["magic"],
49
- veritas: ["veritas"],
50
- }
51
-
52
- all_camera_names = {
53
- "SST": ["sst"],
54
- "ASTRI": ["astri"],
55
- "GCT": ["gct", "gct-s"],
56
- "1M": ["1m"],
57
- "FlashCam": ["flashcam", "flash-cam"],
58
- "NectarCam": ["nectarcam", "nectar-cam"],
59
- "SCT": ["sct"],
60
- "LST": ["lst"],
61
- }
62
-
63
- all_structure_names = {"Structure": ["Structure", "structure"]}
64
-
65
- all_site_names = {"South": ["paranal", "south"], "North": ["lapalma", "north"]}
66
-
67
- all_model_version_names = {
68
- "2015-07-21": [""],
69
- "2015-10-20-p1": [""],
70
- "prod4-v0.0": [""],
71
- "prod4-v0.1": [""],
72
- "2018-02-16": [""],
73
- "prod3_compatible": ["p3", "prod3", "prod3b"],
74
- "prod4": ["p4"],
75
- "post_prod3_updates": [""],
76
- "2016-12-20": [""],
77
- "2018-11-07": [""],
78
- "2019-02-22": [""],
79
- "2019-05-13": [""],
80
- "2019-11-20": [""],
81
- "2019-12-30": [""],
82
- "2020-02-26": [""],
83
- "2020-06-28": ["prod5"],
84
- "prod4-prototype": [""],
85
- "default": [],
86
- "Released": [],
87
- "Latest": [],
88
- }
89
-
90
- all_simtel_mode_names = {
91
- "RayTracing": ["raytracing", "ray-tracing"],
92
- "RayTracingSingleMirror": [
93
- "raytracing-singlemirror",
94
- "ray-tracing-singlemirror",
95
- "ray-tracing-single-mirror",
96
- ],
97
- "Trigger": ["trigger"],
98
- }
99
-
100
- all_array_layout_names = {
101
- "4LST": ["4-lst", "4lst"],
102
- "1LST": ["1-lst", "1lst"],
103
- "4MST": ["4-mst", "4mst"],
104
- "1MST": ["1-mst", "mst"],
105
- "4SST": ["4-sst", "4sst"],
106
- "1SST": ["1-sst", "sst"],
107
- "Prod5": ["prod5", "p5"],
108
- "TestLayout": ["test-layout"],
109
- }
110
-
111
- corsika_to_simtools_names = {
112
- "OBSLEV": "corsika_obs_level",
113
- }
114
-
115
-
116
- def validate_sub_system_name(name):
117
- """
118
- Validate a sub system name (optics structure or camera).
119
26
 
120
- Parameters
121
- ----------
122
- name: str
123
- Name of the subsystem.
27
+ @cache
28
+ def array_elements():
29
+ """
30
+ Load array elements from reference files and keep in cache.
124
31
 
125
32
  Returns
126
33
  -------
127
- str
128
- Validated name.
34
+ dict
35
+ Array elements.
129
36
  """
130
- return validate_name(name, {**all_camera_names, **all_structure_names})
37
+ base_path = Path(__file__).parent
38
+ with open(base_path / "../schemas/array_elements.yml", encoding="utf-8") as file:
39
+ return yaml.safe_load(file)["data"]
131
40
 
132
41
 
133
- def validate_camera_name(name):
42
+ @cache
43
+ def site_names():
134
44
  """
135
- Validate a camera name.
45
+ Site names from reference file.
136
46
 
137
- Parameters
138
- ----------
139
- name: str
140
- Camera name
47
+ The list of sites is derived from the sites listed in the model parameter
48
+ schema files. Return a dictionary for compatibility with the validation routines.
141
49
 
142
50
  Returns
143
51
  -------
144
- str
145
- Validated name.
52
+ dict
53
+ Site names.
146
54
  """
147
- return validate_name(name, all_camera_names)
55
+ _array_elements = array_elements()
56
+ _sites = {entry["site"] for entry in _array_elements.values()}
57
+ return {site: [site.lower()] for site in _sites}
58
+
59
+
60
+ @cache
61
+ def load_model_parameters(class_key_list):
62
+ model_parameters = {}
63
+ schema_files = glob.glob(str(Path(__file__).parent / "../schemas/model_parameters") + "/*.yml")
64
+ for schema_file in schema_files:
65
+ with open(schema_file, encoding="utf-8") as f:
66
+ data = yaml.safe_load(f)
67
+ try:
68
+ if data["instrument"]["class"] in class_key_list:
69
+ model_parameters[data["name"]] = data
70
+ except KeyError:
71
+ pass
72
+ return model_parameters
73
+
74
+
75
+ def site_parameters():
76
+ return load_model_parameters(class_key_list="Site")
77
+
78
+
79
+ def telescope_parameters():
80
+ return load_model_parameters(class_key_list=("Structure", "Camera", "Telescope"))
148
81
 
149
82
 
150
- def validate_telescope_id_name(name):
83
+ def validate_array_element_id_name(name):
151
84
  """
152
- Validate a telescope ID name
85
+ Validate array element ID.
153
86
 
154
- Valid names e.g.,
155
- - D
156
- - telescope ID
87
+ Allowed IDs are
88
+ - design (for design array elements or testing)
89
+ - array element ID (e.g., 1, 5, 15)
90
+ - test (for testing)
157
91
 
158
92
  Parameters
159
93
  ----------
160
- name: str
161
- Telescope ID name.
94
+ name: str or int
95
+ Array element ID name.
162
96
 
163
97
  Returns
164
98
  -------
165
99
  str
166
- Validated name.
100
+ Validated array element ID (added leading zeros, e.g., 1 is converted to 01).
167
101
 
168
102
  Raises
169
103
  ------
170
104
  ValueError
171
105
  If name is not valid.
172
106
  """
107
+ if isinstance(name, int) or name.isdigit():
108
+ return f"{int(name):02d}"
109
+ if name.lower() in ("design", "test"):
110
+ return str(name).lower()
173
111
 
174
- if name == "D" or name.isdigit():
175
- return name
176
-
177
- msg = f"Invalid telescope ID name {name}"
112
+ msg = f"Invalid array element ID name {name}"
178
113
  _logger.error(msg)
179
114
  raise ValueError(msg)
180
115
 
181
116
 
182
- def validate_model_version_name(name):
117
+ def validate_site_name(name):
183
118
  """
184
- Validate a model version name.
119
+ Validate site name.
185
120
 
186
121
  Parameters
187
122
  ----------
188
123
  name: str
189
- Model version name.
124
+ Site name.
190
125
 
191
126
  Returns
192
127
  -------
193
128
  str
194
129
  Validated name.
195
130
  """
196
- return validate_name(name, all_model_version_names)
131
+ return _validate_name(name, site_names())
197
132
 
198
133
 
199
- def validate_simtel_mode_name(name):
134
+ def _validate_name(name, all_names):
200
135
  """
201
- Validate a sim_telarray mode name.
136
+ Validate name given the all_names options.
137
+
138
+ For each key in all_names, a list of options is given.
139
+ If name is in this list, the key name is returned.
202
140
 
203
141
  Parameters
204
142
  ----------
205
143
  name: str
206
- sim_telarray mode name.
144
+ Name to validate.
145
+ all_names: dict
146
+ Dictionary with valid names.
207
147
 
208
148
  Returns
209
149
  -------
210
150
  str
211
151
  Validated name.
212
- """
213
- return validate_name(name, all_simtel_mode_names)
214
-
215
152
 
216
- def validate_site_name(name):
153
+ Raises
154
+ ------
155
+ ValueError
156
+ If name is not valid.
217
157
  """
218
- Validate a site name.
158
+ for key in all_names.keys():
159
+ if isinstance(all_names[key], list) and name.lower() in [
160
+ item.lower() for item in all_names[key]
161
+ ]:
162
+ return key
163
+ if name.lower() == key.lower():
164
+ return key
219
165
 
220
- Parameters
221
- ----------
222
- name: str
223
- Site name.
224
-
225
- Returns
226
- -------
227
- str
228
- Validated name.
229
- """
230
- return validate_name(name, all_site_names)
166
+ msg = f"Invalid name {name}"
167
+ raise ValueError(msg)
231
168
 
232
169
 
233
- def validate_array_layout_name(name):
170
+ def validate_array_element_type(name):
234
171
  """
235
- Validate a array layout name.
172
+ Validate array element type (e.g., LSTN, MSTN).
236
173
 
237
174
  Parameters
238
175
  ----------
239
176
  name: str
240
- Layout array name.
177
+ Array element type.
241
178
 
242
179
  Returns
243
180
  -------
244
181
  str
245
182
  Validated name.
246
183
  """
247
- return validate_name(name, all_array_layout_names)
184
+ return _validate_name(name, array_elements())
248
185
 
249
186
 
250
- def validate_name(name, all_names):
187
+ def validate_array_element_name(name):
251
188
  """
252
- Validate a name given the all_names options. For each key in all_names, a list of options is \
253
- given. If name is in this list, the key name is returned.
189
+ Validate array element name (e.g., MSTN-design, MSTN-01).
254
190
 
255
191
  Parameters
256
192
  ----------
257
193
  name: str
258
- Name to validate.
259
- all_names: dict
260
- Dictionary with valid names.
194
+ Array element name.
195
+
261
196
  Returns
262
197
  -------
263
198
  str
264
199
  Validated name.
265
-
266
- Raises
267
- ------
268
- ValueError
269
- If name is not valid.
270
200
  """
271
-
272
- if not is_valid_name(name, all_names):
201
+ try:
202
+ _array_element_type, _array_element_id = name.split("-")
203
+ except ValueError as exc:
273
204
  msg = f"Invalid name {name}"
274
- raise ValueError(msg)
275
- for main_name, list_of_names in all_names.items():
276
- if name.lower() in list_of_names + [main_name.lower()]:
277
- if name != main_name:
278
- _logger.debug(f"Correcting name {name} -> {main_name}")
279
- return main_name
280
- return None
205
+ raise ValueError(msg) from exc
206
+ return (
207
+ _validate_name(_array_element_type, array_elements())
208
+ + "-"
209
+ + validate_array_element_id_name(_array_element_id)
210
+ )
281
211
 
282
212
 
283
- def is_valid_name(name, all_names):
213
+ def get_array_element_name_from_type_site_id(array_element_type, site, array_element_id):
284
214
  """
285
- Check if name is valid.
215
+ Get array element name from type, site and ID.
286
216
 
287
217
  Parameters
288
218
  ----------
289
- name: str
290
- Name to validated.
291
- all_names: dict
292
- Dictionary with valid names.
219
+ array_element_type: str
220
+ Array element type.
221
+ site: str
222
+ Site name.
223
+ array_element_id: str
224
+ Array element ID.
293
225
 
294
226
  Returns
295
227
  -------
296
- bool
297
- True if name is valid. Otherwise, false.
228
+ str
229
+ Array element name.
298
230
  """
231
+ _short_site = validate_site_name(site)[0]
232
+ _val_id = validate_array_element_id_name(array_element_id)
233
+ return f"{array_element_type}{_short_site}-{_val_id}"
299
234
 
300
- if not isinstance(name, str):
301
- return False
302
- for main_name in all_names.keys():
303
- if name.lower() in all_names[main_name] + [main_name.lower()]:
304
- return True
305
- return False
306
235
 
307
-
308
- def validate_telescope_model_name(name):
236
+ def get_array_element_type_from_name(name):
309
237
  """
310
- Validate a telescope model name.
238
+ Get array element type from name, e.g. "LSTN", "MSTN".
311
239
 
312
240
  Parameters
313
241
  ----------
314
242
  name: str
315
- Telescope model name.
243
+ Array element name
316
244
 
317
245
  Returns
318
246
  -------
319
247
  str
320
- Validated name.
248
+ Array element type.
321
249
  """
250
+ return _validate_name(name.split("-")[0], array_elements())
322
251
 
323
- tel_class, tel_type = split_telescope_model_name(name)
324
- tel_class = validate_name(tel_class, all_telescope_class_names)
325
- if "flashcam" in tel_type:
326
- tel_type = tel_type.replace("flashcam", "FlashCam")
327
- if "nectarcam" in tel_type:
328
- tel_type = tel_type.replace("nectarcam", "NectarCam")
329
- if "1m" in tel_type:
330
- tel_type = tel_type.replace("1m", "1M")
331
- if "gct" in tel_type:
332
- tel_type = tel_type.replace("gct", "GCT")
333
- if "astri" in tel_type:
334
- tel_type = tel_type.replace("astri", "ASTRI")
335
- if "-d" in "-" + tel_type:
336
- tel_type = tel_type.replace("d", "D")
337
252
 
338
- return tel_class + "-" + tel_type
339
-
340
-
341
- def split_telescope_model_name(name):
253
+ def get_list_of_array_element_types(
254
+ array_element_class="telescopes", site=None, observatory="CTAO"
255
+ ):
342
256
  """
343
- Split a telescope name into class and type.
257
+ Get list of array element types.
344
258
 
345
259
  Parameters
346
260
  ----------
347
- name: str
348
- Telescope name.
261
+ array_element_class: str
262
+ Array element class
263
+ site: str
264
+ Site name (e.g., South or North).
349
265
 
350
266
  Returns
351
267
  -------
352
- str, str
353
- class (LST, MST, SST ...) and type (any complement).
268
+ list
269
+ List of array element types.
354
270
  """
355
-
356
- name_parts = name.split("-")
357
- tel_class = name_parts[0]
358
- tel_type = "-".join(name_parts[1:])
359
- return tel_class, tel_type
271
+ return [
272
+ key
273
+ for key, value in array_elements().items()
274
+ if value["collection"] == array_element_class
275
+ and (site is None or value["site"] == site)
276
+ and (observatory is None or value["observatory"] == observatory)
277
+ ]
360
278
 
361
279
 
362
- def get_site_from_telescope_name(name):
280
+ def get_site_from_array_element_name(name):
363
281
  """
364
- Get site name (South or North) from the (validated) telescope name.
282
+ Get site name from array element name.
365
283
 
366
284
  Parameters
367
285
  ----------
368
286
  name: str
369
- Telescope name.
287
+ Array element name.
370
288
 
371
289
  Returns
372
290
  -------
373
291
  str
374
292
  Site name (South or North).
375
293
  """
376
- return validate_site_name(name.split("-")[0])
294
+ return array_elements()[get_array_element_type_from_name(name)]["site"]
377
295
 
378
296
 
379
- def validate_telescope_name_db(name):
297
+ def get_collection_name_from_array_element_name(name):
380
298
  """
381
- Validate a telescope DB name.
299
+ Get collection name (e.g., telescopes, calibration_devices, sites) of array element from name.
382
300
 
383
301
  Parameters
384
302
  ----------
385
303
  name: str
304
+ Array element name.
386
305
 
387
306
  Returns
388
307
  -------
389
308
  str
390
- Validated name.
309
+ Collection name .
391
310
  """
392
- site = get_site_from_telescope_name(name)
393
- tel_model_name = "-".join(name.split("-")[1:])
394
-
395
- return f"{validate_site_name(site)}-{validate_telescope_model_name(tel_model_name)}"
311
+ try:
312
+ return array_elements()[get_array_element_type_from_name(name)]["collection"]
313
+ except ValueError:
314
+ pass
315
+ try:
316
+ validate_site_name(name)
317
+ return "sites"
318
+ except ValueError as exc:
319
+ raise ValueError(f"Invalid array element name {name}: {exc}") from exc
396
320
 
397
321
 
398
- def convert_telescope_model_name_to_yaml(name):
322
+ def get_simulation_software_name_from_parameter_name(
323
+ par_name,
324
+ simulation_software="sim_telarray",
325
+ search_telescope_parameters=True,
326
+ search_site_parameters=True,
327
+ ):
399
328
  """
400
- Get telescope name following the old convention (yaml files) from the current telescope name.
329
+ Get the name used in the simulation software from the model parameter name.
330
+
331
+ Name convention is expected to be defined in the schema.
332
+ Returns the parameter name if no simulation software name is found.
401
333
 
402
334
  Parameters
403
335
  ----------
404
- name: str
405
- Telescope model name.
336
+ par_name: str
337
+ Model parameter name.
338
+ simulation_software: str
339
+ Simulation software name.
340
+ search_telescope_parameters: bool
341
+ If True, telescope model parameters are included.
342
+ search_site_parameters: bool
343
+ If True, site model parameters are included.
406
344
 
407
345
  Returns
408
346
  -------
409
347
  str
410
- Telescope name (old convention).
411
-
412
- Raises
413
- ------
414
- ValueError
415
- if name is not valid.
348
+ Simtel parameter name.
416
349
  """
417
- tel_class, tel_type = split_telescope_model_name(name)
418
- new_name = tel_class + "-" + tel_type
419
- old_names = {
420
- "SST-D": "SST",
421
- "SST-1M": "SST-1M",
422
- "SST-ASTRI": "SST-2M-ASTRI",
423
- "SST-GCT": "SST-2M-GCT-S",
424
- "MST-FlashCam-D": "MST-FlashCam",
425
- "MST-NectarCam-D": "MST-NectarCam",
426
- "SCT-D": "SCT",
427
- "LST-D234": "LST",
428
- "LST-1": "LST",
429
- }
350
+ _parameter_names = {}
351
+ if search_telescope_parameters:
352
+ _parameter_names.update(telescope_parameters())
353
+ if search_site_parameters:
354
+ _parameter_names.update(site_parameters())
430
355
 
431
- if new_name not in old_names:
432
- raise ValueError(f"Telescope name {name} could not be converted to yml names")
356
+ try:
357
+ _parameter = _parameter_names[par_name]
358
+ except KeyError as err:
359
+ _logger.error(f"Parameter {par_name} without schema definition")
360
+ raise err
433
361
 
434
- return old_names[new_name]
362
+ try:
363
+ for software in _parameter.get("simulation_software", []):
364
+ if software.get("name") == simulation_software:
365
+ return software.get("internal_parameter_name", par_name)
366
+ except TypeError: # catches cases for which 'simulation_software' is None
367
+ pass
368
+ return None
435
369
 
436
370
 
437
- def simtools_instrument_name(site, telescope_class_name, sub_system_name, telescope_id_name):
371
+ def get_parameter_name_from_simtel_name(simtel_name):
438
372
  """
439
- Instrument name following simtools naming convention
373
+ Get the model parameter name from the simtel parameter name.
374
+
375
+ Assumes that both names are equal if not defined otherwise in names.py.
440
376
 
441
377
  Parameters
442
378
  ----------
443
- site: str
444
- South or North.
445
- telescope_class_name: str
446
- LST, MST, ...
447
- sub_system_name: str
448
- FlashCam, NectarCam
449
- telescope_id_name: str
450
- telescope ID (e.g., D, numerical value)
379
+ simtel_name: str
380
+ Simtel parameter name.
451
381
 
452
382
  Returns
453
383
  -------
454
- instrument: name: str
455
- Instrument name.
384
+ str
385
+ Model parameter name.
456
386
  """
387
+ _parameters = {**telescope_parameters(), **site_parameters()}
457
388
 
458
- return (
459
- validate_site_name(site)
460
- + "-"
461
- + validate_name(telescope_class_name, all_telescope_class_names)
462
- + "-"
463
- + validate_sub_system_name(sub_system_name)
464
- + "-"
465
- + validate_telescope_id_name(telescope_id_name)
466
- )
389
+ for par_name, par_info in _parameters.items():
390
+ try:
391
+ for software in par_info["simulation_software"]:
392
+ if (
393
+ software["name"] == "sim_telarray"
394
+ and software["internal_parameter_name"] == simtel_name
395
+ ):
396
+ return par_name
397
+ except (KeyError, TypeError): # catches cases for which 'simulation_software' is None
398
+ pass
399
+ return simtel_name
467
400
 
468
401
 
469
- def simtel_telescope_config_file_name(
470
- site, telescope_model_name, model_version, label, extra_label
402
+ def simtel_config_file_name(
403
+ site,
404
+ model_version,
405
+ array_name=None,
406
+ telescope_model_name=None,
407
+ label=None,
408
+ extra_label=None,
471
409
  ):
472
410
  """
473
411
  sim_telarray config file name for a telescope.
@@ -490,39 +428,17 @@ def simtel_telescope_config_file_name(
490
428
  str
491
429
  File name.
492
430
  """
493
- name = f"CTA-{site}-{telescope_model_name}-{model_version}"
431
+ name = "CTA"
432
+ name += f"-{array_name}" if array_name is not None else ""
433
+ name += f"-{site}"
434
+ name += f"-{telescope_model_name}" if telescope_model_name is not None else ""
435
+ name += f"-{model_version}"
494
436
  name += f"_{label}" if label is not None else ""
495
437
  name += f"_{extra_label}" if extra_label is not None else ""
496
438
  name += ".cfg"
497
439
  return name
498
440
 
499
441
 
500
- def simtel_array_config_file_name(array_name, site, version, label):
501
- """
502
- sim_telarray config file name for an array.
503
-
504
- Parameters
505
- ----------
506
- array_name: str
507
- Prod5, ...
508
- site: str
509
- South or North.
510
- version: str
511
- Version of the model.
512
- label: str
513
- Instance label.
514
-
515
- Returns
516
- -------
517
- str
518
- File name.
519
- """
520
- name = f"CTA-{array_name}-{site}-{version}"
521
- name += f"_{label}" if label is not None else ""
522
- name += ".cfg"
523
- return name
524
-
525
-
526
442
  def simtel_single_mirror_list_file_name(
527
443
  site, telescope_model_name, model_version, mirror_number, label
528
444
  ):
@@ -576,283 +492,66 @@ def layout_telescope_list_file_name(name, label):
576
492
  return file_name
577
493
 
578
494
 
579
- def ray_tracing_file_name(
495
+ def generate_file_name(
496
+ file_type,
497
+ suffix,
580
498
  site,
581
499
  telescope_model_name,
582
- source_distance,
583
500
  zenith_angle,
584
- off_axis_angle,
585
- mirror_number,
586
- label,
587
- base,
501
+ azimuth_angle=None,
502
+ off_axis_angle=None,
503
+ source_distance=None,
504
+ mirror_number=None,
505
+ label=None,
506
+ extra_label=None,
588
507
  ):
589
508
  """
590
- File name for files required at the RayTracing class.
509
+ Generate a file name for output, config, or plotting.
510
+
511
+ Used e.g., to generate camera-efficiency and ray-tracing output files.
591
512
 
592
513
  Parameters
593
514
  ----------
515
+ file_type: str
516
+ Type of file (e.g., config, output, plot)
517
+ suffix: str
518
+ File suffix
594
519
  site: str
595
520
  South or North.
596
521
  telescope_model_name: str
597
- LST-1, MST-FlashCam, ...
598
- source_distance: float
599
- Source distance (km).
522
+ LSTN-01, MSTS-01, ...
600
523
  zenith_angle: float
601
524
  Zenith angle (deg).
525
+ azimuth_angle: float
526
+ Azimuth angle (deg).
602
527
  off_axis_angle: float
603
528
  Off-axis angle (deg).
604
- mirror_number: int
605
- Mirror number. None if not single mirror case.
606
- label: str
607
- Instance label.
608
- base: str
609
- Photons, stars or log.
610
-
611
- Returns
612
- -------
613
- str
614
- File name.
615
- """
616
- name = (
617
- f"{base}-{site}-{telescope_model_name}-d{source_distance:.1f}"
618
- f"-za{zenith_angle:.1f}-off{off_axis_angle:.3f}"
619
- )
620
- name += f"_mirror{mirror_number}" if mirror_number is not None else ""
621
- name += f"_{label}" if label is not None else ""
622
- name += ".log" if base == "log" else ".lis"
623
- return name
624
-
625
-
626
- def ray_tracing_results_file_name(site, telescope_model_name, source_distance, zenith_angle, label):
627
- """
628
- Ray tracing results file name.
629
-
630
- Parameters
631
- ----------
632
- site: str
633
- South or North.
634
- telescope_model_name: str
635
- LST-1, MST-FlashCam, ...
636
529
  source_distance: float
637
530
  Source distance (km).
638
- zenith_angle: float
639
- Zenith angle (deg).
640
- label: str
641
- Instance label.
642
-
643
- Returns
644
- -------
645
- str
646
- File name.
647
- """
648
- name = f"ray-tracing-{site}-{telescope_model_name}-d{source_distance:.1f}-za{zenith_angle:.1f}"
649
- name += f"_{label}" if label is not None else ""
650
- name += ".ecsv"
651
- return name
652
-
653
-
654
- def ray_tracing_plot_file_name(
655
- key, site, telescope_model_name, source_distance, zenith_angle, label
656
- ):
657
- """
658
- Ray tracing plot file name.
659
-
660
- Parameters
661
- ----------
662
- key: str
663
- Quantity to be plotted (d80_cm, d80_deg, eff_area or eff_flen)
664
- site: str
665
- South or North.
666
- telescope_model_name: str
667
- LST-1, MST-FlashCam, ...
668
- source_distance: float
669
- Source distance (km).
670
- zenith_angle: float
671
- Zenith angle (deg).
531
+ mirror_number: int
532
+ Mirror number.
672
533
  label: str
673
534
  Instance label.
535
+ extra_label: str
536
+ Extra label.
674
537
 
675
538
  Returns
676
539
  -------
677
540
  str
678
541
  File name.
679
542
  """
680
- name = (
681
- f"ray-tracing-{site}-{telescope_model_name}-{key}-"
682
- f"d{source_distance:.1f}-za{zenith_angle:.1f}"
683
- )
543
+ name = f"{file_type}-{site}-{telescope_model_name}"
544
+ name += f"-d{source_distance:.1f}km" if source_distance is not None else ""
545
+ name += f"-za{float(zenith_angle):.1f}deg"
546
+ name += f"-off{off_axis_angle:.3f}deg" if off_axis_angle is not None else ""
547
+ name += f"_azm{round(azimuth_angle):03}deg" if azimuth_angle is not None else ""
548
+ name += f"_mirror{mirror_number}" if mirror_number is not None else ""
684
549
  name += f"_{label}" if label is not None else ""
685
- name += ".pdf"
686
- return name
687
-
688
-
689
- def camera_efficiency_results_file_name(
690
- site, telescope_model_name, zenith_angle, azimuth_angle, label
691
- ):
692
- """
693
- Camera efficiency results file name.
694
-
695
- Parameters
696
- ----------
697
- site: str
698
- South or North.
699
- telescope_model_name: str
700
- LST-1, MST-FlashCam, ...
701
- zenith_angle: float
702
- Zenith angle (deg).
703
- azimuth_angle: float
704
- Azimuth angle (deg).
705
- label: str
706
- Instance label.
707
-
708
- Returns
709
- -------
710
- str
711
- File name.
712
- """
713
- _label = f"_{label}" if label is not None else ""
714
- name = (
715
- f"camera-efficiency-table-{site}-{telescope_model_name}-"
716
- f"za{round(zenith_angle):03}deg_azm{round(azimuth_angle):03}deg"
717
- f"{_label}.ecsv"
718
- )
719
- return name
720
-
721
-
722
- def camera_efficiency_simtel_file_name(
723
- site, telescope_model_name, zenith_angle, azimuth_angle, label
724
- ):
725
- """
726
- Camera efficiency simtel output file name.
727
-
728
- Parameters
729
- ----------
730
- site: str
731
- South or North.
732
- telescope_model_name: str
733
- LST-1, MST-FlashCam-D, ...
734
- zenith_angle: float
735
- Zenith angle (deg).
736
- azimuth_angle: float
737
- Azimuth angle (deg).
738
- label: str
739
- Instance label.
740
-
741
- Returns
742
- -------
743
- str
744
- File name.
745
- """
746
- _label = f"_{label}" if label is not None else ""
747
- name = (
748
- f"camera-efficiency-{site}-{telescope_model_name}-"
749
- f"za{round(zenith_angle):03}deg_azm{round(azimuth_angle):03}deg"
750
- f"{_label}.dat"
751
- )
752
- return name
753
-
754
-
755
- def camera_efficiency_log_file_name(site, telescope_model_name, zenith_angle, azimuth_angle, label):
756
- """
757
- Camera efficiency log file name.
758
-
759
- Parameters
760
- ----------
761
- site: str
762
- South or North.
763
- telescope_model_name: str
764
- LST-1, MST-FlashCam-D, ...
765
- zenith_angle: float
766
- Zenith angle (deg).
767
- azimuth_angle: float
768
- Azimuth angle (deg).
769
- label: str
770
- Instance label.
771
-
772
- Returns
773
- -------
774
- str
775
- File name.
776
- """
777
- _label = f"_{label}" if label is not None else ""
778
- name = (
779
- f"camera-efficiency-{site}-{telescope_model_name}"
780
- f"-za{round(zenith_angle):03}deg_azm{round(azimuth_angle):03}deg"
781
- f"{_label}.log"
782
- )
550
+ name += f"_{extra_label}" if extra_label is not None else ""
551
+ name += f"{suffix}"
783
552
  return name
784
553
 
785
554
 
786
- def get_telescope_type(telescope_name):
787
- """
788
- Guess telescope type from name, e.g. "LST", "MST", ...
789
-
790
- Parameters
791
- ----------
792
- telescope_name: str
793
- Telescope name
794
-
795
- Returns
796
- -------
797
- str
798
- Telescope type.
799
- """
800
-
801
- _tel_class, _ = split_telescope_model_name(telescope_name)
802
- try:
803
- for _class in all_telescope_class_names:
804
- if len(_class) == 3 and _tel_class[0:3] == _class:
805
- return _class
806
- if _tel_class == _class:
807
- return _class
808
- except IndexError:
809
- pass
810
-
811
- return ""
812
-
813
-
814
- def translate_corsika_to_simtools(corsika_par):
815
- """
816
- Translate the name of a CORSIKA parameter to the name used in simtools.
817
-
818
- Parameters
819
- ----------
820
- corsika_par: str
821
- Name of the corsika parameter to be translated.
822
-
823
- """
824
-
825
- try:
826
- return corsika_to_simtools_names[corsika_par]
827
- except KeyError:
828
- msg = f"Translation not found. We will proceed with the original parameter name:\
829
- {corsika_par}."
830
- _logger.debug(msg)
831
- return corsika_par
832
-
833
-
834
- def translate_simtools_to_corsika(simtools_par):
835
- """
836
- Translate the name of a simtools parameter to the name used in CORSIKA.
837
-
838
- Parameters
839
- ----------
840
- simtools_par: str
841
- Name of the simtools parameter to be translated.
842
- """
843
-
844
- simtools_to_corsika_names = {
845
- new_key: new_value for new_value, new_key in corsika_to_simtools_names.items()
846
- }
847
- try:
848
- return simtools_to_corsika_names[simtools_par]
849
- except KeyError:
850
- msg = f"Translation not found. We will proceed with the original parameter name:\
851
- {simtools_par}."
852
- _logger.debug(msg)
853
- return simtools_par
854
-
855
-
856
555
  def sanitize_name(name):
857
556
  """
858
557
  Sanitize name to be a valid Python identifier.
@@ -875,9 +574,8 @@ def sanitize_name(name):
875
574
  Raises
876
575
  ------
877
576
  ValueError:
878
- if the string `name` can not be sanitized.
577
+ if the string name can not be sanitized.
879
578
  """
880
-
881
579
  # Convert to lowercase
882
580
  sanitized = name.lower()
883
581
 
@@ -889,5 +587,5 @@ def sanitize_name(name):
889
587
  if not sanitized.isidentifier():
890
588
  msg = f"The string {name} could not be sanitized."
891
589
  _logger.error(msg)
892
- raise ValueError
590
+ raise ValueError(msg)
893
591
  return sanitized