gammasimtools 0.21.0__py3-none-any.whl → 0.23.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {gammasimtools-0.21.0.dist-info → gammasimtools-0.23.0.dist-info}/METADATA +3 -3
- gammasimtools-0.23.0.dist-info/RECORD +414 -0
- {gammasimtools-0.21.0.dist-info → gammasimtools-0.23.0.dist-info}/entry_points.txt +2 -1
- simtools/_version.py +2 -2
- simtools/application_control.py +118 -0
- simtools/applications/calculate_incident_angles.py +17 -25
- simtools/applications/convert_all_model_parameters_from_simtel.py +29 -45
- simtools/applications/convert_geo_coordinates_of_array_elements.py +26 -45
- simtools/applications/convert_model_parameter_from_simtel.py +21 -42
- simtools/applications/db_add_file_to_db.py +12 -13
- simtools/applications/db_add_simulation_model_from_repository_to_db.py +20 -33
- simtools/applications/db_add_value_from_json_to_db.py +28 -23
- simtools/applications/db_development_tools/write_array_elements_positions_to_repository.py +19 -34
- simtools/applications/db_generate_compound_indexes.py +12 -27
- simtools/applications/db_get_array_layouts_from_db.py +19 -39
- simtools/applications/db_get_file_from_db.py +15 -17
- simtools/applications/db_get_parameter_from_db.py +33 -35
- simtools/applications/db_inspect_databases.py +10 -11
- simtools/applications/db_upload_model_repository.py +104 -0
- simtools/applications/derive_ctao_array_layouts.py +16 -21
- simtools/applications/derive_mirror_rnda.py +9 -14
- simtools/applications/derive_photon_electron_spectrum.py +7 -10
- simtools/applications/derive_psf_parameters.py +24 -21
- simtools/applications/derive_trigger_rates.py +6 -9
- simtools/applications/docs_produce_array_element_report.py +22 -23
- simtools/applications/docs_produce_calibration_reports.py +26 -24
- simtools/applications/docs_produce_model_parameter_reports.py +15 -22
- simtools/applications/docs_produce_simulation_configuration_report.py +21 -22
- simtools/applications/generate_array_config.py +14 -33
- simtools/applications/generate_corsika_histograms.py +22 -43
- simtools/applications/generate_default_metadata.py +15 -36
- simtools/applications/generate_regular_arrays.py +11 -15
- simtools/applications/generate_simtel_event_data.py +23 -33
- simtools/applications/maintain_simulation_model_add_production.py +17 -48
- simtools/applications/maintain_simulation_model_compare_productions.py +10 -12
- simtools/applications/maintain_simulation_model_verify_production_tables.py +8 -11
- simtools/applications/merge_tables.py +15 -24
- simtools/applications/plot_array_layout.py +77 -55
- simtools/applications/plot_simtel_events.py +11 -13
- simtools/applications/plot_tabular_data.py +17 -38
- simtools/applications/plot_tabular_data_for_model_parameter.py +16 -23
- simtools/applications/print_version.py +14 -42
- simtools/applications/production_derive_corsika_limits.py +5 -9
- simtools/applications/production_derive_statistics.py +12 -26
- simtools/applications/production_generate_grid.py +20 -48
- simtools/applications/production_merge_corsika_limits.py +17 -21
- simtools/applications/run_application.py +12 -32
- simtools/applications/simulate_flasher.py +79 -81
- simtools/applications/simulate_illuminator.py +56 -197
- simtools/applications/{simulate_calibration_events.py → simulate_pedestals.py} +22 -68
- simtools/applications/simulate_prod.py +21 -33
- simtools/applications/simulate_prod_htcondor_generator.py +11 -25
- simtools/applications/submit_array_layouts.py +15 -18
- simtools/applications/submit_data_from_external.py +18 -34
- simtools/applications/submit_model_parameter_from_external.py +27 -41
- simtools/applications/validate_camera_efficiency.py +23 -22
- simtools/applications/validate_camera_fov.py +21 -27
- simtools/applications/validate_cumulative_psf.py +28 -37
- simtools/applications/validate_file_using_schema.py +35 -45
- simtools/applications/validate_optics.py +27 -33
- simtools/camera/camera_efficiency.py +8 -13
- simtools/configuration/commandline_parser.py +33 -11
- simtools/configuration/configurator.py +0 -7
- simtools/corsika/corsika_config.py +9 -16
- simtools/corsika/corsika_histograms.py +1 -1
- simtools/data_model/data_reader.py +0 -2
- simtools/data_model/metadata_collector.py +0 -2
- simtools/data_model/model_data_writer.py +87 -27
- simtools/data_model/schema.py +61 -2
- simtools/data_model/validate_data.py +1 -3
- simtools/db/db_handler.py +58 -39
- simtools/db/db_model_upload.py +210 -5
- simtools/io/hdf5_handler.py +0 -5
- simtools/io/io_handler.py +31 -83
- simtools/io/legacy_data_handler.py +0 -5
- simtools/job_execution/job_manager.py +43 -1
- simtools/layout/array_layout.py +0 -2
- simtools/layout/array_layout_utils.py +1 -5
- simtools/layout/telescope_position.py +0 -2
- simtools/model/array_model.py +95 -46
- simtools/model/calibration_model.py +0 -2
- simtools/model/camera.py +0 -2
- simtools/model/mirrors.py +0 -2
- simtools/model/model_parameter.py +50 -16
- simtools/model/model_repository.py +139 -106
- simtools/model/model_utils.py +21 -11
- simtools/model/site_model.py +0 -2
- simtools/model/telescope_model.py +20 -2
- simtools/production_configuration/calculate_statistical_uncertainties_grid_point.py +0 -2
- simtools/production_configuration/derive_corsika_limits.py +1 -1
- simtools/production_configuration/derive_production_statistics.py +0 -2
- simtools/production_configuration/interpolation_handler.py +0 -2
- simtools/ray_tracing/incident_angles.py +7 -7
- simtools/ray_tracing/mirror_panel_psf.py +1 -1
- simtools/ray_tracing/psf_analysis.py +0 -2
- simtools/ray_tracing/psf_parameter_optimisation.py +180 -73
- simtools/ray_tracing/ray_tracing.py +1 -5
- simtools/reporting/docs_auto_report_generator.py +108 -0
- simtools/reporting/docs_read_parameters.py +168 -104
- simtools/resources/array_elements.yml +26 -0
- simtools/runners/corsika_runner.py +0 -2
- simtools/runners/corsika_simtel_runner.py +11 -19
- simtools/runners/runner_services.py +5 -6
- simtools/runners/simtel_runner.py +0 -2
- simtools/runners/simtools_runner.py +0 -2
- simtools/schemas/application_workflow.metaschema.yml +1 -1
- simtools/schemas/common_definitions.schema.yml +39 -0
- simtools/schemas/model_parameter.metaschema.yml +19 -13
- simtools/schemas/model_parameter_and_data_schema.metaschema.yml +6 -12
- simtools/schemas/model_parameters/adjust_gain.schema.yml +0 -5
- simtools/schemas/model_parameters/altitude.schema.yml +0 -5
- simtools/schemas/model_parameters/array_coordinates.schema.yml +0 -5
- simtools/schemas/model_parameters/array_coordinates_UTM.schema.yml +0 -5
- simtools/schemas/model_parameters/array_element_position_ground.schema.yml +0 -7
- simtools/schemas/model_parameters/array_element_position_utm.schema.yml +0 -7
- simtools/schemas/model_parameters/array_layouts.schema.yml +0 -5
- simtools/schemas/model_parameters/array_triggers.schema.yml +0 -5
- simtools/schemas/model_parameters/array_window.schema.yml +0 -7
- simtools/schemas/model_parameters/asum_clipping.schema.yml +0 -3
- simtools/schemas/model_parameters/asum_offset.schema.yml +0 -7
- simtools/schemas/model_parameters/asum_shaping.schema.yml +0 -7
- simtools/schemas/model_parameters/asum_threshold.schema.yml +0 -7
- simtools/schemas/model_parameters/atmospheric_profile.schema.yml +0 -5
- simtools/schemas/model_parameters/atmospheric_transmission.schema.yml +0 -5
- simtools/schemas/model_parameters/axes_offsets.schema.yml +0 -7
- simtools/schemas/model_parameters/calibration_devices.schema.yml +30 -0
- simtools/schemas/model_parameters/camera_body_diameter.schema.yml +0 -7
- simtools/schemas/model_parameters/camera_body_shape.schema.yml +0 -7
- simtools/schemas/model_parameters/camera_config_file.schema.yml +0 -7
- simtools/schemas/model_parameters/camera_config_rotate.schema.yml +0 -7
- simtools/schemas/model_parameters/camera_degraded_efficiency.schema.yml +0 -7
- simtools/schemas/model_parameters/camera_degraded_map.schema.yml +0 -7
- simtools/schemas/model_parameters/camera_depth.schema.yml +0 -7
- simtools/schemas/model_parameters/camera_filter.schema.yml +0 -7
- simtools/schemas/model_parameters/camera_filter_incidence_angle.schema.yml +0 -3
- simtools/schemas/model_parameters/camera_pixels.schema.yml +0 -7
- simtools/schemas/model_parameters/camera_transmission.schema.yml +0 -7
- simtools/schemas/model_parameters/channels_per_chip.schema.yml +0 -7
- simtools/schemas/model_parameters/correct_nsb_spectrum_to_telescope_altitude.schema.yml +0 -7
- simtools/schemas/model_parameters/corsika_observation_level.schema.yml +0 -5
- simtools/schemas/model_parameters/dark_events.schema.yml +4 -3
- simtools/schemas/model_parameters/default_trigger.schema.yml +0 -7
- simtools/schemas/model_parameters/design_model.schema.yml +0 -7
- simtools/schemas/model_parameters/disc_ac_coupled.schema.yml +0 -7
- simtools/schemas/model_parameters/disc_bins.schema.yml +0 -7
- simtools/schemas/model_parameters/disc_start.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_amplitude.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_fall_time.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_gate_length.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_hysteresis.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_output_amplitude.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_output_var_percent.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_pulse_shape.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_rise_time.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_scale_threshold.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_sigsum_over_threshold.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_threshold.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_time_over_threshold.schema.yml +1 -9
- simtools/schemas/model_parameters/discriminator_var_gate_length.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_var_sigsum_over_threshold.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_var_threshold.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_var_time_over_threshold.schema.yml +0 -7
- simtools/schemas/model_parameters/dish_shape_length.schema.yml +0 -5
- simtools/schemas/model_parameters/dsum_clipping.schema.yml +1 -5
- simtools/schemas/model_parameters/dsum_ignore_below.schema.yml +0 -3
- simtools/schemas/model_parameters/dsum_offset.schema.yml +0 -3
- simtools/schemas/model_parameters/dsum_pedsub.schema.yml +0 -3
- simtools/schemas/model_parameters/dsum_pre_clipping.schema.yml +0 -3
- simtools/schemas/model_parameters/dsum_prescale.schema.yml +0 -3
- simtools/schemas/model_parameters/dsum_presum_max.schema.yml +0 -3
- simtools/schemas/model_parameters/dsum_presum_shift.schema.yml +0 -3
- simtools/schemas/model_parameters/dsum_shaping.schema.yml +0 -3
- simtools/schemas/model_parameters/dsum_shaping_renormalize.schema.yml +0 -3
- simtools/schemas/model_parameters/dsum_threshold.schema.yml +2 -12
- simtools/schemas/model_parameters/dsum_zero_clip.schema.yml +0 -3
- simtools/schemas/model_parameters/effective_focal_length.schema.yml +0 -7
- simtools/schemas/model_parameters/epsg_code.schema.yml +0 -5
- simtools/schemas/model_parameters/fadc_ac_coupled.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_amplitude.schema.yml +2 -9
- simtools/schemas/model_parameters/fadc_bins.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_compensate_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_dev_pedestal.schema.yml +0 -2
- simtools/schemas/model_parameters/fadc_err_compensate_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_err_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_lg_amplitude.schema.yml +2 -9
- simtools/schemas/model_parameters/fadc_lg_compensate_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_lg_dev_pedestal.schema.yml +0 -2
- simtools/schemas/model_parameters/fadc_lg_err_compensate_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_lg_err_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_lg_max_signal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_lg_max_sum.schema.yml +0 -2
- simtools/schemas/model_parameters/fadc_lg_noise.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_lg_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_lg_sensitivity.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_lg_sysvar_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_lg_var_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_lg_var_sensitivity.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_long_event_threshold.schema.yml +0 -3
- simtools/schemas/model_parameters/fadc_long_sum_bins.schema.yml +0 -3
- simtools/schemas/model_parameters/fadc_long_sum_offset.schema.yml +0 -3
- simtools/schemas/model_parameters/fadc_max_signal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_max_sum.schema.yml +0 -2
- simtools/schemas/model_parameters/fadc_mhz.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_noise.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_pulse_shape.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_sensitivity.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_sum_bins.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_sum_offset.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_sysvar_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_var_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_var_sensitivity.schema.yml +0 -7
- simtools/schemas/model_parameters/fake_mirror_list.schema.yml +0 -3
- simtools/schemas/model_parameters/flasher_angular_distribution.schema.yml +32 -0
- simtools/schemas/model_parameters/flasher_angular_distribution_width.schema.yml +32 -0
- simtools/schemas/model_parameters/flasher_bunch_size.schema.yml +28 -0
- simtools/schemas/model_parameters/flasher_external_trigger.schema.yml +32 -0
- simtools/schemas/model_parameters/flasher_photons.schema.yml +34 -0
- simtools/schemas/model_parameters/flasher_position.schema.yml +43 -0
- simtools/schemas/model_parameters/flasher_pulse_exp_decay.schema.yml +29 -0
- simtools/schemas/model_parameters/flasher_pulse_offset.schema.yml +35 -0
- simtools/schemas/model_parameters/flasher_pulse_shape.schema.yml +30 -0
- simtools/schemas/model_parameters/flasher_pulse_width.schema.yml +32 -0
- simtools/schemas/model_parameters/flasher_type.schema.yml +28 -0
- simtools/schemas/model_parameters/flasher_var_photons.schema.yml +31 -0
- simtools/schemas/model_parameters/flasher_wavelength.schema.yml +33 -0
- simtools/schemas/model_parameters/flatfielding.schema.yml +0 -7
- simtools/schemas/model_parameters/focal_length.schema.yml +0 -7
- simtools/schemas/model_parameters/focal_surface_parameters.schema.yml +0 -3
- simtools/schemas/model_parameters/focal_surface_ref_radius.schema.yml +0 -3
- simtools/schemas/model_parameters/focus_offset.schema.yml +0 -7
- simtools/schemas/model_parameters/gain_variation.schema.yml +0 -7
- simtools/schemas/model_parameters/geomag_horizontal.schema.yml +2 -7
- simtools/schemas/model_parameters/geomag_rotation.schema.yml +2 -7
- simtools/schemas/model_parameters/geomag_vertical.schema.yml +2 -7
- simtools/schemas/model_parameters/hg_lg_variation.schema.yml +0 -5
- simtools/schemas/model_parameters/iobuf_maximum.schema.yml +0 -7
- simtools/schemas/model_parameters/iobuf_output_maximum.schema.yml +0 -7
- simtools/schemas/model_parameters/laser_events.schema.yml +4 -3
- simtools/schemas/model_parameters/laser_external_trigger.schema.yml +4 -3
- simtools/schemas/model_parameters/laser_photons.schema.yml +4 -3
- simtools/schemas/model_parameters/laser_pulse_exptime.schema.yml +4 -3
- simtools/schemas/model_parameters/laser_pulse_offset.schema.yml +4 -3
- simtools/schemas/model_parameters/laser_pulse_sigtime.schema.yml +4 -3
- simtools/schemas/model_parameters/laser_pulse_twidth.schema.yml +4 -3
- simtools/schemas/model_parameters/laser_var_photons.schema.yml +4 -3
- simtools/schemas/model_parameters/laser_wavelength.schema.yml +4 -3
- simtools/schemas/model_parameters/led_events.schema.yml +4 -3
- simtools/schemas/model_parameters/led_photons.schema.yml +4 -3
- simtools/schemas/model_parameters/led_pulse_offset.schema.yml +4 -3
- simtools/schemas/model_parameters/led_pulse_sigtime.schema.yml +4 -3
- simtools/schemas/model_parameters/led_var_photons.schema.yml +4 -3
- simtools/schemas/model_parameters/lightguide_efficiency_vs_incidence_angle.schema.yml +0 -7
- simtools/schemas/model_parameters/lightguide_efficiency_vs_wavelength.schema.yml +0 -7
- simtools/schemas/model_parameters/min_photoelectrons.schema.yml +0 -7
- simtools/schemas/model_parameters/min_photons.schema.yml +0 -7
- simtools/schemas/model_parameters/mirror_align_random_distance.schema.yml +0 -5
- simtools/schemas/model_parameters/mirror_align_random_horizontal.schema.yml +0 -7
- simtools/schemas/model_parameters/mirror_align_random_vertical.schema.yml +0 -7
- simtools/schemas/model_parameters/mirror_class.schema.yml +2 -9
- simtools/schemas/model_parameters/mirror_degraded_reflection.schema.yml +0 -7
- simtools/schemas/model_parameters/mirror_focal_length.schema.yml +0 -5
- simtools/schemas/model_parameters/mirror_list.schema.yml +0 -7
- simtools/schemas/model_parameters/mirror_offset.schema.yml +0 -7
- simtools/schemas/model_parameters/mirror_reflection_random_angle.schema.yml +0 -7
- simtools/schemas/model_parameters/mirror_reflectivity.schema.yml +0 -7
- simtools/schemas/model_parameters/multiplicity_offset.schema.yml +0 -7
- simtools/schemas/model_parameters/muon_mono_threshold.schema.yml +0 -7
- simtools/schemas/model_parameters/nsb_autoscale_airmass.schema.yml +0 -7
- simtools/schemas/model_parameters/nsb_gain_drop_scale.schema.yml +0 -3
- simtools/schemas/model_parameters/nsb_offaxis.schema.yml +0 -7
- simtools/schemas/model_parameters/nsb_pixel_rate.schema.yml +0 -7
- simtools/schemas/model_parameters/nsb_reference_spectrum.schema.yml +0 -5
- simtools/schemas/model_parameters/nsb_reference_value.schema.yml +0 -5
- simtools/schemas/model_parameters/nsb_scaling_factor.schema.yml +0 -5
- simtools/schemas/model_parameters/nsb_sky_map.schema.yml +0 -5
- simtools/schemas/model_parameters/nsb_spectrum.schema.yml +0 -5
- simtools/schemas/model_parameters/num_gains.schema.yml +0 -7
- simtools/schemas/model_parameters/only_triggered_telescopes.schema.yml +0 -7
- simtools/schemas/model_parameters/optics_properties.schema.yml +0 -7
- simtools/schemas/model_parameters/parabolic_dish.schema.yml +0 -3
- simtools/schemas/model_parameters/pedestal_events.schema.yml +4 -7
- simtools/schemas/model_parameters/photon_delay.schema.yml +0 -7
- simtools/schemas/model_parameters/photons_per_run.schema.yml +4 -4
- simtools/schemas/model_parameters/pixel_cells.schema.yml +0 -3
- simtools/schemas/model_parameters/pixels_parallel.schema.yml +0 -3
- simtools/schemas/model_parameters/pixeltrg_time_step.schema.yml +0 -7
- simtools/schemas/model_parameters/pm_average_gain.schema.yml +0 -5
- simtools/schemas/model_parameters/pm_collection_efficiency.schema.yml +0 -5
- simtools/schemas/model_parameters/pm_gain_index.schema.yml +0 -5
- simtools/schemas/model_parameters/pm_photoelectron_spectrum.schema.yml +0 -7
- simtools/schemas/model_parameters/pm_transit_time.schema.yml +4 -9
- simtools/schemas/model_parameters/pm_voltage_variation.schema.yml +0 -5
- simtools/schemas/model_parameters/primary_mirror_degraded_map.schema.yml +0 -7
- simtools/schemas/model_parameters/primary_mirror_diameter.schema.yml +0 -3
- simtools/schemas/model_parameters/primary_mirror_hole_diameter.schema.yml +0 -3
- simtools/schemas/model_parameters/primary_mirror_incidence_angle.schema.yml +0 -3
- simtools/schemas/model_parameters/primary_mirror_parameters.schema.yml +0 -3
- simtools/schemas/model_parameters/primary_mirror_ref_radius.schema.yml +0 -3
- simtools/schemas/model_parameters/primary_mirror_segmentation.schema.yml +0 -3
- simtools/schemas/model_parameters/qe_variation.schema.yml +0 -7
- simtools/schemas/model_parameters/quantum_efficiency.schema.yml +0 -7
- simtools/schemas/model_parameters/random_focal_length.schema.yml +2 -7
- simtools/schemas/model_parameters/random_generator.schema.yml +0 -7
- simtools/schemas/model_parameters/random_mono_probability.schema.yml +0 -7
- simtools/schemas/model_parameters/reference_point_altitude.schema.yml +0 -5
- simtools/schemas/model_parameters/reference_point_latitude.schema.yml +0 -5
- simtools/schemas/model_parameters/reference_point_longitude.schema.yml +0 -5
- simtools/schemas/model_parameters/reference_point_utm_east.schema.yml +0 -5
- simtools/schemas/model_parameters/reference_point_utm_north.schema.yml +0 -5
- simtools/schemas/model_parameters/sampled_output.schema.yml +0 -7
- simtools/schemas/model_parameters/save_pe_with_amplitude.schema.yml +0 -7
- simtools/schemas/model_parameters/secondary_mirror_baffle.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_degraded_map.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_degraded_reflection.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_diameter.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_hole_diameter.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_incidence_angle.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_parameters.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_ref_radius.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_reflectivity.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_segmentation.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_shadow_diameter.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_shadow_offset.schema.yml +0 -3
- simtools/schemas/model_parameters/stars.schema.yml +0 -5
- simtools/schemas/model_parameters/store_photoelectrons.schema.yml +0 -7
- simtools/schemas/model_parameters/tailcut_scale.schema.yml +0 -7
- simtools/schemas/model_parameters/telescope_axis_height.schema.yml +0 -7
- simtools/schemas/model_parameters/telescope_random_angle.schema.yml +0 -7
- simtools/schemas/model_parameters/telescope_random_error.schema.yml +0 -7
- simtools/schemas/model_parameters/telescope_sphere_radius.schema.yml +0 -7
- simtools/schemas/model_parameters/telescope_transmission.schema.yml +0 -7
- simtools/schemas/model_parameters/teltrig_min_sigsum.schema.yml +0 -7
- simtools/schemas/model_parameters/teltrig_min_time.schema.yml +0 -7
- simtools/schemas/model_parameters/transit_time_calib_error.schema.yml +0 -7
- simtools/schemas/model_parameters/transit_time_compensate_error.schema.yml +0 -7
- simtools/schemas/model_parameters/transit_time_compensate_step.schema.yml +0 -7
- simtools/schemas/model_parameters/transit_time_error.schema.yml +0 -7
- simtools/schemas/model_parameters/transit_time_jitter.schema.yml +0 -7
- simtools/schemas/model_parameters/transit_time_random.schema.yml +29 -0
- simtools/schemas/model_parameters/trigger_current_limit.schema.yml +0 -7
- simtools/schemas/model_parameters/trigger_delay_compensation.schema.yml +0 -7
- simtools/schemas/model_parameters/trigger_pixels.schema.yml +0 -7
- simtools/schemas/production_tables.schema.yml +8 -8
- simtools/schemas/simulation_models_info.schema.yml +78 -0
- simtools/simtel/simtel_config_reader.py +0 -2
- simtools/simtel/simtel_config_writer.py +118 -26
- simtools/simtel/simtel_io_metadata.py +3 -3
- simtools/simtel/simulator_array.py +43 -85
- simtools/simtel/simulator_camera_efficiency.py +0 -2
- simtools/simtel/simulator_light_emission.py +336 -631
- simtools/simtel/simulator_ray_tracing.py +2 -4
- simtools/simulator.py +45 -19
- simtools/testing/assertions.py +2 -2
- simtools/testing/configuration.py +21 -6
- simtools/testing/sim_telarray_metadata.py +4 -4
- simtools/utils/general.py +5 -13
- simtools/utils/geometry.py +34 -5
- simtools/utils/names.py +1 -13
- simtools/version.py +83 -0
- simtools/visualization/plot_array_layout.py +129 -23
- simtools/visualization/plot_incident_angles.py +0 -2
- simtools/visualization/plot_psf.py +163 -61
- simtools/visualization/plot_simtel_events.py +1 -12
- simtools/visualization/visualize.py +0 -12
- gammasimtools-0.21.0.dist-info/RECORD +0 -396
- simtools/model/flasher_model.py +0 -106
- {gammasimtools-0.21.0.dist-info → gammasimtools-0.23.0.dist-info}/WHEEL +0 -0
- {gammasimtools-0.21.0.dist-info → gammasimtools-0.23.0.dist-info}/licenses/LICENSE +0 -0
- {gammasimtools-0.21.0.dist-info → gammasimtools-0.23.0.dist-info}/top_level.txt +0 -0
|
@@ -10,8 +10,6 @@ from simtools.runners.simtel_runner import SimtelRunner
|
|
|
10
10
|
from simtools.utils import names
|
|
11
11
|
from simtools.utils.general import clear_default_sim_telarray_cfg_directories
|
|
12
12
|
|
|
13
|
-
__all__ = ["SimulatorRayTracing"]
|
|
14
|
-
|
|
15
13
|
# pylint: disable=no-member
|
|
16
14
|
# The line above is needed because there are members which are created
|
|
17
15
|
# by adding them to the __dict__ of the class rather than directly.
|
|
@@ -61,7 +59,7 @@ class SimulatorRayTracing(SimtelRunner):
|
|
|
61
59
|
self.label = label if label is not None else self.telescope_model.label
|
|
62
60
|
|
|
63
61
|
self.io_handler = io_handler.IOHandler()
|
|
64
|
-
self._base_directory = self.io_handler.get_output_directory(
|
|
62
|
+
self._base_directory = self.io_handler.get_output_directory()
|
|
65
63
|
|
|
66
64
|
self.config = (
|
|
67
65
|
self._config_to_namedtuple(config_data)
|
|
@@ -146,7 +144,7 @@ class SimulatorRayTracing(SimtelRunner):
|
|
|
146
144
|
|
|
147
145
|
The run_number and input_file parameters are not relevant for the ray tracing simulation.
|
|
148
146
|
"""
|
|
149
|
-
self.telescope_model.write_sim_telarray_config_file(
|
|
147
|
+
self.telescope_model.write_sim_telarray_config_file(additional_models=self.site_model)
|
|
150
148
|
|
|
151
149
|
if self.config.single_mirror_mode:
|
|
152
150
|
# Note: no mirror length defined for dual-mirror telescopes
|
simtools/simulator.py
CHANGED
|
@@ -8,6 +8,7 @@ from collections import defaultdict
|
|
|
8
8
|
from pathlib import Path
|
|
9
9
|
|
|
10
10
|
import numpy as np
|
|
11
|
+
from astropy import units as u
|
|
11
12
|
|
|
12
13
|
import simtools.utils.general as gen
|
|
13
14
|
from simtools.corsika.corsika_config import CorsikaConfig
|
|
@@ -21,11 +22,6 @@ from simtools.simtel.simulator_array import SimulatorArray
|
|
|
21
22
|
from simtools.testing.sim_telarray_metadata import assert_sim_telarray_metadata
|
|
22
23
|
from simtools.version import semver_to_int
|
|
23
24
|
|
|
24
|
-
__all__ = [
|
|
25
|
-
"InvalidRunsToSimulateError",
|
|
26
|
-
"Simulator",
|
|
27
|
-
]
|
|
28
|
-
|
|
29
25
|
|
|
30
26
|
class InvalidRunsToSimulateError(Exception):
|
|
31
27
|
"""Exception for invalid runs to simulate."""
|
|
@@ -68,8 +64,8 @@ class Simulator:
|
|
|
68
64
|
self.db_config = db_config
|
|
69
65
|
|
|
70
66
|
self.simulation_software = self.args_dict.get("simulation_software", "corsika_sim_telarray")
|
|
71
|
-
self.run_mode = self.args_dict.get("run_mode")
|
|
72
67
|
self.logger.debug(f"Init Simulator {self.simulation_software}")
|
|
68
|
+
self.run_mode = args_dict.get("run_mode", None)
|
|
73
69
|
|
|
74
70
|
self.io_handler = io_handler.IOHandler()
|
|
75
71
|
|
|
@@ -141,6 +137,9 @@ class Simulator:
|
|
|
141
137
|
"seed_file_name": self.sim_telarray_seeds["seed_file_name"],
|
|
142
138
|
},
|
|
143
139
|
simtel_path=self.args_dict.get("simtel_path", None),
|
|
140
|
+
calibration_device_types=self._get_calibration_device_types(
|
|
141
|
+
self.args_dict.get("run_mode")
|
|
142
|
+
),
|
|
144
143
|
)
|
|
145
144
|
for version in versions
|
|
146
145
|
]
|
|
@@ -166,8 +165,8 @@ class Simulator:
|
|
|
166
165
|
|
|
167
166
|
seed = semver_to_int(model_version) * 10000000
|
|
168
167
|
seed = seed + 1000000 if self.args_dict.get("site") != "North" else seed + 2000000
|
|
169
|
-
seed = seed + (int)(self.args_dict
|
|
170
|
-
return seed + (int)(self.args_dict
|
|
168
|
+
seed = seed + (int)(self.args_dict.get("zenith_angle", 0.0 * u.deg).value) * 1000
|
|
169
|
+
return seed + (int)(self.args_dict.get("azimuth_angle", 0.0 * u.deg).value)
|
|
171
170
|
|
|
172
171
|
def _initialize_run_list(self):
|
|
173
172
|
"""
|
|
@@ -257,7 +256,7 @@ class Simulator:
|
|
|
257
256
|
label=self.label,
|
|
258
257
|
args_dict=self.args_dict,
|
|
259
258
|
db_config=self.db_config,
|
|
260
|
-
dummy_simulations=self._is_calibration_run(),
|
|
259
|
+
dummy_simulations=self._is_calibration_run(self.run_mode),
|
|
261
260
|
)
|
|
262
261
|
)
|
|
263
262
|
return (
|
|
@@ -296,8 +295,9 @@ class Simulator:
|
|
|
296
295
|
runner_args["sim_telarray_seeds"] = self.sim_telarray_seeds
|
|
297
296
|
if runner_class is CorsikaSimtelRunner:
|
|
298
297
|
runner_args["sequential"] = self.args_dict.get("sequential", False)
|
|
299
|
-
|
|
300
|
-
|
|
298
|
+
runner_args["calibration_config"] = (
|
|
299
|
+
self.args_dict if self._is_calibration_run(self.run_mode) else None
|
|
300
|
+
)
|
|
301
301
|
|
|
302
302
|
return runner_class(**runner_args)
|
|
303
303
|
|
|
@@ -583,9 +583,7 @@ class Simulator:
|
|
|
583
583
|
def save_file_lists(self):
|
|
584
584
|
"""Save files lists for output and log files."""
|
|
585
585
|
for file_type in ["simtel_output", "log", "corsika_log", "hist"]:
|
|
586
|
-
file_name = self.io_handler.get_output_directory(
|
|
587
|
-
f"{file_type}_files.txt"
|
|
588
|
-
)
|
|
586
|
+
file_name = self.io_handler.get_output_directory().joinpath(f"{file_type}_files.txt")
|
|
589
587
|
file_list = self.get_file_list(file_type=file_type)
|
|
590
588
|
if all(element is not None for element in file_list) and len(file_list) > 0:
|
|
591
589
|
self.logger.info(f"Saving list of {file_type} files to {file_name}")
|
|
@@ -646,9 +644,7 @@ class Simulator:
|
|
|
646
644
|
directory_for_grid_upload = (
|
|
647
645
|
Path(directory_for_grid_upload)
|
|
648
646
|
if directory_for_grid_upload
|
|
649
|
-
else self.io_handler.get_output_directory(
|
|
650
|
-
"directory_for_grid_upload"
|
|
651
|
-
)
|
|
647
|
+
else self.io_handler.get_output_directory().joinpath("directory_for_grid_upload")
|
|
652
648
|
)
|
|
653
649
|
directory_for_grid_upload.mkdir(parents=True, exist_ok=True)
|
|
654
650
|
|
|
@@ -749,13 +745,43 @@ class Simulator:
|
|
|
749
745
|
|
|
750
746
|
corsika_log_files.append(str(new_log))
|
|
751
747
|
|
|
752
|
-
|
|
748
|
+
@staticmethod
|
|
749
|
+
def _is_calibration_run(run_mode):
|
|
753
750
|
"""
|
|
754
751
|
Check if this simulation is a calibration run.
|
|
755
752
|
|
|
753
|
+
Parameters
|
|
754
|
+
----------
|
|
755
|
+
run_mode: str
|
|
756
|
+
Run mode of the simulation.
|
|
757
|
+
|
|
756
758
|
Returns
|
|
757
759
|
-------
|
|
758
760
|
bool
|
|
759
761
|
True if it is a calibration run, False otherwise.
|
|
760
762
|
"""
|
|
761
|
-
return
|
|
763
|
+
return run_mode in [
|
|
764
|
+
"pedestals",
|
|
765
|
+
"dark_pedestals",
|
|
766
|
+
"nsb_only_pedestals",
|
|
767
|
+
"direct_injection",
|
|
768
|
+
]
|
|
769
|
+
|
|
770
|
+
@staticmethod
|
|
771
|
+
def _get_calibration_device_types(run_mode):
|
|
772
|
+
"""
|
|
773
|
+
Get the list of calibration device types based on the run mode.
|
|
774
|
+
|
|
775
|
+
Parameters
|
|
776
|
+
----------
|
|
777
|
+
run_mode: str
|
|
778
|
+
Run mode of the simulation.
|
|
779
|
+
|
|
780
|
+
Returns
|
|
781
|
+
-------
|
|
782
|
+
list
|
|
783
|
+
List of calibration device types.
|
|
784
|
+
"""
|
|
785
|
+
if run_mode == "direct_injection":
|
|
786
|
+
return ["flat_fielding"]
|
|
787
|
+
return []
|
simtools/testing/assertions.py
CHANGED
|
@@ -62,9 +62,9 @@ def assert_n_showers_and_energy_range(file):
|
|
|
62
62
|
|
|
63
63
|
simulated_energies = []
|
|
64
64
|
simulation_config = {}
|
|
65
|
-
with SimTelFile(file) as f:
|
|
65
|
+
with SimTelFile(file, skip_non_triggered=False) as f:
|
|
66
66
|
simulation_config = f.mc_run_headers[0]
|
|
67
|
-
for event in f
|
|
67
|
+
for event in f:
|
|
68
68
|
simulated_energies.append(event["mc_shower"]["energy"])
|
|
69
69
|
|
|
70
70
|
# The relative tolerance is set to 1% because ~0.5% shower simulations do not
|
|
@@ -5,6 +5,7 @@ import os
|
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
|
|
7
7
|
import simtools.utils.general as gen
|
|
8
|
+
import simtools.version as simtools_version
|
|
8
9
|
from simtools.io import ascii_handler
|
|
9
10
|
|
|
10
11
|
_logger = logging.getLogger(__name__)
|
|
@@ -130,11 +131,23 @@ def configure(config, tmp_test_directory, request):
|
|
|
130
131
|
|
|
131
132
|
|
|
132
133
|
def _skip_test_for_model_version(config, model_version_requested):
|
|
133
|
-
"""
|
|
134
|
-
|
|
134
|
+
"""
|
|
135
|
+
Skip test if model version requested is not supported.
|
|
136
|
+
|
|
137
|
+
Compares full and major.minor version strings.
|
|
138
|
+
"""
|
|
139
|
+
if not (config.get("model_version_use_current") and model_version_requested):
|
|
135
140
|
return
|
|
136
|
-
model_version_config = config["configuration"]["model_version"]
|
|
137
|
-
|
|
141
|
+
model_version_config = str(config["configuration"]["model_version"])
|
|
142
|
+
|
|
143
|
+
if (
|
|
144
|
+
simtools_version.compare_versions(
|
|
145
|
+
model_version_requested,
|
|
146
|
+
model_version_config,
|
|
147
|
+
level=simtools_version.version_kind(model_version_requested),
|
|
148
|
+
)
|
|
149
|
+
!= 0
|
|
150
|
+
):
|
|
138
151
|
raise VersionError(
|
|
139
152
|
f"Model version requested {model_version_requested} not supported for this test"
|
|
140
153
|
)
|
|
@@ -184,14 +197,16 @@ def _prepare_test_options(config, output_path, model_version=None):
|
|
|
184
197
|
|
|
185
198
|
tmp_config_file = output_path / "tmp_config.yml"
|
|
186
199
|
config_file_model_version = config.get("model_version")
|
|
200
|
+
if isinstance(config_file_model_version, list):
|
|
201
|
+
config_file_model_version = [str(item) for item in config_file_model_version]
|
|
202
|
+
elif config_file_model_version is not None:
|
|
203
|
+
config_file_model_version = str(config_file_model_version)
|
|
187
204
|
if model_version and "model_version" in config:
|
|
188
205
|
config.update({"model_version": model_version})
|
|
189
206
|
|
|
190
207
|
for key in ["output_path", "data_directory", "pack_for_grid_register"]:
|
|
191
208
|
if key in config:
|
|
192
209
|
config[key] = str(Path(output_path).joinpath(config[key]))
|
|
193
|
-
if key == "output_path":
|
|
194
|
-
config["use_plain_output_path"] = True
|
|
195
210
|
|
|
196
211
|
_logger.info(f"Writing config file: {tmp_config_file}")
|
|
197
212
|
ascii_handler.write_data_to_file(data=config, output_file=tmp_config_file, sort_keys=False)
|
|
@@ -35,19 +35,19 @@ def assert_sim_telarray_metadata(file, array_model):
|
|
|
35
35
|
if sim_telarray_seed_mismatch:
|
|
36
36
|
site_parameter_mismatch.append(sim_telarray_seed_mismatch)
|
|
37
37
|
|
|
38
|
-
if len(telescope_meta) != len(array_model.
|
|
38
|
+
if len(telescope_meta) != len(array_model.telescope_models):
|
|
39
39
|
raise ValueError(
|
|
40
40
|
f"Number of telescopes in sim_telarray file ({len(telescope_meta)}) does not match "
|
|
41
|
-
f"number of telescopes in array model ({len(array_model.
|
|
41
|
+
f"number of telescopes in array model ({len(array_model.telescope_models)})"
|
|
42
42
|
)
|
|
43
43
|
|
|
44
|
-
for telescope_name in array_model.
|
|
44
|
+
for telescope_name in array_model.telescope_models.keys():
|
|
45
45
|
if not get_sim_telarray_telescope_id(telescope_name, file):
|
|
46
46
|
raise ValueError(f"Telescope {telescope_name} not found in sim_telarray file metadata")
|
|
47
47
|
|
|
48
48
|
telescope_parameter_mismatch = [
|
|
49
49
|
_assert_model_parameters(telescope_meta[i], model)
|
|
50
|
-
for i, model in enumerate(array_model.
|
|
50
|
+
for i, model in enumerate(array_model.telescope_models.values(), start=1)
|
|
51
51
|
]
|
|
52
52
|
|
|
53
53
|
# ensure printout of all mismatches, not only those found first
|
simtools/utils/general.py
CHANGED
|
@@ -13,17 +13,6 @@ from urllib.parse import urlparse
|
|
|
13
13
|
|
|
14
14
|
import numpy as np
|
|
15
15
|
|
|
16
|
-
__all__ = [
|
|
17
|
-
"change_dict_keys_case",
|
|
18
|
-
"clear_default_sim_telarray_cfg_directories",
|
|
19
|
-
"collect_final_lines",
|
|
20
|
-
"collect_kwargs",
|
|
21
|
-
"get_log_excerpt",
|
|
22
|
-
"get_log_level_from_user",
|
|
23
|
-
"remove_substring_recursively_from_dict",
|
|
24
|
-
"set_default_kwargs",
|
|
25
|
-
]
|
|
26
|
-
|
|
27
16
|
_logger = logging.getLogger(__name__)
|
|
28
17
|
|
|
29
18
|
|
|
@@ -345,7 +334,7 @@ def resolve_file_patterns(file_names):
|
|
|
345
334
|
return _files
|
|
346
335
|
|
|
347
336
|
|
|
348
|
-
def pack_tar_file(tar_file_name, file_list):
|
|
337
|
+
def pack_tar_file(tar_file_name, file_list, sub_dir=None):
|
|
349
338
|
"""
|
|
350
339
|
Pack files into a tar.gz archive.
|
|
351
340
|
|
|
@@ -355,6 +344,8 @@ def pack_tar_file(tar_file_name, file_list):
|
|
|
355
344
|
Name of the output tar.gz file.
|
|
356
345
|
file_list: list
|
|
357
346
|
List of files to include in the archive.
|
|
347
|
+
sub_dir: str, optional
|
|
348
|
+
Subdirectory within the archive to place the files.
|
|
358
349
|
"""
|
|
359
350
|
file_list = [Path(f) for f in file_list]
|
|
360
351
|
base = Path(os.path.commonpath([f.resolve() for f in file_list]))
|
|
@@ -365,7 +356,8 @@ def pack_tar_file(tar_file_name, file_list):
|
|
|
365
356
|
|
|
366
357
|
with tarfile.open(tar_file_name, "w:gz") as tar:
|
|
367
358
|
for file in file_list:
|
|
368
|
-
|
|
359
|
+
arc_name = Path(sub_dir) / file.name if sub_dir else file.name
|
|
360
|
+
tar.add(file, arcname=str(arc_name))
|
|
369
361
|
|
|
370
362
|
|
|
371
363
|
def get_log_excerpt(log_file, n_last_lines=30):
|
simtools/utils/geometry.py
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"""A collection of functions related to geometrical transformations."""
|
|
2
2
|
|
|
3
3
|
import logging
|
|
4
|
+
import math
|
|
4
5
|
|
|
5
6
|
import astropy.units as u
|
|
6
7
|
import numpy as np
|
|
7
8
|
from astropy.units import UnitsError
|
|
8
9
|
|
|
9
|
-
__all__ = [
|
|
10
|
-
"convert_2d_to_radial_distr",
|
|
11
|
-
"rotate",
|
|
12
|
-
]
|
|
13
|
-
|
|
14
10
|
_logger = logging.getLogger(__name__)
|
|
15
11
|
|
|
16
12
|
|
|
@@ -236,3 +232,36 @@ def transform_ground_to_shower_coordinates(x_ground, y_ground, z_ground, azimuth
|
|
|
236
232
|
z_s = -sz * x + cz * z
|
|
237
233
|
|
|
238
234
|
return x_s, y_s, z_s
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
def fiducial_radius_from_shape(width, shape):
|
|
238
|
+
"""
|
|
239
|
+
Calculate minimum radius including different geometrical shapes.
|
|
240
|
+
|
|
241
|
+
Assumes definition of shapes as in 'camera_body_shape' model parameter:
|
|
242
|
+
|
|
243
|
+
- circle: shape = 0, width is diameter
|
|
244
|
+
- hexagon: shape = 1 or 3, width is flat-to-flat distance
|
|
245
|
+
- square: shape = 2, width is side length
|
|
246
|
+
|
|
247
|
+
Parameters
|
|
248
|
+
----------
|
|
249
|
+
width : float
|
|
250
|
+
Characteristic width
|
|
251
|
+
shape : int
|
|
252
|
+
Geometrical shape parameter
|
|
253
|
+
|
|
254
|
+
Returns
|
|
255
|
+
-------
|
|
256
|
+
float
|
|
257
|
+
Minimum fiducial radius
|
|
258
|
+
"""
|
|
259
|
+
if shape == 0:
|
|
260
|
+
return width / 2.0
|
|
261
|
+
if shape == 2:
|
|
262
|
+
return width / math.sqrt(2.0)
|
|
263
|
+
if shape in (1, 3):
|
|
264
|
+
return width / math.sqrt(3.0)
|
|
265
|
+
raise ValueError(
|
|
266
|
+
f"Unknown shape value {shape}. Valid values are: 0 (circle), 1 or 3 (hexagon), 2 (square)."
|
|
267
|
+
)
|
simtools/utils/names.py
CHANGED
|
@@ -28,18 +28,6 @@ from simtools.constants import (
|
|
|
28
28
|
|
|
29
29
|
_logger = logging.getLogger(__name__)
|
|
30
30
|
|
|
31
|
-
__all__ = [
|
|
32
|
-
"generate_file_name",
|
|
33
|
-
"get_array_element_type_from_name",
|
|
34
|
-
"get_site_from_array_element_name",
|
|
35
|
-
"sanitize_name",
|
|
36
|
-
"simtel_config_file_name",
|
|
37
|
-
"simtel_single_mirror_list_file_name",
|
|
38
|
-
"validate_array_element_id_name",
|
|
39
|
-
"validate_array_element_name",
|
|
40
|
-
"validate_site_name",
|
|
41
|
-
]
|
|
42
|
-
|
|
43
31
|
# Mapping of db collection names to class keys
|
|
44
32
|
db_collections_to_class_keys = {
|
|
45
33
|
"sites": ["Site"],
|
|
@@ -122,7 +110,7 @@ def site_names():
|
|
|
122
110
|
@cache
|
|
123
111
|
def array_element_design_types(array_element_type):
|
|
124
112
|
"""
|
|
125
|
-
Get array element
|
|
113
|
+
Get array element design type (e.g., 'design' or 'flashcam').
|
|
126
114
|
|
|
127
115
|
Default values are ['design', 'test'].
|
|
128
116
|
|
simtools/version.py
CHANGED
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
from packaging.version import InvalidVersion, Version
|
|
8
8
|
|
|
9
|
+
MAJOR_MINOR_PATCH = "major.minor.patch"
|
|
10
|
+
MAJOR_MINOR = "major.minor"
|
|
11
|
+
|
|
9
12
|
try:
|
|
10
13
|
try:
|
|
11
14
|
from ._dev_version import version
|
|
@@ -106,3 +109,83 @@ def semver_to_int(version_string):
|
|
|
106
109
|
release = v.release + (0,) * (3 - len(v.release))
|
|
107
110
|
major, minor, patch = release[:3]
|
|
108
111
|
return major * 10000 + minor * 100 + patch
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def sort_versions(version_list, reverse=False):
|
|
115
|
+
"""
|
|
116
|
+
Sort a list of semantic version strings.
|
|
117
|
+
|
|
118
|
+
Parameters
|
|
119
|
+
----------
|
|
120
|
+
version_list : list of str
|
|
121
|
+
List of semantic version strings (e.g., ["5.0.0", "6.0.2", "5.1.0"])
|
|
122
|
+
reverse : bool, optional
|
|
123
|
+
Sort in descending order if True (default False)
|
|
124
|
+
|
|
125
|
+
Returns
|
|
126
|
+
-------
|
|
127
|
+
list of str
|
|
128
|
+
Sorted list of version strings.
|
|
129
|
+
"""
|
|
130
|
+
try:
|
|
131
|
+
return [str(v) for v in sorted(map(Version, version_list), reverse=reverse)]
|
|
132
|
+
except InvalidVersion as exc:
|
|
133
|
+
raise ValueError(f"Invalid version in list: {version_list}") from exc
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def version_kind(version_string):
|
|
137
|
+
"""
|
|
138
|
+
Determine the kind of version string.
|
|
139
|
+
|
|
140
|
+
Parameters
|
|
141
|
+
----------
|
|
142
|
+
version_string : str
|
|
143
|
+
The version string to analyze.
|
|
144
|
+
|
|
145
|
+
Returns
|
|
146
|
+
-------
|
|
147
|
+
str
|
|
148
|
+
The kind of version string ("major.minor", "major.minor.patch", or "major").
|
|
149
|
+
"""
|
|
150
|
+
try:
|
|
151
|
+
ver = Version(version_string)
|
|
152
|
+
except InvalidVersion as exc:
|
|
153
|
+
raise ValueError(f"Invalid version string: {version_string}") from exc
|
|
154
|
+
if ver.release and len(ver.release) >= 3:
|
|
155
|
+
return MAJOR_MINOR_PATCH
|
|
156
|
+
if len(ver.release) == 2:
|
|
157
|
+
return MAJOR_MINOR
|
|
158
|
+
return "major"
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def compare_versions(version_string_1, version_string_2, level=MAJOR_MINOR_PATCH):
|
|
162
|
+
"""
|
|
163
|
+
Compare two versions at the given level: "major", "major.minor", "major.minor.patch".
|
|
164
|
+
|
|
165
|
+
Parameters
|
|
166
|
+
----------
|
|
167
|
+
version_string_1 : str
|
|
168
|
+
First version string to compare.
|
|
169
|
+
version_string_2 : str
|
|
170
|
+
Second version string to compare.
|
|
171
|
+
level : str, optional
|
|
172
|
+
Level of comparison: "major", "major.minor", or "major.minor.patch"
|
|
173
|
+
|
|
174
|
+
Returns
|
|
175
|
+
-------
|
|
176
|
+
int
|
|
177
|
+
-1 if version_string_1 < version_string_2
|
|
178
|
+
0 if version_string_1 == version_string_2
|
|
179
|
+
1 if version_string_1 > version_string_2
|
|
180
|
+
"""
|
|
181
|
+
ver1 = Version(version_string_1).release
|
|
182
|
+
ver2 = Version(version_string_2).release
|
|
183
|
+
|
|
184
|
+
if level == "major":
|
|
185
|
+
ver1, ver2 = ver1[:1], ver2[:1]
|
|
186
|
+
elif level == MAJOR_MINOR:
|
|
187
|
+
ver1, ver2 = ver1[:2], ver2[:2]
|
|
188
|
+
elif level != MAJOR_MINOR_PATCH:
|
|
189
|
+
raise ValueError(f"Unknown level: {level}")
|
|
190
|
+
|
|
191
|
+
return (ver1 > ver2) - (ver1 < ver2)
|