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
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"""Visualize Cherenkov photon distributions from CORSIKA."""
|
|
2
|
+
|
|
1
3
|
import logging
|
|
2
4
|
from pathlib import Path
|
|
3
5
|
|
|
@@ -12,10 +14,9 @@ _logger = logging.getLogger(__name__)
|
|
|
12
14
|
|
|
13
15
|
def _kernel_plot_2d_photons(histograms_instance, property_name, log_z=False):
|
|
14
16
|
"""
|
|
15
|
-
|
|
16
|
-
information from the Cherenkov photons saved.
|
|
17
|
+
Provide helper functions for plotting Cherenkov photon distributions saved in CorsikaHistograms.
|
|
17
18
|
|
|
18
|
-
Create the figure of a 2D plot. The parameter
|
|
19
|
+
Create the figure of a 2D plot. The parameter name indicate which plot.
|
|
19
20
|
Choices are "counts", "density", "direction", "time_altitude", and "num_photons_per_telescope".
|
|
20
21
|
|
|
21
22
|
Parameters
|
|
@@ -36,7 +37,7 @@ def _kernel_plot_2d_photons(histograms_instance, property_name, log_z=False):
|
|
|
36
37
|
Raises
|
|
37
38
|
------
|
|
38
39
|
ValueError
|
|
39
|
-
if
|
|
40
|
+
if property is not allowed.
|
|
40
41
|
"""
|
|
41
42
|
if property_name not in histograms_instance.dict_2d_distributions:
|
|
42
43
|
msg = (
|
|
@@ -44,12 +45,12 @@ def _kernel_plot_2d_photons(histograms_instance, property_name, log_z=False):
|
|
|
44
45
|
f"{histograms_instance.dict_2d_distributions}"
|
|
45
46
|
)
|
|
46
47
|
_logger.error(msg)
|
|
47
|
-
raise ValueError
|
|
48
|
-
|
|
48
|
+
raise ValueError(msg)
|
|
49
|
+
_function = getattr(
|
|
49
50
|
histograms_instance,
|
|
50
51
|
histograms_instance.dict_2d_distributions[property_name]["function"],
|
|
51
52
|
)
|
|
52
|
-
hist_values, x_bin_edges, y_bin_edges =
|
|
53
|
+
hist_values, x_bin_edges, y_bin_edges = _function()
|
|
53
54
|
|
|
54
55
|
all_figs = []
|
|
55
56
|
for i_hist, _ in enumerate(x_bin_edges):
|
|
@@ -215,7 +216,7 @@ def plot_2d_num_photons_per_telescope(histograms_instance, log_z=True):
|
|
|
215
216
|
|
|
216
217
|
def _kernel_plot_1d_photons(histograms_instance, property_name, log_y=True):
|
|
217
218
|
"""
|
|
218
|
-
Create the figure of a 1D plot. The parameter
|
|
219
|
+
Create the figure of a 1D plot. The parameter property indicate which plot.
|
|
219
220
|
|
|
220
221
|
Parameters
|
|
221
222
|
----------
|
|
@@ -236,7 +237,7 @@ def _kernel_plot_1d_photons(histograms_instance, property_name, log_y=True):
|
|
|
236
237
|
Raises
|
|
237
238
|
------
|
|
238
239
|
ValueError
|
|
239
|
-
if
|
|
240
|
+
if property is not allowed.
|
|
240
241
|
"""
|
|
241
242
|
if property_name not in histograms_instance.dict_1d_distributions:
|
|
242
243
|
msg = (
|
|
@@ -244,13 +245,13 @@ def _kernel_plot_1d_photons(histograms_instance, property_name, log_y=True):
|
|
|
244
245
|
f"{histograms_instance.dict_1d_distributions}"
|
|
245
246
|
)
|
|
246
247
|
_logger.error(msg)
|
|
247
|
-
raise ValueError
|
|
248
|
+
raise ValueError(msg)
|
|
248
249
|
|
|
249
|
-
|
|
250
|
+
_function = getattr(
|
|
250
251
|
histograms_instance,
|
|
251
252
|
histograms_instance.dict_1d_distributions[property_name]["function"],
|
|
252
253
|
)
|
|
253
|
-
hist_values, bin_edges =
|
|
254
|
+
hist_values, bin_edges = _function()
|
|
254
255
|
all_figs = []
|
|
255
256
|
for i_hist, _ in enumerate(bin_edges):
|
|
256
257
|
fig, ax = plt.subplots()
|
|
@@ -299,7 +300,7 @@ def _kernel_plot_1d_photons(histograms_instance, property_name, log_y=True):
|
|
|
299
300
|
|
|
300
301
|
def plot_wavelength_distr(histograms_instance, log_y=True):
|
|
301
302
|
"""
|
|
302
|
-
|
|
303
|
+
Plot the 1D distribution of the photon wavelengths.
|
|
303
304
|
|
|
304
305
|
Parameters
|
|
305
306
|
----------
|
|
@@ -318,7 +319,7 @@ def plot_wavelength_distr(histograms_instance, log_y=True):
|
|
|
318
319
|
|
|
319
320
|
def plot_counts_distr(histograms_instance, log_y=True):
|
|
320
321
|
"""
|
|
321
|
-
|
|
322
|
+
Plot the 1D distribution, i.e. the radial distribution, of the photons on the ground.
|
|
322
323
|
|
|
323
324
|
Parameters
|
|
324
325
|
----------
|
|
@@ -337,7 +338,7 @@ def plot_counts_distr(histograms_instance, log_y=True):
|
|
|
337
338
|
|
|
338
339
|
def plot_density_distr(histograms_instance, log_y=True):
|
|
339
340
|
"""
|
|
340
|
-
|
|
341
|
+
Plot the photon density distribution on the ground.
|
|
341
342
|
|
|
342
343
|
Parameters
|
|
343
344
|
----------
|
|
@@ -356,7 +357,7 @@ def plot_density_distr(histograms_instance, log_y=True):
|
|
|
356
357
|
|
|
357
358
|
def plot_time_distr(histograms_instance, log_y=True):
|
|
358
359
|
"""
|
|
359
|
-
|
|
360
|
+
Plot the distribution times in which the photons were generated in ns.
|
|
360
361
|
|
|
361
362
|
Parameters
|
|
362
363
|
----------
|
|
@@ -375,7 +376,7 @@ def plot_time_distr(histograms_instance, log_y=True):
|
|
|
375
376
|
|
|
376
377
|
def plot_altitude_distr(histograms_instance, log_y=True):
|
|
377
378
|
"""
|
|
378
|
-
|
|
379
|
+
Plot the distribution of altitude in which the photons were generated in km.
|
|
379
380
|
|
|
380
381
|
Parameters
|
|
381
382
|
----------
|
|
@@ -394,7 +395,7 @@ def plot_altitude_distr(histograms_instance, log_y=True):
|
|
|
394
395
|
|
|
395
396
|
def plot_photon_per_event_distr(histograms_instance, log_y=True):
|
|
396
397
|
"""
|
|
397
|
-
|
|
398
|
+
Plot the distribution of the number of Cherenkov photons per event.
|
|
398
399
|
|
|
399
400
|
Parameters
|
|
400
401
|
----------
|
|
@@ -409,13 +410,12 @@ def plot_photon_per_event_distr(histograms_instance, log_y=True):
|
|
|
409
410
|
List of figures for the given telescopes.
|
|
410
411
|
|
|
411
412
|
"""
|
|
412
|
-
|
|
413
413
|
return _kernel_plot_1d_photons(histograms_instance, "num_photons_per_event", log_y=log_y)
|
|
414
414
|
|
|
415
415
|
|
|
416
416
|
def plot_photon_per_telescope_distr(histograms_instance, log_y=True):
|
|
417
417
|
"""
|
|
418
|
-
|
|
418
|
+
Plot the distribution of the number of Cherenkov photons per telescope.
|
|
419
419
|
|
|
420
420
|
Parameters
|
|
421
421
|
----------
|
|
@@ -430,7 +430,6 @@ def plot_photon_per_telescope_distr(histograms_instance, log_y=True):
|
|
|
430
430
|
List of figures for the given telescopes.
|
|
431
431
|
|
|
432
432
|
"""
|
|
433
|
-
|
|
434
433
|
return _kernel_plot_1d_photons(histograms_instance, "num_photons_per_telescope", log_y=log_y)
|
|
435
434
|
|
|
436
435
|
|
|
@@ -438,7 +437,7 @@ def plot_1d_event_header_distribution(
|
|
|
438
437
|
histograms_instance, event_header_element, log_y=True, bins=50, hist_range=None
|
|
439
438
|
):
|
|
440
439
|
"""
|
|
441
|
-
|
|
440
|
+
Plot the distribution of the quantity given by .
|
|
442
441
|
|
|
443
442
|
Parameters
|
|
444
443
|
----------
|
|
@@ -496,7 +495,7 @@ def plot_2d_event_header_distribution(
|
|
|
496
495
|
hist_range=None,
|
|
497
496
|
):
|
|
498
497
|
"""
|
|
499
|
-
|
|
498
|
+
Plot the distribution of the quantity given by CorsikaHistograms.
|
|
500
499
|
|
|
501
500
|
Parameters
|
|
502
501
|
----------
|
|
@@ -563,7 +562,7 @@ def save_figs_to_pdf(figs, pdf_file_name):
|
|
|
563
562
|
Parameters
|
|
564
563
|
----------
|
|
565
564
|
figs: list or numpy.array
|
|
566
|
-
List with the figures output by
|
|
565
|
+
List with the figures output by corsika_output_visualize.py.
|
|
567
566
|
pdf_file_name: str or Path
|
|
568
567
|
Name of the pdf file.
|
|
569
568
|
"""
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"""Primary particle definition."""
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
|
|
5
|
+
from particle import Corsika7ID, InvalidParticle, Particle
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class PrimaryParticle:
|
|
9
|
+
"""
|
|
10
|
+
Primary particle definition using CORSIKA7 or PDG ID.
|
|
11
|
+
|
|
12
|
+
Uses a dictionary to map particle common names to CORSIKA7 IDs.
|
|
13
|
+
Particles not found in the dictionary are searched in the PDG particle database.
|
|
14
|
+
|
|
15
|
+
Parameters
|
|
16
|
+
----------
|
|
17
|
+
particle_id_type : str
|
|
18
|
+
Type of the primary particle ID ('corsika7_id', 'common_name', or 'pdg_id').
|
|
19
|
+
particle_id : int or str
|
|
20
|
+
The actual ID of the primary particle.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
def __init__(self, particle_id_type=None, particle_id=None):
|
|
24
|
+
self._logger = logging.getLogger(__name__)
|
|
25
|
+
|
|
26
|
+
self._corsika7_id = None
|
|
27
|
+
self._name = None
|
|
28
|
+
self._pdg_id = None
|
|
29
|
+
self._pdg_name = None
|
|
30
|
+
|
|
31
|
+
if bool(particle_id_type) != bool(particle_id):
|
|
32
|
+
raise ValueError("Both 'particle_id_type' and 'particle_id' must be provided together.")
|
|
33
|
+
|
|
34
|
+
valid_id_types = {"corsika7_id", "common_name", "pdg_id"}
|
|
35
|
+
if particle_id_type and particle_id_type not in valid_id_types:
|
|
36
|
+
raise ValueError(f"Particle ID type must be one of {valid_id_types}")
|
|
37
|
+
|
|
38
|
+
if particle_id_type == "corsika7_id":
|
|
39
|
+
self.corsika7_id = particle_id
|
|
40
|
+
elif particle_id_type == "common_name":
|
|
41
|
+
self.name = particle_id
|
|
42
|
+
elif particle_id_type == "pdg_id":
|
|
43
|
+
self.pdg_id = particle_id
|
|
44
|
+
|
|
45
|
+
def __str__(self):
|
|
46
|
+
"""Return a string representation of the primary particle."""
|
|
47
|
+
return f"{self.name} ({self.corsika7_id}, {self.pdg_id}, {self.pdg_name})"
|
|
48
|
+
|
|
49
|
+
@property
|
|
50
|
+
def corsika7_id(self):
|
|
51
|
+
"""CORSIKA7 ID of the primary particle."""
|
|
52
|
+
return self._corsika7_id
|
|
53
|
+
|
|
54
|
+
@corsika7_id.setter
|
|
55
|
+
def corsika7_id(self, value):
|
|
56
|
+
"""Set CORSIKA7 ID of the primary particle."""
|
|
57
|
+
for name, ids in self.particle_names().items():
|
|
58
|
+
if value == ids["corsika7_id"]:
|
|
59
|
+
self._corsika7_id = int(value)
|
|
60
|
+
self._name = name
|
|
61
|
+
self._pdg_id = ids["pdg_id"]
|
|
62
|
+
self._pdg_name = ids["pdg_name"]
|
|
63
|
+
return
|
|
64
|
+
# no particle found - check PDG
|
|
65
|
+
try:
|
|
66
|
+
self._pdg_id = Corsika7ID(value).to_pdgid().numerator
|
|
67
|
+
self._pdg_name = Particle.findall(pdgid=self._pdg_id)[0].name
|
|
68
|
+
self._name = Corsika7ID(value).name()
|
|
69
|
+
except (IndexError, InvalidParticle) as exc:
|
|
70
|
+
raise ValueError(f"Invalid CORSIKA7 ID: {value}") from exc
|
|
71
|
+
self._corsika7_id = int(value)
|
|
72
|
+
|
|
73
|
+
@property
|
|
74
|
+
def name(self):
|
|
75
|
+
"""Common name of the primary particle."""
|
|
76
|
+
return self._name
|
|
77
|
+
|
|
78
|
+
@name.setter
|
|
79
|
+
def name(self, value):
|
|
80
|
+
"""Set common name of the primary particle."""
|
|
81
|
+
particles = self.particle_names()
|
|
82
|
+
if value.lower() in particles:
|
|
83
|
+
self._name = value.lower()
|
|
84
|
+
self._corsika7_id = particles[self._name]["corsika7_id"]
|
|
85
|
+
self._pdg_id = particles[self._name]["pdg_id"]
|
|
86
|
+
self._pdg_name = particles[self._name]["pdg_name"]
|
|
87
|
+
return
|
|
88
|
+
|
|
89
|
+
pdg_list = Particle.findall(lambda p: value in p.name)
|
|
90
|
+
if len(pdg_list) == 1:
|
|
91
|
+
self._pdg_id = pdg_list[0].pdgid.numerator
|
|
92
|
+
self._pdg_name = pdg_list[0].name
|
|
93
|
+
self._corsika7_id = Corsika7ID.from_pdgid(self._pdg_id).numerator
|
|
94
|
+
self._name = Corsika7ID.from_pdgid(self._pdg_id).name()
|
|
95
|
+
return
|
|
96
|
+
if len(pdg_list) > 1:
|
|
97
|
+
raise ValueError(f"Found more than one particle with name {value}: {pdg_list}")
|
|
98
|
+
|
|
99
|
+
raise ValueError(f"Invalid particle name: {value}")
|
|
100
|
+
|
|
101
|
+
@property
|
|
102
|
+
def pdg_id(self):
|
|
103
|
+
"""PDG ID of the primary particle."""
|
|
104
|
+
return self._pdg_id
|
|
105
|
+
|
|
106
|
+
@pdg_id.setter
|
|
107
|
+
def pdg_id(self, value):
|
|
108
|
+
"""Set PDG ID of the primary particle."""
|
|
109
|
+
# check if particle is in the default particle dictionary
|
|
110
|
+
for name, ids in self.particle_names().items():
|
|
111
|
+
if value == ids["pdg_id"]:
|
|
112
|
+
self._corsika7_id = ids["corsika7_id"]
|
|
113
|
+
self._name = name
|
|
114
|
+
self._pdg_id = value
|
|
115
|
+
self._pdg_name = ids["pdg_name"]
|
|
116
|
+
return
|
|
117
|
+
# no particle found - check PDG
|
|
118
|
+
try:
|
|
119
|
+
self._pdg_id = Particle.findall(pdgid=value)[0].pdgid.numerator
|
|
120
|
+
self._pdg_name = Particle.findall(pdgid=value)[0].name
|
|
121
|
+
except IndexError as exc:
|
|
122
|
+
raise ValueError(f"Invalid DPG ID: {value}") from exc
|
|
123
|
+
self._corsika7_id = Corsika7ID.from_pdgid(self._pdg_id).numerator
|
|
124
|
+
self._name = Corsika7ID.from_pdgid(self._pdg_id).name()
|
|
125
|
+
|
|
126
|
+
@property
|
|
127
|
+
def pdg_name(self):
|
|
128
|
+
"""PDG name of the primary particle."""
|
|
129
|
+
return self._pdg_name
|
|
130
|
+
|
|
131
|
+
@staticmethod
|
|
132
|
+
def particle_names():
|
|
133
|
+
"""
|
|
134
|
+
Primary particles including common names, CORSIKA7 IDs, and PDG IDs.
|
|
135
|
+
|
|
136
|
+
Returns
|
|
137
|
+
-------
|
|
138
|
+
dict
|
|
139
|
+
Dictionary of particle names, CORSIKA7 IDs, and PDG IDs.
|
|
140
|
+
"""
|
|
141
|
+
particles = {
|
|
142
|
+
"gamma": {"corsika7_id": 1},
|
|
143
|
+
"electron": {"corsika7_id": 3},
|
|
144
|
+
"positron": {"corsika7_id": 2},
|
|
145
|
+
"muon+": {"corsika7_id": 5},
|
|
146
|
+
"muon-": {"corsika7_id": 6},
|
|
147
|
+
"proton": {"corsika7_id": 14},
|
|
148
|
+
"neutron": {"corsika7_id": 13},
|
|
149
|
+
"helium": {"corsika7_id": 402},
|
|
150
|
+
"carbon": {"corsika7_id": 601},
|
|
151
|
+
"nitrogen": {"corsika7_id": 1407},
|
|
152
|
+
"silicon": {"corsika7_id": 2814},
|
|
153
|
+
"iron": {"corsika7_id": 5626},
|
|
154
|
+
}
|
|
155
|
+
for _, ids in particles.items():
|
|
156
|
+
ids["pdg_id"] = Corsika7ID(ids["corsika7_id"]).to_pdgid().numerator
|
|
157
|
+
ids["pdg_name"] = Particle.findall(pdgid=ids["pdg_id"])[0].name
|
|
158
|
+
|
|
159
|
+
return particles
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"""Helper module for reading of standardized simtools data products."""
|
|
2
|
+
|
|
1
3
|
import logging
|
|
2
4
|
|
|
3
5
|
import astropy.units as u
|
|
@@ -5,7 +7,7 @@ from astropy.io.registry.base import IORegistryError
|
|
|
5
7
|
from astropy.table import QTable
|
|
6
8
|
|
|
7
9
|
import simtools.utils.general as gen
|
|
8
|
-
from simtools.data_model import
|
|
10
|
+
from simtools.data_model import validate_data
|
|
9
11
|
from simtools.data_model.metadata_collector import MetadataCollector
|
|
10
12
|
|
|
11
13
|
__all__ = ["read_table_from_file", "read_value_from_file"]
|
|
@@ -16,12 +18,13 @@ _logger = logging.getLogger(__name__)
|
|
|
16
18
|
def read_table_from_file(file_name, schema_file=None, validate=False, metadata_file=None):
|
|
17
19
|
"""
|
|
18
20
|
Read astropy table from file and validate against schema.
|
|
21
|
+
|
|
19
22
|
Metadata is read from metadata file or from the metadata section of the data file.
|
|
20
23
|
Schema for validation can be given as argument, or is determined
|
|
21
24
|
from the metadata associated to the file.
|
|
22
25
|
|
|
23
|
-
Parameters
|
|
24
|
-
|
|
26
|
+
Parameters
|
|
27
|
+
----------
|
|
25
28
|
file_name: str or Path
|
|
26
29
|
Name of file to be read.
|
|
27
30
|
schema_file: str or Path
|
|
@@ -31,8 +34,8 @@ def read_table_from_file(file_name, schema_file=None, validate=False, metadata_f
|
|
|
31
34
|
metadata_file: str or Path
|
|
32
35
|
Name of metadata file to be read.
|
|
33
36
|
|
|
34
|
-
Returns
|
|
35
|
-
|
|
37
|
+
Returns
|
|
38
|
+
-------
|
|
36
39
|
astropy Table
|
|
37
40
|
Table read from file.
|
|
38
41
|
|
|
@@ -42,7 +45,6 @@ def read_table_from_file(file_name, schema_file=None, validate=False, metadata_f
|
|
|
42
45
|
If file does not exist.
|
|
43
46
|
|
|
44
47
|
"""
|
|
45
|
-
|
|
46
48
|
try:
|
|
47
49
|
data_table = QTable.read(file_name)
|
|
48
50
|
except (FileNotFoundError, IORegistryError) as exc:
|
|
@@ -72,15 +74,17 @@ def read_table_from_file(file_name, schema_file=None, validate=False, metadata_f
|
|
|
72
74
|
|
|
73
75
|
def read_value_from_file(file_name, schema_file=None, validate=False):
|
|
74
76
|
"""
|
|
75
|
-
Read value from file and validate against schema.
|
|
77
|
+
Read value from file and validate against schema.
|
|
78
|
+
|
|
79
|
+
Expect data to follow the convention for
|
|
76
80
|
how simulation model parameters are stored in the simulation model database: to be a single
|
|
77
81
|
value stored in the 'value' field (with possible units in the 'units' field).
|
|
78
82
|
Metadata is read from metadata file or from the metadata section of the data file.
|
|
79
83
|
Schema for validation can be given as argument, or is determined
|
|
80
84
|
from the metadata associated to the file.
|
|
81
85
|
|
|
82
|
-
Parameters
|
|
83
|
-
|
|
86
|
+
Parameters
|
|
87
|
+
----------
|
|
84
88
|
file_name: str or Path
|
|
85
89
|
Name of file to be read.
|
|
86
90
|
schema_file: str or Path
|
|
@@ -88,8 +92,8 @@ def read_value_from_file(file_name, schema_file=None, validate=False):
|
|
|
88
92
|
validate: bool
|
|
89
93
|
Validate data against schema (if true).
|
|
90
94
|
|
|
91
|
-
Returns
|
|
92
|
-
|
|
95
|
+
Returns
|
|
96
|
+
-------
|
|
93
97
|
astro quantity or str
|
|
94
98
|
Value read from file. If units are given, return an astropy quantity, otherwise a string.
|
|
95
99
|
Return None if no value is found in the file.
|
|
@@ -100,9 +104,8 @@ def read_value_from_file(file_name, schema_file=None, validate=False):
|
|
|
100
104
|
If file does not exist.
|
|
101
105
|
|
|
102
106
|
"""
|
|
103
|
-
|
|
104
107
|
try:
|
|
105
|
-
data = gen.
|
|
108
|
+
data = gen.collect_data_from_file(file_name=file_name)
|
|
106
109
|
except FileNotFoundError as exc:
|
|
107
110
|
_logger.error("Error reading data from %s", file_name)
|
|
108
111
|
raise exc
|
|
@@ -117,13 +120,15 @@ def read_value_from_file(file_name, schema_file=None, validate=False):
|
|
|
117
120
|
schema_file = _collector.get_data_model_schema_file_name()
|
|
118
121
|
_logger.debug(f"Using schema from meta_data_url: {schema_file}")
|
|
119
122
|
|
|
120
|
-
|
|
123
|
+
_validator = validate_data.DataValidator(
|
|
124
|
+
schema_file=schema_file,
|
|
125
|
+
data_dict=data,
|
|
126
|
+
)
|
|
127
|
+
data = _validator.validate_and_transform()
|
|
121
128
|
_logger.debug("Successful validation of yaml/json file")
|
|
122
129
|
|
|
123
|
-
|
|
130
|
+
_value = data.get("value")
|
|
131
|
+
if _value is None:
|
|
124
132
|
return None
|
|
125
|
-
|
|
126
|
-
if
|
|
127
|
-
return data["Value"] * u.Unit(data["units"])
|
|
128
|
-
|
|
129
|
-
return data["Value"]
|
|
133
|
+
_unit = data.get("unit")
|
|
134
|
+
return _value if _unit is None else _value * u.Unit(_unit)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""Custom format checkers for jsonschema validation."""
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
|
|
5
|
+
import astropy.units as u
|
|
6
|
+
import jsonschema
|
|
7
|
+
|
|
8
|
+
from simtools.utils import names
|
|
9
|
+
|
|
10
|
+
format_checker = jsonschema.FormatChecker()
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@format_checker.checks("astropy_unit")
|
|
14
|
+
def check_astropy_unit(unit_string):
|
|
15
|
+
"""Validate astropy units (including dimensionless) for jsonschema."""
|
|
16
|
+
try:
|
|
17
|
+
u.Unit(unit_string)
|
|
18
|
+
except (ValueError, TypeError) as exc:
|
|
19
|
+
if unit_string != "dimensionless":
|
|
20
|
+
raise ValueError(f"'{unit_string}' is not a valid Unit") from exc
|
|
21
|
+
return True
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@format_checker.checks("astropy_unit_of_time")
|
|
25
|
+
def check_astropy_unit_of_time(unit_string):
|
|
26
|
+
"""Validate astropy units that this is an astropy unit of time."""
|
|
27
|
+
u.Unit(unit_string).to("s")
|
|
28
|
+
return True
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@format_checker.checks("astropy_unit_of_length)")
|
|
32
|
+
def check_astropy_unit_of_length(unit_string):
|
|
33
|
+
"""Validate astropy units that this is an astropy unit of length."""
|
|
34
|
+
u.Unit(unit_string).to("m")
|
|
35
|
+
return True
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@format_checker.checks("array_element")
|
|
39
|
+
def check_array_element(element):
|
|
40
|
+
"""Validate array elements for jsonschema."""
|
|
41
|
+
names.validate_array_element_name(element)
|
|
42
|
+
return True
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@format_checker.checks("array_triggers_name")
|
|
46
|
+
def check_array_triggers_name(name):
|
|
47
|
+
"""Validate array trigger names for jsonschema."""
|
|
48
|
+
pattern = r"(.*)(?=_single_telescope|_array)"
|
|
49
|
+
if not re.match(pattern, name):
|
|
50
|
+
raise ValueError(f"Array trigger name '{name}' does not match pattern '{pattern}'")
|
|
51
|
+
names.validate_array_element_type(re.match(pattern, name).group(1))
|
|
52
|
+
return True
|