gammasimtools 0.20.0__py3-none-any.whl → 0.22.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {gammasimtools-0.20.0.dist-info → gammasimtools-0.22.0.dist-info}/METADATA +2 -3
- {gammasimtools-0.20.0.dist-info → gammasimtools-0.22.0.dist-info}/RECORD +313 -296
- {gammasimtools-0.20.0.dist-info → gammasimtools-0.22.0.dist-info}/entry_points.txt +3 -2
- simtools/_version.py +2 -2
- simtools/applications/calculate_incident_angles.py +1 -4
- simtools/applications/convert_all_model_parameters_from_simtel.py +1 -2
- simtools/applications/convert_model_parameter_from_simtel.py +0 -1
- simtools/applications/db_generate_compound_indexes.py +4 -17
- simtools/applications/db_upload_model_repository.py +122 -0
- simtools/applications/derive_psf_parameters.py +71 -42
- simtools/applications/docs_produce_array_element_report.py +1 -1
- simtools/applications/docs_produce_calibration_reports.py +1 -1
- simtools/applications/docs_produce_model_parameter_reports.py +1 -1
- simtools/applications/docs_produce_simulation_configuration_report.py +1 -1
- simtools/applications/generate_corsika_histograms.py +8 -185
- simtools/applications/maintain_simulation_model_add_production.py +81 -0
- simtools/applications/merge_tables.py +1 -1
- simtools/applications/plot_array_layout.py +1 -2
- simtools/applications/plot_simtel_events.py +2 -228
- simtools/applications/print_version.py +8 -7
- simtools/applications/production_derive_statistics.py +1 -2
- simtools/applications/production_generate_grid.py +1 -1
- simtools/applications/simulate_flasher.py +74 -72
- simtools/applications/simulate_illuminator.py +52 -186
- simtools/applications/{simulate_calibration_events.py → simulate_pedestals.py} +9 -55
- simtools/applications/submit_model_parameter_from_external.py +0 -1
- simtools/applications/validate_camera_efficiency.py +0 -1
- simtools/applications/validate_camera_fov.py +1 -2
- simtools/applications/validate_cumulative_psf.py +2 -3
- simtools/applications/validate_file_using_schema.py +20 -12
- simtools/applications/validate_optics.py +2 -2
- simtools/camera/camera_efficiency.py +8 -11
- simtools/configuration/commandline_parser.py +1 -7
- simtools/configuration/configurator.py +0 -2
- simtools/corsika/corsika_config.py +9 -11
- simtools/corsika/corsika_histograms.py +82 -1
- simtools/data_model/model_data_writer.py +87 -25
- simtools/data_model/schema.py +61 -2
- simtools/data_model/validate_data.py +1 -1
- simtools/db/db_handler.py +103 -48
- simtools/db/db_model_upload.py +247 -16
- simtools/io/io_handler.py +31 -83
- simtools/job_execution/job_manager.py +45 -0
- simtools/layout/array_layout_utils.py +1 -5
- simtools/model/array_model.py +93 -42
- simtools/model/model_parameter.py +20 -9
- simtools/model/model_repository.py +197 -109
- simtools/model/model_utils.py +21 -6
- simtools/model/telescope_model.py +20 -0
- simtools/production_configuration/derive_corsika_limits.py +1 -1
- simtools/ray_tracing/incident_angles.py +7 -7
- simtools/ray_tracing/mirror_panel_psf.py +1 -1
- simtools/ray_tracing/psf_parameter_optimisation.py +1106 -565
- simtools/ray_tracing/ray_tracing.py +1 -3
- simtools/reporting/docs_read_parameters.py +171 -101
- simtools/resources/array_elements.yml +26 -0
- simtools/runners/corsika_simtel_runner.py +11 -17
- simtools/runners/runner_services.py +5 -6
- simtools/runners/simtools_runner.py +0 -2
- simtools/schemas/application_workflow.metaschema.yml +1 -1
- simtools/schemas/common_definitions.schema.yml +39 -0
- simtools/schemas/model_parameter.metaschema.yml +19 -13
- simtools/schemas/model_parameter_and_data_schema.metaschema.yml +6 -12
- simtools/schemas/model_parameters/adjust_gain.schema.yml +0 -5
- simtools/schemas/model_parameters/altitude.schema.yml +0 -5
- simtools/schemas/model_parameters/array_coordinates.schema.yml +0 -5
- simtools/schemas/model_parameters/array_coordinates_UTM.schema.yml +0 -5
- simtools/schemas/model_parameters/array_element_position_ground.schema.yml +0 -7
- simtools/schemas/model_parameters/array_element_position_utm.schema.yml +0 -7
- simtools/schemas/model_parameters/array_layouts.schema.yml +0 -5
- simtools/schemas/model_parameters/array_triggers.schema.yml +0 -5
- simtools/schemas/model_parameters/array_window.schema.yml +0 -7
- simtools/schemas/model_parameters/asum_clipping.schema.yml +0 -3
- simtools/schemas/model_parameters/asum_offset.schema.yml +0 -7
- simtools/schemas/model_parameters/asum_shaping.schema.yml +0 -7
- simtools/schemas/model_parameters/asum_threshold.schema.yml +0 -7
- simtools/schemas/model_parameters/atmospheric_profile.schema.yml +0 -5
- simtools/schemas/model_parameters/atmospheric_transmission.schema.yml +0 -5
- simtools/schemas/model_parameters/axes_offsets.schema.yml +0 -7
- simtools/schemas/model_parameters/calibration_devices.schema.yml +30 -0
- simtools/schemas/model_parameters/camera_body_diameter.schema.yml +0 -7
- simtools/schemas/model_parameters/camera_body_shape.schema.yml +0 -7
- simtools/schemas/model_parameters/camera_config_file.schema.yml +0 -7
- simtools/schemas/model_parameters/camera_config_rotate.schema.yml +0 -7
- simtools/schemas/model_parameters/camera_degraded_efficiency.schema.yml +0 -7
- simtools/schemas/model_parameters/camera_degraded_map.schema.yml +0 -7
- simtools/schemas/model_parameters/camera_depth.schema.yml +0 -7
- simtools/schemas/model_parameters/camera_filter.schema.yml +0 -7
- simtools/schemas/model_parameters/camera_filter_incidence_angle.schema.yml +0 -3
- simtools/schemas/model_parameters/camera_pixels.schema.yml +0 -7
- simtools/schemas/model_parameters/camera_transmission.schema.yml +0 -7
- simtools/schemas/model_parameters/channels_per_chip.schema.yml +0 -7
- simtools/schemas/model_parameters/correct_nsb_spectrum_to_telescope_altitude.schema.yml +0 -7
- simtools/schemas/model_parameters/corsika_observation_level.schema.yml +0 -5
- simtools/schemas/model_parameters/dark_events.schema.yml +4 -3
- simtools/schemas/model_parameters/default_trigger.schema.yml +0 -7
- simtools/schemas/model_parameters/design_model.schema.yml +0 -7
- simtools/schemas/model_parameters/disc_ac_coupled.schema.yml +0 -7
- simtools/schemas/model_parameters/disc_bins.schema.yml +0 -7
- simtools/schemas/model_parameters/disc_start.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_amplitude.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_fall_time.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_gate_length.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_hysteresis.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_output_amplitude.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_output_var_percent.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_pulse_shape.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_rise_time.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_scale_threshold.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_sigsum_over_threshold.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_threshold.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_time_over_threshold.schema.yml +1 -9
- simtools/schemas/model_parameters/discriminator_var_gate_length.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_var_sigsum_over_threshold.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_var_threshold.schema.yml +0 -7
- simtools/schemas/model_parameters/discriminator_var_time_over_threshold.schema.yml +0 -7
- simtools/schemas/model_parameters/dish_shape_length.schema.yml +0 -5
- simtools/schemas/model_parameters/dsum_clipping.schema.yml +1 -5
- simtools/schemas/model_parameters/dsum_ignore_below.schema.yml +0 -3
- simtools/schemas/model_parameters/dsum_offset.schema.yml +0 -3
- simtools/schemas/model_parameters/dsum_pedsub.schema.yml +0 -3
- simtools/schemas/model_parameters/dsum_pre_clipping.schema.yml +0 -3
- simtools/schemas/model_parameters/dsum_prescale.schema.yml +0 -3
- simtools/schemas/model_parameters/dsum_presum_max.schema.yml +0 -3
- simtools/schemas/model_parameters/dsum_presum_shift.schema.yml +0 -3
- simtools/schemas/model_parameters/dsum_shaping.schema.yml +0 -3
- simtools/schemas/model_parameters/dsum_shaping_renormalize.schema.yml +0 -3
- simtools/schemas/model_parameters/dsum_threshold.schema.yml +2 -12
- simtools/schemas/model_parameters/dsum_zero_clip.schema.yml +0 -3
- simtools/schemas/model_parameters/effective_focal_length.schema.yml +0 -7
- simtools/schemas/model_parameters/epsg_code.schema.yml +0 -5
- simtools/schemas/model_parameters/fadc_ac_coupled.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_amplitude.schema.yml +2 -9
- simtools/schemas/model_parameters/fadc_bins.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_compensate_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_dev_pedestal.schema.yml +0 -2
- simtools/schemas/model_parameters/fadc_err_compensate_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_err_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_lg_amplitude.schema.yml +2 -9
- simtools/schemas/model_parameters/fadc_lg_compensate_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_lg_dev_pedestal.schema.yml +0 -2
- simtools/schemas/model_parameters/fadc_lg_err_compensate_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_lg_err_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_lg_max_signal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_lg_max_sum.schema.yml +0 -2
- simtools/schemas/model_parameters/fadc_lg_noise.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_lg_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_lg_sensitivity.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_lg_sysvar_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_lg_var_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_lg_var_sensitivity.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_long_event_threshold.schema.yml +0 -3
- simtools/schemas/model_parameters/fadc_long_sum_bins.schema.yml +0 -3
- simtools/schemas/model_parameters/fadc_long_sum_offset.schema.yml +0 -3
- simtools/schemas/model_parameters/fadc_max_signal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_max_sum.schema.yml +0 -2
- simtools/schemas/model_parameters/fadc_mhz.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_noise.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_pulse_shape.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_sensitivity.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_sum_bins.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_sum_offset.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_sysvar_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_var_pedestal.schema.yml +0 -7
- simtools/schemas/model_parameters/fadc_var_sensitivity.schema.yml +0 -7
- simtools/schemas/model_parameters/fake_mirror_list.schema.yml +0 -3
- simtools/schemas/model_parameters/flasher_angular_distribution.schema.yml +32 -0
- simtools/schemas/model_parameters/flasher_angular_distribution_width.schema.yml +32 -0
- simtools/schemas/model_parameters/flasher_bunch_size.schema.yml +28 -0
- simtools/schemas/model_parameters/flasher_external_trigger.schema.yml +32 -0
- simtools/schemas/model_parameters/flasher_photons.schema.yml +34 -0
- simtools/schemas/model_parameters/flasher_position.schema.yml +43 -0
- simtools/schemas/model_parameters/flasher_pulse_exp_decay.schema.yml +29 -0
- simtools/schemas/model_parameters/flasher_pulse_offset.schema.yml +35 -0
- simtools/schemas/model_parameters/flasher_pulse_shape.schema.yml +30 -0
- simtools/schemas/model_parameters/flasher_pulse_width.schema.yml +32 -0
- simtools/schemas/model_parameters/flasher_type.schema.yml +28 -0
- simtools/schemas/model_parameters/flasher_var_photons.schema.yml +31 -0
- simtools/schemas/model_parameters/flasher_wavelength.schema.yml +33 -0
- simtools/schemas/model_parameters/flatfielding.schema.yml +0 -7
- simtools/schemas/model_parameters/focal_length.schema.yml +0 -7
- simtools/schemas/model_parameters/focal_surface_parameters.schema.yml +0 -3
- simtools/schemas/model_parameters/focal_surface_ref_radius.schema.yml +0 -3
- simtools/schemas/model_parameters/focus_offset.schema.yml +0 -7
- simtools/schemas/model_parameters/gain_variation.schema.yml +0 -7
- simtools/schemas/model_parameters/geomag_horizontal.schema.yml +2 -7
- simtools/schemas/model_parameters/geomag_rotation.schema.yml +2 -7
- simtools/schemas/model_parameters/geomag_vertical.schema.yml +2 -7
- simtools/schemas/model_parameters/hg_lg_variation.schema.yml +0 -5
- simtools/schemas/model_parameters/iobuf_maximum.schema.yml +0 -7
- simtools/schemas/model_parameters/iobuf_output_maximum.schema.yml +0 -7
- simtools/schemas/model_parameters/laser_events.schema.yml +4 -3
- simtools/schemas/model_parameters/laser_external_trigger.schema.yml +4 -3
- simtools/schemas/model_parameters/laser_photons.schema.yml +4 -3
- simtools/schemas/model_parameters/laser_pulse_exptime.schema.yml +4 -3
- simtools/schemas/model_parameters/laser_pulse_offset.schema.yml +4 -3
- simtools/schemas/model_parameters/laser_pulse_sigtime.schema.yml +4 -3
- simtools/schemas/model_parameters/laser_pulse_twidth.schema.yml +4 -3
- simtools/schemas/model_parameters/laser_var_photons.schema.yml +4 -3
- simtools/schemas/model_parameters/laser_wavelength.schema.yml +4 -3
- simtools/schemas/model_parameters/led_events.schema.yml +4 -3
- simtools/schemas/model_parameters/led_photons.schema.yml +4 -3
- simtools/schemas/model_parameters/led_pulse_offset.schema.yml +4 -3
- simtools/schemas/model_parameters/led_pulse_sigtime.schema.yml +4 -3
- simtools/schemas/model_parameters/led_var_photons.schema.yml +4 -3
- simtools/schemas/model_parameters/lightguide_efficiency_vs_incidence_angle.schema.yml +0 -7
- simtools/schemas/model_parameters/lightguide_efficiency_vs_wavelength.schema.yml +0 -7
- simtools/schemas/model_parameters/min_photoelectrons.schema.yml +0 -7
- simtools/schemas/model_parameters/min_photons.schema.yml +0 -7
- simtools/schemas/model_parameters/mirror_align_random_distance.schema.yml +0 -5
- simtools/schemas/model_parameters/mirror_align_random_horizontal.schema.yml +0 -7
- simtools/schemas/model_parameters/mirror_align_random_vertical.schema.yml +0 -7
- simtools/schemas/model_parameters/mirror_class.schema.yml +2 -9
- simtools/schemas/model_parameters/mirror_degraded_reflection.schema.yml +0 -7
- simtools/schemas/model_parameters/mirror_focal_length.schema.yml +0 -5
- simtools/schemas/model_parameters/mirror_list.schema.yml +0 -7
- simtools/schemas/model_parameters/mirror_offset.schema.yml +0 -7
- simtools/schemas/model_parameters/mirror_reflection_random_angle.schema.yml +0 -7
- simtools/schemas/model_parameters/mirror_reflectivity.schema.yml +0 -7
- simtools/schemas/model_parameters/multiplicity_offset.schema.yml +0 -7
- simtools/schemas/model_parameters/muon_mono_threshold.schema.yml +0 -7
- simtools/schemas/model_parameters/nsb_autoscale_airmass.schema.yml +0 -7
- simtools/schemas/model_parameters/nsb_gain_drop_scale.schema.yml +0 -3
- simtools/schemas/model_parameters/nsb_offaxis.schema.yml +0 -7
- simtools/schemas/model_parameters/nsb_pixel_rate.schema.yml +0 -7
- simtools/schemas/model_parameters/nsb_reference_spectrum.schema.yml +0 -5
- simtools/schemas/model_parameters/nsb_reference_value.schema.yml +0 -5
- simtools/schemas/model_parameters/nsb_scaling_factor.schema.yml +0 -5
- simtools/schemas/model_parameters/nsb_sky_map.schema.yml +0 -5
- simtools/schemas/model_parameters/nsb_spectrum.schema.yml +0 -5
- simtools/schemas/model_parameters/num_gains.schema.yml +0 -7
- simtools/schemas/model_parameters/only_triggered_telescopes.schema.yml +0 -7
- simtools/schemas/model_parameters/optics_properties.schema.yml +0 -7
- simtools/schemas/model_parameters/parabolic_dish.schema.yml +0 -3
- simtools/schemas/model_parameters/pedestal_events.schema.yml +4 -7
- simtools/schemas/model_parameters/photon_delay.schema.yml +0 -7
- simtools/schemas/model_parameters/photons_per_run.schema.yml +4 -4
- simtools/schemas/model_parameters/pixel_cells.schema.yml +0 -3
- simtools/schemas/model_parameters/pixels_parallel.schema.yml +0 -3
- simtools/schemas/model_parameters/pixeltrg_time_step.schema.yml +0 -7
- simtools/schemas/model_parameters/pm_average_gain.schema.yml +0 -5
- simtools/schemas/model_parameters/pm_collection_efficiency.schema.yml +0 -5
- simtools/schemas/model_parameters/pm_gain_index.schema.yml +0 -5
- simtools/schemas/model_parameters/pm_photoelectron_spectrum.schema.yml +0 -7
- simtools/schemas/model_parameters/pm_transit_time.schema.yml +4 -9
- simtools/schemas/model_parameters/pm_voltage_variation.schema.yml +0 -5
- simtools/schemas/model_parameters/primary_mirror_degraded_map.schema.yml +0 -7
- simtools/schemas/model_parameters/primary_mirror_diameter.schema.yml +0 -3
- simtools/schemas/model_parameters/primary_mirror_hole_diameter.schema.yml +0 -3
- simtools/schemas/model_parameters/primary_mirror_incidence_angle.schema.yml +0 -3
- simtools/schemas/model_parameters/primary_mirror_parameters.schema.yml +0 -3
- simtools/schemas/model_parameters/primary_mirror_ref_radius.schema.yml +0 -3
- simtools/schemas/model_parameters/primary_mirror_segmentation.schema.yml +0 -3
- simtools/schemas/model_parameters/qe_variation.schema.yml +0 -7
- simtools/schemas/model_parameters/quantum_efficiency.schema.yml +0 -7
- simtools/schemas/model_parameters/random_focal_length.schema.yml +2 -7
- simtools/schemas/model_parameters/random_generator.schema.yml +0 -7
- simtools/schemas/model_parameters/random_mono_probability.schema.yml +0 -7
- simtools/schemas/model_parameters/reference_point_altitude.schema.yml +0 -5
- simtools/schemas/model_parameters/reference_point_latitude.schema.yml +0 -5
- simtools/schemas/model_parameters/reference_point_longitude.schema.yml +0 -5
- simtools/schemas/model_parameters/reference_point_utm_east.schema.yml +0 -5
- simtools/schemas/model_parameters/reference_point_utm_north.schema.yml +0 -5
- simtools/schemas/model_parameters/sampled_output.schema.yml +0 -7
- simtools/schemas/model_parameters/save_pe_with_amplitude.schema.yml +0 -7
- simtools/schemas/model_parameters/secondary_mirror_baffle.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_degraded_map.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_degraded_reflection.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_diameter.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_hole_diameter.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_incidence_angle.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_parameters.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_ref_radius.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_reflectivity.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_segmentation.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_shadow_diameter.schema.yml +0 -3
- simtools/schemas/model_parameters/secondary_mirror_shadow_offset.schema.yml +0 -3
- simtools/schemas/model_parameters/stars.schema.yml +0 -5
- simtools/schemas/model_parameters/store_photoelectrons.schema.yml +0 -7
- simtools/schemas/model_parameters/tailcut_scale.schema.yml +0 -7
- simtools/schemas/model_parameters/telescope_axis_height.schema.yml +0 -7
- simtools/schemas/model_parameters/telescope_random_angle.schema.yml +0 -7
- simtools/schemas/model_parameters/telescope_random_error.schema.yml +0 -7
- simtools/schemas/model_parameters/telescope_sphere_radius.schema.yml +0 -7
- simtools/schemas/model_parameters/telescope_transmission.schema.yml +0 -7
- simtools/schemas/model_parameters/teltrig_min_sigsum.schema.yml +0 -7
- simtools/schemas/model_parameters/teltrig_min_time.schema.yml +0 -7
- simtools/schemas/model_parameters/transit_time_calib_error.schema.yml +0 -7
- simtools/schemas/model_parameters/transit_time_compensate_error.schema.yml +0 -7
- simtools/schemas/model_parameters/transit_time_compensate_step.schema.yml +0 -7
- simtools/schemas/model_parameters/transit_time_error.schema.yml +0 -7
- simtools/schemas/model_parameters/transit_time_jitter.schema.yml +0 -7
- simtools/schemas/model_parameters/trigger_current_limit.schema.yml +0 -7
- simtools/schemas/model_parameters/trigger_delay_compensation.schema.yml +0 -7
- simtools/schemas/model_parameters/trigger_pixels.schema.yml +0 -7
- simtools/schemas/production_tables.schema.yml +8 -8
- simtools/schemas/simulation_models_info.schema.yml +78 -0
- simtools/simtel/simtel_config_writer.py +88 -14
- simtools/simtel/simulator_array.py +44 -74
- simtools/simtel/simulator_light_emission.py +336 -629
- simtools/simtel/simulator_ray_tracing.py +2 -2
- simtools/simulator.py +46 -18
- simtools/testing/configuration.py +4 -2
- simtools/testing/sim_telarray_metadata.py +4 -4
- simtools/utils/geometry.py +34 -0
- simtools/version.py +111 -0
- simtools/{corsika/corsika_histograms_visualize.py → visualization/plot_corsika_histograms.py} +109 -0
- simtools/visualization/plot_psf.py +775 -0
- simtools/visualization/plot_simtel_events.py +284 -87
- simtools/applications/maintain_simulation_model_add_production_table.py +0 -71
- simtools/model/flasher_model.py +0 -106
- {gammasimtools-0.20.0.dist-info → gammasimtools-0.22.0.dist-info}/WHEEL +0 -0
- {gammasimtools-0.20.0.dist-info → gammasimtools-0.22.0.dist-info}/licenses/LICENSE +0 -0
- {gammasimtools-0.20.0.dist-info → gammasimtools-0.22.0.dist-info}/top_level.txt +0 -0
simtools/db/db_handler.py
CHANGED
|
@@ -11,13 +11,13 @@ import gridfs
|
|
|
11
11
|
import jsonschema
|
|
12
12
|
from astropy.table import Table
|
|
13
13
|
from bson.objectid import ObjectId
|
|
14
|
-
from packaging.version import Version
|
|
15
14
|
from pymongo import MongoClient
|
|
16
15
|
|
|
17
16
|
from simtools.data_model import validate_data
|
|
18
17
|
from simtools.io import ascii_handler, io_handler
|
|
19
18
|
from simtools.simtel import simtel_table_reader
|
|
20
19
|
from simtools.utils import names, value_conversion
|
|
20
|
+
from simtools.version import resolve_version_to_latest_patch
|
|
21
21
|
|
|
22
22
|
__all__ = ["DatabaseHandler"]
|
|
23
23
|
|
|
@@ -72,6 +72,11 @@ class DatabaseHandler:
|
|
|
72
72
|
"""
|
|
73
73
|
DatabaseHandler provides the interface to the DB.
|
|
74
74
|
|
|
75
|
+
Note the two types of version variables used in this class:
|
|
76
|
+
|
|
77
|
+
- db_simulation_model_version (from mongo_db_config): version of the simulation model database
|
|
78
|
+
- model_version (from production_tables): version of the model contained in the database
|
|
79
|
+
|
|
75
80
|
Parameters
|
|
76
81
|
----------
|
|
77
82
|
mongo_db_config: dict
|
|
@@ -83,6 +88,7 @@ class DatabaseHandler:
|
|
|
83
88
|
db_client = None
|
|
84
89
|
production_table_cached = {}
|
|
85
90
|
model_parameters_cached = {}
|
|
91
|
+
model_versions_cached = {}
|
|
86
92
|
|
|
87
93
|
def __init__(self, mongo_db_config=None):
|
|
88
94
|
"""Initialize the DatabaseHandler class."""
|
|
@@ -93,10 +99,9 @@ class DatabaseHandler:
|
|
|
93
99
|
self.list_of_collections = {}
|
|
94
100
|
|
|
95
101
|
self._set_up_connection()
|
|
96
|
-
self._find_latest_simulation_model_db()
|
|
97
102
|
self.db_name = (
|
|
98
103
|
self.get_db_name(
|
|
99
|
-
|
|
104
|
+
db_simulation_model_version=self.mongo_db_config.get("db_simulation_model_version"),
|
|
100
105
|
model_name=self.mongo_db_config.get("db_simulation_model"),
|
|
101
106
|
)
|
|
102
107
|
if self.mongo_db_config
|
|
@@ -110,15 +115,43 @@ class DatabaseHandler:
|
|
|
110
115
|
with lock:
|
|
111
116
|
DatabaseHandler.db_client = self._open_mongo_db()
|
|
112
117
|
|
|
113
|
-
def get_db_name(self, db_name=None,
|
|
118
|
+
def get_db_name(self, db_name=None, db_simulation_model_version=None, model_name=None):
|
|
114
119
|
"""Build DB name from configuration."""
|
|
115
120
|
if db_name:
|
|
116
121
|
return db_name
|
|
117
|
-
if
|
|
118
|
-
return f"{model_name}-{
|
|
119
|
-
if
|
|
122
|
+
if db_simulation_model_version and model_name:
|
|
123
|
+
return f"{model_name}-{db_simulation_model_version.replace('.', '-')}"
|
|
124
|
+
if db_simulation_model_version or model_name:
|
|
120
125
|
return None
|
|
121
|
-
return None if (
|
|
126
|
+
return None if (db_simulation_model_version or model_name) else self.db_name
|
|
127
|
+
|
|
128
|
+
def print_connection_info(self):
|
|
129
|
+
"""Print the connection information."""
|
|
130
|
+
if self.mongo_db_config:
|
|
131
|
+
self._logger.info(
|
|
132
|
+
f"Connected to MongoDB at {self.mongo_db_config['db_server']}:"
|
|
133
|
+
f"{self.mongo_db_config['db_api_port']} "
|
|
134
|
+
f"using database: {self.db_name}"
|
|
135
|
+
)
|
|
136
|
+
else:
|
|
137
|
+
self._logger.info("No MongoDB configuration provided.")
|
|
138
|
+
|
|
139
|
+
def is_remote_database(self):
|
|
140
|
+
"""
|
|
141
|
+
Check if the database is remote.
|
|
142
|
+
|
|
143
|
+
Check for domain pattern like "cta-simpipe-protodb.zeuthen.desy.de"
|
|
144
|
+
|
|
145
|
+
Returns
|
|
146
|
+
-------
|
|
147
|
+
bool
|
|
148
|
+
True if the database is remote, False otherwise.
|
|
149
|
+
"""
|
|
150
|
+
if self.mongo_db_config:
|
|
151
|
+
db_server = self.mongo_db_config["db_server"]
|
|
152
|
+
domain_pattern = r"^([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$"
|
|
153
|
+
return bool(re.match(domain_pattern, db_server))
|
|
154
|
+
return False
|
|
122
155
|
|
|
123
156
|
def _validate_mongo_db_config(self, mongo_db_config):
|
|
124
157
|
"""Validate the MongoDB configuration."""
|
|
@@ -164,50 +197,45 @@ class DatabaseHandler:
|
|
|
164
197
|
tlsallowinvalidcertificates=True,
|
|
165
198
|
)
|
|
166
199
|
|
|
167
|
-
def
|
|
200
|
+
def generate_compound_indexes_for_databases(
|
|
201
|
+
self, db_name, db_simulation_model, db_simulation_model_version
|
|
202
|
+
):
|
|
168
203
|
"""
|
|
169
|
-
|
|
204
|
+
Generate compound indexes for several databases.
|
|
170
205
|
|
|
171
|
-
|
|
172
|
-
|
|
206
|
+
Parameters
|
|
207
|
+
----------
|
|
208
|
+
db_name: str
|
|
209
|
+
Name of the database.
|
|
210
|
+
db_simulation_model: str
|
|
211
|
+
Name of the simulation model.
|
|
212
|
+
db_simulation_model_version: str
|
|
213
|
+
Version of the simulation model.
|
|
173
214
|
|
|
174
215
|
Raises
|
|
175
216
|
------
|
|
176
217
|
ValueError
|
|
177
|
-
If the
|
|
218
|
+
If the requested database is not found.
|
|
178
219
|
|
|
179
220
|
"""
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
db_simulation_model = self.mongo_db_config["db_simulation_model"]
|
|
183
|
-
if db_simulation_model_version != "LATEST":
|
|
184
|
-
return
|
|
185
|
-
except TypeError: # db_simulation_model_version is None
|
|
186
|
-
return
|
|
187
|
-
|
|
188
|
-
list_of_db_names = self.db_client.list_database_names()
|
|
189
|
-
filtered_list_of_db_names = [
|
|
190
|
-
s for s in list_of_db_names if s.startswith(db_simulation_model)
|
|
221
|
+
databases = [
|
|
222
|
+
d for d in self.db_client.list_database_names() if d not in ("config", "admin", "local")
|
|
191
223
|
]
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
versioned_strings.append((s, Version(version_str)))
|
|
202
|
-
|
|
203
|
-
if versioned_strings:
|
|
204
|
-
latest_string, _ = max(versioned_strings, key=lambda x: x[1])
|
|
205
|
-
self.mongo_db_config["db_simulation_model"] = latest_string
|
|
206
|
-
self._logger.info(
|
|
207
|
-
f"Updated the DB simulation model to the latest version {latest_string}"
|
|
224
|
+
requested = self.get_db_name(
|
|
225
|
+
db_name=db_name,
|
|
226
|
+
db_simulation_model_version=db_simulation_model_version,
|
|
227
|
+
model_name=db_simulation_model,
|
|
228
|
+
)
|
|
229
|
+
if requested != "all" and requested not in databases:
|
|
230
|
+
raise ValueError(
|
|
231
|
+
f"Requested database '{requested}' not found. "
|
|
232
|
+
f"Following databases are available: {', '.join(databases)}"
|
|
208
233
|
)
|
|
209
|
-
|
|
210
|
-
|
|
234
|
+
|
|
235
|
+
databases = databases if requested == "all" else [requested]
|
|
236
|
+
for dbs in databases:
|
|
237
|
+
self._logger.info(f"Generating compound indexes for database: {dbs}")
|
|
238
|
+
self.generate_compound_indexes(db_name=dbs)
|
|
211
239
|
|
|
212
240
|
def generate_compound_indexes(self, db_name=None):
|
|
213
241
|
"""
|
|
@@ -269,6 +297,9 @@ class DatabaseHandler:
|
|
|
269
297
|
raise ValueError(
|
|
270
298
|
"Only one model version can be passed to get_model_parameter, not a list."
|
|
271
299
|
)
|
|
300
|
+
model_version = resolve_version_to_latest_patch(
|
|
301
|
+
model_version, self.get_model_versions(collection_name)
|
|
302
|
+
)
|
|
272
303
|
production_table = self.read_production_table_from_mongo_db(
|
|
273
304
|
collection_name, model_version
|
|
274
305
|
)
|
|
@@ -315,6 +346,9 @@ class DatabaseHandler:
|
|
|
315
346
|
dict containing the parameters
|
|
316
347
|
"""
|
|
317
348
|
pars = {}
|
|
349
|
+
model_version = resolve_version_to_latest_patch(
|
|
350
|
+
model_version, self.get_model_versions(collection)
|
|
351
|
+
)
|
|
318
352
|
production_table = self.read_production_table_from_mongo_db(collection, model_version)
|
|
319
353
|
array_element_list = self._get_array_element_list(
|
|
320
354
|
array_element_name, site, production_table, collection
|
|
@@ -361,6 +395,11 @@ class DatabaseHandler:
|
|
|
361
395
|
def _get_parameter_for_model_version(
|
|
362
396
|
self, array_element, model_version, site, collection, production_table
|
|
363
397
|
):
|
|
398
|
+
"""
|
|
399
|
+
Get parameters for a specific model version and array element.
|
|
400
|
+
|
|
401
|
+
Uses caching wherever possible.
|
|
402
|
+
"""
|
|
364
403
|
cache_key, cache_dict = self._read_cache(
|
|
365
404
|
DatabaseHandler.model_parameters_cached,
|
|
366
405
|
names.validate_site_name(site) if site else None,
|
|
@@ -589,6 +628,9 @@ class DatabaseHandler:
|
|
|
589
628
|
ValueError
|
|
590
629
|
if query returned no results.
|
|
591
630
|
"""
|
|
631
|
+
model_version = resolve_version_to_latest_patch(
|
|
632
|
+
model_version, self.get_model_versions(collection_name)
|
|
633
|
+
)
|
|
592
634
|
try:
|
|
593
635
|
return DatabaseHandler.production_table_cached[
|
|
594
636
|
self._cache_key(None, None, model_version, collection_name)
|
|
@@ -612,7 +654,7 @@ class DatabaseHandler:
|
|
|
612
654
|
|
|
613
655
|
def get_model_versions(self, collection_name="telescopes"):
|
|
614
656
|
"""
|
|
615
|
-
Get list of model versions from the DB.
|
|
657
|
+
Get list of model versions from the DB with caching.
|
|
616
658
|
|
|
617
659
|
Parameters
|
|
618
660
|
----------
|
|
@@ -624,10 +666,12 @@ class DatabaseHandler:
|
|
|
624
666
|
list
|
|
625
667
|
List of model versions
|
|
626
668
|
"""
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
669
|
+
if collection_name not in DatabaseHandler.model_versions_cached:
|
|
670
|
+
collection = self.get_collection("production_tables", db_name=self.db_name)
|
|
671
|
+
DatabaseHandler.model_versions_cached[collection_name] = sorted(
|
|
672
|
+
{post["model_version"] for post in collection.find({"collection": collection_name})}
|
|
673
|
+
)
|
|
674
|
+
return DatabaseHandler.model_versions_cached[collection_name]
|
|
631
675
|
|
|
632
676
|
def get_array_elements(self, model_version, collection="telescopes"):
|
|
633
677
|
"""
|
|
@@ -646,6 +690,9 @@ class DatabaseHandler:
|
|
|
646
690
|
list
|
|
647
691
|
Sorted list of all array elements found in collection
|
|
648
692
|
"""
|
|
693
|
+
model_version = resolve_version_to_latest_patch(
|
|
694
|
+
model_version, self.get_model_versions(collection)
|
|
695
|
+
)
|
|
649
696
|
production_table = self.read_production_table_from_mongo_db(collection, model_version)
|
|
650
697
|
return sorted([entry for entry in production_table["parameters"] if "-design" not in entry])
|
|
651
698
|
|
|
@@ -668,6 +715,9 @@ class DatabaseHandler:
|
|
|
668
715
|
str
|
|
669
716
|
Design model for a given array element.
|
|
670
717
|
"""
|
|
718
|
+
model_version = resolve_version_to_latest_patch(
|
|
719
|
+
model_version, self.get_model_versions(collection)
|
|
720
|
+
)
|
|
671
721
|
production_table = self.read_production_table_from_mongo_db(collection, model_version)
|
|
672
722
|
try:
|
|
673
723
|
return production_table["design_model"][array_element_name]
|
|
@@ -696,6 +746,9 @@ class DatabaseHandler:
|
|
|
696
746
|
list
|
|
697
747
|
Sorted list of all array element names found in collection
|
|
698
748
|
"""
|
|
749
|
+
model_version = resolve_version_to_latest_patch(
|
|
750
|
+
model_version, self.get_model_versions(collection)
|
|
751
|
+
)
|
|
699
752
|
production_table = self.read_production_table_from_mongo_db(collection, model_version)
|
|
700
753
|
all_array_elements = production_table["parameters"]
|
|
701
754
|
return sorted(
|
|
@@ -843,9 +896,10 @@ class DatabaseHandler:
|
|
|
843
896
|
"""
|
|
844
897
|
db_name = db_name or self.db_name
|
|
845
898
|
collection = self.get_collection("production_tables", db_name=db_name or self.db_name)
|
|
846
|
-
self._logger.debug(f"Adding production for {production_table.get('collection')} to
|
|
899
|
+
self._logger.debug(f"Adding production for {production_table.get('collection')} to the DB")
|
|
847
900
|
collection.insert_one(production_table)
|
|
848
901
|
DatabaseHandler.production_table_cached.clear()
|
|
902
|
+
DatabaseHandler.model_versions_cached.clear()
|
|
849
903
|
|
|
850
904
|
def add_new_parameter(
|
|
851
905
|
self,
|
|
@@ -1001,6 +1055,7 @@ class DatabaseHandler:
|
|
|
1001
1055
|
def _reset_parameter_cache(self):
|
|
1002
1056
|
"""Reset the cache for the parameters."""
|
|
1003
1057
|
DatabaseHandler.model_parameters_cached.clear()
|
|
1058
|
+
DatabaseHandler.model_versions_cached.clear()
|
|
1004
1059
|
|
|
1005
1060
|
def _get_array_element_list(self, array_element_name, site, production_table, collection):
|
|
1006
1061
|
"""
|
simtools/db/db_model_upload.py
CHANGED
|
@@ -1,14 +1,85 @@
|
|
|
1
1
|
"""Upload a simulation model (parameters and production tables) to the database."""
|
|
2
2
|
|
|
3
3
|
import logging
|
|
4
|
+
import shutil
|
|
4
5
|
from pathlib import Path
|
|
5
6
|
|
|
7
|
+
from packaging.version import Version
|
|
8
|
+
|
|
6
9
|
from simtools.io import ascii_handler
|
|
10
|
+
from simtools.job_execution.job_manager import retry_command
|
|
7
11
|
from simtools.utils import names
|
|
8
12
|
|
|
9
13
|
logger = logging.getLogger(__name__)
|
|
10
14
|
|
|
11
15
|
|
|
16
|
+
def add_complete_model(
|
|
17
|
+
tmp_dir,
|
|
18
|
+
db,
|
|
19
|
+
db_simulation_model,
|
|
20
|
+
db_simulation_model_version,
|
|
21
|
+
repository_url,
|
|
22
|
+
repository_branch=None,
|
|
23
|
+
):
|
|
24
|
+
"""
|
|
25
|
+
Upload a complete model including model parameters and production tables to the database.
|
|
26
|
+
|
|
27
|
+
Generate compound indexes for the new database.
|
|
28
|
+
|
|
29
|
+
Parameters
|
|
30
|
+
----------
|
|
31
|
+
tmp_dir : Path or str
|
|
32
|
+
Temporary directory to use for cloning the repository.
|
|
33
|
+
db : DatabaseHandler
|
|
34
|
+
Database handler object.
|
|
35
|
+
db_simulation_model : str
|
|
36
|
+
Name of the simulation model in the database.
|
|
37
|
+
db_simulation_model_version : str
|
|
38
|
+
Version of the simulation model in the database.
|
|
39
|
+
repository_url : str
|
|
40
|
+
URL of the simulation model repository to clone.
|
|
41
|
+
repository_branch : str, optional
|
|
42
|
+
Branch of the repository to use. If None, the default branch is used.
|
|
43
|
+
|
|
44
|
+
Returns
|
|
45
|
+
-------
|
|
46
|
+
None
|
|
47
|
+
This function does not return a value.
|
|
48
|
+
"""
|
|
49
|
+
if not _confirm_remote_database_upload(db):
|
|
50
|
+
return
|
|
51
|
+
|
|
52
|
+
repository_dir = None
|
|
53
|
+
try:
|
|
54
|
+
repository_dir = clone_simulation_model_repository(
|
|
55
|
+
tmp_dir,
|
|
56
|
+
repository_url,
|
|
57
|
+
db_simulation_model_version=db_simulation_model_version,
|
|
58
|
+
repository_branch=repository_branch,
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
add_model_parameters_to_db(
|
|
62
|
+
input_path=repository_dir / "simulation-models" / "model_parameters", db=db
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
add_production_tables_to_db(
|
|
66
|
+
input_path=repository_dir / "simulation-models" / "productions", db=db
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
db.generate_compound_indexes_for_databases(
|
|
70
|
+
db_name=None,
|
|
71
|
+
db_simulation_model=db_simulation_model,
|
|
72
|
+
db_simulation_model_version=db_simulation_model_version,
|
|
73
|
+
)
|
|
74
|
+
except Exception as exc:
|
|
75
|
+
raise RuntimeError(f"Upload of simulation model failed: {exc}") from exc
|
|
76
|
+
finally:
|
|
77
|
+
if repository_dir is not None and repository_dir.exists():
|
|
78
|
+
shutil.rmtree(repository_dir)
|
|
79
|
+
|
|
80
|
+
logger.info("Upload of simulation model completed successfully")
|
|
81
|
+
|
|
82
|
+
|
|
12
83
|
def add_values_from_json_to_db(file, collection, db, file_prefix):
|
|
13
84
|
"""
|
|
14
85
|
Upload new model parameter from json files to db.
|
|
@@ -51,8 +122,7 @@ def add_model_parameters_to_db(input_path, db):
|
|
|
51
122
|
"""
|
|
52
123
|
input_path = Path(input_path)
|
|
53
124
|
logger.info(f"Reading model parameters from repository path {input_path}")
|
|
54
|
-
|
|
55
|
-
for element in array_elements:
|
|
125
|
+
for element in filter(Path.is_dir, input_path.iterdir()):
|
|
56
126
|
collection = names.get_collection_name_from_array_element_name(element.name, False)
|
|
57
127
|
if collection == "Files":
|
|
58
128
|
logger.info("Files (tables) are uploaded with the corresponding model parameters")
|
|
@@ -85,20 +155,51 @@ def add_production_tables_to_db(input_path, db):
|
|
|
85
155
|
input_path = Path(input_path)
|
|
86
156
|
logger.info(f"Reading production tables from repository path {input_path}")
|
|
87
157
|
|
|
88
|
-
for model in filter(Path.is_dir, input_path.iterdir()):
|
|
158
|
+
for model in sorted(filter(Path.is_dir, input_path.iterdir())):
|
|
89
159
|
logger.info(f"Reading production tables for model version {model.name}")
|
|
90
|
-
model_dict =
|
|
91
|
-
for file in sorted(model.rglob("*json")):
|
|
92
|
-
_read_production_table(model_dict, file, model.name)
|
|
160
|
+
model_dict = _read_production_tables(model)
|
|
93
161
|
|
|
94
162
|
for collection, data in model_dict.items():
|
|
95
|
-
if
|
|
163
|
+
if data["parameters"]:
|
|
164
|
+
logger.info(
|
|
165
|
+
f"Adding production table for {collection} "
|
|
166
|
+
f"(model version {model.name}) to the database"
|
|
167
|
+
)
|
|
168
|
+
db.add_production_table(production_table=data)
|
|
169
|
+
else:
|
|
96
170
|
logger.info(f"No production table for {collection} in model version {model.name}")
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def _read_production_tables(model_path):
|
|
174
|
+
"""
|
|
175
|
+
Read production tables from a directory.
|
|
176
|
+
|
|
177
|
+
Take into account that some productions include patch updates only. Read in this cases
|
|
178
|
+
all models from the model version history, starting with the earliest one.
|
|
179
|
+
|
|
180
|
+
Parameters
|
|
181
|
+
----------
|
|
182
|
+
model_path : Path
|
|
183
|
+
Path to the directory containing the production tables for a specific model version.
|
|
184
|
+
"""
|
|
185
|
+
model_dict = {}
|
|
186
|
+
models = [model_path.name]
|
|
187
|
+
if (model_path / "info.yml").exists():
|
|
188
|
+
info = ascii_handler.collect_data_from_file(file_name=model_path / "info.yml")
|
|
189
|
+
models.extend(info.get("model_version_history", []))
|
|
190
|
+
# sort oldest --> newest
|
|
191
|
+
models = sorted(set(models), key=Version, reverse=False)
|
|
192
|
+
for model in models:
|
|
193
|
+
for file in sorted((model_path.parent / model).rglob("*json")):
|
|
194
|
+
_read_production_table(model_dict, file, model)
|
|
195
|
+
|
|
196
|
+
# ensure that the for patch updates the model version is set correctly
|
|
197
|
+
for table in model_dict.values():
|
|
198
|
+
table["model_version"] = model_path.name
|
|
199
|
+
|
|
200
|
+
_remove_deprecated_model_parameters(model_dict)
|
|
201
|
+
|
|
202
|
+
return model_dict
|
|
102
203
|
|
|
103
204
|
|
|
104
205
|
def _read_production_table(model_dict, file, model_name):
|
|
@@ -112,23 +213,153 @@ def _read_production_table(model_dict, file, model_name):
|
|
|
112
213
|
"model_version": model_name,
|
|
113
214
|
"parameters": {},
|
|
114
215
|
"design_model": {},
|
|
216
|
+
"deprecated_parameters": [],
|
|
115
217
|
},
|
|
116
218
|
)
|
|
117
219
|
parameter_dict = ascii_handler.collect_data_from_file(file_name=file)
|
|
118
|
-
logger.debug(
|
|
220
|
+
logger.debug(
|
|
221
|
+
f"Reading production table for {array_element} "
|
|
222
|
+
f"(model_version {model_name}, collection {collection})"
|
|
223
|
+
)
|
|
119
224
|
try:
|
|
120
225
|
if array_element in ("configuration_corsika", "configuration_sim_telarray"):
|
|
121
226
|
model_dict[collection]["parameters"] = parameter_dict["parameters"]
|
|
122
227
|
else:
|
|
123
|
-
model_dict[collection]["parameters"]
|
|
124
|
-
array_element
|
|
125
|
-
|
|
228
|
+
model_dict[collection]["parameters"].setdefault(array_element, {}).update(
|
|
229
|
+
parameter_dict["parameters"][array_element]
|
|
230
|
+
)
|
|
126
231
|
except KeyError as exc:
|
|
127
232
|
logger.error(f"KeyError: {exc}")
|
|
128
233
|
raise
|
|
234
|
+
|
|
129
235
|
try:
|
|
130
236
|
model_dict[collection]["design_model"][array_element] = parameter_dict["design_model"][
|
|
131
237
|
array_element
|
|
132
238
|
]
|
|
133
239
|
except KeyError:
|
|
134
240
|
pass
|
|
241
|
+
|
|
242
|
+
try:
|
|
243
|
+
model_dict[collection]["deprecated_parameters"] = parameter_dict["deprecated_parameters"]
|
|
244
|
+
except KeyError:
|
|
245
|
+
pass
|
|
246
|
+
|
|
247
|
+
model_dict[collection]["model_version"] = model_name
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def _remove_deprecated_model_parameters(model_dict):
|
|
251
|
+
"""
|
|
252
|
+
Remove deprecated parameters from all tables in a model dictionary.
|
|
253
|
+
|
|
254
|
+
Parameters
|
|
255
|
+
----------
|
|
256
|
+
model_dict : dict
|
|
257
|
+
Production tables for a specific model version.
|
|
258
|
+
"""
|
|
259
|
+
for table in model_dict.values():
|
|
260
|
+
for params in table.get("parameters", {}).values():
|
|
261
|
+
for param in table.get("deprecated_parameters", []):
|
|
262
|
+
if param in params:
|
|
263
|
+
logger.info(
|
|
264
|
+
f"Deprecated parameter {param} in production table {table['collection']}"
|
|
265
|
+
)
|
|
266
|
+
params.pop(param)
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
def _confirm_remote_database_upload(db):
|
|
270
|
+
"""
|
|
271
|
+
Confirm with the user that they want to upload to a remote database.
|
|
272
|
+
|
|
273
|
+
Returns True if the user confirms, False otherwise. Returns also True
|
|
274
|
+
if the database is not remote.
|
|
275
|
+
|
|
276
|
+
Parameters
|
|
277
|
+
----------
|
|
278
|
+
db : DatabaseHandler
|
|
279
|
+
Database handler object.
|
|
280
|
+
|
|
281
|
+
Returns
|
|
282
|
+
-------
|
|
283
|
+
bool
|
|
284
|
+
True if user confirms upload, False otherwise.
|
|
285
|
+
"""
|
|
286
|
+
abort_message = "Operation aborted."
|
|
287
|
+
|
|
288
|
+
if not db.is_remote_database():
|
|
289
|
+
return True
|
|
290
|
+
|
|
291
|
+
db_config = db.mongo_db_config
|
|
292
|
+
db_server = db_config.get("db_server", "unknown server") if db_config else "unknown server"
|
|
293
|
+
|
|
294
|
+
try:
|
|
295
|
+
# First confirmation
|
|
296
|
+
user_input = input(
|
|
297
|
+
f"Do you really want to upload to remote DB {db_server}? Type 'yes' to confirm: "
|
|
298
|
+
)
|
|
299
|
+
if user_input != "yes":
|
|
300
|
+
logger.info(abort_message)
|
|
301
|
+
return False
|
|
302
|
+
|
|
303
|
+
# Second confirmation
|
|
304
|
+
user_input = input(
|
|
305
|
+
f"Let be sure: do you really want to upload to remote DB {db_server}? "
|
|
306
|
+
"Type 'yes' to confirm: "
|
|
307
|
+
)
|
|
308
|
+
if user_input != "yes":
|
|
309
|
+
logger.info(abort_message)
|
|
310
|
+
return False
|
|
311
|
+
|
|
312
|
+
return True
|
|
313
|
+
|
|
314
|
+
except (EOFError, KeyboardInterrupt):
|
|
315
|
+
logger.info(abort_message)
|
|
316
|
+
return False
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
def clone_simulation_model_repository(
|
|
320
|
+
target_dir, repository_url, db_simulation_model_version, repository_branch
|
|
321
|
+
):
|
|
322
|
+
"""
|
|
323
|
+
Clone a git repository containing simulation model parameters and production tables.
|
|
324
|
+
|
|
325
|
+
Parameters
|
|
326
|
+
----------
|
|
327
|
+
target_dir : Path or str
|
|
328
|
+
Target directory to clone the repository into.
|
|
329
|
+
repository_url : str
|
|
330
|
+
URL of the git repository to clone.
|
|
331
|
+
db_simulation_model_version : str
|
|
332
|
+
Version tag of the simulation model to checkout.
|
|
333
|
+
repository_branch : str, optional
|
|
334
|
+
Branch of the repository to use. If None, the version tag is used.
|
|
335
|
+
|
|
336
|
+
Returns
|
|
337
|
+
-------
|
|
338
|
+
Path
|
|
339
|
+
Path to the cloned repository.
|
|
340
|
+
"""
|
|
341
|
+
if repository_branch:
|
|
342
|
+
logger.info(f"Using branch: {repository_branch}")
|
|
343
|
+
else:
|
|
344
|
+
logger.info(f"Using version tag: {db_simulation_model_version}")
|
|
345
|
+
|
|
346
|
+
target_dir = Path(target_dir)
|
|
347
|
+
target_dir = target_dir if target_dir.is_absolute() else Path.cwd() / target_dir
|
|
348
|
+
|
|
349
|
+
if target_dir.exists():
|
|
350
|
+
shutil.rmtree(target_dir)
|
|
351
|
+
|
|
352
|
+
logger.info(f"Cloning model parameters from {repository_url}")
|
|
353
|
+
|
|
354
|
+
if repository_branch:
|
|
355
|
+
command = f'git clone --depth=1 -b "{repository_branch}" "{repository_url}" "{target_dir}"'
|
|
356
|
+
else:
|
|
357
|
+
# Use version tag with detached head (generates warning but that's fine)
|
|
358
|
+
command = (
|
|
359
|
+
f'git clone --branch "{db_simulation_model_version}" '
|
|
360
|
+
f'--depth 1 "{repository_url}" "{target_dir}"'
|
|
361
|
+
)
|
|
362
|
+
|
|
363
|
+
retry_command(command)
|
|
364
|
+
|
|
365
|
+
return target_dir
|