gammasimtools 0.20.0__py3-none-any.whl → 0.22.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {gammasimtools-0.20.0.dist-info → gammasimtools-0.22.0.dist-info}/METADATA +2 -3
- {gammasimtools-0.20.0.dist-info → gammasimtools-0.22.0.dist-info}/RECORD +313 -296
- {gammasimtools-0.20.0.dist-info → gammasimtools-0.22.0.dist-info}/entry_points.txt +3 -2
- simtools/_version.py +2 -2
- simtools/applications/calculate_incident_angles.py +1 -4
- simtools/applications/convert_all_model_parameters_from_simtel.py +1 -2
- simtools/applications/convert_model_parameter_from_simtel.py +0 -1
- simtools/applications/db_generate_compound_indexes.py +4 -17
- simtools/applications/db_upload_model_repository.py +122 -0
- simtools/applications/derive_psf_parameters.py +71 -42
- simtools/applications/docs_produce_array_element_report.py +1 -1
- simtools/applications/docs_produce_calibration_reports.py +1 -1
- simtools/applications/docs_produce_model_parameter_reports.py +1 -1
- simtools/applications/docs_produce_simulation_configuration_report.py +1 -1
- simtools/applications/generate_corsika_histograms.py +8 -185
- simtools/applications/maintain_simulation_model_add_production.py +81 -0
- simtools/applications/merge_tables.py +1 -1
- simtools/applications/plot_array_layout.py +1 -2
- simtools/applications/plot_simtel_events.py +2 -228
- simtools/applications/print_version.py +8 -7
- simtools/applications/production_derive_statistics.py +1 -2
- simtools/applications/production_generate_grid.py +1 -1
- simtools/applications/simulate_flasher.py +74 -72
- simtools/applications/simulate_illuminator.py +52 -186
- simtools/applications/{simulate_calibration_events.py → simulate_pedestals.py} +9 -55
- simtools/applications/submit_model_parameter_from_external.py +0 -1
- simtools/applications/validate_camera_efficiency.py +0 -1
- simtools/applications/validate_camera_fov.py +1 -2
- simtools/applications/validate_cumulative_psf.py +2 -3
- simtools/applications/validate_file_using_schema.py +20 -12
- simtools/applications/validate_optics.py +2 -2
- simtools/camera/camera_efficiency.py +8 -11
- simtools/configuration/commandline_parser.py +1 -7
- simtools/configuration/configurator.py +0 -2
- simtools/corsika/corsika_config.py +9 -11
- simtools/corsika/corsika_histograms.py +82 -1
- simtools/data_model/model_data_writer.py +87 -25
- simtools/data_model/schema.py +61 -2
- simtools/data_model/validate_data.py +1 -1
- simtools/db/db_handler.py +103 -48
- simtools/db/db_model_upload.py +247 -16
- simtools/io/io_handler.py +31 -83
- simtools/job_execution/job_manager.py +45 -0
- simtools/layout/array_layout_utils.py +1 -5
- simtools/model/array_model.py +93 -42
- simtools/model/model_parameter.py +20 -9
- simtools/model/model_repository.py +197 -109
- simtools/model/model_utils.py +21 -6
- simtools/model/telescope_model.py +20 -0
- simtools/production_configuration/derive_corsika_limits.py +1 -1
- simtools/ray_tracing/incident_angles.py +7 -7
- simtools/ray_tracing/mirror_panel_psf.py +1 -1
- simtools/ray_tracing/psf_parameter_optimisation.py +1106 -565
- simtools/ray_tracing/ray_tracing.py +1 -3
- simtools/reporting/docs_read_parameters.py +171 -101
- simtools/resources/array_elements.yml +26 -0
- simtools/runners/corsika_simtel_runner.py +11 -17
- simtools/runners/runner_services.py +5 -6
- simtools/runners/simtools_runner.py +0 -2
- simtools/schemas/application_workflow.metaschema.yml +1 -1
- simtools/schemas/common_definitions.schema.yml +39 -0
- simtools/schemas/model_parameter.metaschema.yml +19 -13
- simtools/schemas/model_parameter_and_data_schema.metaschema.yml +6 -12
- simtools/schemas/model_parameters/adjust_gain.schema.yml +0 -5
- simtools/schemas/model_parameters/altitude.schema.yml +0 -5
- simtools/schemas/model_parameters/array_coordinates.schema.yml +0 -5
- simtools/schemas/model_parameters/array_coordinates_UTM.schema.yml +0 -5
- simtools/schemas/model_parameters/array_element_position_ground.schema.yml +0 -7
- simtools/schemas/model_parameters/array_element_position_utm.schema.yml +0 -7
- simtools/schemas/model_parameters/array_layouts.schema.yml +0 -5
- simtools/schemas/model_parameters/array_triggers.schema.yml +0 -5
- simtools/schemas/model_parameters/array_window.schema.yml +0 -7
- simtools/schemas/model_parameters/asum_clipping.schema.yml +0 -3
- simtools/schemas/model_parameters/asum_offset.schema.yml +0 -7
- simtools/schemas/model_parameters/asum_shaping.schema.yml +0 -7
- simtools/schemas/model_parameters/asum_threshold.schema.yml +0 -7
- simtools/schemas/model_parameters/atmospheric_profile.schema.yml +0 -5
- simtools/schemas/model_parameters/atmospheric_transmission.schema.yml +0 -5
- simtools/schemas/model_parameters/axes_offsets.schema.yml +0 -7
- simtools/schemas/model_parameters/calibration_devices.schema.yml +30 -0
- simtools/schemas/model_parameters/camera_body_diameter.schema.yml +0 -7
- simtools/schemas/model_parameters/camera_body_shape.schema.yml +0 -7
- simtools/schemas/model_parameters/camera_config_file.schema.yml +0 -7
- simtools/schemas/model_parameters/camera_config_rotate.schema.yml +0 -7
- simtools/schemas/model_parameters/camera_degraded_efficiency.schema.yml +0 -7
- simtools/schemas/model_parameters/camera_degraded_map.schema.yml +0 -7
- simtools/schemas/model_parameters/camera_depth.schema.yml +0 -7
- simtools/schemas/model_parameters/camera_filter.schema.yml +0 -7
- simtools/schemas/model_parameters/camera_filter_incidence_angle.schema.yml +0 -3
- simtools/schemas/model_parameters/camera_pixels.schema.yml +0 -7
- simtools/schemas/model_parameters/camera_transmission.schema.yml +0 -7
- simtools/schemas/model_parameters/channels_per_chip.schema.yml +0 -7
- simtools/schemas/model_parameters/correct_nsb_spectrum_to_telescope_altitude.schema.yml +0 -7
- simtools/schemas/model_parameters/corsika_observation_level.schema.yml +0 -5
- simtools/schemas/model_parameters/dark_events.schema.yml +4 -3
- simtools/schemas/model_parameters/default_trigger.schema.yml +0 -7
- simtools/schemas/model_parameters/design_model.schema.yml +0 -7
- simtools/schemas/model_parameters/disc_ac_coupled.schema.yml +0 -7
- simtools/schemas/model_parameters/disc_bins.schema.yml +0 -7
- simtools/schemas/model_parameters/disc_start.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_amplitude.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_fall_time.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_gate_length.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_hysteresis.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_output_amplitude.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_output_var_percent.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_pulse_shape.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_rise_time.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_scale_threshold.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_sigsum_over_threshold.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_threshold.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_time_over_threshold.schema.yml +1 -9
- simtools/schemas/model_parameters/discriminator_var_gate_length.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_var_sigsum_over_threshold.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_var_threshold.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_var_time_over_threshold.schema.yml +0 -7
- simtools/schemas/model_parameters/dish_shape_length.schema.yml +0 -5
- simtools/schemas/model_parameters/dsum_clipping.schema.yml +1 -5
- simtools/schemas/model_parameters/dsum_ignore_below.schema.yml +0 -3
- simtools/schemas/model_parameters/dsum_offset.schema.yml +0 -3
- simtools/schemas/model_parameters/dsum_pedsub.schema.yml +0 -3
- simtools/schemas/model_parameters/dsum_pre_clipping.schema.yml +0 -3
- simtools/schemas/model_parameters/dsum_prescale.schema.yml +0 -3
- simtools/schemas/model_parameters/dsum_presum_max.schema.yml +0 -3
- simtools/schemas/model_parameters/dsum_presum_shift.schema.yml +0 -3
- simtools/schemas/model_parameters/dsum_shaping.schema.yml +0 -3
- simtools/schemas/model_parameters/dsum_shaping_renormalize.schema.yml +0 -3
- simtools/schemas/model_parameters/dsum_threshold.schema.yml +2 -12
- simtools/schemas/model_parameters/dsum_zero_clip.schema.yml +0 -3
- simtools/schemas/model_parameters/effective_focal_length.schema.yml +0 -7
- simtools/schemas/model_parameters/epsg_code.schema.yml +0 -5
- simtools/schemas/model_parameters/fadc_ac_coupled.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_amplitude.schema.yml +2 -9
- simtools/schemas/model_parameters/fadc_bins.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_compensate_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_dev_pedestal.schema.yml +0 -2
- simtools/schemas/model_parameters/fadc_err_compensate_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_err_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_lg_amplitude.schema.yml +2 -9
- simtools/schemas/model_parameters/fadc_lg_compensate_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_lg_dev_pedestal.schema.yml +0 -2
- simtools/schemas/model_parameters/fadc_lg_err_compensate_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_lg_err_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_lg_max_signal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_lg_max_sum.schema.yml +0 -2
- simtools/schemas/model_parameters/fadc_lg_noise.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_lg_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_lg_sensitivity.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_lg_sysvar_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_lg_var_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_lg_var_sensitivity.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_long_event_threshold.schema.yml +0 -3
- simtools/schemas/model_parameters/fadc_long_sum_bins.schema.yml +0 -3
- simtools/schemas/model_parameters/fadc_long_sum_offset.schema.yml +0 -3
- simtools/schemas/model_parameters/fadc_max_signal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_max_sum.schema.yml +0 -2
- simtools/schemas/model_parameters/fadc_mhz.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_noise.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_pulse_shape.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_sensitivity.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_sum_bins.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_sum_offset.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_sysvar_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_var_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_var_sensitivity.schema.yml +0 -7
- simtools/schemas/model_parameters/fake_mirror_list.schema.yml +0 -3
- simtools/schemas/model_parameters/flasher_angular_distribution.schema.yml +32 -0
- simtools/schemas/model_parameters/flasher_angular_distribution_width.schema.yml +32 -0
- simtools/schemas/model_parameters/flasher_bunch_size.schema.yml +28 -0
- simtools/schemas/model_parameters/flasher_external_trigger.schema.yml +32 -0
- simtools/schemas/model_parameters/flasher_photons.schema.yml +34 -0
- simtools/schemas/model_parameters/flasher_position.schema.yml +43 -0
- simtools/schemas/model_parameters/flasher_pulse_exp_decay.schema.yml +29 -0
- simtools/schemas/model_parameters/flasher_pulse_offset.schema.yml +35 -0
- simtools/schemas/model_parameters/flasher_pulse_shape.schema.yml +30 -0
- simtools/schemas/model_parameters/flasher_pulse_width.schema.yml +32 -0
- simtools/schemas/model_parameters/flasher_type.schema.yml +28 -0
- simtools/schemas/model_parameters/flasher_var_photons.schema.yml +31 -0
- simtools/schemas/model_parameters/flasher_wavelength.schema.yml +33 -0
- simtools/schemas/model_parameters/flatfielding.schema.yml +0 -7
- simtools/schemas/model_parameters/focal_length.schema.yml +0 -7
- simtools/schemas/model_parameters/focal_surface_parameters.schema.yml +0 -3
- simtools/schemas/model_parameters/focal_surface_ref_radius.schema.yml +0 -3
- simtools/schemas/model_parameters/focus_offset.schema.yml +0 -7
- simtools/schemas/model_parameters/gain_variation.schema.yml +0 -7
- simtools/schemas/model_parameters/geomag_horizontal.schema.yml +2 -7
- simtools/schemas/model_parameters/geomag_rotation.schema.yml +2 -7
- simtools/schemas/model_parameters/geomag_vertical.schema.yml +2 -7
- simtools/schemas/model_parameters/hg_lg_variation.schema.yml +0 -5
- simtools/schemas/model_parameters/iobuf_maximum.schema.yml +0 -7
- simtools/schemas/model_parameters/iobuf_output_maximum.schema.yml +0 -7
- simtools/schemas/model_parameters/laser_events.schema.yml +4 -3
- simtools/schemas/model_parameters/laser_external_trigger.schema.yml +4 -3
- simtools/schemas/model_parameters/laser_photons.schema.yml +4 -3
- simtools/schemas/model_parameters/laser_pulse_exptime.schema.yml +4 -3
- simtools/schemas/model_parameters/laser_pulse_offset.schema.yml +4 -3
- simtools/schemas/model_parameters/laser_pulse_sigtime.schema.yml +4 -3
- simtools/schemas/model_parameters/laser_pulse_twidth.schema.yml +4 -3
- simtools/schemas/model_parameters/laser_var_photons.schema.yml +4 -3
- simtools/schemas/model_parameters/laser_wavelength.schema.yml +4 -3
- simtools/schemas/model_parameters/led_events.schema.yml +4 -3
- simtools/schemas/model_parameters/led_photons.schema.yml +4 -3
- simtools/schemas/model_parameters/led_pulse_offset.schema.yml +4 -3
- simtools/schemas/model_parameters/led_pulse_sigtime.schema.yml +4 -3
- simtools/schemas/model_parameters/led_var_photons.schema.yml +4 -3
- simtools/schemas/model_parameters/lightguide_efficiency_vs_incidence_angle.schema.yml +0 -7
- simtools/schemas/model_parameters/lightguide_efficiency_vs_wavelength.schema.yml +0 -7
- simtools/schemas/model_parameters/min_photoelectrons.schema.yml +0 -7
- simtools/schemas/model_parameters/min_photons.schema.yml +0 -7
- simtools/schemas/model_parameters/mirror_align_random_distance.schema.yml +0 -5
- simtools/schemas/model_parameters/mirror_align_random_horizontal.schema.yml +0 -7
- simtools/schemas/model_parameters/mirror_align_random_vertical.schema.yml +0 -7
- simtools/schemas/model_parameters/mirror_class.schema.yml +2 -9
- simtools/schemas/model_parameters/mirror_degraded_reflection.schema.yml +0 -7
- simtools/schemas/model_parameters/mirror_focal_length.schema.yml +0 -5
- simtools/schemas/model_parameters/mirror_list.schema.yml +0 -7
- simtools/schemas/model_parameters/mirror_offset.schema.yml +0 -7
- simtools/schemas/model_parameters/mirror_reflection_random_angle.schema.yml +0 -7
- simtools/schemas/model_parameters/mirror_reflectivity.schema.yml +0 -7
- simtools/schemas/model_parameters/multiplicity_offset.schema.yml +0 -7
- simtools/schemas/model_parameters/muon_mono_threshold.schema.yml +0 -7
- simtools/schemas/model_parameters/nsb_autoscale_airmass.schema.yml +0 -7
- simtools/schemas/model_parameters/nsb_gain_drop_scale.schema.yml +0 -3
- simtools/schemas/model_parameters/nsb_offaxis.schema.yml +0 -7
- simtools/schemas/model_parameters/nsb_pixel_rate.schema.yml +0 -7
- simtools/schemas/model_parameters/nsb_reference_spectrum.schema.yml +0 -5
- simtools/schemas/model_parameters/nsb_reference_value.schema.yml +0 -5
- simtools/schemas/model_parameters/nsb_scaling_factor.schema.yml +0 -5
- simtools/schemas/model_parameters/nsb_sky_map.schema.yml +0 -5
- simtools/schemas/model_parameters/nsb_spectrum.schema.yml +0 -5
- simtools/schemas/model_parameters/num_gains.schema.yml +0 -7
- simtools/schemas/model_parameters/only_triggered_telescopes.schema.yml +0 -7
- simtools/schemas/model_parameters/optics_properties.schema.yml +0 -7
- simtools/schemas/model_parameters/parabolic_dish.schema.yml +0 -3
- simtools/schemas/model_parameters/pedestal_events.schema.yml +4 -7
- simtools/schemas/model_parameters/photon_delay.schema.yml +0 -7
- simtools/schemas/model_parameters/photons_per_run.schema.yml +4 -4
- simtools/schemas/model_parameters/pixel_cells.schema.yml +0 -3
- simtools/schemas/model_parameters/pixels_parallel.schema.yml +0 -3
- simtools/schemas/model_parameters/pixeltrg_time_step.schema.yml +0 -7
- simtools/schemas/model_parameters/pm_average_gain.schema.yml +0 -5
- simtools/schemas/model_parameters/pm_collection_efficiency.schema.yml +0 -5
- simtools/schemas/model_parameters/pm_gain_index.schema.yml +0 -5
- simtools/schemas/model_parameters/pm_photoelectron_spectrum.schema.yml +0 -7
- simtools/schemas/model_parameters/pm_transit_time.schema.yml +4 -9
- simtools/schemas/model_parameters/pm_voltage_variation.schema.yml +0 -5
- simtools/schemas/model_parameters/primary_mirror_degraded_map.schema.yml +0 -7
- simtools/schemas/model_parameters/primary_mirror_diameter.schema.yml +0 -3
- simtools/schemas/model_parameters/primary_mirror_hole_diameter.schema.yml +0 -3
- simtools/schemas/model_parameters/primary_mirror_incidence_angle.schema.yml +0 -3
- simtools/schemas/model_parameters/primary_mirror_parameters.schema.yml +0 -3
- simtools/schemas/model_parameters/primary_mirror_ref_radius.schema.yml +0 -3
- simtools/schemas/model_parameters/primary_mirror_segmentation.schema.yml +0 -3
- simtools/schemas/model_parameters/qe_variation.schema.yml +0 -7
- simtools/schemas/model_parameters/quantum_efficiency.schema.yml +0 -7
- simtools/schemas/model_parameters/random_focal_length.schema.yml +2 -7
- simtools/schemas/model_parameters/random_generator.schema.yml +0 -7
- simtools/schemas/model_parameters/random_mono_probability.schema.yml +0 -7
- simtools/schemas/model_parameters/reference_point_altitude.schema.yml +0 -5
- simtools/schemas/model_parameters/reference_point_latitude.schema.yml +0 -5
- simtools/schemas/model_parameters/reference_point_longitude.schema.yml +0 -5
- simtools/schemas/model_parameters/reference_point_utm_east.schema.yml +0 -5
- simtools/schemas/model_parameters/reference_point_utm_north.schema.yml +0 -5
- simtools/schemas/model_parameters/sampled_output.schema.yml +0 -7
- simtools/schemas/model_parameters/save_pe_with_amplitude.schema.yml +0 -7
- simtools/schemas/model_parameters/secondary_mirror_baffle.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_degraded_map.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_degraded_reflection.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_diameter.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_hole_diameter.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_incidence_angle.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_parameters.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_ref_radius.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_reflectivity.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_segmentation.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_shadow_diameter.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_shadow_offset.schema.yml +0 -3
- simtools/schemas/model_parameters/stars.schema.yml +0 -5
- simtools/schemas/model_parameters/store_photoelectrons.schema.yml +0 -7
- simtools/schemas/model_parameters/tailcut_scale.schema.yml +0 -7
- simtools/schemas/model_parameters/telescope_axis_height.schema.yml +0 -7
- simtools/schemas/model_parameters/telescope_random_angle.schema.yml +0 -7
- simtools/schemas/model_parameters/telescope_random_error.schema.yml +0 -7
- simtools/schemas/model_parameters/telescope_sphere_radius.schema.yml +0 -7
- simtools/schemas/model_parameters/telescope_transmission.schema.yml +0 -7
- simtools/schemas/model_parameters/teltrig_min_sigsum.schema.yml +0 -7
- simtools/schemas/model_parameters/teltrig_min_time.schema.yml +0 -7
- simtools/schemas/model_parameters/transit_time_calib_error.schema.yml +0 -7
- simtools/schemas/model_parameters/transit_time_compensate_error.schema.yml +0 -7
- simtools/schemas/model_parameters/transit_time_compensate_step.schema.yml +0 -7
- simtools/schemas/model_parameters/transit_time_error.schema.yml +0 -7
- simtools/schemas/model_parameters/transit_time_jitter.schema.yml +0 -7
- simtools/schemas/model_parameters/trigger_current_limit.schema.yml +0 -7
- simtools/schemas/model_parameters/trigger_delay_compensation.schema.yml +0 -7
- simtools/schemas/model_parameters/trigger_pixels.schema.yml +0 -7
- simtools/schemas/production_tables.schema.yml +8 -8
- simtools/schemas/simulation_models_info.schema.yml +78 -0
- simtools/simtel/simtel_config_writer.py +88 -14
- simtools/simtel/simulator_array.py +44 -74
- simtools/simtel/simulator_light_emission.py +336 -629
- simtools/simtel/simulator_ray_tracing.py +2 -2
- simtools/simulator.py +46 -18
- simtools/testing/configuration.py +4 -2
- simtools/testing/sim_telarray_metadata.py +4 -4
- simtools/utils/geometry.py +34 -0
- simtools/version.py +111 -0
- simtools/{corsika/corsika_histograms_visualize.py → visualization/plot_corsika_histograms.py} +109 -0
- simtools/visualization/plot_psf.py +775 -0
- simtools/visualization/plot_simtel_events.py +284 -87
- simtools/applications/maintain_simulation_model_add_production_table.py +0 -71
- simtools/model/flasher_model.py +0 -106
- {gammasimtools-0.20.0.dist-info → gammasimtools-0.22.0.dist-info}/WHEEL +0 -0
- {gammasimtools-0.20.0.dist-info → gammasimtools-0.22.0.dist-info}/licenses/LICENSE +0 -0
- {gammasimtools-0.20.0.dist-info → gammasimtools-0.22.0.dist-info}/top_level.txt +0 -0
|
@@ -165,15 +165,11 @@ r"""
|
|
|
165
165
|
"""
|
|
166
166
|
|
|
167
167
|
import logging
|
|
168
|
-
import re
|
|
169
168
|
import time
|
|
170
169
|
from pathlib import Path
|
|
171
170
|
|
|
172
|
-
import numpy as np
|
|
173
|
-
|
|
174
171
|
import simtools.utils.general as gen
|
|
175
172
|
from simtools.configuration import configurator
|
|
176
|
-
from simtools.corsika import corsika_histograms_visualize
|
|
177
173
|
from simtools.corsika.corsika_histograms import CorsikaHistograms
|
|
178
174
|
from simtools.io import io_handler
|
|
179
175
|
|
|
@@ -284,141 +280,13 @@ def _parse(label, description):
|
|
|
284
280
|
return config_parser, _
|
|
285
281
|
|
|
286
282
|
|
|
287
|
-
def _plot_figures(corsika_histograms_instance, test=False):
|
|
288
|
-
"""
|
|
289
|
-
Auxiliary function to centralize the plotting functions.
|
|
290
|
-
|
|
291
|
-
Parameters
|
|
292
|
-
----------
|
|
293
|
-
corsika_histograms_instance: CorsikaHistograms instance.
|
|
294
|
-
The CorsikaHistograms instance created in main.
|
|
295
|
-
test: bool
|
|
296
|
-
If true plots the figures for the first two functions only.
|
|
297
|
-
"""
|
|
298
|
-
plot_function_names = [
|
|
299
|
-
plotting_method
|
|
300
|
-
for plotting_method in dir(corsika_histograms_visualize)
|
|
301
|
-
if plotting_method.startswith("plot_")
|
|
302
|
-
and "event_header_distribution" not in plotting_method
|
|
303
|
-
]
|
|
304
|
-
if test:
|
|
305
|
-
plot_function_names = plot_function_names[:2]
|
|
306
|
-
|
|
307
|
-
figure_list = []
|
|
308
|
-
for function_name in plot_function_names:
|
|
309
|
-
plot_function = getattr(corsika_histograms_visualize, function_name)
|
|
310
|
-
figures = plot_function(corsika_histograms_instance)
|
|
311
|
-
for fig in figures:
|
|
312
|
-
figure_list.append(fig)
|
|
313
|
-
|
|
314
|
-
figure_list = np.array(figure_list).flatten()
|
|
315
|
-
core_name = re.sub(r"\.hdf5$", "", corsika_histograms_instance.hdf5_file_name)
|
|
316
|
-
output_file_name = Path(corsika_histograms_instance.output_path).joinpath(f"{core_name}.pdf")
|
|
317
|
-
corsika_histograms_visualize.save_figs_to_pdf(figure_list, output_file_name)
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
def _derive_event_1d_histograms(
|
|
321
|
-
corsika_histograms_instance, event_1d_header_keys, pdf, hdf5, overwrite=False
|
|
322
|
-
):
|
|
323
|
-
"""
|
|
324
|
-
Auxiliary function to derive the histograms for the arguments given by event_1d_histograms.
|
|
325
|
-
|
|
326
|
-
Parameters
|
|
327
|
-
----------
|
|
328
|
-
corsika_histograms_instance: CorsikaHistograms instance.
|
|
329
|
-
The CorsikaHistograms instance created in main.
|
|
330
|
-
event_1d_header_keys: str
|
|
331
|
-
Generate 1D histograms for elements given in event_1d_header_keys from the CORSIKA event
|
|
332
|
-
header and save into hdf5/pdf files.
|
|
333
|
-
pdf: bool
|
|
334
|
-
If true, histograms are saved into a pdf file.
|
|
335
|
-
hdf5: bool
|
|
336
|
-
If true, histograms are saved into hdf5 files.
|
|
337
|
-
overwrite: bool
|
|
338
|
-
If true, overwrites the current output hdf5 file.
|
|
339
|
-
"""
|
|
340
|
-
figure_list = []
|
|
341
|
-
for event_header_element in event_1d_header_keys:
|
|
342
|
-
if pdf:
|
|
343
|
-
figure = corsika_histograms_visualize.plot_1d_event_header_distribution(
|
|
344
|
-
corsika_histograms_instance, event_header_element
|
|
345
|
-
)
|
|
346
|
-
figure_list.append(figure)
|
|
347
|
-
if hdf5:
|
|
348
|
-
corsika_histograms_instance.export_event_header_1d_histogram(
|
|
349
|
-
event_header_element, bins=50, hist_range=None, overwrite=overwrite
|
|
350
|
-
)
|
|
351
|
-
if pdf:
|
|
352
|
-
figures_list = np.array(figure_list).flatten()
|
|
353
|
-
output_file_name = Path(corsika_histograms_instance.output_path).joinpath(
|
|
354
|
-
f"{corsika_histograms_instance.hdf5_file_name}_event_1d_histograms.pdf"
|
|
355
|
-
)
|
|
356
|
-
corsika_histograms_visualize.save_figs_to_pdf(figures_list, output_file_name)
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
def _derive_event_2d_histograms(
|
|
360
|
-
corsika_histograms_instance, event_2d_header_keys, pdf, hdf5, overwrite=False
|
|
361
|
-
):
|
|
362
|
-
"""
|
|
363
|
-
Auxiliary function to derive the histograms for the arguments given by event_1d_histograms.
|
|
364
|
-
|
|
365
|
-
If an odd number of event header keys are given, the last one is discarded.
|
|
366
|
-
|
|
367
|
-
Parameters
|
|
368
|
-
----------
|
|
369
|
-
corsika_histograms_instance: CorsikaHistograms instance.
|
|
370
|
-
The CorsikaHistograms instance created in main.
|
|
371
|
-
event_2d_header_keys: str
|
|
372
|
-
Generate 1D histograms for elements given in event_1d_header_keys from the CORSIKA event
|
|
373
|
-
header and save into hdf5/pdf files.
|
|
374
|
-
pdf: bool
|
|
375
|
-
If true, histograms are saved into a pdf file.
|
|
376
|
-
hdf5: bool
|
|
377
|
-
If true, histograms are saved into hdf5 files.
|
|
378
|
-
overwrite: bool
|
|
379
|
-
If true, overwrites the current output hdf5 file.
|
|
380
|
-
"""
|
|
381
|
-
figure_list = []
|
|
382
|
-
for i_event_header_element, _ in enumerate(event_2d_header_keys[::2]):
|
|
383
|
-
# [::2] to discard the last one in case an odd number of keys are passed
|
|
384
|
-
|
|
385
|
-
if len(event_2d_header_keys) % 2 == 1: # if odd number of keys
|
|
386
|
-
msg = (
|
|
387
|
-
"An odd number of keys was passed to generate 2D histograms."
|
|
388
|
-
"The last key is being ignored."
|
|
389
|
-
)
|
|
390
|
-
logger.warning(msg)
|
|
391
|
-
|
|
392
|
-
if pdf:
|
|
393
|
-
figure = corsika_histograms_visualize.plot_2d_event_header_distribution(
|
|
394
|
-
corsika_histograms_instance,
|
|
395
|
-
event_2d_header_keys[i_event_header_element],
|
|
396
|
-
event_2d_header_keys[i_event_header_element + 1],
|
|
397
|
-
)
|
|
398
|
-
figure_list.append(figure)
|
|
399
|
-
if hdf5:
|
|
400
|
-
corsika_histograms_instance.export_event_header_2d_histogram(
|
|
401
|
-
event_2d_header_keys[i_event_header_element],
|
|
402
|
-
event_2d_header_keys[i_event_header_element + 1],
|
|
403
|
-
bins=50,
|
|
404
|
-
hist_range=None,
|
|
405
|
-
overwrite=overwrite,
|
|
406
|
-
)
|
|
407
|
-
if pdf:
|
|
408
|
-
figures_list = np.array(figure_list).flatten()
|
|
409
|
-
output_file_name = Path(corsika_histograms_instance.output_path).joinpath(
|
|
410
|
-
f"{corsika_histograms_instance.hdf5_file_name}_event_2d_histograms.pdf"
|
|
411
|
-
)
|
|
412
|
-
corsika_histograms_visualize.save_figs_to_pdf(figures_list, output_file_name)
|
|
413
|
-
|
|
414
|
-
|
|
415
283
|
def main(): # noqa: D103
|
|
416
284
|
label = Path(__file__).stem
|
|
417
285
|
description = "Generate histograms for the Cherenkov photons saved in the CORSIKA IACT file."
|
|
418
286
|
io_handler_instance = io_handler.IOHandler()
|
|
419
287
|
args_dict, _ = _parse(label, description)
|
|
420
288
|
|
|
421
|
-
output_path = io_handler_instance.get_output_directory(
|
|
289
|
+
output_path = io_handler_instance.get_output_directory()
|
|
422
290
|
|
|
423
291
|
logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
|
|
424
292
|
initial_time = time.time()
|
|
@@ -427,62 +295,17 @@ def main(): # noqa: D103
|
|
|
427
295
|
corsika_histograms_instance = CorsikaHistograms(
|
|
428
296
|
args_dict["iact_file"], output_path=output_path, hdf5_file_name=args_dict["hdf5_file_name"]
|
|
429
297
|
)
|
|
430
|
-
|
|
431
|
-
try:
|
|
432
|
-
indices = np.array(args_dict["telescope_indices"]).astype(int)
|
|
433
|
-
except ValueError:
|
|
434
|
-
msg = (
|
|
435
|
-
f"{args_dict['telescope_indices']} not a valid input. "
|
|
436
|
-
f"Please use integer numbers for telescope_indices"
|
|
437
|
-
)
|
|
438
|
-
logger.error(msg)
|
|
439
|
-
raise
|
|
440
|
-
else:
|
|
441
|
-
indices = None
|
|
442
|
-
# If the hdf5 output file already exists, the results are appended to it.
|
|
443
|
-
if (Path(corsika_histograms_instance.hdf5_file_name).exists()) and (
|
|
444
|
-
args_dict["hdf5"] or args_dict["event_1d_histograms"] or args_dict["event_2d_histograms"]
|
|
445
|
-
):
|
|
446
|
-
msg = (
|
|
447
|
-
f"Output hdf5 file {corsika_histograms_instance.hdf5_file_name} already exists. "
|
|
448
|
-
f"Overwriting it."
|
|
449
|
-
)
|
|
450
|
-
logger.warning(msg)
|
|
451
|
-
overwrite = True
|
|
452
|
-
else:
|
|
453
|
-
overwrite = False
|
|
454
|
-
corsika_histograms_instance.set_histograms(
|
|
455
|
-
telescope_indices=indices,
|
|
298
|
+
corsika_histograms_instance.run_export_pipeline(
|
|
456
299
|
individual_telescopes=args_dict["individual_telescopes"],
|
|
457
300
|
hist_config=args_dict["hist_config"],
|
|
301
|
+
indices_arg=args_dict["telescope_indices"],
|
|
302
|
+
write_pdf=args_dict["pdf"],
|
|
303
|
+
write_hdf5=args_dict["hdf5"],
|
|
304
|
+
event1d=args_dict["event_1d_histograms"],
|
|
305
|
+
event2d=args_dict["event_2d_histograms"],
|
|
306
|
+
test=args_dict["test"],
|
|
458
307
|
)
|
|
459
308
|
|
|
460
|
-
# Cherenkov photons
|
|
461
|
-
if args_dict["pdf"]:
|
|
462
|
-
_plot_figures(
|
|
463
|
-
corsika_histograms_instance=corsika_histograms_instance, test=args_dict["test"]
|
|
464
|
-
)
|
|
465
|
-
if args_dict["hdf5"]:
|
|
466
|
-
corsika_histograms_instance.export_histograms(overwrite=overwrite)
|
|
467
|
-
|
|
468
|
-
# Event information
|
|
469
|
-
if args_dict["event_1d_histograms"] is not None:
|
|
470
|
-
_derive_event_1d_histograms(
|
|
471
|
-
corsika_histograms_instance,
|
|
472
|
-
args_dict["event_1d_histograms"],
|
|
473
|
-
args_dict["pdf"],
|
|
474
|
-
args_dict["hdf5"],
|
|
475
|
-
overwrite=not args_dict["hdf5"],
|
|
476
|
-
)
|
|
477
|
-
if args_dict["event_2d_histograms"] is not None:
|
|
478
|
-
_derive_event_2d_histograms(
|
|
479
|
-
corsika_histograms_instance,
|
|
480
|
-
args_dict["event_2d_histograms"],
|
|
481
|
-
args_dict["pdf"],
|
|
482
|
-
args_dict["hdf5"],
|
|
483
|
-
overwrite=not (args_dict["hdf5"] or args_dict["event_1d_histograms"]),
|
|
484
|
-
)
|
|
485
|
-
|
|
486
309
|
final_time = time.time()
|
|
487
310
|
logger.info(
|
|
488
311
|
f"Finalizing the application. Total time needed: {round(final_time - initial_time)}s."
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
r"""
|
|
2
|
+
Generate a new simulation model production and update tables and model parameters.
|
|
3
|
+
|
|
4
|
+
This script is used to maintain the simulation model repository. It allows to create
|
|
5
|
+
new production tables by copying an existing base version and applies modifications
|
|
6
|
+
to production tables and model parameters as provided in a YAML file (see the example file below).
|
|
7
|
+
|
|
8
|
+
Two main use cases are covered by this script:
|
|
9
|
+
|
|
10
|
+
1. full update: Create a complete new set of production tables (e.g. for new major or minor
|
|
11
|
+
versions of the simulation models). This will copy all production tables from the source
|
|
12
|
+
directory and apply the modifications to the tables that are listed in the modifications file.
|
|
13
|
+
|
|
14
|
+
2. patch update: Create a set of new production tables including the changes defined in the
|
|
15
|
+
modifications file. No unmodified tables are copied. For new production tables with patch
|
|
16
|
+
modifications, the key-value pair 'base_model_version: <base_model version>' is added.
|
|
17
|
+
|
|
18
|
+
Both use cases will also apply the modifications to the model parameters as defined in the
|
|
19
|
+
modifications file.
|
|
20
|
+
|
|
21
|
+
Example
|
|
22
|
+
-------
|
|
23
|
+
|
|
24
|
+
The following example applies a patch update with changes defined in a YAML file.
|
|
25
|
+
|
|
26
|
+
.. code-block:: console
|
|
27
|
+
|
|
28
|
+
simtools-maintain-simulation-model-add-new-production \\
|
|
29
|
+
--simulation_models_path ../simulation-models-dev/simulation-models/ \\
|
|
30
|
+
--modifications tests/resources/production_tables_changes_for_threshold_study_6.2.0.yml
|
|
31
|
+
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
import logging
|
|
35
|
+
from pathlib import Path
|
|
36
|
+
|
|
37
|
+
import simtools.utils.general as gen
|
|
38
|
+
from simtools.configuration import configurator
|
|
39
|
+
from simtools.model import model_repository
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _parse(label, description):
|
|
43
|
+
"""
|
|
44
|
+
Parse command line arguments.
|
|
45
|
+
|
|
46
|
+
Returns
|
|
47
|
+
-------
|
|
48
|
+
dict
|
|
49
|
+
Parsed command-line arguments.
|
|
50
|
+
"""
|
|
51
|
+
config = configurator.Configurator(label=label, description=description)
|
|
52
|
+
config.parser.add_argument(
|
|
53
|
+
"--simulation_models_path",
|
|
54
|
+
type=str,
|
|
55
|
+
required=True,
|
|
56
|
+
help="Path to the simulation models repository.",
|
|
57
|
+
)
|
|
58
|
+
config.parser.add_argument(
|
|
59
|
+
"--modifications",
|
|
60
|
+
type=str,
|
|
61
|
+
required=True,
|
|
62
|
+
help="File containing the list of changes to apply.",
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
return config.initialize(db_config=False, output=False)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def main(): # noqa: D103
|
|
69
|
+
label = Path(__file__).stem
|
|
70
|
+
args_dict, _ = _parse(label=label, description="Generate a new simulation model production")
|
|
71
|
+
logger = logging.getLogger()
|
|
72
|
+
logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
|
|
73
|
+
|
|
74
|
+
model_repository.generate_new_production(
|
|
75
|
+
modifications=args_dict["modifications"],
|
|
76
|
+
simulation_models_path=Path(args_dict["simulation_models_path"]),
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
if __name__ == "__main__":
|
|
81
|
+
main()
|
|
@@ -88,7 +88,7 @@ def main(): # noqa: D103
|
|
|
88
88
|
args_dict["input_files"], [".hdf5", ".gz"]
|
|
89
89
|
)
|
|
90
90
|
|
|
91
|
-
output_path = io_handler.IOHandler().get_output_directory(
|
|
91
|
+
output_path = io_handler.IOHandler().get_output_directory()
|
|
92
92
|
output_filepath = Path(output_path).joinpath(f"{args_dict['output_file']}")
|
|
93
93
|
|
|
94
94
|
table_handler.merge_tables(
|
|
@@ -299,8 +299,7 @@ def main():
|
|
|
299
299
|
|
|
300
300
|
visualize.save_figure(
|
|
301
301
|
fig_out,
|
|
302
|
-
io_handler_instance.get_output_directory(
|
|
303
|
-
/ plot_file_name,
|
|
302
|
+
io_handler_instance.get_output_directory() / plot_file_name,
|
|
304
303
|
dpi=400,
|
|
305
304
|
)
|
|
306
305
|
plt.close()
|
|
@@ -81,87 +81,8 @@ from pathlib import Path
|
|
|
81
81
|
|
|
82
82
|
import simtools.utils.general as gen
|
|
83
83
|
from simtools.configuration import configurator
|
|
84
|
-
from simtools.corsika.corsika_histograms_visualize import save_figs_to_pdf
|
|
85
|
-
from simtools.data_model.metadata_collector import MetadataCollector
|
|
86
84
|
from simtools.io import io_handler
|
|
87
|
-
from simtools.visualization.plot_simtel_events import
|
|
88
|
-
plot_simtel_event_image,
|
|
89
|
-
plot_simtel_integrated_pedestal_image,
|
|
90
|
-
plot_simtel_integrated_signal_image,
|
|
91
|
-
plot_simtel_peak_timing,
|
|
92
|
-
plot_simtel_step_traces,
|
|
93
|
-
plot_simtel_time_traces,
|
|
94
|
-
plot_simtel_waveform_matrix,
|
|
95
|
-
)
|
|
96
|
-
|
|
97
|
-
PLOT_CHOICES = {
|
|
98
|
-
"event_image": "event_image",
|
|
99
|
-
"time_traces": "time_traces",
|
|
100
|
-
"waveform_matrix": "waveform_matrix",
|
|
101
|
-
"step_traces": "step_traces",
|
|
102
|
-
"integrated_signal_image": "integrated_signal_image",
|
|
103
|
-
"integrated_pedestal_image": "integrated_pedestal_image",
|
|
104
|
-
"peak_timing": "peak_timing",
|
|
105
|
-
"all": "all",
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
def _call_peak_timing(
|
|
110
|
-
filename,
|
|
111
|
-
*,
|
|
112
|
-
tel_id=None,
|
|
113
|
-
sum_threshold=10.0,
|
|
114
|
-
peak_width=8,
|
|
115
|
-
examples=3,
|
|
116
|
-
timing_bins=None,
|
|
117
|
-
event_index=None,
|
|
118
|
-
):
|
|
119
|
-
"""Call ``plot_simtel_peak_timing`` and support optional ``return_stats``.
|
|
120
|
-
|
|
121
|
-
Parameters
|
|
122
|
-
----------
|
|
123
|
-
filename : pathlib.Path or str
|
|
124
|
-
Path to the input simtel file.
|
|
125
|
-
tel_id : int, optional
|
|
126
|
-
Telescope ID to visualize.
|
|
127
|
-
sum_threshold : float, default 10.0
|
|
128
|
-
Minimum pixel sum to consider a pixel.
|
|
129
|
-
peak_width : int, default 8
|
|
130
|
-
Expected peak width in samples.
|
|
131
|
-
examples : int, default 3
|
|
132
|
-
Number of example traces to draw.
|
|
133
|
-
timing_bins : int or None, optional
|
|
134
|
-
Number of bins for timing histogram (contiguous if not set).
|
|
135
|
-
event_index : int or None, optional
|
|
136
|
-
0-based index of the event to plot; default is the first event.
|
|
137
|
-
|
|
138
|
-
Returns
|
|
139
|
-
-------
|
|
140
|
-
object or None
|
|
141
|
-
The matplotlib Figure if available, otherwise ``None``.
|
|
142
|
-
"""
|
|
143
|
-
try:
|
|
144
|
-
fig_stats = plot_simtel_peak_timing(
|
|
145
|
-
filename,
|
|
146
|
-
tel_id=tel_id,
|
|
147
|
-
sum_threshold=sum_threshold,
|
|
148
|
-
peak_width=peak_width,
|
|
149
|
-
examples=examples,
|
|
150
|
-
timing_bins=timing_bins,
|
|
151
|
-
return_stats=True,
|
|
152
|
-
event_index=event_index,
|
|
153
|
-
)
|
|
154
|
-
return fig_stats[0] if isinstance(fig_stats, tuple) else fig_stats
|
|
155
|
-
except TypeError:
|
|
156
|
-
return plot_simtel_peak_timing(
|
|
157
|
-
filename,
|
|
158
|
-
tel_id=tel_id,
|
|
159
|
-
sum_threshold=sum_threshold,
|
|
160
|
-
peak_width=peak_width,
|
|
161
|
-
examples=examples,
|
|
162
|
-
timing_bins=timing_bins,
|
|
163
|
-
event_index=event_index,
|
|
164
|
-
)
|
|
85
|
+
from simtools.visualization.plot_simtel_events import PLOT_CHOICES, generate_and_save_plots
|
|
165
86
|
|
|
166
87
|
|
|
167
88
|
def _parse(label: str):
|
|
@@ -186,7 +107,6 @@ def _parse(label: str):
|
|
|
186
107
|
default=["event_image"],
|
|
187
108
|
choices=sorted(PLOT_CHOICES),
|
|
188
109
|
)
|
|
189
|
-
# common plotting options
|
|
190
110
|
config.parser.add_argument("--tel_id", type=int, default=None, help="Telescope ID")
|
|
191
111
|
config.parser.add_argument(
|
|
192
112
|
"--n_pixels", type=int, default=3, help="For time_traces: number of pixel traces"
|
|
@@ -237,7 +157,6 @@ def _parse(label: str):
|
|
|
237
157
|
default=None,
|
|
238
158
|
help="0-based index of the event to plot; default is the first event",
|
|
239
159
|
)
|
|
240
|
-
# outputs
|
|
241
160
|
config.parser.add_argument(
|
|
242
161
|
"--output_file",
|
|
243
162
|
type=str,
|
|
@@ -257,123 +176,6 @@ def _parse(label: str):
|
|
|
257
176
|
return config.initialize(db_config=False, require_command_line=True)
|
|
258
177
|
|
|
259
178
|
|
|
260
|
-
def _save_png(fig, out_dir: Path, stem: str, suffix: str, dpi: int):
|
|
261
|
-
"""Save ``fig`` as a PNG into ``out_dir`` using ``stem`` and ``suffix``.
|
|
262
|
-
|
|
263
|
-
Errors during saving are logged as warnings and otherwise ignored.
|
|
264
|
-
"""
|
|
265
|
-
png_path = out_dir.joinpath(f"{stem}_{suffix}.png")
|
|
266
|
-
try:
|
|
267
|
-
fig.savefig(png_path, dpi=dpi, bbox_inches="tight")
|
|
268
|
-
except Exception as ex: # pylint:disable=broad-except
|
|
269
|
-
logging.getLogger(__name__).warning("Failed to save PNG %s: %s", png_path, ex)
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
def _make_output_paths(
|
|
273
|
-
ioh: io_handler.IOHandler, base: str | None, input_file: Path
|
|
274
|
-
) -> tuple[Path, Path]:
|
|
275
|
-
"""Return (out_dir, pdf_path) based on base and input_file."""
|
|
276
|
-
out_dir = ioh.get_output_directory(label=Path(__file__).stem)
|
|
277
|
-
if base:
|
|
278
|
-
pdf_path = ioh.get_output_file(f"{base}_{input_file.stem}")
|
|
279
|
-
else:
|
|
280
|
-
pdf_path = ioh.get_output_file(input_file.stem)
|
|
281
|
-
pdf_path = Path(f"{pdf_path}.pdf") if pdf_path.suffix != ".pdf" else Path(pdf_path)
|
|
282
|
-
return out_dir, pdf_path
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
def _collect_figures_for_file(
|
|
286
|
-
filename: Path,
|
|
287
|
-
plots: list[str],
|
|
288
|
-
args: dict,
|
|
289
|
-
out_dir: Path,
|
|
290
|
-
base_stem: str,
|
|
291
|
-
save_pngs: bool,
|
|
292
|
-
dpi: int,
|
|
293
|
-
):
|
|
294
|
-
"""Generate the selected plots for a single sim_telarray file.
|
|
295
|
-
|
|
296
|
-
Returns a list of figures. If ``save_pngs`` is True, also writes PNGs to
|
|
297
|
-
``out_dir`` using ``base_stem`` for filenames.
|
|
298
|
-
"""
|
|
299
|
-
logger = logging.getLogger(__name__)
|
|
300
|
-
figures: list[object] = []
|
|
301
|
-
|
|
302
|
-
def add(fig, tag: str):
|
|
303
|
-
if fig is not None:
|
|
304
|
-
figures.append(fig)
|
|
305
|
-
if save_pngs:
|
|
306
|
-
_save_png(fig, out_dir, base_stem, tag, dpi)
|
|
307
|
-
else:
|
|
308
|
-
logger.warning("Plot '%s' returned no figure for %s", tag, filename)
|
|
309
|
-
|
|
310
|
-
plots_to_run = (
|
|
311
|
-
[
|
|
312
|
-
"event_image",
|
|
313
|
-
"time_traces",
|
|
314
|
-
"waveform_matrix",
|
|
315
|
-
"step_traces",
|
|
316
|
-
"integrated_signal_image",
|
|
317
|
-
"integrated_pedestal_image",
|
|
318
|
-
"peak_timing",
|
|
319
|
-
]
|
|
320
|
-
if "all" in plots
|
|
321
|
-
else list(plots)
|
|
322
|
-
)
|
|
323
|
-
|
|
324
|
-
# function name -> (callable, defaults)
|
|
325
|
-
dispatch: dict[str, tuple[object, dict[str, object]]] = {
|
|
326
|
-
"event_image": (
|
|
327
|
-
plot_simtel_event_image,
|
|
328
|
-
{"distance": None, "event_index": None},
|
|
329
|
-
),
|
|
330
|
-
"time_traces": (
|
|
331
|
-
plot_simtel_time_traces,
|
|
332
|
-
{"tel_id": None, "n_pixels": 3, "event_index": None},
|
|
333
|
-
),
|
|
334
|
-
"waveform_matrix": (
|
|
335
|
-
plot_simtel_waveform_matrix,
|
|
336
|
-
{"tel_id": None, "vmax": None, "event_index": None},
|
|
337
|
-
),
|
|
338
|
-
"step_traces": (
|
|
339
|
-
plot_simtel_step_traces,
|
|
340
|
-
{"tel_id": None, "pixel_step": None, "max_pixels": None, "event_index": None},
|
|
341
|
-
),
|
|
342
|
-
"integrated_signal_image": (
|
|
343
|
-
plot_simtel_integrated_signal_image,
|
|
344
|
-
{"tel_id": None, "half_width": 8, "event_index": None},
|
|
345
|
-
),
|
|
346
|
-
"integrated_pedestal_image": (
|
|
347
|
-
plot_simtel_integrated_pedestal_image,
|
|
348
|
-
{"tel_id": None, "half_width": 8, "offset": 16, "event_index": None},
|
|
349
|
-
),
|
|
350
|
-
"peak_timing": (
|
|
351
|
-
_call_peak_timing,
|
|
352
|
-
{
|
|
353
|
-
"tel_id": None,
|
|
354
|
-
"sum_threshold": 10.0,
|
|
355
|
-
"peak_width": 8,
|
|
356
|
-
"examples": 3,
|
|
357
|
-
"timing_bins": None,
|
|
358
|
-
"event_index": None,
|
|
359
|
-
},
|
|
360
|
-
),
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
for plot_name in plots_to_run:
|
|
364
|
-
entry = dispatch.get(plot_name)
|
|
365
|
-
if entry is None:
|
|
366
|
-
logger.warning("Unknown plot selection '%s'", plot_name)
|
|
367
|
-
continue
|
|
368
|
-
func, defaults = entry
|
|
369
|
-
# Build kwargs with user args overriding defaults
|
|
370
|
-
kwargs = {k: args.get(k, v) for k, v in defaults.items()}
|
|
371
|
-
fig = func(filename, **kwargs) # type: ignore[misc]
|
|
372
|
-
add(fig, plot_name)
|
|
373
|
-
|
|
374
|
-
return figures
|
|
375
|
-
|
|
376
|
-
|
|
377
179
|
def main():
|
|
378
180
|
"""Generate plots from sim_telarray files."""
|
|
379
181
|
label = Path(__file__).stem
|
|
@@ -383,38 +185,10 @@ def main():
|
|
|
383
185
|
logger.setLevel(gen.get_log_level_from_user(args.get("log_level", "INFO")))
|
|
384
186
|
|
|
385
187
|
ioh = io_handler.IOHandler()
|
|
386
|
-
|
|
387
188
|
simtel_files = [Path(p).expanduser() for p in gen.ensure_iterable(args["simtel_files"])]
|
|
388
189
|
plots = list(gen.ensure_iterable(args.get("plots")))
|
|
389
190
|
|
|
390
|
-
|
|
391
|
-
out_dir, pdf_path = _make_output_paths(ioh, args.get("output_file"), simtel)
|
|
392
|
-
figures = _collect_figures_for_file(
|
|
393
|
-
filename=simtel,
|
|
394
|
-
plots=plots,
|
|
395
|
-
args=args,
|
|
396
|
-
out_dir=out_dir,
|
|
397
|
-
base_stem=simtel.stem,
|
|
398
|
-
save_pngs=bool(args.get("save_pngs", False)),
|
|
399
|
-
dpi=int(args.get("dpi", 300)),
|
|
400
|
-
)
|
|
401
|
-
|
|
402
|
-
if not figures:
|
|
403
|
-
logger.warning("No figures produced for %s", simtel)
|
|
404
|
-
continue
|
|
405
|
-
|
|
406
|
-
# Save a multipage PDF
|
|
407
|
-
try:
|
|
408
|
-
save_figs_to_pdf(figures, pdf_path)
|
|
409
|
-
logger.info("Saved PDF: %s", pdf_path)
|
|
410
|
-
except Exception as ex: # pylint:disable=broad-except
|
|
411
|
-
logger.error("Failed to save PDF %s: %s", pdf_path, ex)
|
|
412
|
-
|
|
413
|
-
# Dump run metadata alongside PDF
|
|
414
|
-
try:
|
|
415
|
-
MetadataCollector.dump(args, pdf_path, add_activity_name=True)
|
|
416
|
-
except Exception as ex: # pylint:disable=broad-except
|
|
417
|
-
logger.warning("Failed to write metadata for %s: %s", pdf_path, ex)
|
|
191
|
+
generate_and_save_plots(simtel_files=simtel_files, plots=plots, args=args, ioh=ioh)
|
|
418
192
|
|
|
419
193
|
|
|
420
194
|
if __name__ == "__main__":
|
|
@@ -39,7 +39,7 @@ def _parse(label, description, usage):
|
|
|
39
39
|
"""
|
|
40
40
|
config = configurator.Configurator(label=label, description=description, usage=usage)
|
|
41
41
|
|
|
42
|
-
return config.initialize(db_config=True, output=True)
|
|
42
|
+
return config.initialize(db_config=True, output=True, require_command_line=False)
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
def main():
|
|
@@ -68,12 +68,13 @@ def main():
|
|
|
68
68
|
key, value = version_entry.split(": ", 1)
|
|
69
69
|
version_dict[key] = value
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
71
|
+
if not args_dict.get("output_file_from_default", False):
|
|
72
|
+
ascii_handler.write_data_to_file(
|
|
73
|
+
data=version_dict,
|
|
74
|
+
output_file=io_handler_instance.get_output_file(
|
|
75
|
+
args_dict.get("output_file", "simtools_version.json")
|
|
76
|
+
),
|
|
77
|
+
)
|
|
77
78
|
|
|
78
79
|
|
|
79
80
|
if __name__ == "__main__":
|
|
@@ -149,9 +149,8 @@ def main():
|
|
|
149
149
|
logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
|
|
150
150
|
|
|
151
151
|
_io_handler = io_handler.IOHandler()
|
|
152
|
-
output_path = _io_handler.get_output_directory(label, sub_dir="")
|
|
153
152
|
|
|
154
|
-
manager = ProductionStatisticsHandler(args_dict, output_path=
|
|
153
|
+
manager = ProductionStatisticsHandler(args_dict, output_path=_io_handler.get_output_directory())
|
|
155
154
|
manager.run()
|
|
156
155
|
|
|
157
156
|
|
|
@@ -157,7 +157,7 @@ def main():
|
|
|
157
157
|
_logger = logging.getLogger()
|
|
158
158
|
_logger.setLevel(logging.INFO)
|
|
159
159
|
|
|
160
|
-
output_path = io_handler.IOHandler().get_output_directory(
|
|
160
|
+
output_path = io_handler.IOHandler().get_output_directory()
|
|
161
161
|
output_filepath = Path(output_path).joinpath(f"{args_dict['output_file']}")
|
|
162
162
|
|
|
163
163
|
axes = load_axes(args_dict["axes"])
|