gammasimtools 0.21.0__py3-none-any.whl → 0.22.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {gammasimtools-0.21.0.dist-info → gammasimtools-0.22.0.dist-info}/METADATA +2 -3
- {gammasimtools-0.21.0.dist-info → gammasimtools-0.22.0.dist-info}/RECORD +311 -295
- {gammasimtools-0.21.0.dist-info → gammasimtools-0.22.0.dist-info}/entry_points.txt +2 -1
- 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 +3 -16
- simtools/applications/db_upload_model_repository.py +122 -0
- simtools/applications/derive_psf_parameters.py +13 -3
- 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 +1 -1
- simtools/applications/maintain_simulation_model_add_production.py +7 -31
- simtools/applications/merge_tables.py +1 -1
- simtools/applications/plot_array_layout.py +1 -2
- simtools/applications/print_version.py +1 -1
- 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 +1 -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 +58 -37
- simtools/db/db_model_upload.py +210 -5
- 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 +139 -106
- 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 +180 -73
- 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 +87 -13
- 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 +45 -14
- simtools/testing/configuration.py +4 -2
- simtools/testing/sim_telarray_metadata.py +4 -4
- simtools/utils/geometry.py +34 -0
- simtools/version.py +22 -0
- simtools/visualization/plot_psf.py +163 -61
- simtools/visualization/plot_simtel_events.py +1 -1
- simtools/model/flasher_model.py +0 -106
- {gammasimtools-0.21.0.dist-info → gammasimtools-0.22.0.dist-info}/WHEEL +0 -0
- {gammasimtools-0.21.0.dist-info → gammasimtools-0.22.0.dist-info}/licenses/LICENSE +0 -0
- {gammasimtools-0.21.0.dist-info → gammasimtools-0.22.0.dist-info}/top_level.txt +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Optical PSF plotting functions for parameter optimization visualization.
|
|
3
3
|
|
|
4
4
|
This module provides plotting functionality for PSF parameter optimization,
|
|
5
|
-
including parameter comparison plots, convergence plots, and
|
|
5
|
+
including parameter comparison plots, convergence plots, and PSF diameter vs off-axis plots.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
8
|
import logging
|
|
@@ -15,14 +15,36 @@ from matplotlib.backends.backend_pdf import PdfPages
|
|
|
15
15
|
from simtools.ray_tracing.ray_tracing import RayTracing
|
|
16
16
|
from simtools.visualization import visualize
|
|
17
17
|
|
|
18
|
-
logger = logging.getLogger(__name__)
|
|
19
|
-
|
|
20
18
|
# Constants
|
|
21
|
-
|
|
19
|
+
RADIUS = "Radius [cm]"
|
|
22
20
|
CUMULATIVE_PSF = "Cumulative PSF"
|
|
23
|
-
D80_CM_LABEL = "D80 (cm)"
|
|
24
21
|
MAX_OFFSET_DEFAULT = 4.5 # Maximum off-axis angle in degrees
|
|
25
22
|
OFFSET_STEPS_DEFAULT = 0.1 # Step size for off-axis angle sampling
|
|
23
|
+
DEFAULT_FRACTION = 0.8 # Default PSF containment fraction
|
|
24
|
+
|
|
25
|
+
logger = logging.getLogger(__name__)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def get_psf_diameter_label(fraction, unit="cm"):
|
|
29
|
+
"""
|
|
30
|
+
Generate PSF diameter label based on containment fraction.
|
|
31
|
+
|
|
32
|
+
Parameters
|
|
33
|
+
----------
|
|
34
|
+
fraction : float
|
|
35
|
+
PSF containment fraction (e.g., 0.8 for D80, 0.95 for D95)
|
|
36
|
+
unit : str, optional
|
|
37
|
+
Unit for the label (default: "cm")
|
|
38
|
+
|
|
39
|
+
Returns
|
|
40
|
+
-------
|
|
41
|
+
str
|
|
42
|
+
Formatted PSF diameter label (e.g., "D80 (cm)", "D95 (cm)", "D95")
|
|
43
|
+
"""
|
|
44
|
+
percentage = int(fraction * 100)
|
|
45
|
+
if unit:
|
|
46
|
+
return f"D{percentage} ({unit})"
|
|
47
|
+
return f"D{percentage}"
|
|
26
48
|
|
|
27
49
|
|
|
28
50
|
def get_significance_label(p_value):
|
|
@@ -34,16 +56,25 @@ def get_significance_label(p_value):
|
|
|
34
56
|
return "POOR" # null hypothesis rejected at 99% level
|
|
35
57
|
|
|
36
58
|
|
|
37
|
-
def _format_metric_text(
|
|
59
|
+
def _format_metric_text(
|
|
60
|
+
psf_diameter,
|
|
61
|
+
metric,
|
|
62
|
+
fraction=DEFAULT_FRACTION,
|
|
63
|
+
p_value=None,
|
|
64
|
+
use_ks_statistic=False,
|
|
65
|
+
second_metric=None,
|
|
66
|
+
):
|
|
38
67
|
"""
|
|
39
68
|
Format metric text for display in plots.
|
|
40
69
|
|
|
41
70
|
Parameters
|
|
42
71
|
----------
|
|
43
|
-
|
|
44
|
-
|
|
72
|
+
psf_diameter : float
|
|
73
|
+
PSF diameter value
|
|
45
74
|
metric : float
|
|
46
75
|
Primary metric value (RMSD or KS statistic)
|
|
76
|
+
fraction : float, optional
|
|
77
|
+
PSF containment fraction (default: 0.8)
|
|
47
78
|
p_value : float, optional
|
|
48
79
|
P-value from KS test
|
|
49
80
|
use_ks_statistic : bool
|
|
@@ -56,7 +87,8 @@ def _format_metric_text(d80, metric, p_value=None, use_ks_statistic=False, secon
|
|
|
56
87
|
str
|
|
57
88
|
Formatted metric text
|
|
58
89
|
"""
|
|
59
|
-
|
|
90
|
+
psf_label = get_psf_diameter_label(fraction, unit="")
|
|
91
|
+
psf_text = f"{psf_label} = {psf_diameter:.5f} cm"
|
|
60
92
|
|
|
61
93
|
# Create metric text based on the optimization method
|
|
62
94
|
if second_metric is not None:
|
|
@@ -73,7 +105,7 @@ def _format_metric_text(d80, metric, p_value=None, use_ks_statistic=False, secon
|
|
|
73
105
|
else:
|
|
74
106
|
metric_text = f"RMSD = {metric:.4f}"
|
|
75
107
|
|
|
76
|
-
return f"{
|
|
108
|
+
return f"{psf_text}\n{metric_text}"
|
|
77
109
|
|
|
78
110
|
|
|
79
111
|
def _create_base_plot_figure(data_to_plot, simulated_data=None):
|
|
@@ -129,8 +161,8 @@ def _build_parameter_title(pars, is_best):
|
|
|
129
161
|
|
|
130
162
|
def _add_metric_text_box(ax, metrics_text, is_best):
|
|
131
163
|
"""Add metric text box to plot."""
|
|
132
|
-
|
|
133
|
-
|
|
164
|
+
psf_color = "red" if is_best else "black"
|
|
165
|
+
psf_weight = "bold" if is_best else "normal"
|
|
134
166
|
|
|
135
167
|
ax.text(
|
|
136
168
|
0.5,
|
|
@@ -139,8 +171,8 @@ def _add_metric_text_box(ax, metrics_text, is_best):
|
|
|
139
171
|
verticalalignment="center",
|
|
140
172
|
horizontalalignment="left",
|
|
141
173
|
transform=ax.transAxes,
|
|
142
|
-
color=
|
|
143
|
-
weight=
|
|
174
|
+
color=psf_color,
|
|
175
|
+
weight=psf_weight,
|
|
144
176
|
bbox={"boxstyle": "round,pad=0.3", "facecolor": "yellow", "alpha": 0.7}
|
|
145
177
|
if is_best
|
|
146
178
|
else None,
|
|
@@ -148,7 +180,16 @@ def _add_metric_text_box(ax, metrics_text, is_best):
|
|
|
148
180
|
|
|
149
181
|
|
|
150
182
|
def _add_plot_annotations(
|
|
151
|
-
ax,
|
|
183
|
+
ax,
|
|
184
|
+
fig,
|
|
185
|
+
pars,
|
|
186
|
+
psf_diameter,
|
|
187
|
+
metric,
|
|
188
|
+
is_best,
|
|
189
|
+
fraction=DEFAULT_FRACTION,
|
|
190
|
+
p_value=None,
|
|
191
|
+
use_ks_statistic=False,
|
|
192
|
+
second_metric=None,
|
|
152
193
|
):
|
|
153
194
|
"""
|
|
154
195
|
Add title, text annotations, and best parameter indicators to plot.
|
|
@@ -161,12 +202,14 @@ def _add_plot_annotations(
|
|
|
161
202
|
The plot figure
|
|
162
203
|
pars : dict
|
|
163
204
|
Parameter set dictionary
|
|
164
|
-
|
|
165
|
-
|
|
205
|
+
psf_diameter : float
|
|
206
|
+
PSF diameter value
|
|
166
207
|
metric : float
|
|
167
208
|
Primary metric value
|
|
168
209
|
is_best : bool
|
|
169
210
|
Whether this is the best parameter set
|
|
211
|
+
fraction : float, optional
|
|
212
|
+
PSF containment fraction (default: 0.8)
|
|
170
213
|
p_value : float, optional
|
|
171
214
|
P-value from KS test
|
|
172
215
|
use_ks_statistic : bool
|
|
@@ -177,7 +220,9 @@ def _add_plot_annotations(
|
|
|
177
220
|
title = _build_parameter_title(pars, is_best)
|
|
178
221
|
ax.set_title(title)
|
|
179
222
|
|
|
180
|
-
metrics_text = _format_metric_text(
|
|
223
|
+
metrics_text = _format_metric_text(
|
|
224
|
+
psf_diameter, metric, fraction, p_value, use_ks_statistic, second_metric
|
|
225
|
+
)
|
|
181
226
|
_add_metric_text_box(ax, metrics_text, is_best)
|
|
182
227
|
|
|
183
228
|
if is_best:
|
|
@@ -194,10 +239,11 @@ def _add_plot_annotations(
|
|
|
194
239
|
def create_psf_parameter_plot(
|
|
195
240
|
data_to_plot,
|
|
196
241
|
pars,
|
|
197
|
-
|
|
242
|
+
psf_diameter,
|
|
198
243
|
metric,
|
|
199
244
|
is_best,
|
|
200
245
|
pdf_pages,
|
|
246
|
+
fraction=DEFAULT_FRACTION,
|
|
201
247
|
p_value=None,
|
|
202
248
|
use_ks_statistic=False,
|
|
203
249
|
second_metric=None,
|
|
@@ -211,14 +257,16 @@ def create_psf_parameter_plot(
|
|
|
211
257
|
Data dictionary for plotting.
|
|
212
258
|
pars : dict
|
|
213
259
|
Parameter set dictionary.
|
|
214
|
-
|
|
215
|
-
|
|
260
|
+
psf_diameter : float
|
|
261
|
+
PSF diameter value.
|
|
216
262
|
metric : float
|
|
217
263
|
RMSD value (if use_ks_statistic=False) or KS statistic (if use_ks_statistic=True).
|
|
218
264
|
is_best : bool
|
|
219
265
|
Whether this is the best parameter set.
|
|
220
266
|
pdf_pages : PdfPages
|
|
221
267
|
PDF pages object for saving plots.
|
|
268
|
+
fraction : float, optional
|
|
269
|
+
PSF containment fraction (default: 0.8).
|
|
222
270
|
p_value : float, optional
|
|
223
271
|
P-value from KS test (only used when use_ks_statistic=True).
|
|
224
272
|
use_ks_statistic : bool, optional
|
|
@@ -229,7 +277,16 @@ def create_psf_parameter_plot(
|
|
|
229
277
|
fig, ax = _create_base_plot_figure(data_to_plot)
|
|
230
278
|
|
|
231
279
|
_add_plot_annotations(
|
|
232
|
-
ax,
|
|
280
|
+
ax,
|
|
281
|
+
fig,
|
|
282
|
+
pars,
|
|
283
|
+
psf_diameter,
|
|
284
|
+
metric,
|
|
285
|
+
is_best,
|
|
286
|
+
fraction,
|
|
287
|
+
p_value,
|
|
288
|
+
use_ks_statistic,
|
|
289
|
+
second_metric,
|
|
233
290
|
)
|
|
234
291
|
|
|
235
292
|
pdf_pages.savefig(fig, bbox_inches="tight")
|
|
@@ -237,7 +294,15 @@ def create_psf_parameter_plot(
|
|
|
237
294
|
|
|
238
295
|
|
|
239
296
|
def create_detailed_parameter_plot(
|
|
240
|
-
pars,
|
|
297
|
+
pars,
|
|
298
|
+
ks_statistic,
|
|
299
|
+
psf_diameter,
|
|
300
|
+
simulated_data,
|
|
301
|
+
data_to_plot,
|
|
302
|
+
is_best,
|
|
303
|
+
pdf_pages,
|
|
304
|
+
fraction=DEFAULT_FRACTION,
|
|
305
|
+
p_value=None,
|
|
241
306
|
):
|
|
242
307
|
"""
|
|
243
308
|
Create a detailed plot for a parameter set showing all parameter values.
|
|
@@ -248,8 +313,8 @@ def create_detailed_parameter_plot(
|
|
|
248
313
|
Parameter set dictionary
|
|
249
314
|
ks_statistic : float
|
|
250
315
|
KS statistic value for this parameter set
|
|
251
|
-
|
|
252
|
-
|
|
316
|
+
psf_diameter : float
|
|
317
|
+
PSF diameter value for this parameter set
|
|
253
318
|
simulated_data : array
|
|
254
319
|
Simulated data for plotting
|
|
255
320
|
data_to_plot : dict
|
|
@@ -258,6 +323,8 @@ def create_detailed_parameter_plot(
|
|
|
258
323
|
Whether this is the best parameter set
|
|
259
324
|
pdf_pages : PdfPages
|
|
260
325
|
PDF pages object to save the plot
|
|
326
|
+
fraction : float, optional
|
|
327
|
+
PSF containment fraction (default: 0.8)
|
|
261
328
|
p_value : float, optional
|
|
262
329
|
P-value from KS test for statistical significance
|
|
263
330
|
"""
|
|
@@ -278,9 +345,10 @@ def create_detailed_parameter_plot(
|
|
|
278
345
|
ax,
|
|
279
346
|
fig,
|
|
280
347
|
pars,
|
|
281
|
-
|
|
348
|
+
psf_diameter,
|
|
282
349
|
ks_statistic,
|
|
283
350
|
is_best,
|
|
351
|
+
fraction,
|
|
284
352
|
p_value,
|
|
285
353
|
use_ks_statistic=True,
|
|
286
354
|
second_metric=None,
|
|
@@ -290,24 +358,28 @@ def create_detailed_parameter_plot(
|
|
|
290
358
|
plt.clf()
|
|
291
359
|
|
|
292
360
|
|
|
293
|
-
def create_parameter_progression_plots(
|
|
361
|
+
def create_parameter_progression_plots(
|
|
362
|
+
results, best_pars, data_to_plot, pdf_pages, fraction=DEFAULT_FRACTION
|
|
363
|
+
):
|
|
294
364
|
"""
|
|
295
365
|
Create plots for all parameter sets showing optimization progression.
|
|
296
366
|
|
|
297
367
|
Parameters
|
|
298
368
|
----------
|
|
299
369
|
results : list
|
|
300
|
-
List of (pars, ks_statistic, p_value,
|
|
370
|
+
List of (pars, ks_statistic, p_value, psf_diameter, simulated_data) tuples
|
|
301
371
|
best_pars : dict
|
|
302
372
|
Best parameter set for highlighting
|
|
303
373
|
data_to_plot : dict
|
|
304
374
|
Data dictionary for plotting
|
|
305
375
|
pdf_pages : PdfPages
|
|
306
376
|
PDF pages object to save plots
|
|
377
|
+
fraction : float, optional
|
|
378
|
+
PSF containment fraction (default: 0.8)
|
|
307
379
|
"""
|
|
308
380
|
logger.info("Creating plots for all parameter sets...")
|
|
309
381
|
|
|
310
|
-
for i, (pars, ks_statistic, p_value,
|
|
382
|
+
for i, (pars, ks_statistic, p_value, psf_diameter, simulated_data) in enumerate(results):
|
|
311
383
|
if simulated_data is None:
|
|
312
384
|
logger.warning(f"No simulated data for iteration {i}, skipping plot")
|
|
313
385
|
continue
|
|
@@ -316,24 +388,34 @@ def create_parameter_progression_plots(results, best_pars, data_to_plot, pdf_pag
|
|
|
316
388
|
logger.info(f"Creating plot {i + 1}/{len(results)}{' (BEST)' if is_best else ''}")
|
|
317
389
|
|
|
318
390
|
create_detailed_parameter_plot(
|
|
319
|
-
pars,
|
|
391
|
+
pars,
|
|
392
|
+
ks_statistic,
|
|
393
|
+
psf_diameter,
|
|
394
|
+
simulated_data,
|
|
395
|
+
data_to_plot,
|
|
396
|
+
is_best,
|
|
397
|
+
pdf_pages,
|
|
398
|
+
fraction,
|
|
399
|
+
p_value,
|
|
320
400
|
)
|
|
321
401
|
|
|
322
402
|
|
|
323
403
|
def create_gradient_descent_convergence_plot(
|
|
324
|
-
gd_results, threshold, output_file, use_ks_statistic=False
|
|
404
|
+
gd_results, threshold, output_file, fraction=DEFAULT_FRACTION, use_ks_statistic=False
|
|
325
405
|
):
|
|
326
406
|
"""
|
|
327
|
-
Create convergence plot
|
|
407
|
+
Create convergence plot during gradient descent.
|
|
328
408
|
|
|
329
409
|
Parameters
|
|
330
410
|
----------
|
|
331
411
|
gd_results : list
|
|
332
|
-
List of (params, metric, p_value,
|
|
412
|
+
List of (params, metric, p_value, psf_diameter, simulated_data) tuples from gradient descent
|
|
333
413
|
threshold : float
|
|
334
414
|
Optimization metric threshold used for convergence
|
|
335
415
|
output_file : Path
|
|
336
416
|
Output file path for saving the plot
|
|
417
|
+
fraction : float, optional
|
|
418
|
+
PSF containment fraction for labeling (default: 0.8)
|
|
337
419
|
use_ks_statistic : bool
|
|
338
420
|
Whether to use KS statistic or RMSD labels and titles
|
|
339
421
|
"""
|
|
@@ -349,9 +431,10 @@ def create_gradient_descent_convergence_plot(
|
|
|
349
431
|
|
|
350
432
|
iterations = list(range(len(gd_results)))
|
|
351
433
|
metrics = [r[1] for r in gd_results]
|
|
352
|
-
|
|
434
|
+
psf_diameters = [r[3] for r in gd_results]
|
|
353
435
|
|
|
354
436
|
metric_name = "KS Statistic" if use_ks_statistic else "RMSD"
|
|
437
|
+
psf_label = get_psf_diameter_label(fraction)
|
|
355
438
|
|
|
356
439
|
# Plot optimization metric progression
|
|
357
440
|
ax1.plot(iterations, metrics, "b.-", linewidth=2, markersize=6)
|
|
@@ -362,11 +445,11 @@ def create_gradient_descent_convergence_plot(
|
|
|
362
445
|
ax1.grid(True, alpha=0.3)
|
|
363
446
|
ax1.legend()
|
|
364
447
|
|
|
365
|
-
# Plot
|
|
366
|
-
ax2.plot(iterations,
|
|
448
|
+
# Plot PSF diameter progression
|
|
449
|
+
ax2.plot(iterations, psf_diameters, "g.-", linewidth=2, markersize=6)
|
|
367
450
|
ax2.set_xlabel("Iteration")
|
|
368
|
-
ax2.set_ylabel(
|
|
369
|
-
ax2.set_title("Gradient Descent Convergence -
|
|
451
|
+
ax2.set_ylabel(psf_label)
|
|
452
|
+
ax2.set_title(f"Gradient Descent Convergence - {get_psf_diameter_label(fraction, unit='')}")
|
|
370
453
|
ax2.grid(True, alpha=0.3)
|
|
371
454
|
|
|
372
455
|
# Plot p-value progression if available and using KS statistic
|
|
@@ -394,7 +477,9 @@ def create_gradient_descent_convergence_plot(
|
|
|
394
477
|
logger.info(f"Convergence plot saved to {output_file}")
|
|
395
478
|
|
|
396
479
|
|
|
397
|
-
def create_monte_carlo_uncertainty_plot(
|
|
480
|
+
def create_monte_carlo_uncertainty_plot(
|
|
481
|
+
mc_results, output_file, fraction=DEFAULT_FRACTION, use_ks_statistic=False
|
|
482
|
+
):
|
|
398
483
|
"""
|
|
399
484
|
Create uncertainty analysis plots showing optimization metric and p-value distributions.
|
|
400
485
|
|
|
@@ -402,9 +487,11 @@ def create_monte_carlo_uncertainty_plot(mc_results, output_file, use_ks_statisti
|
|
|
402
487
|
----------
|
|
403
488
|
mc_results : tuple
|
|
404
489
|
Results from Monte Carlo analysis: (mean_metric, std_metric, metric_values,
|
|
405
|
-
mean_p, std_p, p_values,
|
|
490
|
+
mean_p, std_p, p_values, mean_psf_diameter, std_psf_diameter, psf_diameter_values)
|
|
406
491
|
output_file : Path
|
|
407
492
|
Output file path for saving the plot
|
|
493
|
+
fraction : float, optional
|
|
494
|
+
PSF containment fraction for labeling (default: 0.8)
|
|
408
495
|
use_ks_statistic : bool, optional
|
|
409
496
|
Whether KS statistic mode is being used (affects filename suffix)
|
|
410
497
|
"""
|
|
@@ -415,9 +502,9 @@ def create_monte_carlo_uncertainty_plot(mc_results, output_file, use_ks_statisti
|
|
|
415
502
|
mean_p_value,
|
|
416
503
|
_, # std_p_value (unused)
|
|
417
504
|
p_values,
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
505
|
+
mean_psf_diameter,
|
|
506
|
+
std_psf_diameter,
|
|
507
|
+
psf_diameter_values,
|
|
421
508
|
) = mc_results
|
|
422
509
|
|
|
423
510
|
logger.info("Creating Monte Carlo uncertainty analysis plot...")
|
|
@@ -431,11 +518,13 @@ def create_monte_carlo_uncertainty_plot(mc_results, output_file, use_ks_statisti
|
|
|
431
518
|
# KS mode: 2x2 layout with all 4 plots
|
|
432
519
|
_, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, figsize=(12, 10), tight_layout=True)
|
|
433
520
|
else:
|
|
434
|
-
# RMSD mode: 1x2 layout with only metric and
|
|
521
|
+
# RMSD mode: 1x2 layout with only metric and PSF diameter plots
|
|
435
522
|
_, (ax1, ax3) = plt.subplots(1, 2, figsize=(12, 5), tight_layout=True)
|
|
436
523
|
|
|
437
524
|
# Metric histogram (KS statistic or RMSD)
|
|
438
525
|
metric_name = "KS Statistic" if is_ks_mode else "RMSD"
|
|
526
|
+
psf_label = get_psf_diameter_label(fraction)
|
|
527
|
+
|
|
439
528
|
ax1.hist(metric_values, bins=20, alpha=0.7, color="blue", edgecolor="black")
|
|
440
529
|
ax1.axvline(
|
|
441
530
|
mean_metric, color="red", linestyle="--", linewidth=2, label=f"Mean: {mean_metric:.6f}"
|
|
@@ -473,22 +562,26 @@ def create_monte_carlo_uncertainty_plot(mc_results, output_file, use_ks_statisti
|
|
|
473
562
|
ax2.legend()
|
|
474
563
|
ax2.grid(True, alpha=0.3)
|
|
475
564
|
|
|
476
|
-
#
|
|
477
|
-
ax3.hist(
|
|
565
|
+
# PSF diameter histogram
|
|
566
|
+
ax3.hist(psf_diameter_values, bins=20, alpha=0.7, color="green", edgecolor="black")
|
|
478
567
|
ax3.axvline(
|
|
479
|
-
|
|
568
|
+
mean_psf_diameter,
|
|
569
|
+
color="red",
|
|
570
|
+
linestyle="--",
|
|
571
|
+
linewidth=2,
|
|
572
|
+
label=f"Mean: {mean_psf_diameter:.4f} cm",
|
|
480
573
|
)
|
|
481
574
|
ax3.axvline(
|
|
482
|
-
|
|
575
|
+
mean_psf_diameter - std_psf_diameter,
|
|
483
576
|
color="orange",
|
|
484
577
|
linestyle=":",
|
|
485
578
|
alpha=0.7,
|
|
486
|
-
label=f"$\\sigma$: {
|
|
579
|
+
label=f"$\\sigma$: {std_psf_diameter:.4f} cm",
|
|
487
580
|
)
|
|
488
|
-
ax3.axvline(
|
|
489
|
-
ax3.set_xlabel(
|
|
581
|
+
ax3.axvline(mean_psf_diameter + std_psf_diameter, color="orange", linestyle=":", alpha=0.7)
|
|
582
|
+
ax3.set_xlabel(psf_label)
|
|
490
583
|
ax3.set_ylabel("Counts")
|
|
491
|
-
ax3.set_title("
|
|
584
|
+
ax3.set_title(f"{get_psf_diameter_label(fraction, unit='')} Distribution")
|
|
492
585
|
ax3.legend()
|
|
493
586
|
ax3.grid(True, alpha=0.3)
|
|
494
587
|
|
|
@@ -523,9 +616,9 @@ def create_monte_carlo_uncertainty_plot(mc_results, output_file, use_ks_statisti
|
|
|
523
616
|
logger.info(f"Monte Carlo uncertainty plot saved to {png_file}")
|
|
524
617
|
|
|
525
618
|
|
|
526
|
-
def
|
|
619
|
+
def create_psf_vs_offaxis_plot(tel_model, site_model, args_dict, best_pars, output_dir):
|
|
527
620
|
"""
|
|
528
|
-
Create
|
|
621
|
+
Create PSF diameter vs off-axis angle plot using the best parameters.
|
|
529
622
|
|
|
530
623
|
Parameters
|
|
531
624
|
----------
|
|
@@ -540,7 +633,11 @@ def create_d80_vs_offaxis_plot(tel_model, site_model, args_dict, best_pars, outp
|
|
|
540
633
|
output_dir : Path
|
|
541
634
|
Output directory for saving plots.
|
|
542
635
|
"""
|
|
543
|
-
|
|
636
|
+
fraction = args_dict.get("fraction", DEFAULT_FRACTION)
|
|
637
|
+
psf_label_cm = get_psf_diameter_label(fraction, unit="cm")
|
|
638
|
+
psf_label_deg = get_psf_diameter_label(fraction, unit="degrees")
|
|
639
|
+
|
|
640
|
+
logger.info(f"Creating {psf_label_cm} vs off-axis angle plot with best parameters...")
|
|
544
641
|
|
|
545
642
|
# Apply best parameters to telescope model
|
|
546
643
|
tel_model.change_multiple_parameters(**best_pars)
|
|
@@ -583,16 +680,19 @@ def create_d80_vs_offaxis_plot(tel_model, site_model, args_dict, best_pars, outp
|
|
|
583
680
|
)
|
|
584
681
|
plt.title(parameters_text)
|
|
585
682
|
plt.xlabel("Off-axis Angle (degrees)")
|
|
586
|
-
plt.ylabel(
|
|
683
|
+
plt.ylabel(psf_label_cm if "_cm" in key else psf_label_deg)
|
|
587
684
|
plt.ylim(bottom=0)
|
|
588
685
|
plt.xticks(rotation=45)
|
|
589
686
|
plt.xlim(0, max_offset)
|
|
590
687
|
plt.grid(True, alpha=0.3)
|
|
591
688
|
|
|
592
|
-
|
|
689
|
+
# Create dynamic file name based on fraction
|
|
690
|
+
psf_identifier = get_psf_diameter_label(fraction, unit="").lower() # e.g., "d80", "d95"
|
|
691
|
+
unit_suffix = "cm" if "_cm" in key else "deg"
|
|
692
|
+
plot_file_name = f"{tel_model.name}_best_params_{psf_identifier}_{unit_suffix}.png"
|
|
593
693
|
plot_file = output_dir.joinpath(plot_file_name)
|
|
594
694
|
visualize.save_figure(
|
|
595
|
-
plt, plot_file, figure_format=["png"], log_title=f"
|
|
695
|
+
plt, plot_file, figure_format=["png"], log_title=f"{psf_label_cm} vs off-axis ({key})"
|
|
596
696
|
)
|
|
597
697
|
|
|
598
698
|
plt.close("all")
|
|
@@ -638,7 +738,7 @@ def create_optimization_plots(args_dict, gd_results, tel_model, data_to_plot, ou
|
|
|
638
738
|
args_dict : dict
|
|
639
739
|
Dictionary containing command-line arguments with save_plots flag.
|
|
640
740
|
gd_results : list
|
|
641
|
-
List of (params, rmsd, _,
|
|
741
|
+
List of (params, rmsd, _, psf_diameter, _) tuples from gradient descent optimization.
|
|
642
742
|
tel_model : TelescopeModel
|
|
643
743
|
Telescope model object for naming files.
|
|
644
744
|
data_to_plot : dict
|
|
@@ -655,19 +755,21 @@ def create_optimization_plots(args_dict, gd_results, tel_model, data_to_plot, ou
|
|
|
655
755
|
if not args_dict.get("save_plots", False):
|
|
656
756
|
return
|
|
657
757
|
|
|
758
|
+
fraction = args_dict.get("fraction", DEFAULT_FRACTION)
|
|
658
759
|
pdf_filename = output_dir.joinpath(f"psf_optimization_results_{tel_model.name}.pdf")
|
|
659
760
|
pdf_pages = PdfPages(pdf_filename)
|
|
660
761
|
logger.info(f"Creating PSF plots for each optimization iteration (saving to {pdf_filename})")
|
|
661
762
|
|
|
662
|
-
for i, (params, rmsd, _,
|
|
763
|
+
for i, (params, rmsd, _, psf_diameter, _) in enumerate(gd_results):
|
|
663
764
|
if i % 5 == 0 or i == len(gd_results) - 1:
|
|
664
765
|
create_psf_parameter_plot(
|
|
665
766
|
data_to_plot,
|
|
666
767
|
params,
|
|
667
|
-
|
|
768
|
+
psf_diameter,
|
|
668
769
|
rmsd,
|
|
669
770
|
is_best=(i == len(gd_results) - 1),
|
|
670
771
|
pdf_pages=pdf_pages,
|
|
772
|
+
fraction=fraction,
|
|
671
773
|
use_ks_statistic=False,
|
|
672
774
|
)
|
|
673
775
|
pdf_pages.close()
|
|
@@ -840,7 +840,7 @@ def _plot_simtel_integrated_image(
|
|
|
840
840
|
|
|
841
841
|
def _make_output_paths(ioh, base, input_file):
|
|
842
842
|
"""Return (out_dir, pdf_path) based on base name and input file."""
|
|
843
|
-
out_dir = ioh.get_output_directory(
|
|
843
|
+
out_dir = ioh.get_output_directory()
|
|
844
844
|
pdf_path = ioh.get_output_file(f"{base}_{input_file.stem}" if base else input_file.stem)
|
|
845
845
|
pdf_path = Path(f"{pdf_path}.pdf") if Path(pdf_path).suffix != ".pdf" else Path(pdf_path)
|
|
846
846
|
return out_dir, pdf_path
|
simtools/model/flasher_model.py
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"""Definition and modeling of a flasher device."""
|
|
2
|
-
|
|
3
|
-
import logging
|
|
4
|
-
|
|
5
|
-
from simtools.model.model_parameter import ModelParameter
|
|
6
|
-
|
|
7
|
-
__all__ = ["FlasherModel"]
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class FlasherModel(ModelParameter):
|
|
11
|
-
"""
|
|
12
|
-
FlasherModel represents the MC model of an individual flasher device.
|
|
13
|
-
|
|
14
|
-
It provides functionality to read the required parameters from the DB.
|
|
15
|
-
Flasher devices are used for flat fielding of the camera pixels.
|
|
16
|
-
|
|
17
|
-
Parameters
|
|
18
|
-
----------
|
|
19
|
-
site: str
|
|
20
|
-
Site name (e.g., South or North).
|
|
21
|
-
flasher_device_model_name: str
|
|
22
|
-
Flasher device model name (ex. FLSN-01, FLSS-01, ...).
|
|
23
|
-
mongo_db_config: dict
|
|
24
|
-
MongoDB configuration.
|
|
25
|
-
model_version: str
|
|
26
|
-
Model version.
|
|
27
|
-
label: str, optional
|
|
28
|
-
Instance label. Important for output file naming.
|
|
29
|
-
"""
|
|
30
|
-
|
|
31
|
-
def __init__(
|
|
32
|
-
self,
|
|
33
|
-
site: str,
|
|
34
|
-
flasher_device_model_name: str,
|
|
35
|
-
mongo_db_config: dict,
|
|
36
|
-
model_version: str,
|
|
37
|
-
label: str | None = None,
|
|
38
|
-
):
|
|
39
|
-
# Minimal dummy DB to avoid real DB access
|
|
40
|
-
class _DummyDB: # pylint: disable=too-few-public-methods
|
|
41
|
-
def get_design_model(self, *_, **__):
|
|
42
|
-
return {}
|
|
43
|
-
|
|
44
|
-
def get_model_parameters(self, *_, **__):
|
|
45
|
-
return {}
|
|
46
|
-
|
|
47
|
-
def get_simulation_configuration_parameters(self, *_, **__):
|
|
48
|
-
return {}
|
|
49
|
-
|
|
50
|
-
def export_model_files(self, *_, **__):
|
|
51
|
-
return None
|
|
52
|
-
|
|
53
|
-
super().__init__(
|
|
54
|
-
site=site,
|
|
55
|
-
array_element_name=None, # bypass validation (no flasher in array_elements)
|
|
56
|
-
collection="flasher_devices",
|
|
57
|
-
mongo_db_config=mongo_db_config,
|
|
58
|
-
model_version=model_version,
|
|
59
|
-
db=_DummyDB(), # do not query DB
|
|
60
|
-
label=label,
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
self._logger = logging.getLogger(__name__)
|
|
64
|
-
self._logger.debug(f"Init FlasherModel {site} {flasher_device_model_name}")
|
|
65
|
-
|
|
66
|
-
# Keep provided flasher name for reference/logging only
|
|
67
|
-
self._flasher_device_model_name = flasher_device_model_name
|
|
68
|
-
|
|
69
|
-
# Inject defaults for MST (single-mirror) when DB entries are missing.
|
|
70
|
-
self._inject_mst_defaults_if_missing()
|
|
71
|
-
|
|
72
|
-
def _inject_mst_defaults_if_missing(self):
|
|
73
|
-
"""Provide dummy defaults (here NectarCam) when flasher collection is absent."""
|
|
74
|
-
defaults = {
|
|
75
|
-
"photons_per_flasher": {"value": 2.5e6, "type": "float"},
|
|
76
|
-
# Position near optical axis (cm)
|
|
77
|
-
"flasher_position": {
|
|
78
|
-
"value": [0.0, 0.0],
|
|
79
|
-
"unit": "cm,cm",
|
|
80
|
-
"type": "float_list",
|
|
81
|
-
},
|
|
82
|
-
# Distance flasher window to Winston cones (16.75 m)
|
|
83
|
-
"flasher_depth": {"value": 1675.0, "unit": "cm", "type": "float"},
|
|
84
|
-
# Received wavelength at PMT (nm)
|
|
85
|
-
"spectrum": {"value": 392, "unit": "nm", "type": "float"},
|
|
86
|
-
# Simple Gaussian pulse width (ns)
|
|
87
|
-
"lightpulse": {"value": "Gauss:3.0", "type": "string"},
|
|
88
|
-
# Store rise/decay for future use
|
|
89
|
-
"rise_time_10_90": {"value": 2.5, "unit": "ns", "type": "float"},
|
|
90
|
-
"decay_time_90_10": {"value": 5.0, "unit": "ns", "type": "float"},
|
|
91
|
-
# Angular distribution width ~11 deg around axis
|
|
92
|
-
"angular_distribution": {"value": "gauss:11", "type": "string"},
|
|
93
|
-
"centroid_offset_deg": {"value": 0.5, "unit": "deg", "type": "float"},
|
|
94
|
-
# Bunch size for LE
|
|
95
|
-
"bunch_size": {"value": 1.0, "type": "float"},
|
|
96
|
-
# Placeholder for future spectral file usage
|
|
97
|
-
"spectrum_file": {"value": None, "type": "string"},
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
missing = []
|
|
101
|
-
for key, entry in defaults.items():
|
|
102
|
-
if key not in self.parameters:
|
|
103
|
-
self.parameters[key] = entry
|
|
104
|
-
missing.append(key)
|
|
105
|
-
if missing:
|
|
106
|
-
self._logger.info(f"Using built-in MST flasher defaults for: {', '.join(missing)}")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|