gammasimtools 0.6.1__py3-none-any.whl → 0.8.2__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.2.dist-info/METADATA +173 -0
- gammasimtools-0.8.2.dist-info/RECORD +345 -0
- {gammasimtools-0.6.1.dist-info → gammasimtools-0.8.2.dist-info}/WHEEL +1 -1
- gammasimtools-0.8.2.dist-info/entry_points.txt +31 -0
- simtools/_dev_version/__init__.py +9 -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 +111 -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 +211 -185
- 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 +312 -259
- simtools/model/calibration_model.py +50 -0
- simtools/model/camera.py +277 -523
- simtools/model/mirrors.py +68 -49
- simtools/model/model_parameter.py +602 -0
- simtools/model/model_utils.py +11 -39
- simtools/model/site_model.py +161 -0
- simtools/model/telescope_model.py +143 -633
- 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 +257 -644
- simtools/utils/value_conversion.py +176 -0
- simtools/version.py +3 -1
- 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/_dev_version/scm_version.py +0 -10
- 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.2.dist-info}/LICENSE +0 -0
- {gammasimtools-0.6.1.dist-info → gammasimtools-0.8.2.dist-info}/top_level.txt +0 -0
- /simtools/{corsika_simtel → db}/__init__.py +0 -0
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/python3
|
|
2
|
-
|
|
3
|
-
"""
|
|
4
|
-
Summary
|
|
5
|
-
-------
|
|
6
|
-
This application simulates showers to be used in trigger rate calculations.
|
|
7
|
-
Arrays with one (1MST) or four telescopes (4LST) can be used, in case of \
|
|
8
|
-
mono or stereo trigger configurations, respectively.
|
|
9
|
-
|
|
10
|
-
Simulations are managed by the Simulator module.
|
|
11
|
-
Each run is simulated in a job. Each job is submitted by using the submission \
|
|
12
|
-
command from the global config settings. The config entry extra_commands can be used \
|
|
13
|
-
to extra commands to be ran in each job, before the actual simulation.
|
|
14
|
-
|
|
15
|
-
At the moment, the shower simulations are performed by CORSIKA, which requires \
|
|
16
|
-
the zstd package. Please, make sure that the command to set your zstd path is \
|
|
17
|
-
properly set by the extra_commands in the command line configuration.
|
|
18
|
-
|
|
19
|
-
Command line arguments
|
|
20
|
-
----------------------
|
|
21
|
-
array (str, required)
|
|
22
|
-
Name of the array (1MST, 4LST ...).
|
|
23
|
-
site (str, required)
|
|
24
|
-
South or North.
|
|
25
|
-
primary (str, required)
|
|
26
|
-
Name of the primary particle (proton, helium ...).
|
|
27
|
-
nruns (int, optional)
|
|
28
|
-
Number of runs to be simulated.
|
|
29
|
-
nevents (int, optional)
|
|
30
|
-
Number of events simulated per run.
|
|
31
|
-
zenith (float, optional)
|
|
32
|
-
Zenith angle in deg.
|
|
33
|
-
azimuth (float, optional)
|
|
34
|
-
Azimuth angle in deg.
|
|
35
|
-
data_directory (str, optional)
|
|
36
|
-
The location of the output directories corsika-data.
|
|
37
|
-
the label is added to the data_directory, such that the output
|
|
38
|
-
will be written to `data_directory/label/corsika-data`.
|
|
39
|
-
test (activation mode, optional)
|
|
40
|
-
If activated, no job will be submitted. Instead, an example of the \
|
|
41
|
-
run script will be printed.
|
|
42
|
-
verbosity (str, optional)
|
|
43
|
-
Log level to print.
|
|
44
|
-
|
|
45
|
-
Example
|
|
46
|
-
-------
|
|
47
|
-
Producing a set of proton showers for trigger rate simulations of LST.
|
|
48
|
-
|
|
49
|
-
.. code-block:: console
|
|
50
|
-
|
|
51
|
-
simtools-sim-showers-for-trigger-rates --array 4LST --site North --primary \
|
|
52
|
-
proton --nruns 2 --nevents 10000 --test --submit_command local
|
|
53
|
-
|
|
54
|
-
The output is saved in simtools-output/sim_showers_for_trigger_rates.
|
|
55
|
-
|
|
56
|
-
Expected final print-out message:
|
|
57
|
-
|
|
58
|
-
.. code-block:: console
|
|
59
|
-
|
|
60
|
-
INFO::sim_showers_for_trigger_rates(l174)::main::List of log files exported to \
|
|
61
|
-
/workdir/external/simtools/simtools-output/sim_showers_for_trigger_rates/application-\
|
|
62
|
-
plots/log_files_proton.list
|
|
63
|
-
INFO::simulator(l646)::get_list_of_log_files::Getting list of log files
|
|
64
|
-
|
|
65
|
-
"""
|
|
66
|
-
|
|
67
|
-
import logging
|
|
68
|
-
from pathlib import Path
|
|
69
|
-
|
|
70
|
-
import astropy.units as u
|
|
71
|
-
|
|
72
|
-
from simtools.configuration import configurator
|
|
73
|
-
from simtools.io_operations import io_handler
|
|
74
|
-
from simtools.simulator import Simulator
|
|
75
|
-
from simtools.utils import general as gen
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
def _parse(label=None, description=None):
|
|
79
|
-
"""
|
|
80
|
-
Parse command line configuration
|
|
81
|
-
|
|
82
|
-
Parameters
|
|
83
|
-
----------
|
|
84
|
-
label: str
|
|
85
|
-
application label.
|
|
86
|
-
description: str
|
|
87
|
-
description of application.
|
|
88
|
-
|
|
89
|
-
Returns
|
|
90
|
-
-------
|
|
91
|
-
CommandLineParser
|
|
92
|
-
command line parser object
|
|
93
|
-
|
|
94
|
-
"""
|
|
95
|
-
|
|
96
|
-
config = configurator.Configurator(label=label, description=description)
|
|
97
|
-
config.parser.add_argument(
|
|
98
|
-
"--array",
|
|
99
|
-
help="Name of the array (e.g. 1MST, 4LST ...)",
|
|
100
|
-
type=str,
|
|
101
|
-
required=True,
|
|
102
|
-
)
|
|
103
|
-
config.parser.add_argument(
|
|
104
|
-
"--primary",
|
|
105
|
-
help="Name of the primary particle (e.g. proton, helium ...)",
|
|
106
|
-
type=str,
|
|
107
|
-
required=True,
|
|
108
|
-
)
|
|
109
|
-
config.parser.add_argument("--nruns", help="Number of runs", type=int, default=100)
|
|
110
|
-
config.parser.add_argument("--nevents", help="Number of events/run", type=int, default=100000)
|
|
111
|
-
config.parser.add_argument("--zenith", help="Zenith angle in deg", type=float, default=20)
|
|
112
|
-
config.parser.add_argument("--azimuth", help="Azimuth angle in deg", type=float, default=0)
|
|
113
|
-
config.parser.add_argument(
|
|
114
|
-
"--data_directory",
|
|
115
|
-
help=(
|
|
116
|
-
"The directory where to save the corsika-data output directories."
|
|
117
|
-
"the label is added to the data_directory, such that the output"
|
|
118
|
-
"will be written to `data_directory/label/corsika-data`."
|
|
119
|
-
),
|
|
120
|
-
type=str.lower,
|
|
121
|
-
required=False,
|
|
122
|
-
default="./simtools-output/",
|
|
123
|
-
)
|
|
124
|
-
return config.initialize(telescope_model=True, job_submission=True, db_config=True)
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
def main():
|
|
128
|
-
label = Path(__file__).stem
|
|
129
|
-
args_dict, db_config = _parse(
|
|
130
|
-
label=label, description="Simulate showers to be used for trigger rate calculations"
|
|
131
|
-
)
|
|
132
|
-
|
|
133
|
-
logger = logging.getLogger()
|
|
134
|
-
logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
|
|
135
|
-
|
|
136
|
-
# Output directory to save files related directly to this app
|
|
137
|
-
_io_handler = io_handler.IOHandler()
|
|
138
|
-
output_dir = _io_handler.get_output_directory(label, sub_dir="application-plots")
|
|
139
|
-
shower_config_data = {
|
|
140
|
-
"data_directory": Path(args_dict["data_directory"]) / label,
|
|
141
|
-
"site": args_dict["site"],
|
|
142
|
-
"layout_name": args_dict["array"],
|
|
143
|
-
"run_range": [1, args_dict["nruns"] + 1],
|
|
144
|
-
"nshow": args_dict["nevents"],
|
|
145
|
-
"primary": args_dict["primary"],
|
|
146
|
-
"erange": [10 * u.GeV, 300 * u.TeV],
|
|
147
|
-
"eslope": -2,
|
|
148
|
-
"zenith": args_dict["zenith"] * u.deg,
|
|
149
|
-
"azimuth": args_dict["azimuth"] * u.deg,
|
|
150
|
-
"viewcone": 10 * u.deg,
|
|
151
|
-
"cscat": [20, 1500 * u.m, 0],
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
shower_simulator = Simulator(
|
|
155
|
-
label=label,
|
|
156
|
-
simulator="corsika",
|
|
157
|
-
simulator_source_path=args_dict.get("simtel_path", None),
|
|
158
|
-
config_data=shower_config_data,
|
|
159
|
-
submit_command=args_dict.get("submit_command", ""),
|
|
160
|
-
test=args_dict["test"],
|
|
161
|
-
mongo_db_config=db_config,
|
|
162
|
-
)
|
|
163
|
-
|
|
164
|
-
if not args_dict["test"]:
|
|
165
|
-
shower_simulator.simulate()
|
|
166
|
-
else:
|
|
167
|
-
logger.info("Test flag is on - it will not submit any job.")
|
|
168
|
-
logger.info("This is an example of the run script:")
|
|
169
|
-
shower_simulator.simulate()
|
|
170
|
-
|
|
171
|
-
# Exporting the list of output/log/input files into the application folder
|
|
172
|
-
output_file_list = output_dir.joinpath(f"output_files_{args_dict['primary']}.list")
|
|
173
|
-
log_file_list = output_dir.joinpath(f"log_files_{args_dict['primary']}.list")
|
|
174
|
-
|
|
175
|
-
def print_list_into_file(list_of_files, file_name):
|
|
176
|
-
with open(file_name, "w", encoding="utf-8") as f:
|
|
177
|
-
for line in list_of_files:
|
|
178
|
-
f.write(line + "\n")
|
|
179
|
-
|
|
180
|
-
logger.info(f"List of output files exported to {output_file_list}")
|
|
181
|
-
print_list_into_file(shower_simulator.get_list_of_output_files(), output_file_list)
|
|
182
|
-
logger.info(f"List of log files exported to {log_file_list}")
|
|
183
|
-
print_list_into_file(shower_simulator.get_list_of_log_files(), log_file_list)
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
if __name__ == "__main__":
|
|
187
|
-
main()
|
|
@@ -1,334 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/python3
|
|
2
|
-
|
|
3
|
-
"""
|
|
4
|
-
Summary
|
|
5
|
-
-------
|
|
6
|
-
This applications tunes the parameters mirror_reflection_random_angle, \
|
|
7
|
-
mirror_align_random_horizontal and mirror_align_random_vertical using \
|
|
8
|
-
cumulative PSF measurement.
|
|
9
|
-
|
|
10
|
-
The telescope zenith angle and the source distance can be set by command line arguments.
|
|
11
|
-
|
|
12
|
-
The measured cumulative PSF should be provided by using the command line argument data. \
|
|
13
|
-
A file name is expected, in which the file should contain 3 columns: radial distance in mm, \
|
|
14
|
-
differential value of photon intensity and its integral value.
|
|
15
|
-
|
|
16
|
-
The tuning is performed through a random search. A number of random combination of the \
|
|
17
|
-
parameters are tested and the best ones are selected based on the minimum value of \
|
|
18
|
-
the Root Mean Squared Deviation between data and simulations. The range in which the \
|
|
19
|
-
parameter are drawn uniformly are defined based on the previous value on the telescope model.
|
|
20
|
-
|
|
21
|
-
The assumption are:
|
|
22
|
-
|
|
23
|
-
a) mirror_align_random_horizontal and mirror_align_random_vertical are the same.
|
|
24
|
-
|
|
25
|
-
b) mirror_align_random_horizontal/vertical have no dependence on the zenith angle.
|
|
26
|
-
|
|
27
|
-
One example of the plot generated by this applications are shown below.
|
|
28
|
-
|
|
29
|
-
.. _tune_psf_plot:
|
|
30
|
-
.. image:: images/tune_psf.png
|
|
31
|
-
:width: 49 %
|
|
32
|
-
|
|
33
|
-
Command line arguments
|
|
34
|
-
----------------------
|
|
35
|
-
site (str, required)
|
|
36
|
-
North or South.
|
|
37
|
-
telescope (str, required)
|
|
38
|
-
Telescope model name (e.g. LST-1, SST-D, ...).
|
|
39
|
-
model_version (str, optional)
|
|
40
|
-
Model version.
|
|
41
|
-
src_distance (float, optional)
|
|
42
|
-
Source distance in km.
|
|
43
|
-
zenith (float, optional)
|
|
44
|
-
Zenith angle in deg.
|
|
45
|
-
data (str, optional)
|
|
46
|
-
Name of the data file with the measured cumulative PSF.
|
|
47
|
-
plot_all (activation mode, optional)
|
|
48
|
-
If activated, plots will be generated for all values tested during tuning.
|
|
49
|
-
fixed (activation mode, optional)
|
|
50
|
-
Keep the first entry of mirror_reflection_random_angle fixed.
|
|
51
|
-
test (activation mode, optional)
|
|
52
|
-
If activated, application will be faster by simulating fewer photons.
|
|
53
|
-
verbosity (str, optional)
|
|
54
|
-
Log level to print.
|
|
55
|
-
|
|
56
|
-
Example
|
|
57
|
-
-------
|
|
58
|
-
LST-1 Prod5
|
|
59
|
-
|
|
60
|
-
Runtime < 3 min.
|
|
61
|
-
|
|
62
|
-
Get PSF data from the DB:
|
|
63
|
-
|
|
64
|
-
.. code-block:: console
|
|
65
|
-
|
|
66
|
-
simtools-get-file-from_db --file_name PSFcurve_data_v2.txt
|
|
67
|
-
|
|
68
|
-
Run the application:
|
|
69
|
-
|
|
70
|
-
.. code-block:: console
|
|
71
|
-
|
|
72
|
-
simtools-tune-psf --site North --telescope LST-1 \
|
|
73
|
-
--model_version prod5 --data PSFcurve_data_v2.txt --plot_all --test
|
|
74
|
-
|
|
75
|
-
The output is saved in simtools-output/tune_psf.
|
|
76
|
-
|
|
77
|
-
Expected final print-out message:
|
|
78
|
-
|
|
79
|
-
.. code-block:: console
|
|
80
|
-
|
|
81
|
-
Best parameters:
|
|
82
|
-
mirror_reflection_random_angle = 0.0043,0.08,0.0470
|
|
83
|
-
mirror_align_random_horizontal = 0.0047,28.,0.,0.
|
|
84
|
-
mirror_align_random_vertical = 0.0047,28.,0.,0.
|
|
85
|
-
|
|
86
|
-
"""
|
|
87
|
-
|
|
88
|
-
import logging
|
|
89
|
-
from collections import OrderedDict
|
|
90
|
-
|
|
91
|
-
import astropy.units as u
|
|
92
|
-
import matplotlib.pyplot as plt
|
|
93
|
-
import numpy as np
|
|
94
|
-
from matplotlib.backends.backend_pdf import PdfPages
|
|
95
|
-
|
|
96
|
-
import simtools.utils.general as gen
|
|
97
|
-
from simtools.configuration import configurator
|
|
98
|
-
from simtools.io_operations import io_handler
|
|
99
|
-
from simtools.model.model_utils import split_simtel_parameter
|
|
100
|
-
from simtools.model.telescope_model import TelescopeModel
|
|
101
|
-
from simtools.ray_tracing import RayTracing
|
|
102
|
-
from simtools.visualization import visualize
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
def load_data(data_file):
|
|
106
|
-
"""
|
|
107
|
-
Load data from file txt file.
|
|
108
|
-
|
|
109
|
-
Parameters
|
|
110
|
-
----------
|
|
111
|
-
data_file: str
|
|
112
|
-
Name of the data file with the measured cumulative PSF.
|
|
113
|
-
"""
|
|
114
|
-
d_type = {"names": ("Radius [cm]", "Cumulative PSF"), "formats": ("f8", "f8")}
|
|
115
|
-
data = np.loadtxt(data_file, dtype=d_type, usecols=(0, 2))
|
|
116
|
-
data["Radius [cm]"] *= 0.1
|
|
117
|
-
data["Cumulative PSF"] /= np.max(np.abs(data["Cumulative PSF"]))
|
|
118
|
-
return data
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
def main():
|
|
122
|
-
config = configurator.Configurator(
|
|
123
|
-
description=(
|
|
124
|
-
"Tune mirror_reflection_random_angle, mirror_align_random_horizontal "
|
|
125
|
-
"and mirror_align_random_vertical using cumulative PSF measurement."
|
|
126
|
-
)
|
|
127
|
-
)
|
|
128
|
-
config.parser.add_argument(
|
|
129
|
-
"--src_distance",
|
|
130
|
-
help="Source distance in km",
|
|
131
|
-
type=float,
|
|
132
|
-
default=10,
|
|
133
|
-
)
|
|
134
|
-
config.parser.add_argument("--zenith", help="Zenith angle in deg", type=float, default=20)
|
|
135
|
-
config.parser.add_argument(
|
|
136
|
-
"--data", help="Data file name with the measured PSF vs radius [cm]", type=str
|
|
137
|
-
)
|
|
138
|
-
config.parser.add_argument(
|
|
139
|
-
"--plot_all",
|
|
140
|
-
help=(
|
|
141
|
-
"On: plot cumulative PSF for all tested combinations, "
|
|
142
|
-
"Off: plot it only for the best set of values"
|
|
143
|
-
),
|
|
144
|
-
action="store_true",
|
|
145
|
-
)
|
|
146
|
-
config.parser.add_argument(
|
|
147
|
-
"--fixed",
|
|
148
|
-
help=("Keep the first entry of mirror_reflection_random_angle fixed."),
|
|
149
|
-
action="store_true",
|
|
150
|
-
)
|
|
151
|
-
|
|
152
|
-
args_dict, db_config = config.initialize(db_config=True, telescope_model=True)
|
|
153
|
-
label = "tune_psf"
|
|
154
|
-
|
|
155
|
-
logger = logging.getLogger()
|
|
156
|
-
logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
|
|
157
|
-
|
|
158
|
-
# Output directory to save files related directly to this app
|
|
159
|
-
_io_handler = io_handler.IOHandler()
|
|
160
|
-
output_dir = _io_handler.get_output_directory(label, sub_dir="application-plots")
|
|
161
|
-
|
|
162
|
-
tel_model = TelescopeModel(
|
|
163
|
-
site=args_dict["site"],
|
|
164
|
-
telescope_model_name=args_dict["telescope"],
|
|
165
|
-
mongo_db_config=db_config,
|
|
166
|
-
model_version=args_dict["model_version"],
|
|
167
|
-
label=label,
|
|
168
|
-
)
|
|
169
|
-
# If we want to start from values different than the ones currently in the model:
|
|
170
|
-
# align = 0.0046
|
|
171
|
-
# pars_to_change = {
|
|
172
|
-
# 'mirror_reflection_random_angle': '0.0075 0.125 0.0037',
|
|
173
|
-
# 'mirror_align_random_horizontal': f'{align} 28 0 0',
|
|
174
|
-
# 'mirror_align_random_vertical': f'{align} 28 0 0',
|
|
175
|
-
# }
|
|
176
|
-
# tel_model.change_multiple_parameters(**pars_to_change)
|
|
177
|
-
|
|
178
|
-
all_parameters = []
|
|
179
|
-
|
|
180
|
-
def add_parameters(
|
|
181
|
-
mirror_reflection, mirror_align, mirror_reflection_fraction=0.15, mirror_reflection_2=0.035
|
|
182
|
-
):
|
|
183
|
-
"""
|
|
184
|
-
Transform the parameters to the proper format and add a new set of
|
|
185
|
-
parameters to the all_parameters list.
|
|
186
|
-
"""
|
|
187
|
-
pars = {}
|
|
188
|
-
mrra = f"{mirror_reflection:.4f},{mirror_reflection_fraction:.2f},{mirror_reflection_2:.4f}"
|
|
189
|
-
pars["mirror_reflection_random_angle"] = mrra
|
|
190
|
-
mar = f"{mirror_align:.4f},28.,0.,0."
|
|
191
|
-
pars["mirror_align_random_horizontal"] = mar
|
|
192
|
-
pars["mirror_align_random_vertical"] = mar
|
|
193
|
-
all_parameters.append(pars)
|
|
194
|
-
|
|
195
|
-
# Grabbing the previous values of the parameters from the tel model.
|
|
196
|
-
#
|
|
197
|
-
# mrra -> mirror reflection random angle (first entry of mirror_reflection_random_angle)
|
|
198
|
-
# mfr -> mirror fraction random (second entry of mirror_reflection_random_angle)
|
|
199
|
-
# mrra2 -> mirror reflection random angle 2 (third entry of mirror_reflection_random_angle)
|
|
200
|
-
# mar -> mirror align random (first entry of mirror_align_random_horizontal/vertical)
|
|
201
|
-
|
|
202
|
-
raw_par = tel_model.get_parameter("mirror_reflection_random_angle")["Value"]
|
|
203
|
-
split_par = split_simtel_parameter(raw_par)
|
|
204
|
-
mrra_0 = split_par[0]
|
|
205
|
-
mfr_0 = split_par[1]
|
|
206
|
-
mrra2_0 = split_par[2]
|
|
207
|
-
|
|
208
|
-
raw_par = tel_model.get_parameter("mirror_align_random_horizontal")["Value"]
|
|
209
|
-
mar_0 = split_simtel_parameter(raw_par)[0]
|
|
210
|
-
|
|
211
|
-
logger.debug(
|
|
212
|
-
"Previous parameter values:\n"
|
|
213
|
-
f"MRRA = {str(mrra_0)}\n"
|
|
214
|
-
f"MRF = {str(mfr_0)}\n"
|
|
215
|
-
f"MRRA2 = {str(mrra2_0)}\n"
|
|
216
|
-
f"MAR = {str(mar_0)}\n"
|
|
217
|
-
)
|
|
218
|
-
|
|
219
|
-
if args_dict["fixed"]:
|
|
220
|
-
logger.debug("fixed=True - First entry of mirror_reflection_random_angle is kept fixed.")
|
|
221
|
-
|
|
222
|
-
# Drawing parameters randonly
|
|
223
|
-
# Range around the previous values are hardcoded
|
|
224
|
-
# Number of runs is hardcoded
|
|
225
|
-
n_runs = 50
|
|
226
|
-
for _ in range(n_runs):
|
|
227
|
-
mrra_range = 0.004 if not args_dict["fixed"] else 0
|
|
228
|
-
mrf_range = 0.1
|
|
229
|
-
mrra2_range = 0.03
|
|
230
|
-
mar_range = 0.005
|
|
231
|
-
mrra = np.random.uniform(max(mrra_0 - mrra_range, 0), mrra_0 + mrra_range)
|
|
232
|
-
mrf = np.random.uniform(max(mfr_0 - mrf_range, 0), mfr_0 + mrf_range)
|
|
233
|
-
mrra2 = np.random.uniform(max(mrra2_0 - mrra2_range, 0), mrra2_0 + mrra2_range)
|
|
234
|
-
mar = np.random.uniform(max(mar_0 - mar_range, 0), mar_0 + mar_range)
|
|
235
|
-
add_parameters(mrra, mar, mrf, mrra2)
|
|
236
|
-
|
|
237
|
-
# Loading measured cumulative PSF
|
|
238
|
-
data_to_plot = OrderedDict()
|
|
239
|
-
if args_dict["data"] is not None:
|
|
240
|
-
data_file = gen.find_file(args_dict["data"], args_dict["model_path"])
|
|
241
|
-
data_to_plot["measured"] = load_data(data_file)
|
|
242
|
-
radius = data_to_plot["measured"]["Radius [cm]"]
|
|
243
|
-
|
|
244
|
-
# Preparing figure name
|
|
245
|
-
plot_file_name = "_".join((label, tel_model.name + ".pdf"))
|
|
246
|
-
plot_file = output_dir.joinpath(plot_file_name)
|
|
247
|
-
pdf_pages = PdfPages(plot_file)
|
|
248
|
-
|
|
249
|
-
def calculate_rmsd(data, sim):
|
|
250
|
-
"""
|
|
251
|
-
Calculates the Root Mean Squared Deviation to be used
|
|
252
|
-
as metric to find the best parameters.
|
|
253
|
-
"""
|
|
254
|
-
return np.sqrt(np.mean((data - sim) ** 2))
|
|
255
|
-
|
|
256
|
-
def run_pars(pars, plot=True):
|
|
257
|
-
"""
|
|
258
|
-
Runs the tuning for one set of parameters, add a plot to the pdfPages
|
|
259
|
-
(if plot=True) and returns the RMSD and the D80.
|
|
260
|
-
"""
|
|
261
|
-
tel_model.change_multiple_parameters(**pars)
|
|
262
|
-
|
|
263
|
-
ray = RayTracing.from_kwargs(
|
|
264
|
-
telescope_model=tel_model,
|
|
265
|
-
simtel_source_path=args_dict["simtel_path"],
|
|
266
|
-
source_distance=args_dict["src_distance"] * u.km,
|
|
267
|
-
zenith_angle=args_dict["zenith"] * u.deg,
|
|
268
|
-
off_axis_angle=[0.0 * u.deg],
|
|
269
|
-
)
|
|
270
|
-
|
|
271
|
-
ray.simulate(test=args_dict["test"], force=True)
|
|
272
|
-
ray.analyze(force=True, use_rx=False)
|
|
273
|
-
|
|
274
|
-
# Plotting cumulative PSF
|
|
275
|
-
im = ray.images()[0]
|
|
276
|
-
d80 = im.get_psf()
|
|
277
|
-
|
|
278
|
-
# Simulated cumulative PSF
|
|
279
|
-
data_to_plot["simulated"] = im.get_cumulative_data(radius * u.cm)
|
|
280
|
-
|
|
281
|
-
rmsd = calculate_rmsd(
|
|
282
|
-
data_to_plot["measured"]["Cumulative PSF"], data_to_plot["simulated"]["Cumulative PSF"]
|
|
283
|
-
)
|
|
284
|
-
|
|
285
|
-
if plot:
|
|
286
|
-
fig = visualize.plot_1d(
|
|
287
|
-
data_to_plot,
|
|
288
|
-
plot_difference=True,
|
|
289
|
-
no_markers=True,
|
|
290
|
-
)
|
|
291
|
-
ax = fig.get_axes()[0]
|
|
292
|
-
ax.set_ylim(0, 1.05)
|
|
293
|
-
ax.set_title(
|
|
294
|
-
f"refl_rnd={pars['mirror_reflection_random_angle']}, "
|
|
295
|
-
f"align_rnd={pars['mirror_align_random_vertical']}"
|
|
296
|
-
)
|
|
297
|
-
|
|
298
|
-
ax.text(
|
|
299
|
-
0.8,
|
|
300
|
-
0.3,
|
|
301
|
-
f"D80 = {d80:.3f} cm\nRMSD = {rmsd:.4f}",
|
|
302
|
-
verticalalignment="center",
|
|
303
|
-
horizontalalignment="center",
|
|
304
|
-
transform=ax.transAxes,
|
|
305
|
-
)
|
|
306
|
-
plt.tight_layout()
|
|
307
|
-
pdf_pages.savefig(fig)
|
|
308
|
-
plt.clf()
|
|
309
|
-
|
|
310
|
-
return d80, rmsd
|
|
311
|
-
|
|
312
|
-
# Running the tuning for all parameters in all_parameters
|
|
313
|
-
# and storing the best parameters in best_pars
|
|
314
|
-
min_rmsd = 100
|
|
315
|
-
for pars in all_parameters:
|
|
316
|
-
_, rmsd = run_pars(pars, plot=args_dict["plot_all"])
|
|
317
|
-
if rmsd < min_rmsd:
|
|
318
|
-
min_rmsd = rmsd
|
|
319
|
-
best_pars = pars
|
|
320
|
-
|
|
321
|
-
# Rerunnig and plotting the best pars
|
|
322
|
-
run_pars(best_pars, plot=True)
|
|
323
|
-
|
|
324
|
-
plt.close()
|
|
325
|
-
pdf_pages.close()
|
|
326
|
-
|
|
327
|
-
# Printing the results
|
|
328
|
-
print("Best parameters:")
|
|
329
|
-
for par, value in best_pars.items():
|
|
330
|
-
print(f"{par} = {value}")
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
if __name__ == "__main__":
|
|
334
|
-
main()
|