gammasimtools 0.15.0__py3-none-any.whl → 0.17.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (248) hide show
  1. {gammasimtools-0.15.0.dist-info → gammasimtools-0.17.0.dist-info}/METADATA +5 -33
  2. {gammasimtools-0.15.0.dist-info → gammasimtools-0.17.0.dist-info}/RECORD +243 -229
  3. {gammasimtools-0.15.0.dist-info → gammasimtools-0.17.0.dist-info}/WHEEL +1 -1
  4. {gammasimtools-0.15.0.dist-info → gammasimtools-0.17.0.dist-info}/entry_points.txt +8 -3
  5. simtools/_version.py +2 -2
  6. simtools/applications/calculate_trigger_rate.py +10 -10
  7. simtools/applications/convert_all_model_parameters_from_simtel.py +16 -16
  8. simtools/applications/convert_model_parameter_from_simtel.py +1 -1
  9. simtools/applications/derive_ctao_array_layouts.py +5 -5
  10. simtools/applications/derive_psf_parameters.py +12 -9
  11. simtools/applications/docs_produce_array_element_report.py +3 -3
  12. simtools/applications/docs_produce_calibration_reports.py +49 -0
  13. simtools/applications/docs_produce_simulation_configuration_report.py +50 -0
  14. simtools/applications/{generate_simtel_array_histograms.py → generate_sim_telarray_histograms.py} +2 -2
  15. simtools/applications/generate_simtel_event_data.py +36 -46
  16. simtools/applications/merge_tables.py +104 -0
  17. simtools/applications/plot_array_layout.py +145 -258
  18. simtools/applications/production_derive_corsika_limits.py +35 -167
  19. simtools/applications/production_derive_statistics.py +159 -0
  20. simtools/applications/production_generate_grid.py +197 -0
  21. simtools/applications/simulate_light_emission.py +6 -13
  22. simtools/applications/simulate_prod.py +45 -21
  23. simtools/applications/simulate_prod_htcondor_generator.py +0 -1
  24. simtools/applications/submit_array_layouts.py +93 -0
  25. simtools/applications/validate_cumulative_psf.py +6 -4
  26. simtools/applications/validate_file_using_schema.py +7 -3
  27. simtools/applications/validate_optics.py +5 -4
  28. simtools/applications/verify_simulation_model_production_tables.py +52 -0
  29. simtools/camera/camera_efficiency.py +17 -42
  30. simtools/configuration/commandline_parser.py +32 -37
  31. simtools/configuration/configurator.py +10 -4
  32. simtools/corsika/corsika_config.py +120 -17
  33. simtools/corsika/primary_particle.py +46 -13
  34. simtools/data_model/format_checkers.py +9 -0
  35. simtools/data_model/metadata_collector.py +7 -3
  36. simtools/data_model/model_data_writer.py +3 -0
  37. simtools/data_model/schema.py +27 -16
  38. simtools/data_model/validate_data.py +27 -7
  39. simtools/db/db_handler.py +21 -15
  40. simtools/db/db_model_upload.py +2 -2
  41. simtools/io_operations/io_handler.py +2 -2
  42. simtools/io_operations/io_table_handler.py +345 -0
  43. simtools/job_execution/htcondor_script_generator.py +2 -2
  44. simtools/job_execution/job_manager.py +7 -121
  45. simtools/layout/array_layout.py +1 -0
  46. simtools/layout/array_layout_utils.py +385 -0
  47. simtools/model/array_model.py +68 -29
  48. simtools/model/model_parameter.py +76 -51
  49. simtools/model/model_repository.py +134 -0
  50. simtools/model/model_utils.py +43 -1
  51. simtools/model/site_model.py +3 -2
  52. simtools/model/telescope_model.py +4 -4
  53. simtools/production_configuration/{calculate_statistical_errors_grid_point.py → calculate_statistical_uncertainties_grid_point.py} +101 -116
  54. simtools/production_configuration/derive_corsika_limits.py +239 -111
  55. simtools/production_configuration/derive_corsika_limits_grid.py +189 -0
  56. simtools/production_configuration/derive_production_statistics.py +155 -0
  57. simtools/production_configuration/derive_production_statistics_handler.py +152 -0
  58. simtools/production_configuration/generate_production_grid.py +364 -0
  59. simtools/production_configuration/interpolation_handler.py +303 -96
  60. simtools/ray_tracing/mirror_panel_psf.py +16 -20
  61. simtools/ray_tracing/psf_analysis.py +2 -2
  62. simtools/ray_tracing/ray_tracing.py +12 -7
  63. simtools/reporting/docs_read_parameters.py +426 -81
  64. simtools/runners/corsika_runner.py +11 -1
  65. simtools/runners/corsika_simtel_runner.py +84 -90
  66. simtools/runners/runner_services.py +22 -8
  67. simtools/runners/simtel_runner.py +27 -10
  68. simtools/schemas/model_parameter.metaschema.yml +4 -0
  69. simtools/schemas/model_parameter_and_data_schema.metaschema.yml +1 -0
  70. simtools/schemas/model_parameters/adjust_gain.schema.yml +2 -2
  71. simtools/schemas/model_parameters/array_element_position_ground.schema.yml +2 -2
  72. simtools/schemas/model_parameters/array_element_position_utm.schema.yml +2 -2
  73. simtools/schemas/model_parameters/array_window.schema.yml +2 -2
  74. simtools/schemas/model_parameters/asum_offset.schema.yml +2 -2
  75. simtools/schemas/model_parameters/asum_shaping.schema.yml +2 -2
  76. simtools/schemas/model_parameters/asum_threshold.schema.yml +2 -2
  77. simtools/schemas/model_parameters/axes_offsets.schema.yml +2 -2
  78. simtools/schemas/model_parameters/camera_body_diameter.schema.yml +2 -2
  79. simtools/schemas/model_parameters/camera_body_shape.schema.yml +2 -2
  80. simtools/schemas/model_parameters/camera_config_file.schema.yml +2 -2
  81. simtools/schemas/model_parameters/camera_config_rotate.schema.yml +2 -2
  82. simtools/schemas/model_parameters/camera_degraded_efficiency.schema.yml +2 -2
  83. simtools/schemas/model_parameters/camera_degraded_map.schema.yml +2 -2
  84. simtools/schemas/model_parameters/camera_depth.schema.yml +2 -2
  85. simtools/schemas/model_parameters/camera_filter.schema.yml +2 -2
  86. simtools/schemas/model_parameters/camera_pixels.schema.yml +2 -2
  87. simtools/schemas/model_parameters/camera_transmission.schema.yml +2 -2
  88. simtools/schemas/model_parameters/channels_per_chip.schema.yml +2 -2
  89. simtools/schemas/model_parameters/correct_nsb_spectrum_to_telescope_altitude.schema.yml +2 -2
  90. simtools/schemas/model_parameters/corsika_starting_grammage.schema.yml +90 -1
  91. simtools/schemas/model_parameters/default_trigger.schema.yml +2 -2
  92. simtools/schemas/model_parameters/design_model.schema.yml +2 -2
  93. simtools/schemas/model_parameters/disc_ac_coupled.schema.yml +2 -2
  94. simtools/schemas/model_parameters/disc_bins.schema.yml +2 -2
  95. simtools/schemas/model_parameters/disc_start.schema.yml +2 -2
  96. simtools/schemas/model_parameters/discriminator_amplitude.schema.yml +2 -2
  97. simtools/schemas/model_parameters/discriminator_fall_time.schema.yml +2 -2
  98. simtools/schemas/model_parameters/discriminator_gate_length.schema.yml +2 -2
  99. simtools/schemas/model_parameters/discriminator_hysteresis.schema.yml +2 -2
  100. simtools/schemas/model_parameters/discriminator_output_amplitude.schema.yml +2 -2
  101. simtools/schemas/model_parameters/discriminator_output_var_percent.schema.yml +2 -2
  102. simtools/schemas/model_parameters/discriminator_pulse_shape.schema.yml +2 -2
  103. simtools/schemas/model_parameters/discriminator_rise_time.schema.yml +2 -2
  104. simtools/schemas/model_parameters/discriminator_scale_threshold.schema.yml +2 -2
  105. simtools/schemas/model_parameters/discriminator_sigsum_over_threshold.schema.yml +2 -2
  106. simtools/schemas/model_parameters/discriminator_threshold.schema.yml +2 -2
  107. simtools/schemas/model_parameters/discriminator_time_over_threshold.schema.yml +2 -2
  108. simtools/schemas/model_parameters/discriminator_var_gate_length.schema.yml +2 -2
  109. simtools/schemas/model_parameters/discriminator_var_sigsum_over_threshold.schema.yml +2 -2
  110. simtools/schemas/model_parameters/discriminator_var_threshold.schema.yml +2 -2
  111. simtools/schemas/model_parameters/discriminator_var_time_over_threshold.schema.yml +2 -2
  112. simtools/schemas/model_parameters/dish_shape_length.schema.yml +2 -2
  113. simtools/schemas/model_parameters/dsum_clipping.schema.yml +2 -2
  114. simtools/schemas/model_parameters/dsum_ignore_below.schema.yml +2 -2
  115. simtools/schemas/model_parameters/dsum_offset.schema.yml +2 -2
  116. simtools/schemas/model_parameters/dsum_pedsub.schema.yml +2 -2
  117. simtools/schemas/model_parameters/dsum_pre_clipping.schema.yml +2 -2
  118. simtools/schemas/model_parameters/dsum_prescale.schema.yml +2 -2
  119. simtools/schemas/model_parameters/dsum_presum_max.schema.yml +2 -2
  120. simtools/schemas/model_parameters/dsum_presum_shift.schema.yml +2 -2
  121. simtools/schemas/model_parameters/dsum_shaping.schema.yml +2 -2
  122. simtools/schemas/model_parameters/dsum_shaping_renormalize.schema.yml +2 -2
  123. simtools/schemas/model_parameters/dsum_threshold.schema.yml +44 -3
  124. simtools/schemas/model_parameters/dsum_zero_clip.schema.yml +2 -2
  125. simtools/schemas/model_parameters/effective_focal_length.schema.yml +2 -2
  126. simtools/schemas/model_parameters/fadc_ac_coupled.schema.yml +2 -2
  127. simtools/schemas/model_parameters/fadc_amplitude.schema.yml +2 -2
  128. simtools/schemas/model_parameters/fadc_bins.schema.yml +2 -2
  129. simtools/schemas/model_parameters/fadc_compensate_pedestal.schema.yml +2 -2
  130. simtools/schemas/model_parameters/fadc_err_compensate_pedestal.schema.yml +2 -2
  131. simtools/schemas/model_parameters/fadc_err_pedestal.schema.yml +2 -2
  132. simtools/schemas/model_parameters/fadc_lg_amplitude.schema.yml +2 -2
  133. simtools/schemas/model_parameters/fadc_lg_compensate_pedestal.schema.yml +2 -2
  134. simtools/schemas/model_parameters/fadc_lg_err_compensate_pedestal.schema.yml +2 -2
  135. simtools/schemas/model_parameters/fadc_lg_err_pedestal.schema.yml +2 -2
  136. simtools/schemas/model_parameters/fadc_lg_max_signal.schema.yml +2 -2
  137. simtools/schemas/model_parameters/fadc_lg_noise.schema.yml +2 -2
  138. simtools/schemas/model_parameters/fadc_lg_pedestal.schema.yml +2 -2
  139. simtools/schemas/model_parameters/fadc_lg_sensitivity.schema.yml +2 -2
  140. simtools/schemas/model_parameters/fadc_lg_sysvar_pedestal.schema.yml +2 -2
  141. simtools/schemas/model_parameters/fadc_lg_var_pedestal.schema.yml +2 -2
  142. simtools/schemas/model_parameters/fadc_lg_var_sensitivity.schema.yml +2 -2
  143. simtools/schemas/model_parameters/fadc_max_signal.schema.yml +2 -2
  144. simtools/schemas/model_parameters/fadc_mhz.schema.yml +2 -2
  145. simtools/schemas/model_parameters/fadc_noise.schema.yml +2 -2
  146. simtools/schemas/model_parameters/fadc_pedestal.schema.yml +2 -2
  147. simtools/schemas/model_parameters/fadc_pulse_shape.schema.yml +2 -2
  148. simtools/schemas/model_parameters/fadc_sensitivity.schema.yml +2 -2
  149. simtools/schemas/model_parameters/fadc_sum_bins.schema.yml +2 -2
  150. simtools/schemas/model_parameters/fadc_sum_offset.schema.yml +2 -2
  151. simtools/schemas/model_parameters/fadc_sysvar_pedestal.schema.yml +2 -2
  152. simtools/schemas/model_parameters/fadc_var_pedestal.schema.yml +2 -2
  153. simtools/schemas/model_parameters/fadc_var_sensitivity.schema.yml +2 -2
  154. simtools/schemas/model_parameters/fake_mirror_list.schema.yml +1 -1
  155. simtools/schemas/model_parameters/flatfielding.schema.yml +2 -2
  156. simtools/schemas/model_parameters/focal_length.schema.yml +2 -2
  157. simtools/schemas/model_parameters/focus_offset.schema.yml +2 -2
  158. simtools/schemas/model_parameters/gain_variation.schema.yml +2 -2
  159. simtools/schemas/model_parameters/hg_lg_variation.schema.yml +2 -2
  160. simtools/schemas/model_parameters/iobuf_maximum.schema.yml +2 -2
  161. simtools/schemas/model_parameters/iobuf_output_maximum.schema.yml +2 -2
  162. simtools/schemas/model_parameters/laser_events.schema.yml +1 -1
  163. simtools/schemas/model_parameters/lightguide_efficiency_vs_incidence_angle.schema.yml +2 -2
  164. simtools/schemas/model_parameters/lightguide_efficiency_vs_wavelength.schema.yml +2 -2
  165. simtools/schemas/model_parameters/min_photoelectrons.schema.yml +2 -2
  166. simtools/schemas/model_parameters/min_photons.schema.yml +2 -2
  167. simtools/schemas/model_parameters/mirror_align_random_distance.schema.yml +2 -2
  168. simtools/schemas/model_parameters/mirror_align_random_horizontal.schema.yml +2 -2
  169. simtools/schemas/model_parameters/mirror_align_random_vertical.schema.yml +2 -2
  170. simtools/schemas/model_parameters/mirror_class.schema.yml +2 -2
  171. simtools/schemas/model_parameters/mirror_degraded_reflection.schema.yml +2 -2
  172. simtools/schemas/model_parameters/mirror_focal_length.schema.yml +2 -2
  173. simtools/schemas/model_parameters/mirror_list.schema.yml +2 -2
  174. simtools/schemas/model_parameters/mirror_offset.schema.yml +2 -2
  175. simtools/schemas/model_parameters/mirror_reflection_random_angle.schema.yml +2 -2
  176. simtools/schemas/model_parameters/mirror_reflectivity.schema.yml +2 -2
  177. simtools/schemas/model_parameters/multiplicity_offset.schema.yml +2 -2
  178. simtools/schemas/model_parameters/muon_mono_threshold.schema.yml +2 -2
  179. simtools/schemas/model_parameters/nsb_autoscale_airmass.schema.yml +2 -2
  180. simtools/schemas/model_parameters/nsb_offaxis.schema.yml +2 -2
  181. simtools/schemas/model_parameters/nsb_pixel_rate.schema.yml +2 -2
  182. simtools/schemas/model_parameters/num_gains.schema.yml +2 -2
  183. simtools/schemas/model_parameters/only_triggered_telescopes.schema.yml +2 -2
  184. simtools/schemas/model_parameters/optics_properties.schema.yml +2 -2
  185. simtools/schemas/model_parameters/pedestal_events.schema.yml +7 -3
  186. simtools/schemas/model_parameters/photon_delay.schema.yml +2 -2
  187. simtools/schemas/model_parameters/pixeltrg_time_step.schema.yml +2 -2
  188. simtools/schemas/model_parameters/pm_average_gain.schema.yml +2 -2
  189. simtools/schemas/model_parameters/pm_collection_efficiency.schema.yml +2 -2
  190. simtools/schemas/model_parameters/pm_gain_index.schema.yml +2 -2
  191. simtools/schemas/model_parameters/pm_photoelectron_spectrum.schema.yml +2 -2
  192. simtools/schemas/model_parameters/pm_transit_time.schema.yml +2 -2
  193. simtools/schemas/model_parameters/pm_voltage_variation.schema.yml +2 -2
  194. simtools/schemas/model_parameters/primary_mirror_degraded_map.schema.yml +2 -2
  195. simtools/schemas/model_parameters/qe_variation.schema.yml +2 -2
  196. simtools/schemas/model_parameters/quantum_efficiency.schema.yml +2 -2
  197. simtools/schemas/model_parameters/random_focal_length.schema.yml +2 -2
  198. simtools/schemas/model_parameters/random_generator.schema.yml +2 -2
  199. simtools/schemas/model_parameters/random_mono_probability.schema.yml +2 -2
  200. simtools/schemas/model_parameters/sampled_output.schema.yml +2 -2
  201. simtools/schemas/model_parameters/save_pe_with_amplitude.schema.yml +2 -2
  202. simtools/schemas/model_parameters/store_photoelectrons.schema.yml +2 -2
  203. simtools/schemas/model_parameters/tailcut_scale.schema.yml +2 -2
  204. simtools/schemas/model_parameters/telescope_axis_height.schema.yml +2 -2
  205. simtools/schemas/model_parameters/telescope_random_angle.schema.yml +2 -2
  206. simtools/schemas/model_parameters/telescope_random_error.schema.yml +2 -2
  207. simtools/schemas/model_parameters/telescope_sphere_radius.schema.yml +2 -2
  208. simtools/schemas/model_parameters/telescope_transmission.schema.yml +2 -2
  209. simtools/schemas/model_parameters/teltrig_min_sigsum.schema.yml +2 -2
  210. simtools/schemas/model_parameters/teltrig_min_time.schema.yml +2 -2
  211. simtools/schemas/model_parameters/transit_time_calib_error.schema.yml +2 -2
  212. simtools/schemas/model_parameters/transit_time_compensate_error.schema.yml +2 -2
  213. simtools/schemas/model_parameters/transit_time_compensate_step.schema.yml +2 -2
  214. simtools/schemas/model_parameters/transit_time_error.schema.yml +2 -2
  215. simtools/schemas/model_parameters/transit_time_jitter.schema.yml +2 -2
  216. simtools/schemas/model_parameters/trigger_current_limit.schema.yml +2 -2
  217. simtools/schemas/model_parameters/trigger_delay_compensation.schema.yml +2 -2
  218. simtools/schemas/model_parameters/trigger_pixels.schema.yml +2 -2
  219. simtools/schemas/production_configuration_metrics.schema.yml +2 -2
  220. simtools/simtel/simtel_config_reader.py +21 -17
  221. simtools/simtel/simtel_config_writer.py +258 -66
  222. simtools/simtel/simtel_io_event_reader.py +301 -194
  223. simtools/simtel/simtel_io_event_writer.py +207 -227
  224. simtools/simtel/simtel_io_file_info.py +62 -0
  225. simtools/simtel/simtel_io_histogram.py +10 -14
  226. simtools/simtel/simtel_io_histograms.py +2 -2
  227. simtools/simtel/simtel_io_metadata.py +106 -0
  228. simtools/simtel/simulator_array.py +28 -14
  229. simtools/simtel/simulator_camera_efficiency.py +12 -6
  230. simtools/simtel/simulator_light_emission.py +85 -45
  231. simtools/simtel/simulator_ray_tracing.py +16 -6
  232. simtools/simulator.py +286 -89
  233. simtools/testing/configuration.py +5 -0
  234. simtools/testing/helpers.py +18 -0
  235. simtools/testing/sim_telarray_metadata.py +212 -0
  236. simtools/testing/validate_output.py +16 -6
  237. simtools/utils/general.py +18 -27
  238. simtools/utils/names.py +32 -10
  239. simtools/visualization/plot_array_layout.py +242 -0
  240. simtools/visualization/plot_pixels.py +681 -0
  241. simtools/visualization/visualize.py +5 -221
  242. simtools/applications/production_generate_simulation_config.py +0 -162
  243. simtools/applications/production_scale_events.py +0 -185
  244. simtools/layout/ctao_array_layouts.py +0 -172
  245. simtools/production_configuration/event_scaler.py +0 -120
  246. simtools/production_configuration/generate_simulation_config.py +0 -158
  247. {gammasimtools-0.15.0.dist-info → gammasimtools-0.17.0.dist-info}/licenses/LICENSE +0 -0
  248. {gammasimtools-0.15.0.dist-info → gammasimtools-0.17.0.dist-info}/top_level.txt +0 -0
@@ -8,24 +8,16 @@ from collections import OrderedDict
8
8
  from pathlib import Path
9
9
 
10
10
  import astropy.units as u
11
- import matplotlib.patches as mpatches
12
11
  import matplotlib.pyplot as plt
13
- from astropy.table import Column, QTable
12
+ from astropy.table import QTable
14
13
  from cycler import cycler
15
14
  from matplotlib import gridspec
16
- from matplotlib.collections import PatchCollection
17
-
18
- from simtools.utils import geometry as transf
19
- from simtools.utils import names
20
- from simtools.visualization import legend_handlers as leg_h
21
15
 
22
16
  __all__ = [
23
17
  "get_colors",
24
18
  "get_lines",
25
19
  "get_markers",
26
- "get_telescope_patch",
27
20
  "plot_1d",
28
- "plot_array",
29
21
  "plot_hist_2d",
30
22
  "plot_table",
31
23
  "save_figure",
@@ -635,222 +627,14 @@ def plot_hist_2d(data, **kwargs):
635
627
  return fig
636
628
 
637
629
 
638
- @u.quantity_input(x=u.m, y=u.m, radius=u.m)
639
- def get_telescope_patch(name, x, y, radius):
640
- """
641
- Collect the patch of one telescope to be plotted by plot_array.
642
-
643
- Parameters
644
- ----------
645
- name: str
646
- Name of the telescope (type).
647
- x: astropy.units.Quantity
648
- x position of the telescope usually in meters.
649
- y: astropy.units.Quantity
650
- y position of the telescope usually in meters.
651
- radius: astropy.units.Quantity
652
- Radius of the telescope sphere usually in meters.
653
-
654
- Returns
655
- -------
656
- patch
657
- Instance of mpatches.Circle.
658
- """
659
- tel_obj = leg_h.TelescopeHandler()
660
- valid_name = names.get_array_element_type_from_name(name)
661
- fill_flag = False
662
-
663
- x = x.to(u.m)
664
- y = y.to(u.m)
665
- radius = radius.to(u.m)
666
-
667
- if valid_name.startswith("MST"):
668
- fill_flag = True
669
- if valid_name == "SCTS":
670
- patch = mpatches.Rectangle(
671
- ((x - radius / 2).value, (y - radius / 2).value),
672
- width=radius.value,
673
- height=radius.value,
674
- fill=False,
675
- color=tel_obj.colors_dict["SCTS"],
676
- )
677
- else:
678
- patch = mpatches.Circle(
679
- (x.value, y.value),
680
- radius=radius.value,
681
- fill=fill_flag,
682
- color=tel_obj.colors_dict[valid_name],
683
- )
684
- return patch
685
-
686
-
687
- @u.quantity_input(rotate_angle=u.deg)
688
- def plot_array(
689
- telescopes, rotate_angle=0, show_tel_label=False, axes_range=None, marker_scaling=1.0
690
- ):
691
- """
692
- Plot the array of telescopes.
693
-
694
- The x axis gives the easting direction and y axis gives the northing direction.
695
- Note that in order to convert from the CORSIKA coordinate system to the 'conventional' system
696
- of North/East, a 90 degree rotation is always applied.
697
- Rotation of the array elements is possible through the 'rotate_angle' given either in degrees,
698
- or in radians.
699
- The direction of rotation of the array elements is counterclockwise.
700
- The rotation does not change Telescope instance attributes.
701
-
702
- Parameters
703
- ----------
704
- telescopes: astropy.table
705
- Table with the telescope position and names. Note the orientation of the axes.
706
- rotate_angle:
707
- Angle to rotate the plot. For rotate_angle = 0 the resulting plot will have
708
- the x-axis pointing towards the east, and the y-axis pointing towards the North.
709
- show_tel_label: bool
710
- If True it will print the label of the individual telescopes in the plot.
711
- While it works well for the smaller arrays, it gets crowded for larger arrays.
712
- axes_range : float
713
- Axis range for both axes. Range is from -plot_range to plot_range.
714
- maker_scaling : float
715
- Scaling factor for marker size to be plotted.
716
-
717
- Returns
718
- -------
719
- plt.figure
720
- Instance of plt.figure with the array of telescopes plotted.
721
- """
722
- fig, ax = plt.subplots(1)
723
- legend_objects = []
724
- legend_labels = []
725
- tel_counters = initialize_tel_counters()
726
-
727
- pos_x_rotated, pos_y_rotated = get_rotated_positions(telescopes, rotate_angle)
728
- telescopes.add_column(Column(pos_x_rotated, name="pos_x_rotated"))
729
- telescopes.add_column(Column(pos_y_rotated, name="pos_y_rotated"))
730
-
731
- fontsize, scale = get_plot_params(len(pos_x_rotated))
732
- patches = create_patches(
733
- telescopes, scale, marker_scaling, show_tel_label, ax, fontsize, tel_counters
734
- )
735
-
736
- update_legend(ax, tel_counters, legend_objects, legend_labels)
737
- finalize_plot(ax, patches, x_title="Easting [m]", y_title="Northing [m]", axes_range=axes_range)
738
-
739
- return fig
740
-
741
-
742
- def initialize_tel_counters():
743
- return dict.fromkeys(names.get_list_of_array_element_types(), 0)
744
-
745
-
746
- def get_rotated_positions(telescopes, rotate_angle):
747
- pos_x_rotated = pos_y_rotated = None
748
- if "position_x" in telescopes.colnames and "position_y" in telescopes.colnames:
749
- pos_x_rotated, pos_y_rotated = telescopes["position_x"], telescopes["position_y"]
750
- rotate_angle = rotate_angle + 90.0 * u.deg
751
- elif "utm_east" in telescopes.colnames and "utm_north" in telescopes.colnames:
752
- pos_x_rotated, pos_y_rotated = telescopes["utm_east"], telescopes["utm_north"]
753
- else:
754
- raise ValueError(
755
- "Telescopes table must contain either 'position_x'/'position_y'"
756
- "or 'utm_east'/'utm_north' columns"
757
- )
758
- if rotate_angle != 0:
759
- pos_x_rotated, pos_y_rotated = transf.rotate(pos_x_rotated, pos_y_rotated, rotate_angle)
760
- return pos_x_rotated, pos_y_rotated
761
-
762
-
763
- def get_plot_params(position_length):
764
- if position_length > 30:
765
- return 4, 2
766
- return 8, 1
767
-
768
-
769
- def create_patches(telescopes, scale, marker_scaling, show_tel_label, ax, fontsize, tel_counters):
770
- patches = []
771
- for tel_now in telescopes:
772
- telescope_name = get_telescope_name(tel_now)
773
- update_tel_counters(tel_counters, telescope_name)
774
- sphere_radius = get_sphere_radius(tel_now)
775
- i_tel_name = names.get_array_element_type_from_name(telescope_name)
776
- patches.append(
777
- get_telescope_patch(
778
- i_tel_name,
779
- tel_now["pos_x_rotated"],
780
- tel_now["pos_y_rotated"],
781
- scale * sphere_radius * marker_scaling,
782
- )
783
- )
784
- if show_tel_label:
785
- ax.text(
786
- tel_now["pos_x_rotated"].value,
787
- tel_now["pos_y_rotated"].value + scale * sphere_radius.value,
788
- telescope_name,
789
- horizontalalignment="center",
790
- verticalalignment="bottom",
791
- fontsize=fontsize,
792
- )
793
- return patches
794
-
795
-
796
- def get_telescope_name(tel_now):
797
- """Get the telescope name from the table row."""
798
- try:
799
- return tel_now["telescope_name"]
800
- except KeyError:
801
- return tel_now["asset_code"] + "-" + tel_now["sequence_number"]
802
-
803
-
804
- def update_tel_counters(tel_counters, telescope_name):
805
- """Update the counter for the given telescope type."""
806
- for tel_type in tel_counters:
807
- if tel_type in telescope_name:
808
- tel_counters[tel_type] += 1
809
-
810
-
811
- def get_sphere_radius(tel_now):
812
- """Get the sphere radius of the telescope."""
813
- return 1.0 * u.m if "sphere_radius" not in tel_now.colnames else tel_now["sphere_radius"]
814
-
815
-
816
- def update_legend(ax, tel_counters, legend_objects, legend_labels):
817
- """Update the legend with the telescope counts."""
818
- for one_telescope in names.get_list_of_array_element_types():
819
- if tel_counters[one_telescope] > 0:
820
- legend_objects.append(leg_h.all_telescope_objects[one_telescope]())
821
- legend_labels.append(f"{one_telescope} ({tel_counters[one_telescope]})")
822
- legend_handler_map = {k: v() for k, v in leg_h.legend_handler_map.items()}
823
- ax.legend(
824
- legend_objects,
825
- legend_labels,
826
- handler_map=legend_handler_map,
827
- prop={"size": 11},
828
- loc="best",
829
- )
830
-
831
-
832
- def finalize_plot(ax, patches, x_title, y_title, axes_range):
833
- """Finalize the plot by adding titles, setting limits, and adding patches."""
834
- ax.add_collection(PatchCollection(patches, match_original=True))
835
- ax.set_xlabel(x_title, fontsize=12, labelpad=0)
836
- ax.set_ylabel(y_title, fontsize=12, labelpad=0)
837
- ax.tick_params(axis="both", which="major", labelsize=8)
838
- ax.set_axisbelow(True)
839
- ax.axis("square")
840
- if axes_range is not None:
841
- ax.set_xlim(-axes_range, axes_range)
842
- ax.set_ylim(-axes_range, axes_range)
843
- plt.tight_layout()
844
-
845
-
846
630
  def plot_simtel_ctapipe(filename, cleaning_args, distance, return_cleaned=False):
847
631
  """
848
- Read in a simtel file and plots reconstructed photoelectrons via ctapipe.
632
+ Read in a sim_telarray file and plots reconstructed photoelectrons via ctapipe.
849
633
 
850
634
  Parameters
851
635
  ----------
852
636
  filename : str
853
- Path to the simtel file.
637
+ Path to the sim_telarray file.
854
638
  cleaning_args : tuple, optional
855
639
  Cleaning parameters as (boundary_thresh, picture_thresh, min_number_picture_neighbors).
856
640
  distance : astropy Quantity, optional
@@ -942,7 +726,7 @@ def plot_simtel_ctapipe(filename, cleaning_args, distance, return_cleaned=False)
942
726
  return fig
943
727
 
944
728
 
945
- def save_figure(fig, output_file, figure_format=None, log_title=""):
729
+ def save_figure(fig, output_file, figure_format=None, log_title="", dpi="figure"):
946
730
  """
947
731
  Save figure to output file(s).
948
732
 
@@ -960,7 +744,7 @@ def save_figure(fig, output_file, figure_format=None, log_title=""):
960
744
  figure_format = figure_format or ["pdf", "png"]
961
745
  for fmt in figure_format:
962
746
  _file = Path(output_file).with_suffix(f".{fmt}")
963
- fig.savefig(_file, format=fmt, bbox_inches="tight")
747
+ fig.savefig(_file, format=fmt, bbox_inches="tight", dpi=dpi)
964
748
  logging.info(f"Saved plot {log_title} to {_file}")
965
749
 
966
750
  fig.clf()
@@ -1,162 +0,0 @@
1
- #!/usr/bin/python3
2
-
3
- r"""
4
- Derive simulation configuration parameters for a simulation production.
5
-
6
- Derived simulation configuration parameters include:
7
-
8
- * energy range
9
- * shower core scatter radius
10
- * view cone radius
11
- * total number of events to be simulated
12
-
13
- Configuration parameters depend on characteristics of the observations, especially elevation,
14
- azimuth, and night sky background.
15
-
16
- The configuration parameters are derived according to the required precision. The metrics are:
17
-
18
- * statistical uncertainty on the determination of the effective area as function of primary energy
19
- * fraction of lost events to the selected core scatter and view cone radius (to be implemented)
20
- * statistical uncertainty of the energy migration matrix as function of primary energy
21
- (to be implemented)
22
-
23
- Command line arguments
24
- ----------------------
25
- azimuth (float, required)
26
- Azimuth angle in degrees.
27
- elevation (float, required)
28
- Elevation angle in degrees.
29
- nsb (float, required)
30
- Night sky background value.
31
- file_path (str, required)
32
- Path to file with MC events at CTAO DL2 data level.
33
- Used for statistical uncertainty evaluation.
34
- file_type (str, required)
35
- Type of the DL2 MC event file ('point-like' or 'cone').
36
- metrics (str, required)
37
- Path to a YAML file containing metrics for evaluation.
38
- site (str, required)
39
- The observatory site (North or South).
40
-
41
- Example
42
- -------
43
- To run the simulation configuration, execute the script as follows:
44
-
45
- .. code-block:: console
46
-
47
- simtools-production-generate-simulation-config --azimuth 60.0 --elevation 45.0 \
48
- --nsb 0.3 --file_path tests/resources/production_dl2_fits/dl2_mc_events_file.fits \
49
- --file_type "point-like" \
50
- --metrics_file tests/resources/production_simulation_config_metrics.yml --site North
51
-
52
- The output will show the derived simulation parameters.
53
- """
54
-
55
- import json
56
- import logging
57
- from pathlib import Path
58
-
59
- import astropy.units as u
60
-
61
- import simtools.utils.general as gen
62
- from simtools.configuration import configurator
63
- from simtools.data_model import schema
64
- from simtools.io_operations import io_handler
65
- from simtools.production_configuration.generate_simulation_config import (
66
- SimulationConfig,
67
- )
68
-
69
-
70
- def _parse(label):
71
- """Parse command-line arguments."""
72
- config = configurator.Configurator(
73
- label=label,
74
- description="Derive simulation configuration parameters for a simulation production.",
75
- )
76
- config.parser.add_argument(
77
- "--azimuth", type=float, required=True, help="Azimuth angle in degrees."
78
- )
79
- config.parser.add_argument(
80
- "--elevation", type=float, required=True, help="Elevation angle in degrees."
81
- )
82
- config.parser.add_argument(
83
- "--nsb", type=float, required=True, help="Night sky background in units of 1/(sr*ns*cm**2)."
84
- )
85
- config.parser.add_argument(
86
- "--file_path", type=str, required=True, help="Path to MC event file in DL2 format."
87
- )
88
- config.parser.add_argument(
89
- "--file_type",
90
- type=str,
91
- required=True,
92
- help="Type of the DL2 MC event file ('point-like' or 'cone').",
93
- )
94
- config.parser.add_argument(
95
- "--metrics_file",
96
- required=True,
97
- type=str,
98
- help="Path to YAML file containing metrics and required precision as values.",
99
- )
100
- config.parser.add_argument(
101
- "--site",
102
- type=str,
103
- required=True,
104
- help="Site location for the simulation (e.g., 'North', 'South').",
105
- )
106
- config.parser.add_argument(
107
- "--output_file",
108
- help="Name of the file to save the configured simulation parameters.",
109
- type=str,
110
- required=False,
111
- default="configured_simulation_params.json",
112
- )
113
-
114
- return config.initialize(db_config=False)
115
-
116
-
117
- def main():
118
- """Run the Simulation Config application."""
119
- label = Path(__file__).stem
120
- args_dict, _ = _parse(label)
121
-
122
- logger = logging.getLogger()
123
- logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
124
- output_path = io_handler.IOHandler().get_output_directory(label)
125
- output_filepath = Path(output_path).joinpath(f"{args_dict['output_file']}")
126
-
127
- grid_point_config = {
128
- "azimuth": args_dict["azimuth"],
129
- "elevation": args_dict["elevation"],
130
- "night_sky_background": args_dict["nsb"],
131
- }
132
-
133
- metrics = gen.collect_data_from_file(args_dict["metrics_file"])
134
- schema.validate_dict_using_schema(
135
- data=metrics, schema_file="production_configuration_metrics.schema.yml"
136
- )
137
-
138
- simulation_config = SimulationConfig(
139
- grid_point=grid_point_config,
140
- file_path=args_dict["file_path"],
141
- file_type=args_dict["file_type"],
142
- metrics=metrics,
143
- )
144
-
145
- simulation_params = simulation_config.configure_simulation()
146
-
147
- serializable_config = {}
148
-
149
- for key, value in simulation_params.items():
150
- if isinstance(value, u.Quantity):
151
- serializable_config[key] = f"{value.value} {value.unit}"
152
- else:
153
- serializable_config[key] = value
154
-
155
- logger.info(f"Simulation configuration: {serializable_config}")
156
- with open(output_filepath, "w", encoding="utf-8") as f:
157
- json.dump(serializable_config, f, indent=4)
158
- logger.info(f"Simulation configuration saved to: {output_filepath}")
159
-
160
-
161
- if __name__ == "__main__":
162
- main()
@@ -1,185 +0,0 @@
1
- #!/usr/bin/python3
2
-
3
- r"""
4
- Application to run the StatisticalErrorEvaluator and interpolate results.
5
-
6
- This application evaluates statistical uncertainties from DL2 MC event files
7
- based on input parameters like zenith angles and offsets, and performs interpolation
8
- for a specified query point.
9
-
10
- Command line arguments
11
- ----------------------
12
- base_path (str, required)
13
- Path to the directory containing the DL2 MC event file for interpolation.
14
- zeniths (list of int, required)
15
- List of zenith angles to consider.
16
- offsets (list of int, required)
17
- List of offsets in degrees.
18
- query_point (list of float, required)
19
- Query point for interpolation. The query point must contain exactly 5 values:
20
- - Energy (TeV)
21
- - Azimuth (degrees)
22
- - Zenith (degrees)
23
- - NSB (MHz)
24
- - Offset (degrees)
25
- output_file (str, optional)
26
- Output file to store the results. Default: 'interpolated_scaled_events.json'.
27
- metrics_file (str, optional)
28
- Path to the metrics definition file. Default: 'production_simulation_config_metrics.yml'.
29
- file_name_template (str, optional)
30
- Template for the file name. Default:
31
- 'prod6_LaPalma-{zenith}deg_gamma_cone.N.Am-4LSTs09MSTs_ID0_reduced.fits'.
32
-
33
- Example
34
- -------
35
- To evaluate statistical uncertainties and perform interpolation, run the command line script:
36
-
37
- .. code-block:: console
38
-
39
- simtools-production-scale-events --base_path tests/resources/production_dl2_fits/ \\
40
- --zeniths 20 40 52 60 --offsets 0 --query_point 1 180 30 0 0 \\
41
- --metrics_file "path/to/metrics.yaml" \\
42
- --output_file "output.json"
43
-
44
- The output will display the scaled events for the specified query point and save
45
- the results to the specified output file.
46
- """
47
-
48
- import itertools
49
- import json
50
- import logging
51
- from pathlib import Path
52
-
53
- import astropy.units as u
54
- import numpy as np
55
-
56
- import simtools.utils.general as gen
57
- from simtools.configuration import configurator
58
- from simtools.configuration.commandline_parser import CommandLineParser
59
- from simtools.io_operations import io_handler
60
- from simtools.production_configuration.calculate_statistical_errors_grid_point import (
61
- StatisticalErrorEvaluator,
62
- )
63
- from simtools.production_configuration.interpolation_handler import InterpolationHandler
64
-
65
-
66
- def _parse(label, description):
67
- """
68
- Parse command line arguments for the statistical error evaluator application.
69
-
70
- Returns
71
- -------
72
- argparse.Namespace
73
- Parsed command line arguments.
74
- """
75
- config = configurator.Configurator(label=label, description=description)
76
-
77
- config.parser.add_argument(
78
- "--base_path",
79
- type=str,
80
- required=True,
81
- help="Path to the DL2 MC event files for interpolation.",
82
- )
83
- config.parser.add_argument(
84
- "--zeniths",
85
- required=True,
86
- nargs="+",
87
- type=CommandLineParser.zenith_angle,
88
- help="List of zenith angles.",
89
- )
90
- config.parser.add_argument(
91
- "--offsets", required=True, nargs="+", type=float, help="List of offsets in degrees."
92
- )
93
-
94
- config.parser.add_argument(
95
- "--query_point",
96
- required=True,
97
- nargs=5,
98
- type=float,
99
- help="Grid point for interpolation (energy, azimuth, zenith, NSB, offset).",
100
- )
101
- config.parser.add_argument(
102
- "--output_file",
103
- required=False,
104
- type=str,
105
- default="interpolated_scaled_events.json",
106
- help="Output file to store the results. (default: 'interpolated_scaled_events.json').",
107
- )
108
- config.parser.add_argument(
109
- "--metrics_file",
110
- required=False,
111
- type=str,
112
- default="production_simulation_config_metrics.yml",
113
- help="Metrics definition file. (default: production_simulation_config_metrics.yml)",
114
- )
115
- config.parser.add_argument(
116
- "--file_name_template",
117
- required=False,
118
- type=str,
119
- default=("prod6_LaPalma-{zenith}deg_gamma_cone.N.Am-4LSTs09MSTs_ID0_reduced.fits"),
120
- help=(
121
- "Template for the file name. (default: "
122
- "'prod6_LaPalma-{zenith}deg_gamma_cone.N.Am-4LSTs09MSTs_ID0_reduced.fits')"
123
- ),
124
- )
125
- return config.initialize(db_config=False)
126
-
127
-
128
- def main():
129
- """Run the evaluator and interpolate."""
130
- label = Path(__file__).stem
131
- args_dict, _ = _parse(
132
- label,
133
- "Evaluate statistical uncertainties from DL2 MC event files and interpolate results.",
134
- )
135
- logger = logging.getLogger()
136
- logger.setLevel(logging.INFO)
137
- logger.info(f"args dict: {args_dict}")
138
-
139
- output_path = io_handler.IOHandler().get_output_directory(label)
140
- output_filepath = Path(output_path).joinpath(f"{args_dict['output_file']}")
141
-
142
- evaluator_instances = []
143
-
144
- metrics = gen.collect_data_from_file(args_dict["metrics_file"])
145
-
146
- if args_dict["base_path"] and args_dict["zeniths"] and args_dict["offsets"]:
147
- for zenith, offset in itertools.product(args_dict["zeniths"], args_dict["offsets"]):
148
- file_name = args_dict["file_name_template"].format(zenith=int(zenith.value))
149
- file_path = Path(args_dict["base_path"]).joinpath(file_name)
150
-
151
- if not file_path.exists():
152
- logger.warning(f"File not found: {file_path}. Skipping.")
153
- continue
154
-
155
- evaluator = StatisticalErrorEvaluator(
156
- file_path,
157
- file_type="Gamma-cone",
158
- metrics=metrics,
159
- grid_point=(1 * u.TeV, 180 * u.deg, zenith, 0, offset * u.deg),
160
- )
161
- evaluator.calculate_metrics()
162
- evaluator_instances.append(evaluator)
163
-
164
- else:
165
- logger.warning("No files read")
166
- logger.warning(f"Base Path: {args_dict['base_path']}")
167
- logger.warning(f"Zeniths: {args_dict['zeniths']}")
168
- logger.warning(f"Offsets: {args_dict['offsets']}")
169
-
170
- interpolation_handler = InterpolationHandler(evaluator_instances, metrics=metrics)
171
- query_points = np.array([args_dict["query_point"]])
172
- scaled_events = interpolation_handler.interpolate(query_points)
173
-
174
- output_data = {
175
- "query_point": args_dict["query_point"],
176
- "scaled_events": scaled_events.tolist(),
177
- }
178
- with open(output_filepath, "w", encoding="utf-8") as f:
179
- json.dump(output_data, f, indent=4)
180
- logger.info(f"Output saved to {output_filepath}")
181
- logger.info(f"Scaled events for grid point {args_dict['query_point']}: {scaled_events}")
182
-
183
-
184
- if __name__ == "__main__":
185
- main()