gammasimtools 0.6.1__py3-none-any.whl → 0.8.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gammasimtools-0.8.1.dist-info/METADATA +172 -0
- gammasimtools-0.8.1.dist-info/RECORD +346 -0
- {gammasimtools-0.6.1.dist-info → gammasimtools-0.8.1.dist-info}/WHEEL +1 -1
- gammasimtools-0.8.1.dist-info/entry_points.txt +31 -0
- simtools/_version.py +2 -2
- simtools/applications/calculate_trigger_rate.py +210 -0
- simtools/applications/convert_all_model_parameters_from_simtel.py +372 -0
- simtools/applications/{print_array_elements.py → convert_geo_coordinates_of_array_elements.py} +58 -63
- simtools/applications/convert_model_parameter_from_simtel.py +119 -0
- simtools/applications/{add_file_to_db.py → db_add_file_to_db.py} +70 -60
- simtools/applications/db_add_model_parameters_from_repository_to_db.py +184 -0
- simtools/applications/db_add_value_from_json_to_db.py +105 -0
- simtools/applications/db_development_tools/write_array_elements_positions_to_repository.py +180 -0
- simtools/applications/db_get_array_layouts_from_db.py +162 -0
- simtools/applications/{get_file_from_db.py → db_get_file_from_db.py} +30 -34
- simtools/applications/db_get_parameter_from_db.py +131 -0
- simtools/applications/db_inspect_databases.py +52 -0
- simtools/applications/derive_mirror_rnda.py +39 -255
- simtools/applications/derive_psf_parameters.py +441 -0
- simtools/applications/generate_array_config.py +82 -0
- simtools/applications/generate_corsika_histograms.py +52 -52
- simtools/applications/generate_default_metadata.py +5 -8
- simtools/applications/generate_regular_arrays.py +117 -0
- simtools/applications/generate_simtel_array_histograms.py +97 -56
- simtools/applications/plot_array_layout.py +345 -115
- simtools/applications/production_generate_simulation_config.py +158 -0
- simtools/applications/production_scale_events.py +168 -0
- simtools/applications/simulate_light_emission.py +478 -0
- simtools/applications/simulate_prod.py +97 -175
- simtools/applications/submit_data_from_external.py +9 -12
- simtools/applications/submit_model_parameter_from_external.py +122 -0
- simtools/applications/validate_camera_efficiency.py +35 -102
- simtools/applications/validate_camera_fov.py +20 -19
- simtools/applications/{compare_cumulative_psf.py → validate_cumulative_psf.py} +45 -44
- simtools/applications/validate_file_using_schema.py +113 -47
- simtools/applications/validate_optics.py +17 -22
- simtools/camera_efficiency.py +193 -202
- simtools/configuration/commandline_parser.py +384 -96
- simtools/configuration/configurator.py +55 -71
- simtools/constants.py +5 -5
- simtools/corsika/corsika_config.py +482 -342
- simtools/corsika/corsika_histograms.py +226 -204
- simtools/corsika/corsika_histograms_visualize.py +23 -24
- simtools/corsika/primary_particle.py +159 -0
- simtools/data_model/data_reader.py +25 -20
- simtools/data_model/format_checkers.py +52 -0
- simtools/data_model/metadata_collector.py +210 -184
- simtools/data_model/metadata_model.py +115 -37
- simtools/data_model/model_data_writer.py +335 -26
- simtools/data_model/validate_data.py +366 -154
- simtools/db/db_array_elements.py +130 -0
- simtools/db/db_from_repo_handler.py +106 -0
- simtools/db/db_handler.py +1246 -0
- simtools/io_operations/hdf5_handler.py +3 -1
- simtools/io_operations/io_handler.py +32 -57
- simtools/job_execution/job_manager.py +82 -69
- simtools/layout/array_layout.py +325 -537
- simtools/layout/geo_coordinates.py +8 -11
- simtools/layout/telescope_position.py +163 -86
- simtools/model/array_model.py +305 -256
- simtools/model/calibration_model.py +50 -0
- simtools/model/camera.py +233 -493
- simtools/model/mirrors.py +61 -44
- simtools/model/model_parameter.py +602 -0
- simtools/model/model_utils.py +7 -35
- simtools/model/site_model.py +161 -0
- simtools/model/telescope_model.py +127 -621
- simtools/production_configuration/calculate_statistical_errors_grid_point.py +454 -0
- simtools/production_configuration/event_scaler.py +146 -0
- simtools/production_configuration/generate_simulation_config.py +193 -0
- simtools/production_configuration/interpolation_handler.py +197 -0
- simtools/ray_tracing/__init__.py +0 -0
- simtools/ray_tracing/mirror_panel_psf.py +280 -0
- simtools/{psf_analysis.py → ray_tracing/psf_analysis.py} +133 -47
- simtools/ray_tracing/ray_tracing.py +646 -0
- simtools/runners/__init__.py +0 -0
- simtools/runners/corsika_runner.py +240 -0
- simtools/runners/corsika_simtel_runner.py +225 -0
- simtools/runners/runner_services.py +307 -0
- simtools/runners/simtel_runner.py +224 -0
- simtools/schemas/array_elements.yml +137 -0
- simtools/schemas/integration_tests_config.metaschema.yml +93 -0
- simtools/schemas/metadata.metaschema.yml +6 -0
- simtools/schemas/model_parameter.metaschema.yml +78 -0
- simtools/schemas/{data.metaschema.yml → model_parameter_and_data_schema.metaschema.yml} +27 -44
- simtools/schemas/model_parameters/adjust_gain.schema.yml +37 -0
- simtools/schemas/model_parameters/altitude.schema.yml +37 -0
- simtools/schemas/model_parameters/array_coordinates.schema.yml +33 -0
- simtools/schemas/model_parameters/array_coordinates_UTM.schema.yml +77 -0
- simtools/schemas/model_parameters/array_element_position_ground.schema.yml +39 -0
- simtools/schemas/model_parameters/array_element_position_utm.schema.yml +39 -0
- simtools/schemas/model_parameters/array_layouts.schema.yml +48 -0
- simtools/schemas/model_parameters/array_triggers.schema.yml +93 -0
- simtools/schemas/model_parameters/asum_clipping.schema.yml +38 -0
- simtools/schemas/model_parameters/asum_offset.schema.yml +35 -0
- simtools/schemas/model_parameters/asum_shaping.schema.yml +35 -0
- simtools/schemas/model_parameters/asum_threshold.schema.yml +38 -0
- simtools/schemas/model_parameters/atmospheric_profile.schema.yml +32 -0
- simtools/schemas/model_parameters/atmospheric_transmission.schema.yml +35 -0
- simtools/schemas/model_parameters/axes_offsets.schema.yml +53 -0
- simtools/schemas/model_parameters/camera_body_diameter.schema.yml +40 -0
- simtools/schemas/model_parameters/camera_body_shape.schema.yml +45 -0
- simtools/schemas/model_parameters/camera_config_file.schema.yml +40 -0
- simtools/schemas/model_parameters/camera_config_rotate.schema.yml +36 -0
- simtools/schemas/model_parameters/camera_degraded_efficiency.schema.yml +43 -0
- simtools/schemas/model_parameters/camera_degraded_map.schema.yml +42 -0
- simtools/schemas/model_parameters/camera_depth.schema.yml +42 -0
- simtools/schemas/model_parameters/camera_filter.schema.yml +45 -0
- simtools/schemas/model_parameters/camera_filter_incidence_angle.schema.yml +29 -0
- simtools/schemas/model_parameters/camera_pixels.schema.yml +36 -0
- simtools/schemas/model_parameters/camera_transmission.schema.yml +41 -0
- simtools/schemas/model_parameters/channels_per_chip.schema.yml +36 -0
- simtools/schemas/model_parameters/correct_nsb_spectrum_to_telescope_altitude.schema.yml +35 -0
- simtools/schemas/model_parameters/corsika_cherenkov_photon_bunch_size.schema.yml +27 -0
- simtools/schemas/model_parameters/corsika_cherenkov_photon_wavelength_range.schema.yml +38 -0
- simtools/schemas/model_parameters/corsika_first_interaction_height.schema.yml +28 -0
- simtools/schemas/model_parameters/corsika_iact_io_buffer.schema.yml +23 -0
- simtools/schemas/model_parameters/corsika_iact_max_bunches.schema.yml +27 -0
- simtools/schemas/model_parameters/corsika_iact_split_auto.schema.yml +28 -0
- simtools/schemas/model_parameters/corsika_longitudinal_shower_development.schema.yml +27 -0
- simtools/schemas/model_parameters/corsika_observation_level.schema.yml +38 -0
- simtools/schemas/model_parameters/corsika_particle_kinetic_energy_cutoff.schema.yml +52 -0
- simtools/schemas/model_parameters/corsika_starting_grammage.schema.yml +27 -0
- simtools/schemas/model_parameters/dark_events.schema.yml +32 -0
- simtools/schemas/model_parameters/default_trigger.schema.yml +35 -0
- simtools/schemas/model_parameters/design_model.schema.yml +31 -0
- simtools/schemas/model_parameters/disc_ac_coupled.schema.yml +32 -0
- simtools/schemas/model_parameters/disc_bins.schema.yml +39 -0
- simtools/schemas/model_parameters/disc_start.schema.yml +41 -0
- simtools/schemas/model_parameters/discriminator_amplitude.schema.yml +42 -0
- simtools/schemas/model_parameters/discriminator_fall_time.schema.yml +41 -0
- simtools/schemas/model_parameters/discriminator_gate_length.schema.yml +41 -0
- simtools/schemas/model_parameters/discriminator_hysteresis.schema.yml +39 -0
- simtools/schemas/model_parameters/discriminator_output_amplitude.schema.yml +40 -0
- simtools/schemas/model_parameters/discriminator_output_var_percent.schema.yml +41 -0
- simtools/schemas/model_parameters/discriminator_pulse_shape.schema.yml +33 -0
- simtools/schemas/model_parameters/discriminator_rise_time.schema.yml +42 -0
- simtools/schemas/model_parameters/discriminator_scale_threshold.schema.yml +37 -0
- simtools/schemas/model_parameters/discriminator_sigsum_over_threshold.schema.yml +44 -0
- simtools/schemas/model_parameters/discriminator_threshold.schema.yml +36 -0
- simtools/schemas/model_parameters/discriminator_time_over_threshold.schema.yml +45 -0
- simtools/schemas/model_parameters/discriminator_var_gate_length.schema.yml +40 -0
- simtools/schemas/model_parameters/discriminator_var_sigsum_over_threshold.schema.yml +41 -0
- simtools/schemas/model_parameters/discriminator_var_threshold.schema.yml +38 -0
- simtools/schemas/model_parameters/discriminator_var_time_over_threshold.schema.yml +38 -0
- simtools/schemas/model_parameters/dish_shape_length.schema.yml +41 -0
- simtools/schemas/model_parameters/dsum_clipping.schema.yml +38 -0
- simtools/schemas/model_parameters/dsum_ignore_below.schema.yml +38 -0
- simtools/schemas/model_parameters/dsum_offset.schema.yml +37 -0
- simtools/schemas/model_parameters/dsum_pedsub.schema.yml +33 -0
- simtools/schemas/model_parameters/dsum_pre_clipping.schema.yml +39 -0
- simtools/schemas/model_parameters/dsum_prescale.schema.yml +44 -0
- simtools/schemas/model_parameters/dsum_presum_max.schema.yml +38 -0
- simtools/schemas/model_parameters/dsum_presum_shift.schema.yml +45 -0
- simtools/schemas/model_parameters/dsum_shaping.schema.yml +44 -0
- simtools/schemas/model_parameters/dsum_shaping_renormalize.schema.yml +32 -0
- simtools/schemas/model_parameters/dsum_threshold.schema.yml +43 -0
- simtools/schemas/model_parameters/dsum_zero_clip.schema.yml +42 -0
- simtools/schemas/model_parameters/effective_focal_length.schema.yml +61 -0
- simtools/schemas/model_parameters/epsg_code.schema.yml +37 -0
- simtools/schemas/model_parameters/fadc_ac_coupled.schema.yml +35 -0
- simtools/schemas/model_parameters/fadc_amplitude.schema.yml +46 -0
- simtools/schemas/model_parameters/fadc_bins.schema.yml +40 -0
- simtools/schemas/model_parameters/fadc_compensate_pedestal.schema.yml +50 -0
- simtools/schemas/model_parameters/fadc_dev_pedestal.schema.yml +38 -0
- simtools/schemas/model_parameters/fadc_err_compensate_pedestal.schema.yml +42 -0
- simtools/schemas/model_parameters/fadc_err_pedestal.schema.yml +49 -0
- simtools/schemas/model_parameters/fadc_lg_amplitude.schema.yml +47 -0
- simtools/schemas/model_parameters/fadc_lg_compensate_pedestal.schema.yml +51 -0
- simtools/schemas/model_parameters/fadc_lg_dev_pedestal.schema.yml +37 -0
- simtools/schemas/model_parameters/fadc_lg_err_compensate_pedestal.schema.yml +43 -0
- simtools/schemas/model_parameters/fadc_lg_err_pedestal.schema.yml +49 -0
- simtools/schemas/model_parameters/fadc_lg_max_signal.schema.yml +43 -0
- simtools/schemas/model_parameters/fadc_lg_max_sum.schema.yml +39 -0
- simtools/schemas/model_parameters/fadc_lg_noise.schema.yml +42 -0
- simtools/schemas/model_parameters/fadc_lg_pedestal.schema.yml +40 -0
- simtools/schemas/model_parameters/fadc_lg_sensitivity.schema.yml +50 -0
- simtools/schemas/model_parameters/fadc_lg_sysvar_pedestal.schema.yml +42 -0
- simtools/schemas/model_parameters/fadc_lg_var_pedestal.schema.yml +41 -0
- simtools/schemas/model_parameters/fadc_lg_var_sensitivity.schema.yml +42 -0
- simtools/schemas/model_parameters/fadc_max_signal.schema.yml +43 -0
- simtools/schemas/model_parameters/fadc_max_sum.schema.yml +39 -0
- simtools/schemas/model_parameters/fadc_mhz.schema.yml +31 -0
- simtools/schemas/model_parameters/fadc_noise.schema.yml +41 -0
- simtools/schemas/model_parameters/fadc_pedestal.schema.yml +40 -0
- simtools/schemas/model_parameters/fadc_pulse_shape.schema.yml +39 -0
- simtools/schemas/model_parameters/fadc_sensitivity.schema.yml +50 -0
- simtools/schemas/model_parameters/fadc_sum_bins.schema.yml +43 -0
- simtools/schemas/model_parameters/fadc_sum_offset.schema.yml +43 -0
- simtools/schemas/model_parameters/fadc_sysvar_pedestal.schema.yml +42 -0
- simtools/schemas/model_parameters/fadc_var_pedestal.schema.yml +41 -0
- simtools/schemas/model_parameters/fadc_var_sensitivity.schema.yml +42 -0
- simtools/schemas/model_parameters/flatfielding.schema.yml +37 -0
- simtools/schemas/model_parameters/focal_length.schema.yml +45 -0
- simtools/schemas/model_parameters/focal_surface_parameters.schema.yml +158 -0
- simtools/schemas/model_parameters/focal_surface_ref_radius.schema.yml +29 -0
- simtools/schemas/model_parameters/focus_offset.schema.yml +66 -0
- simtools/schemas/model_parameters/gain_variation.schema.yml +43 -0
- simtools/schemas/model_parameters/geomag_horizontal.schema.yml +34 -0
- simtools/schemas/model_parameters/geomag_rotation.schema.yml +37 -0
- simtools/schemas/model_parameters/geomag_vertical.schema.yml +34 -0
- simtools/schemas/model_parameters/hg_lg_variation.schema.yml +36 -0
- simtools/schemas/model_parameters/iobuf_maximum.schema.yml +34 -0
- simtools/schemas/model_parameters/iobuf_output_maximum.schema.yml +34 -0
- simtools/schemas/model_parameters/laser_events.schema.yml +36 -0
- simtools/schemas/model_parameters/laser_external_trigger.schema.yml +35 -0
- simtools/schemas/model_parameters/laser_photons.schema.yml +32 -0
- simtools/schemas/model_parameters/laser_pulse_exptime.schema.yml +34 -0
- simtools/schemas/model_parameters/laser_pulse_offset.schema.yml +34 -0
- simtools/schemas/model_parameters/laser_pulse_sigtime.schema.yml +33 -0
- simtools/schemas/model_parameters/laser_pulse_twidth.schema.yml +33 -0
- simtools/schemas/model_parameters/laser_var_photons.schema.yml +33 -0
- simtools/schemas/model_parameters/laser_wavelength.schema.yml +33 -0
- simtools/schemas/model_parameters/led_events.schema.yml +34 -0
- simtools/schemas/model_parameters/led_photons.schema.yml +34 -0
- simtools/schemas/model_parameters/led_pulse_offset.schema.yml +32 -0
- simtools/schemas/model_parameters/led_pulse_sigtime.schema.yml +33 -0
- simtools/schemas/model_parameters/led_var_photons.schema.yml +34 -0
- simtools/schemas/model_parameters/lightguide_efficiency_vs_incidence_angle.schema.yml +41 -0
- simtools/schemas/model_parameters/lightguide_efficiency_vs_wavelength.schema.yml +43 -0
- simtools/schemas/model_parameters/min_photoelectrons.schema.yml +35 -0
- simtools/schemas/model_parameters/min_photons.schema.yml +32 -0
- simtools/schemas/model_parameters/mirror_align_random_distance.schema.yml +36 -0
- simtools/schemas/model_parameters/mirror_align_random_horizontal.schema.yml +64 -0
- simtools/schemas/model_parameters/mirror_align_random_vertical.schema.yml +64 -0
- simtools/schemas/model_parameters/mirror_class.schema.yml +41 -0
- simtools/schemas/model_parameters/mirror_degraded_reflection.schema.yml +51 -0
- simtools/schemas/model_parameters/mirror_focal_length.schema.yml +42 -0
- simtools/schemas/model_parameters/mirror_list.schema.yml +38 -0
- simtools/schemas/model_parameters/mirror_offset.schema.yml +41 -0
- simtools/schemas/model_parameters/mirror_panel_2f_measurements.schema.yml +39 -0
- simtools/schemas/model_parameters/mirror_reflection_random_angle.schema.yml +61 -0
- simtools/schemas/model_parameters/mirror_reflectivity.schema.yml +40 -0
- simtools/schemas/model_parameters/multiplicity_offset.schema.yml +46 -0
- simtools/schemas/model_parameters/nsb_autoscale_airmass.schema.yml +51 -0
- simtools/schemas/model_parameters/nsb_gain_drop_scale.schema.yml +37 -0
- simtools/schemas/model_parameters/nsb_offaxis.schema.yml +79 -0
- simtools/schemas/model_parameters/nsb_pixel_rate.schema.yml +47 -0
- simtools/schemas/model_parameters/nsb_reference_spectrum.schema.yml +34 -0
- simtools/schemas/model_parameters/nsb_reference_value.schema.yml +33 -0
- simtools/schemas/model_parameters/nsb_scaling_factor.schema.yml +35 -0
- simtools/schemas/model_parameters/nsb_skymap.schema.yml +39 -0
- simtools/schemas/model_parameters/nsb_spectrum.schema.yml +50 -0
- simtools/schemas/model_parameters/num_gains.schema.yml +34 -0
- simtools/schemas/model_parameters/only_triggered_telescopes.schema.yml +33 -0
- simtools/schemas/model_parameters/optics_properties.schema.yml +31 -0
- simtools/schemas/model_parameters/parabolic_dish.schema.yml +32 -0
- simtools/schemas/model_parameters/pedestal_events.schema.yml +32 -0
- simtools/schemas/model_parameters/photon_delay.schema.yml +38 -0
- simtools/schemas/model_parameters/photons_per_run.schema.yml +33 -0
- simtools/schemas/model_parameters/pixel_cells.schema.yml +35 -0
- simtools/schemas/model_parameters/pixels_parallel.schema.yml +54 -0
- simtools/schemas/model_parameters/pixeltrg_time_step.schema.yml +40 -0
- simtools/schemas/model_parameters/pm_average_gain.schema.yml +34 -0
- simtools/schemas/model_parameters/pm_collection_efficiency.schema.yml +40 -0
- simtools/schemas/model_parameters/pm_gain_index.schema.yml +36 -0
- simtools/schemas/model_parameters/pm_photoelectron_spectrum.schema.yml +41 -0
- simtools/schemas/model_parameters/pm_transit_time.schema.yml +63 -0
- simtools/schemas/model_parameters/pm_voltage_variation.schema.yml +39 -0
- simtools/schemas/model_parameters/primary_mirror_degraded_map.schema.yml +42 -0
- simtools/schemas/model_parameters/primary_mirror_diameter.schema.yml +33 -0
- simtools/schemas/model_parameters/primary_mirror_hole_diameter.schema.yml +33 -0
- simtools/schemas/model_parameters/primary_mirror_incidence_angle.schema.yml +29 -0
- simtools/schemas/model_parameters/primary_mirror_parameters.schema.yml +168 -0
- simtools/schemas/model_parameters/primary_mirror_ref_radius.schema.yml +36 -0
- simtools/schemas/model_parameters/primary_mirror_segmentation.schema.yml +34 -0
- simtools/schemas/model_parameters/qe_variation.schema.yml +43 -0
- simtools/schemas/model_parameters/quantum_efficiency.schema.yml +42 -0
- simtools/schemas/model_parameters/random_focal_length.schema.yml +45 -0
- simtools/schemas/model_parameters/random_generator.schema.yml +36 -0
- simtools/schemas/model_parameters/reference_point_altitude.schema.yml +35 -0
- simtools/schemas/model_parameters/reference_point_latitude.schema.yml +36 -0
- simtools/schemas/model_parameters/reference_point_longitude.schema.yml +36 -0
- simtools/schemas/model_parameters/reference_point_utm_east.schema.yml +34 -0
- simtools/schemas/model_parameters/reference_point_utm_north.schema.yml +34 -0
- simtools/schemas/model_parameters/sampled_output.schema.yml +31 -0
- simtools/schemas/model_parameters/save_pe_with_amplitude.schema.yml +34 -0
- simtools/schemas/model_parameters/secondary_mirror_baffle.schema.yml +79 -0
- simtools/schemas/model_parameters/secondary_mirror_degraded_map.schema.yml +42 -0
- simtools/schemas/model_parameters/secondary_mirror_degraded_reflection.schema.yml +41 -0
- simtools/schemas/model_parameters/secondary_mirror_diameter.schema.yml +33 -0
- simtools/schemas/model_parameters/secondary_mirror_hole_diameter.schema.yml +36 -0
- simtools/schemas/model_parameters/secondary_mirror_incidence_angle.schema.yml +29 -0
- simtools/schemas/model_parameters/secondary_mirror_parameters.schema.yml +168 -0
- simtools/schemas/model_parameters/secondary_mirror_ref_radius.schema.yml +36 -0
- simtools/schemas/model_parameters/secondary_mirror_reflectivity.schema.yml +35 -0
- simtools/schemas/model_parameters/secondary_mirror_segmentation.schema.yml +37 -0
- simtools/schemas/model_parameters/secondary_mirror_shadow_diameter.schema.yml +40 -0
- simtools/schemas/model_parameters/secondary_mirror_shadow_offset.schema.yml +40 -0
- simtools/schemas/model_parameters/store_photoelectrons.schema.yml +41 -0
- simtools/schemas/model_parameters/tailcut_scale.schema.yml +40 -0
- simtools/schemas/model_parameters/telescope_axis_height.schema.yml +31 -0
- simtools/schemas/model_parameters/telescope_random_angle.schema.yml +35 -0
- simtools/schemas/model_parameters/telescope_random_error.schema.yml +34 -0
- simtools/schemas/model_parameters/telescope_sphere_radius.schema.yml +37 -0
- simtools/schemas/model_parameters/telescope_transmission.schema.yml +113 -0
- simtools/schemas/model_parameters/teltrig_min_sigsum.schema.yml +41 -0
- simtools/schemas/model_parameters/teltrig_min_time.schema.yml +36 -0
- simtools/schemas/model_parameters/transit_time_calib_error.schema.yml +36 -0
- simtools/schemas/model_parameters/transit_time_compensate_error.schema.yml +37 -0
- simtools/schemas/model_parameters/transit_time_compensate_step.schema.yml +38 -0
- simtools/schemas/model_parameters/transit_time_error.schema.yml +45 -0
- simtools/schemas/model_parameters/transit_time_jitter.schema.yml +36 -0
- simtools/schemas/model_parameters/trigger_current_limit.schema.yml +32 -0
- simtools/schemas/model_parameters/trigger_delay_compensation.schema.yml +53 -0
- simtools/schemas/model_parameters/trigger_pixels.schema.yml +40 -0
- simtools/simtel/simtel_config_reader.py +353 -0
- simtools/simtel/simtel_config_writer.py +244 -63
- simtools/simtel/{simtel_events.py → simtel_io_events.py} +26 -25
- simtools/simtel/simtel_io_histogram.py +661 -0
- simtools/simtel/simtel_io_histograms.py +569 -0
- simtools/simtel/simulator_array.py +145 -0
- simtools/simtel/{simtel_runner_camera_efficiency.py → simulator_camera_efficiency.py} +76 -52
- simtools/simtel/simulator_light_emission.py +473 -0
- simtools/simtel/simulator_ray_tracing.py +262 -0
- simtools/simulator.py +220 -446
- simtools/testing/__init__.py +0 -0
- simtools/testing/assertions.py +151 -0
- simtools/testing/configuration.py +226 -0
- simtools/testing/helpers.py +42 -0
- simtools/testing/validate_output.py +240 -0
- simtools/utils/general.py +340 -437
- simtools/utils/geometry.py +12 -12
- simtools/utils/names.py +258 -644
- simtools/utils/value_conversion.py +176 -0
- simtools/version.py +2 -0
- simtools/visualization/legend_handlers.py +135 -152
- simtools/visualization/plot_camera.py +379 -0
- simtools/visualization/visualize.py +346 -167
- gammasimtools-0.6.1.dist-info/METADATA +0 -180
- gammasimtools-0.6.1.dist-info/RECORD +0 -91
- gammasimtools-0.6.1.dist-info/entry_points.txt +0 -23
- simtools/applications/db_development_tools/add_new_parameter_to_db.py +0 -81
- simtools/applications/db_development_tools/add_unit_to_parameter_in_db.py +0 -59
- simtools/applications/db_development_tools/mark_non_optics_parameters_non_applicable.py +0 -102
- simtools/applications/get_parameter.py +0 -92
- simtools/applications/make_regular_arrays.py +0 -160
- simtools/applications/produce_array_config.py +0 -136
- simtools/applications/production.py +0 -313
- simtools/applications/sim_showers_for_trigger_rates.py +0 -187
- simtools/applications/tune_psf.py +0 -334
- simtools/corsika/corsika_default_config.py +0 -282
- simtools/corsika/corsika_runner.py +0 -450
- simtools/corsika_simtel/corsika_simtel_runner.py +0 -197
- simtools/db_handler.py +0 -1480
- simtools/ray_tracing.py +0 -525
- simtools/simtel/simtel_histograms.py +0 -414
- simtools/simtel/simtel_runner.py +0 -244
- simtools/simtel/simtel_runner_array.py +0 -293
- simtools/simtel/simtel_runner_ray_tracing.py +0 -277
- {gammasimtools-0.6.1.dist-info → gammasimtools-0.8.1.dist-info}/LICENSE +0 -0
- {gammasimtools-0.6.1.dist-info → gammasimtools-0.8.1.dist-info}/top_level.txt +0 -0
- /simtools/{corsika_simtel → db}/__init__.py +0 -0
|
@@ -0,0 +1,646 @@
|
|
|
1
|
+
"""Ray tracing simulations and analysis."""
|
|
2
|
+
|
|
3
|
+
import gzip
|
|
4
|
+
import logging
|
|
5
|
+
import shutil
|
|
6
|
+
from copy import copy
|
|
7
|
+
from math import pi, tan
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
import astropy.io.ascii
|
|
11
|
+
import astropy.units as u
|
|
12
|
+
import matplotlib.pyplot as plt
|
|
13
|
+
import numpy as np
|
|
14
|
+
from astropy.table import QTable
|
|
15
|
+
|
|
16
|
+
from simtools.io_operations import io_handler
|
|
17
|
+
from simtools.model.model_utils import compute_telescope_transmission
|
|
18
|
+
from simtools.ray_tracing.psf_analysis import PSFImage
|
|
19
|
+
from simtools.simtel.simulator_ray_tracing import SimulatorRayTracing
|
|
20
|
+
from simtools.utils import names
|
|
21
|
+
from simtools.visualization import visualize
|
|
22
|
+
|
|
23
|
+
__all__ = ["RayTracing"]
|
|
24
|
+
|
|
25
|
+
INVALID_KEY_TO_PLOT = "Invalid key to plot"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class RayTracing:
|
|
29
|
+
"""
|
|
30
|
+
Ray tracing simulations and analysis.
|
|
31
|
+
|
|
32
|
+
Parameters
|
|
33
|
+
----------
|
|
34
|
+
telescope_model: TelescopeModel
|
|
35
|
+
telescope model
|
|
36
|
+
simtel_path: str (or Path)
|
|
37
|
+
Location of sim_telarray installation.
|
|
38
|
+
label: str
|
|
39
|
+
label used for output file naming.
|
|
40
|
+
zenith_angle: astropy.units.Quantity
|
|
41
|
+
Zenith angle.
|
|
42
|
+
off_axis_angle: list of astropy.units.Quantity
|
|
43
|
+
Off-axis angles.
|
|
44
|
+
source_distance: astropy.units.Quantity
|
|
45
|
+
Source distance.
|
|
46
|
+
single_mirror_mode: bool
|
|
47
|
+
Single mirror mode flag.
|
|
48
|
+
use_random_focal_length: bool
|
|
49
|
+
Use random focal length flag.
|
|
50
|
+
mirror_numbers: list, str
|
|
51
|
+
List of mirror numbers (or 'all').
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
YLABEL = {
|
|
55
|
+
"d80_cm": r"$D_{80}$",
|
|
56
|
+
"d80_deg": r"$D_{80}$",
|
|
57
|
+
"eff_area": "Eff. mirror area",
|
|
58
|
+
"eff_flen": "Eff. focal length",
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
def __init__(
|
|
62
|
+
self,
|
|
63
|
+
telescope_model,
|
|
64
|
+
simtel_path,
|
|
65
|
+
label=None,
|
|
66
|
+
zenith_angle=20.0 * u.deg,
|
|
67
|
+
off_axis_angle=[0.0] * u.deg,
|
|
68
|
+
source_distance=10.0 * u.km,
|
|
69
|
+
single_mirror_mode=False,
|
|
70
|
+
use_random_focal_length=False,
|
|
71
|
+
mirror_numbers="all",
|
|
72
|
+
):
|
|
73
|
+
"""Initialize RayTracing class."""
|
|
74
|
+
self._logger = logging.getLogger(__name__)
|
|
75
|
+
self._logger.debug(f"Initializing RayTracing class {single_mirror_mode}")
|
|
76
|
+
|
|
77
|
+
self.simtel_path = Path(simtel_path)
|
|
78
|
+
self._io_handler = io_handler.IOHandler()
|
|
79
|
+
|
|
80
|
+
self.telescope_model = telescope_model
|
|
81
|
+
self.label = label if label is not None else self.telescope_model.label
|
|
82
|
+
|
|
83
|
+
self.zenith_angle = zenith_angle.to("deg").value
|
|
84
|
+
self.off_axis_angle = np.around(off_axis_angle.to("deg").value, 5)
|
|
85
|
+
self.single_mirror_mode = single_mirror_mode
|
|
86
|
+
self.use_random_focal_length = use_random_focal_length
|
|
87
|
+
self.mirrors = self._initialize_mirror_configuration(source_distance, mirror_numbers)
|
|
88
|
+
self.output_directory = self._io_handler.get_output_directory(
|
|
89
|
+
label=self.label, sub_dir="ray-tracing"
|
|
90
|
+
)
|
|
91
|
+
self.output_directory.joinpath("results").mkdir(parents=True, exist_ok=True)
|
|
92
|
+
self._file_results = self.output_directory.joinpath("results").joinpath(
|
|
93
|
+
self._generate_file_name(file_type="ray-tracing", suffix=".ecsv")
|
|
94
|
+
)
|
|
95
|
+
self._psf_images = {}
|
|
96
|
+
self._results = None
|
|
97
|
+
|
|
98
|
+
def __repr__(self):
|
|
99
|
+
"""Return string representation of RayTracing class."""
|
|
100
|
+
return f"RayTracing(label={self.label})\n"
|
|
101
|
+
|
|
102
|
+
def _initialize_mirror_configuration(
|
|
103
|
+
self,
|
|
104
|
+
source_distance,
|
|
105
|
+
mirror_numbers,
|
|
106
|
+
):
|
|
107
|
+
"""
|
|
108
|
+
Initialize mirror configuration.
|
|
109
|
+
|
|
110
|
+
Note the difference between single mirror mode and nominal mode.
|
|
111
|
+
In single mirror mode, a 'mirror' is a mirror panel.
|
|
112
|
+
In nominal mode, a 'mirror' is a telescope.
|
|
113
|
+
|
|
114
|
+
Parameters
|
|
115
|
+
----------
|
|
116
|
+
source_distance: astropy.units.Quantity
|
|
117
|
+
Source distance.
|
|
118
|
+
mirror_numbers: list, str
|
|
119
|
+
List of mirror numbers (or 'all').
|
|
120
|
+
|
|
121
|
+
Returns
|
|
122
|
+
-------
|
|
123
|
+
dict
|
|
124
|
+
Dictionary containing mirror numbers, focal lengths, and source distances.
|
|
125
|
+
|
|
126
|
+
"""
|
|
127
|
+
# initialize a mirror as a mirror panel
|
|
128
|
+
if self.single_mirror_mode:
|
|
129
|
+
return self._initialize_single_mirror_mode(mirror_numbers)
|
|
130
|
+
# initialize a mirror as a telescope optical system
|
|
131
|
+
return {
|
|
132
|
+
0: {
|
|
133
|
+
"source_distance": source_distance.to("km").value,
|
|
134
|
+
"focal_length": self.telescope_model.get_parameter_value("focal_length"),
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
def _initialize_single_mirror_mode(self, mirror_numbers):
|
|
139
|
+
"""
|
|
140
|
+
Initialize single mirror mode.
|
|
141
|
+
|
|
142
|
+
Parameters
|
|
143
|
+
----------
|
|
144
|
+
mirror_numbers: list, str
|
|
145
|
+
List of mirror numbers (or 'all').
|
|
146
|
+
|
|
147
|
+
Returns
|
|
148
|
+
-------
|
|
149
|
+
dict
|
|
150
|
+
Dictionary containing mirror numbers, focal lengths, and source distances.
|
|
151
|
+
"""
|
|
152
|
+
self._logger.debug(
|
|
153
|
+
"Single mirror mode is activated - "
|
|
154
|
+
"source distance is being recalculated to 2 * focal length "
|
|
155
|
+
" (this is not correct for dual-mirror telescopes)."
|
|
156
|
+
)
|
|
157
|
+
if "all" in mirror_numbers:
|
|
158
|
+
mirror_numbers = list(range(0, self.telescope_model.mirrors.number_of_mirrors))
|
|
159
|
+
mirrors = {mirror: {"focal_length": 0, "source_distance": 0.0} for mirror in mirror_numbers}
|
|
160
|
+
|
|
161
|
+
for mirror in mirror_numbers:
|
|
162
|
+
_, _, _, _focal_length, _ = self.telescope_model.mirrors.get_single_mirror_parameters(
|
|
163
|
+
mirror
|
|
164
|
+
)
|
|
165
|
+
if np.isnan(_focal_length) or np.isclose(_focal_length, 0, rtol=1.0e-3):
|
|
166
|
+
_focal_length = self._get_mirror_panel_focal_length() * u.cm
|
|
167
|
+
if np.isnan(_focal_length) or np.isclose(_focal_length, 0, rtol=1.0e-3):
|
|
168
|
+
raise ValueError("Focal length is invalid (NaN or close to zero)")
|
|
169
|
+
mirrors[mirror]["focal_length"] = _focal_length
|
|
170
|
+
mirrors[mirror]["source_distance"] = 2 * _focal_length.to("km").value
|
|
171
|
+
|
|
172
|
+
return mirrors
|
|
173
|
+
|
|
174
|
+
def _get_mirror_panel_focal_length(self):
|
|
175
|
+
"""
|
|
176
|
+
Return mirror panel focal length with possible random addition.
|
|
177
|
+
|
|
178
|
+
Returns
|
|
179
|
+
-------
|
|
180
|
+
float
|
|
181
|
+
Focal length.
|
|
182
|
+
"""
|
|
183
|
+
_focal_length = self.telescope_model.get_parameter_value("mirror_focal_length")
|
|
184
|
+
if self.use_random_focal_length:
|
|
185
|
+
rng = np.random.default_rng()
|
|
186
|
+
_random_focal_length = self.telescope_model.get_parameter_value("random_focal_length")
|
|
187
|
+
if _random_focal_length[0] > 0.0:
|
|
188
|
+
_focal_length += rng.normal(loc=0, scale=_random_focal_length[0])
|
|
189
|
+
else:
|
|
190
|
+
_focal_length += rng.uniform(
|
|
191
|
+
low=-1.0 * _random_focal_length[1], high=1.0 * _random_focal_length[1]
|
|
192
|
+
)
|
|
193
|
+
return _focal_length
|
|
194
|
+
|
|
195
|
+
def simulate(self, test=False, force=False):
|
|
196
|
+
"""
|
|
197
|
+
Simulate RayTracing using SimulatorRayTracing.
|
|
198
|
+
|
|
199
|
+
Parameters
|
|
200
|
+
----------
|
|
201
|
+
test: bool
|
|
202
|
+
Test flag will make it faster by simulating much fewer photons.
|
|
203
|
+
force: bool
|
|
204
|
+
Force flag will remove existing files and simulate again.
|
|
205
|
+
"""
|
|
206
|
+
for this_off_axis in self.off_axis_angle:
|
|
207
|
+
for mirror_number, mirror_data in self.mirrors.items():
|
|
208
|
+
self._logger.info(
|
|
209
|
+
f"Simulating RayTracing for off_axis={this_off_axis}, mirror={mirror_number}"
|
|
210
|
+
)
|
|
211
|
+
simtel = SimulatorRayTracing(
|
|
212
|
+
simtel_path=self.simtel_path,
|
|
213
|
+
telescope_model=self.telescope_model,
|
|
214
|
+
test=test,
|
|
215
|
+
config_data={
|
|
216
|
+
"zenith_angle": self.zenith_angle,
|
|
217
|
+
"off_axis_angle": this_off_axis,
|
|
218
|
+
"source_distance": mirror_data["source_distance"],
|
|
219
|
+
"single_mirror_mode": self.single_mirror_mode,
|
|
220
|
+
"use_random_focal_length": self.use_random_focal_length,
|
|
221
|
+
"mirror_numbers": mirror_number,
|
|
222
|
+
},
|
|
223
|
+
force_simulate=force,
|
|
224
|
+
)
|
|
225
|
+
simtel.run(test=test)
|
|
226
|
+
|
|
227
|
+
photons_file = self.output_directory.joinpath(
|
|
228
|
+
self._generate_file_name(
|
|
229
|
+
file_type="photons",
|
|
230
|
+
suffix=".lis",
|
|
231
|
+
off_axis_angle=this_off_axis,
|
|
232
|
+
mirror_number=mirror_number if self.single_mirror_mode else None,
|
|
233
|
+
)
|
|
234
|
+
)
|
|
235
|
+
self._logger.debug(f"Using gzip to compress the photons file {photons_file}.")
|
|
236
|
+
|
|
237
|
+
with open(photons_file, "rb") as f_in:
|
|
238
|
+
with gzip.open(
|
|
239
|
+
photons_file.with_suffix(photons_file.suffix + ".gz"), "wb"
|
|
240
|
+
) as f_out:
|
|
241
|
+
shutil.copyfileobj(f_in, f_out)
|
|
242
|
+
photons_file.unlink()
|
|
243
|
+
|
|
244
|
+
def analyze(
|
|
245
|
+
self,
|
|
246
|
+
export=True,
|
|
247
|
+
force=False,
|
|
248
|
+
use_rx=False,
|
|
249
|
+
no_tel_transmission=False,
|
|
250
|
+
containment_fraction=0.8,
|
|
251
|
+
):
|
|
252
|
+
"""
|
|
253
|
+
Ray tracing analysis.
|
|
254
|
+
|
|
255
|
+
Involves the following: read simtel files, compute PSFs and eff areas, store the
|
|
256
|
+
results in _results.
|
|
257
|
+
|
|
258
|
+
Parameters
|
|
259
|
+
----------
|
|
260
|
+
export: bool
|
|
261
|
+
If True, results will be exported to a file automatically. Alternatively,
|
|
262
|
+
export_results function can be used.
|
|
263
|
+
force: bool
|
|
264
|
+
If True, existing results files will be removed and analysis will be done again.
|
|
265
|
+
use_rx: bool
|
|
266
|
+
If True, calculations are done using the rx binary provided by sim_telarray. If False,
|
|
267
|
+
calculations are done internally, by the module psf_analysis.
|
|
268
|
+
no_tel_transmission: bool
|
|
269
|
+
If True, the telescope transmission is not applied.
|
|
270
|
+
containment_fraction: float
|
|
271
|
+
Containment fraction for PSF containment calculation. Allowed values are in the
|
|
272
|
+
interval [0,1]
|
|
273
|
+
"""
|
|
274
|
+
do_analyze = not self._file_results.exists() or force
|
|
275
|
+
if not do_analyze:
|
|
276
|
+
self._read_results()
|
|
277
|
+
|
|
278
|
+
tel_transmission_pars = self._get_telescope_transmission_params(no_tel_transmission)
|
|
279
|
+
|
|
280
|
+
self._psf_images = {}
|
|
281
|
+
|
|
282
|
+
_rows = self._process_off_axis_and_mirror(
|
|
283
|
+
tel_transmission_pars,
|
|
284
|
+
do_analyze,
|
|
285
|
+
use_rx,
|
|
286
|
+
containment_fraction,
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
if do_analyze:
|
|
290
|
+
self._store_results(_rows)
|
|
291
|
+
if export:
|
|
292
|
+
self.export_results()
|
|
293
|
+
|
|
294
|
+
def _process_off_axis_and_mirror(
|
|
295
|
+
self,
|
|
296
|
+
tel_transmission_pars,
|
|
297
|
+
do_analyze,
|
|
298
|
+
use_rx,
|
|
299
|
+
containment_fraction,
|
|
300
|
+
):
|
|
301
|
+
"""
|
|
302
|
+
Process off-axis angles and mirrors for RayTracing analysis.
|
|
303
|
+
|
|
304
|
+
Parameters
|
|
305
|
+
----------
|
|
306
|
+
all_mirrors: list
|
|
307
|
+
List of mirror numbers to analyze.
|
|
308
|
+
focal_length: float
|
|
309
|
+
Focal length of the telescope.
|
|
310
|
+
tel_transmission_pars: list
|
|
311
|
+
Telescope transmission parameters.
|
|
312
|
+
do_analyze: bool
|
|
313
|
+
Flag indicating whether to perform analysis or not.
|
|
314
|
+
use_rx: bool
|
|
315
|
+
Flag indicating whether to use the RX method for analysis.
|
|
316
|
+
containment_fraction: float
|
|
317
|
+
Containment fraction for PSF containment calculation.
|
|
318
|
+
|
|
319
|
+
Returns
|
|
320
|
+
-------
|
|
321
|
+
list
|
|
322
|
+
List of results for each combination of off-axis angle and mirror.
|
|
323
|
+
"""
|
|
324
|
+
_rows = []
|
|
325
|
+
|
|
326
|
+
for this_off_axis in self.off_axis_angle:
|
|
327
|
+
for mirror_number, mirror_data in self.mirrors.items():
|
|
328
|
+
self._logger.debug(f"Analyzing RayTracing for off_axis={this_off_axis}")
|
|
329
|
+
|
|
330
|
+
photons_file = self.output_directory.joinpath(
|
|
331
|
+
self._generate_file_name(
|
|
332
|
+
"photons", ".lis", off_axis_angle=this_off_axis, mirror_number=mirror_number
|
|
333
|
+
)
|
|
334
|
+
+ ".gz"
|
|
335
|
+
)
|
|
336
|
+
|
|
337
|
+
tel_transmission = compute_telescope_transmission(
|
|
338
|
+
tel_transmission_pars, this_off_axis
|
|
339
|
+
)
|
|
340
|
+
image = self._create_psf_image(
|
|
341
|
+
photons_file,
|
|
342
|
+
mirror_data["focal_length"],
|
|
343
|
+
this_off_axis,
|
|
344
|
+
containment_fraction,
|
|
345
|
+
use_rx,
|
|
346
|
+
)
|
|
347
|
+
|
|
348
|
+
if do_analyze:
|
|
349
|
+
_current_results = self._analyze_image(
|
|
350
|
+
image,
|
|
351
|
+
this_off_axis,
|
|
352
|
+
containment_fraction,
|
|
353
|
+
tel_transmission,
|
|
354
|
+
)
|
|
355
|
+
|
|
356
|
+
if self.single_mirror_mode:
|
|
357
|
+
_current_results += (mirror_number,)
|
|
358
|
+
|
|
359
|
+
_rows.append(_current_results)
|
|
360
|
+
|
|
361
|
+
return _rows
|
|
362
|
+
|
|
363
|
+
def _get_telescope_transmission_params(self, no_tel_transmission):
|
|
364
|
+
"""
|
|
365
|
+
Get telescope transmission parameters.
|
|
366
|
+
|
|
367
|
+
Parameters
|
|
368
|
+
----------
|
|
369
|
+
no_tel_transmission: bool
|
|
370
|
+
Flag indicating whether to apply telescope transmission or not.
|
|
371
|
+
|
|
372
|
+
Returns
|
|
373
|
+
-------
|
|
374
|
+
list
|
|
375
|
+
Telescope transmission parameters.
|
|
376
|
+
"""
|
|
377
|
+
return (
|
|
378
|
+
self.telescope_model.get_parameter_value("telescope_transmission")
|
|
379
|
+
if not no_tel_transmission
|
|
380
|
+
else [1, 0, 0, 0]
|
|
381
|
+
)
|
|
382
|
+
|
|
383
|
+
def _create_psf_image(
|
|
384
|
+
self, photons_file, focal_length, this_off_axis, containment_fraction, use_rx=False
|
|
385
|
+
):
|
|
386
|
+
"""
|
|
387
|
+
Create PSF image from photons file.
|
|
388
|
+
|
|
389
|
+
Parameters
|
|
390
|
+
----------
|
|
391
|
+
photons_file: Path
|
|
392
|
+
Path to the photons file.
|
|
393
|
+
focal_length: float
|
|
394
|
+
Focal length of the telescope.
|
|
395
|
+
this_off_axis: float
|
|
396
|
+
Off-axis angle.
|
|
397
|
+
containment_fraction: float
|
|
398
|
+
Containment fraction for PSF containment calculation.
|
|
399
|
+
use_rx: bool
|
|
400
|
+
Flag indicating whether to use the RX method for analysis.
|
|
401
|
+
|
|
402
|
+
Returns
|
|
403
|
+
-------
|
|
404
|
+
PSFImage
|
|
405
|
+
PSF image object.
|
|
406
|
+
"""
|
|
407
|
+
image = PSFImage(
|
|
408
|
+
focal_length=focal_length,
|
|
409
|
+
containment_fraction=containment_fraction,
|
|
410
|
+
simtel_path=self.simtel_path,
|
|
411
|
+
)
|
|
412
|
+
image.process_photon_list(photons_file, use_rx)
|
|
413
|
+
self._psf_images[this_off_axis] = copy(image)
|
|
414
|
+
return image
|
|
415
|
+
|
|
416
|
+
def _analyze_image(
|
|
417
|
+
self,
|
|
418
|
+
image,
|
|
419
|
+
this_off_axis,
|
|
420
|
+
containment_fraction,
|
|
421
|
+
tel_transmission,
|
|
422
|
+
):
|
|
423
|
+
"""
|
|
424
|
+
Analyze PSF image.
|
|
425
|
+
|
|
426
|
+
Parameters
|
|
427
|
+
----------
|
|
428
|
+
image: PSFImage
|
|
429
|
+
PSF image object.
|
|
430
|
+
photons_file: Path
|
|
431
|
+
Path to the photons file.
|
|
432
|
+
this_off_axis: float
|
|
433
|
+
Off-axis angle.
|
|
434
|
+
cm_to_deg: float
|
|
435
|
+
Conversion factor from centimeters to degrees.
|
|
436
|
+
containment_fraction: float
|
|
437
|
+
Containment fraction for PSF containment calculation.
|
|
438
|
+
tel_transmission: float
|
|
439
|
+
Telescope transmission factor.
|
|
440
|
+
|
|
441
|
+
Returns
|
|
442
|
+
-------
|
|
443
|
+
tuple
|
|
444
|
+
Tuple containing analyzed results.
|
|
445
|
+
"""
|
|
446
|
+
return (
|
|
447
|
+
this_off_axis * u.deg,
|
|
448
|
+
image.get_psf(containment_fraction, "cm") * u.cm,
|
|
449
|
+
image.get_psf(containment_fraction, "deg") * u.deg,
|
|
450
|
+
image.get_effective_area(tel_transmission) * u.m * u.m,
|
|
451
|
+
np.nan if this_off_axis == 0 else image.centroid_x / tan(this_off_axis * pi / 180.0),
|
|
452
|
+
)
|
|
453
|
+
|
|
454
|
+
def _store_results(self, _rows):
|
|
455
|
+
"""
|
|
456
|
+
Store analysis results.
|
|
457
|
+
|
|
458
|
+
Parameters
|
|
459
|
+
----------
|
|
460
|
+
_rows: list
|
|
461
|
+
List of rows containing analysis results.
|
|
462
|
+
"""
|
|
463
|
+
_columns = ["Off-axis angle"]
|
|
464
|
+
_columns.extend(list(self.YLABEL.keys()))
|
|
465
|
+
if self.single_mirror_mode:
|
|
466
|
+
_columns.append("mirror_number")
|
|
467
|
+
self._results = QTable(rows=_rows, names=_columns)
|
|
468
|
+
|
|
469
|
+
def export_results(self):
|
|
470
|
+
"""Export results to a csv file."""
|
|
471
|
+
if self._results:
|
|
472
|
+
self._logger.info(f"Exporting results to {self._file_results}")
|
|
473
|
+
astropy.io.ascii.write(self._results, self._file_results, format="ecsv", overwrite=True)
|
|
474
|
+
else:
|
|
475
|
+
self._logger.error("No results to export")
|
|
476
|
+
|
|
477
|
+
def _read_results(self):
|
|
478
|
+
"""Read existing results file and store it in _results."""
|
|
479
|
+
self._results = astropy.io.ascii.read(self._file_results, format="ecsv")
|
|
480
|
+
|
|
481
|
+
def plot(self, key, save=False, d80=None, **kwargs):
|
|
482
|
+
"""
|
|
483
|
+
Plot key vs off-axis angle and save the figure in pdf.
|
|
484
|
+
|
|
485
|
+
Parameters
|
|
486
|
+
----------
|
|
487
|
+
key: str
|
|
488
|
+
d80_cm, d80_deg, eff_area or eff_flen
|
|
489
|
+
save: bool
|
|
490
|
+
If True, figure will be saved.
|
|
491
|
+
d80: float
|
|
492
|
+
d80 for cumulative PSF plot.
|
|
493
|
+
**kwargs:
|
|
494
|
+
kwargs for plt.plot
|
|
495
|
+
|
|
496
|
+
Raises
|
|
497
|
+
------
|
|
498
|
+
KeyError
|
|
499
|
+
If key is not among the valid options.
|
|
500
|
+
"""
|
|
501
|
+
self._logger.info(f"Plotting {key} vs off-axis angle")
|
|
502
|
+
|
|
503
|
+
try:
|
|
504
|
+
plot = visualize.plot_table(
|
|
505
|
+
self._results["Off-axis angle", key], self.YLABEL[key], no_legend=True, **kwargs
|
|
506
|
+
)
|
|
507
|
+
except KeyError as exc:
|
|
508
|
+
raise KeyError(INVALID_KEY_TO_PLOT) from exc
|
|
509
|
+
|
|
510
|
+
if save:
|
|
511
|
+
plot_file_name = self._generate_file_name(
|
|
512
|
+
file_type="ray-tracing",
|
|
513
|
+
suffix=".pdf",
|
|
514
|
+
extra_label=key,
|
|
515
|
+
)
|
|
516
|
+
self.output_directory.joinpath("figures").mkdir(exist_ok=True)
|
|
517
|
+
plot_file = self.output_directory.joinpath("figures").joinpath(plot_file_name)
|
|
518
|
+
self._logger.info(f"Saving fig in {plot_file}")
|
|
519
|
+
plot.savefig(plot_file)
|
|
520
|
+
|
|
521
|
+
for off_axis_key, image in self._psf_images.items():
|
|
522
|
+
image_file_name = self._generate_file_name(
|
|
523
|
+
file_type="ray-tracing",
|
|
524
|
+
off_axis_angle=off_axis_key,
|
|
525
|
+
suffix=".pdf",
|
|
526
|
+
extra_label=f"image_{key}",
|
|
527
|
+
)
|
|
528
|
+
image_file = self.output_directory.joinpath("figures").joinpath(image_file_name)
|
|
529
|
+
self._logger.info(f"Saving PSF image to {image_file}")
|
|
530
|
+
image.plot_image(file_name=image_file)
|
|
531
|
+
|
|
532
|
+
image_cumulative_file_name = self._generate_file_name(
|
|
533
|
+
file_type="ray-tracing",
|
|
534
|
+
off_axis_angle=off_axis_key,
|
|
535
|
+
suffix=".pdf",
|
|
536
|
+
extra_label=f"cumulative_psf_{key}",
|
|
537
|
+
)
|
|
538
|
+
image_cumulative_file = self.output_directory.joinpath("figures").joinpath(
|
|
539
|
+
image_cumulative_file_name
|
|
540
|
+
)
|
|
541
|
+
self._logger.info(f"Saving cumulative PSF to {image_cumulative_file}")
|
|
542
|
+
image.plot_cumulative(file_name=image_cumulative_file, d80=d80)
|
|
543
|
+
|
|
544
|
+
def plot_histogram(self, key, **kwargs):
|
|
545
|
+
"""
|
|
546
|
+
Plot histogram of key.
|
|
547
|
+
|
|
548
|
+
Parameters
|
|
549
|
+
----------
|
|
550
|
+
key: str
|
|
551
|
+
d80_cm, d80_deg, eff_area or eff_flen
|
|
552
|
+
**kwargs:
|
|
553
|
+
kwargs for plt.hist
|
|
554
|
+
|
|
555
|
+
Raises
|
|
556
|
+
------
|
|
557
|
+
KeyError
|
|
558
|
+
If key is not among the valid options.
|
|
559
|
+
"""
|
|
560
|
+
try:
|
|
561
|
+
ax = plt.gca()
|
|
562
|
+
ax.hist(self._results[key], **kwargs)
|
|
563
|
+
except KeyError as exc:
|
|
564
|
+
raise KeyError(INVALID_KEY_TO_PLOT) from exc
|
|
565
|
+
|
|
566
|
+
def get_mean(self, key):
|
|
567
|
+
"""
|
|
568
|
+
Get mean value of key.
|
|
569
|
+
|
|
570
|
+
Parameters
|
|
571
|
+
----------
|
|
572
|
+
key: str
|
|
573
|
+
d80_cm, d80_deg, eff_area or eff_flen
|
|
574
|
+
|
|
575
|
+
Returns
|
|
576
|
+
-------
|
|
577
|
+
float
|
|
578
|
+
Mean value of key.
|
|
579
|
+
|
|
580
|
+
Raises
|
|
581
|
+
------
|
|
582
|
+
KeyError
|
|
583
|
+
If key is not among the valid options.
|
|
584
|
+
"""
|
|
585
|
+
try:
|
|
586
|
+
return np.mean(self._results[key])
|
|
587
|
+
except KeyError as exc:
|
|
588
|
+
raise KeyError(INVALID_KEY_TO_PLOT) from exc
|
|
589
|
+
|
|
590
|
+
def get_std_dev(self, key):
|
|
591
|
+
"""
|
|
592
|
+
Get std dev of key.
|
|
593
|
+
|
|
594
|
+
Parameters
|
|
595
|
+
----------
|
|
596
|
+
key: str
|
|
597
|
+
d80_cm, d80_deg, eff_area or eff_flen
|
|
598
|
+
|
|
599
|
+
Returns
|
|
600
|
+
-------
|
|
601
|
+
float
|
|
602
|
+
Std deviation of key.
|
|
603
|
+
|
|
604
|
+
Raises
|
|
605
|
+
------
|
|
606
|
+
KeyError
|
|
607
|
+
If key is not among the valid options.
|
|
608
|
+
"""
|
|
609
|
+
try:
|
|
610
|
+
return np.std(self._results[key])
|
|
611
|
+
except KeyError as exc:
|
|
612
|
+
raise KeyError(INVALID_KEY_TO_PLOT) from exc
|
|
613
|
+
|
|
614
|
+
def images(self):
|
|
615
|
+
"""
|
|
616
|
+
Get list of PSFImages.
|
|
617
|
+
|
|
618
|
+
Returns
|
|
619
|
+
-------
|
|
620
|
+
List of PSFImages
|
|
621
|
+
"""
|
|
622
|
+
images = []
|
|
623
|
+
for this_off_axis in self.off_axis_angle:
|
|
624
|
+
if self._psf_images and this_off_axis in self._psf_images:
|
|
625
|
+
images.append(self._psf_images[this_off_axis])
|
|
626
|
+
if len(images) == 0:
|
|
627
|
+
self._logger.warning("No image found")
|
|
628
|
+
return None
|
|
629
|
+
return images
|
|
630
|
+
|
|
631
|
+
def _generate_file_name(
|
|
632
|
+
self, file_type, suffix, off_axis_angle=None, mirror_number=None, extra_label=None
|
|
633
|
+
):
|
|
634
|
+
"""Generate file name for output files."""
|
|
635
|
+
return names.generate_file_name(
|
|
636
|
+
file_type=file_type,
|
|
637
|
+
suffix=suffix,
|
|
638
|
+
site=self.telescope_model.site,
|
|
639
|
+
telescope_model_name=self.telescope_model.name,
|
|
640
|
+
source_distance=None if self.single_mirror_mode else self.mirrors[0]["source_distance"],
|
|
641
|
+
zenith_angle=self.zenith_angle,
|
|
642
|
+
off_axis_angle=off_axis_angle,
|
|
643
|
+
mirror_number=mirror_number if self.single_mirror_mode else None,
|
|
644
|
+
label=self.label,
|
|
645
|
+
extra_label=extra_label,
|
|
646
|
+
)
|
|
File without changes
|