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
simtools/db_handler.py
DELETED
|
@@ -1,1480 +0,0 @@
|
|
|
1
|
-
""" Module to handle interaction with DB. """
|
|
2
|
-
|
|
3
|
-
import logging
|
|
4
|
-
from pathlib import Path
|
|
5
|
-
from threading import Lock
|
|
6
|
-
|
|
7
|
-
import gridfs
|
|
8
|
-
import pymongo
|
|
9
|
-
import yaml
|
|
10
|
-
from bson.objectid import ObjectId
|
|
11
|
-
from pymongo import MongoClient
|
|
12
|
-
from pymongo.errors import BulkWriteError
|
|
13
|
-
|
|
14
|
-
import simtools.utils.general as gen
|
|
15
|
-
from simtools.io_operations import io_handler
|
|
16
|
-
from simtools.utils import names
|
|
17
|
-
|
|
18
|
-
__all__ = ["DatabaseHandler"]
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
# pylint: disable=unsubscriptable-object
|
|
22
|
-
# The above comment is because pylint does not know that DatabaseHandler.db_client is subscriptable
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
class DatabaseHandler:
|
|
26
|
-
"""
|
|
27
|
-
DatabaseHandler provides the interface to the DB.
|
|
28
|
-
|
|
29
|
-
Parameters
|
|
30
|
-
----------
|
|
31
|
-
io_handler: IOHandler
|
|
32
|
-
Instance of IOHandler
|
|
33
|
-
mongo_db_config: dict
|
|
34
|
-
Dictionary with the MongoDB configuration with the following entries:
|
|
35
|
-
"db_server" - DB server address
|
|
36
|
-
"db_api_port" - Port to use
|
|
37
|
-
"db_api_user" - API username
|
|
38
|
-
"db_api_pw" - Password for the API user
|
|
39
|
-
"db_api_authentication_database" - DB with user info (optional, default is "admin")
|
|
40
|
-
"""
|
|
41
|
-
|
|
42
|
-
DB_TABULATED_DATA = "CTA-Simulation-Model"
|
|
43
|
-
DB_CTA_SIMULATION_MODEL = "CTA-Simulation-Model"
|
|
44
|
-
DB_CTA_SIMULATION_MODEL_DESCRIPTIONS = "CTA-Simulation-Model-Descriptions"
|
|
45
|
-
DB_REFERENCE_DATA = "CTA-Reference-Data"
|
|
46
|
-
DB_DERIVED_VALUES = "CTA-Simulation-Model-Derived-Values"
|
|
47
|
-
|
|
48
|
-
ALLOWED_FILE_EXTENSIONS = [".dat", ".txt", ".lis", ".cfg", ".yml", ".yaml", ".ecsv"]
|
|
49
|
-
|
|
50
|
-
db_client = None
|
|
51
|
-
|
|
52
|
-
def __init__(self, mongo_db_config=None):
|
|
53
|
-
"""
|
|
54
|
-
Initialize the DatabaseHandler class.
|
|
55
|
-
|
|
56
|
-
Raises
|
|
57
|
-
------
|
|
58
|
-
KeyError
|
|
59
|
-
if there is non-valid key in the db_config.
|
|
60
|
-
|
|
61
|
-
"""
|
|
62
|
-
self._logger = logging.getLogger(__name__)
|
|
63
|
-
self._logger.debug("Initialize DatabaseHandler")
|
|
64
|
-
|
|
65
|
-
self.mongo_db_config = mongo_db_config
|
|
66
|
-
self._logger.debug(f"DB configuration: {self.mongo_db_config}")
|
|
67
|
-
self.io_handler = io_handler.IOHandler()
|
|
68
|
-
|
|
69
|
-
self._set_up_connection()
|
|
70
|
-
|
|
71
|
-
def _set_up_connection(self):
|
|
72
|
-
"""
|
|
73
|
-
Open the connection to MongoDB.
|
|
74
|
-
"""
|
|
75
|
-
if self.mongo_db_config:
|
|
76
|
-
if DatabaseHandler.db_client is None:
|
|
77
|
-
lock = Lock()
|
|
78
|
-
with lock:
|
|
79
|
-
DatabaseHandler.db_client = self._open_mongo_db()
|
|
80
|
-
|
|
81
|
-
def _open_mongo_db(self):
|
|
82
|
-
"""
|
|
83
|
-
Open a connection to MongoDB and return the client to read/write to the DB with.
|
|
84
|
-
|
|
85
|
-
Returns
|
|
86
|
-
-------
|
|
87
|
-
A PyMongo DB client
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
"""
|
|
91
|
-
try:
|
|
92
|
-
_db_client = MongoClient(
|
|
93
|
-
self.mongo_db_config["db_server"],
|
|
94
|
-
port=self.mongo_db_config["db_api_port"],
|
|
95
|
-
username=self.mongo_db_config["db_api_user"],
|
|
96
|
-
password=self.mongo_db_config["db_api_pw"],
|
|
97
|
-
authSource=self.mongo_db_config.get("db_api_authentication_database", "admin"),
|
|
98
|
-
ssl=True,
|
|
99
|
-
tlsallowinvalidhostnames=True,
|
|
100
|
-
tlsallowinvalidcertificates=True,
|
|
101
|
-
)
|
|
102
|
-
except KeyError:
|
|
103
|
-
self._logger.error("Invalid setting of DB configuration")
|
|
104
|
-
raise
|
|
105
|
-
|
|
106
|
-
return _db_client
|
|
107
|
-
|
|
108
|
-
@staticmethod
|
|
109
|
-
def _get_telescope_model_name_for_db(site, telescope_model_name):
|
|
110
|
-
"""
|
|
111
|
-
Make telescope name as the DB needs from site and telescope_model_name."""
|
|
112
|
-
return site + "-" + telescope_model_name
|
|
113
|
-
|
|
114
|
-
def get_model_parameters(
|
|
115
|
-
self,
|
|
116
|
-
site,
|
|
117
|
-
telescope_model_name,
|
|
118
|
-
model_version,
|
|
119
|
-
only_applicable=False,
|
|
120
|
-
):
|
|
121
|
-
"""
|
|
122
|
-
Get parameters from either MongoDB or yaml DB for a specific telescope.
|
|
123
|
-
|
|
124
|
-
Parameters
|
|
125
|
-
----------
|
|
126
|
-
site: str
|
|
127
|
-
South or North.
|
|
128
|
-
telescope_model_name: str
|
|
129
|
-
Name of the telescope model (e.g. LST-1, MST-FlashCam-D)
|
|
130
|
-
model_version: str
|
|
131
|
-
Version of the model.
|
|
132
|
-
only_applicable: bool
|
|
133
|
-
If True, only applicable parameters will be read.
|
|
134
|
-
|
|
135
|
-
Returns
|
|
136
|
-
-------
|
|
137
|
-
dict containing the parameters
|
|
138
|
-
|
|
139
|
-
"""
|
|
140
|
-
|
|
141
|
-
_site_validated = names.validate_site_name(site)
|
|
142
|
-
_tel_model_name_validated = names.validate_telescope_model_name(telescope_model_name)
|
|
143
|
-
|
|
144
|
-
if self.mongo_db_config:
|
|
145
|
-
# Only MongoDB supports tagged version
|
|
146
|
-
_model_version = self._convert_version_to_tagged(
|
|
147
|
-
model_version, DatabaseHandler.DB_CTA_SIMULATION_MODEL
|
|
148
|
-
)
|
|
149
|
-
_version_validated = names.validate_model_version_name(_model_version)
|
|
150
|
-
|
|
151
|
-
_pars = self._get_model_parameters_mongo_db(
|
|
152
|
-
DatabaseHandler.DB_CTA_SIMULATION_MODEL,
|
|
153
|
-
_site_validated,
|
|
154
|
-
_tel_model_name_validated,
|
|
155
|
-
_version_validated,
|
|
156
|
-
only_applicable,
|
|
157
|
-
)
|
|
158
|
-
return _pars
|
|
159
|
-
|
|
160
|
-
_version_validated = names.validate_model_version_name(model_version)
|
|
161
|
-
|
|
162
|
-
return self._get_model_parameters_yaml(
|
|
163
|
-
_tel_model_name_validated,
|
|
164
|
-
_version_validated,
|
|
165
|
-
only_applicable,
|
|
166
|
-
)
|
|
167
|
-
|
|
168
|
-
def export_file_db(self, db_name, dest, file_name):
|
|
169
|
-
"""
|
|
170
|
-
Get file from the DB and write to disk.
|
|
171
|
-
|
|
172
|
-
Parameters
|
|
173
|
-
----------
|
|
174
|
-
db_name: str
|
|
175
|
-
Name of the DB to search in.
|
|
176
|
-
dest: str or Path
|
|
177
|
-
Location where to write the file to.
|
|
178
|
-
file_name: str
|
|
179
|
-
Name of the file to get.
|
|
180
|
-
|
|
181
|
-
Returns
|
|
182
|
-
-------
|
|
183
|
-
file_id: GridOut._id
|
|
184
|
-
the database ID the file was assigned when it was inserted to the DB.
|
|
185
|
-
|
|
186
|
-
Raises
|
|
187
|
-
------
|
|
188
|
-
FileNotFoundError
|
|
189
|
-
If the desired file is not found.
|
|
190
|
-
|
|
191
|
-
"""
|
|
192
|
-
|
|
193
|
-
self._logger.debug(f"Getting {file_name} from {db_name} and writing it to {dest}")
|
|
194
|
-
file_path_instance = self._get_file_mongo_db(db_name, file_name)
|
|
195
|
-
self._write_file_from_mongo_to_disk(db_name, dest, file_path_instance)
|
|
196
|
-
return file_path_instance._id # pylint: disable=protected-access;
|
|
197
|
-
|
|
198
|
-
def export_model_files(self, parameters, dest):
|
|
199
|
-
"""
|
|
200
|
-
Export all the files in a model from the DB (Mongo or yaml) and write them to disk.
|
|
201
|
-
|
|
202
|
-
Parameters
|
|
203
|
-
----------
|
|
204
|
-
parameters: dict
|
|
205
|
-
Dict of model parameters
|
|
206
|
-
dest: str or Path
|
|
207
|
-
Location where to write the files to.
|
|
208
|
-
|
|
209
|
-
Raises
|
|
210
|
-
------
|
|
211
|
-
FileNotFoundError
|
|
212
|
-
if a file in parameters.values is not found
|
|
213
|
-
|
|
214
|
-
"""
|
|
215
|
-
|
|
216
|
-
if self.mongo_db_config:
|
|
217
|
-
self._logger.debug("Exporting model files from MongoDB")
|
|
218
|
-
for info in parameters.values():
|
|
219
|
-
if not info["File"]:
|
|
220
|
-
continue
|
|
221
|
-
if Path(dest).joinpath(info["Value"]).exists():
|
|
222
|
-
self._logger.debug(f"File {info['Value']} already exists in {dest}")
|
|
223
|
-
continue
|
|
224
|
-
file = self._get_file_mongo_db(
|
|
225
|
-
DatabaseHandler.DB_CTA_SIMULATION_MODEL, info["Value"]
|
|
226
|
-
)
|
|
227
|
-
self._write_file_from_mongo_to_disk(
|
|
228
|
-
DatabaseHandler.DB_CTA_SIMULATION_MODEL, dest, file
|
|
229
|
-
)
|
|
230
|
-
else:
|
|
231
|
-
self._logger.debug("Exporting model files from local model file directories")
|
|
232
|
-
for value in parameters.values():
|
|
233
|
-
if not self._is_file(value):
|
|
234
|
-
continue
|
|
235
|
-
self._write_model_file_yaml(value, dest, no_file_ok=True)
|
|
236
|
-
|
|
237
|
-
@staticmethod
|
|
238
|
-
def _is_file(value):
|
|
239
|
-
"""Verify if a parameter value is a file name."""
|
|
240
|
-
return any(ext in str(value) for ext in DatabaseHandler.ALLOWED_FILE_EXTENSIONS)
|
|
241
|
-
|
|
242
|
-
def _write_model_file_yaml(self, file_name, dest_dir, no_file_ok=False):
|
|
243
|
-
"""
|
|
244
|
-
Find the file_name in the model files location and write a copy
|
|
245
|
-
at the dest_dir directory.
|
|
246
|
-
|
|
247
|
-
Parameters
|
|
248
|
-
----------
|
|
249
|
-
file_name: str or Path
|
|
250
|
-
File name to be found and copied.
|
|
251
|
-
dest_dir: str or Path
|
|
252
|
-
Path of the directory where the file will be written.
|
|
253
|
-
|
|
254
|
-
"""
|
|
255
|
-
|
|
256
|
-
dest_file = Path(dest_dir).joinpath(file_name)
|
|
257
|
-
try:
|
|
258
|
-
file = gen.find_file(file_name, self.io_handler.model_path)
|
|
259
|
-
except FileNotFoundError:
|
|
260
|
-
if no_file_ok:
|
|
261
|
-
self._logger.debug(f"File {file_name} not found but no_file_ok")
|
|
262
|
-
return
|
|
263
|
-
|
|
264
|
-
raise
|
|
265
|
-
|
|
266
|
-
dest_file.write_text(file.read_text(encoding="utf-8"), encoding="utf-8")
|
|
267
|
-
|
|
268
|
-
def _get_model_parameters_yaml(
|
|
269
|
-
self, telescope_model_name, model_version, only_applicable=False
|
|
270
|
-
):
|
|
271
|
-
"""
|
|
272
|
-
Get parameters from DB for one specific type.
|
|
273
|
-
|
|
274
|
-
Parameters
|
|
275
|
-
----------
|
|
276
|
-
telescope_model_name: str
|
|
277
|
-
Telescope model name (e.g MST-FlashCam-D ...).
|
|
278
|
-
model_version: str
|
|
279
|
-
Version of the model.
|
|
280
|
-
only_applicable: bool
|
|
281
|
-
If True, only applicable parameters will be read.
|
|
282
|
-
|
|
283
|
-
Returns
|
|
284
|
-
-------
|
|
285
|
-
dict containing the parameters
|
|
286
|
-
|
|
287
|
-
"""
|
|
288
|
-
|
|
289
|
-
_tel_class = names.get_telescope_class(telescope_model_name)
|
|
290
|
-
_tel_name_converted = names.convert_telescope_model_name_to_yaml_name(telescope_model_name)
|
|
291
|
-
|
|
292
|
-
if _tel_class == "MST":
|
|
293
|
-
# MST-FlashCam or MST-NectarCam
|
|
294
|
-
_which_tel_labels = [_tel_name_converted, "MST-optics"]
|
|
295
|
-
elif _tel_class == "SST":
|
|
296
|
-
# SST = SST-Camera + SST-Structure
|
|
297
|
-
_which_tel_labels = ["SST-Camera", "SST-Structure"]
|
|
298
|
-
else:
|
|
299
|
-
_which_tel_labels = [_tel_name_converted]
|
|
300
|
-
|
|
301
|
-
# Selecting version and applicable (if on)
|
|
302
|
-
_pars = {}
|
|
303
|
-
for _tel in _which_tel_labels:
|
|
304
|
-
_all_pars = self._get_all_model_parameters_yaml(_tel)
|
|
305
|
-
|
|
306
|
-
# If _tel is a structure, only the applicable parameters will be collected, always.
|
|
307
|
-
# The default ones will be covered by the camera parameters.
|
|
308
|
-
_select_only_applicable = only_applicable or (_tel in ["MST-optics", "SST-Structure"])
|
|
309
|
-
|
|
310
|
-
for par_name_in, par_info in _all_pars.items():
|
|
311
|
-
if not par_info["Applicable"] and _select_only_applicable:
|
|
312
|
-
continue
|
|
313
|
-
|
|
314
|
-
if model_version not in par_info:
|
|
315
|
-
continue
|
|
316
|
-
|
|
317
|
-
_pars[par_name_in] = par_info[model_version]
|
|
318
|
-
|
|
319
|
-
return _pars
|
|
320
|
-
|
|
321
|
-
def _get_model_parameters_mongo_db(
|
|
322
|
-
self, db_name, site, telescope_model_name, model_version, only_applicable=False
|
|
323
|
-
):
|
|
324
|
-
"""
|
|
325
|
-
Get parameters from MongoDB for a specific telescope.
|
|
326
|
-
|
|
327
|
-
Parameters
|
|
328
|
-
----------
|
|
329
|
-
db_name: str
|
|
330
|
-
the name of the DB
|
|
331
|
-
site: str
|
|
332
|
-
South or North.
|
|
333
|
-
telescope_model_name: str
|
|
334
|
-
Name of the telescope model (e.g. MST-FlashCam-D ...)
|
|
335
|
-
model_version: str
|
|
336
|
-
Version of the model.
|
|
337
|
-
only_applicable: bool
|
|
338
|
-
If True, only applicable parameters will be read.
|
|
339
|
-
|
|
340
|
-
Returns
|
|
341
|
-
-------
|
|
342
|
-
dict containing the parameters
|
|
343
|
-
|
|
344
|
-
"""
|
|
345
|
-
|
|
346
|
-
_site_validated = names.validate_site_name(site)
|
|
347
|
-
_tel_name_db = self._get_telescope_model_name_for_db(_site_validated, telescope_model_name)
|
|
348
|
-
_tel_class = names.get_telescope_class(telescope_model_name)
|
|
349
|
-
|
|
350
|
-
self._logger.debug(f"Tel_name_db: {_tel_name_db}")
|
|
351
|
-
self._logger.debug(f"Tel_class: {_tel_class}")
|
|
352
|
-
|
|
353
|
-
if _tel_class == "MST":
|
|
354
|
-
# MST-FlashCam or MST-NectarCam
|
|
355
|
-
_which_tel_labels = [f"{_site_validated}-MST-Structure-D", _tel_name_db]
|
|
356
|
-
elif _tel_class == "SST":
|
|
357
|
-
# SST = SST-Camera + SST-Structure
|
|
358
|
-
_which_tel_labels = [
|
|
359
|
-
f"{_site_validated}-SST-Camera-D",
|
|
360
|
-
f"{_site_validated}-SST-Structure-D",
|
|
361
|
-
]
|
|
362
|
-
else:
|
|
363
|
-
_which_tel_labels = [_tel_name_db]
|
|
364
|
-
|
|
365
|
-
# Selecting version and applicable (if on)
|
|
366
|
-
_pars = {}
|
|
367
|
-
for _tel in _which_tel_labels:
|
|
368
|
-
self._logger.debug(f"Getting {_tel} parameters from MongoDB")
|
|
369
|
-
|
|
370
|
-
# If tel is a structure, only applicable pars will be collected, always.
|
|
371
|
-
# The default ones will be covered by the camera pars.
|
|
372
|
-
_select_only_applicable = only_applicable or (
|
|
373
|
-
_tel
|
|
374
|
-
in [
|
|
375
|
-
f"{_site_validated}-MST-Structure-D",
|
|
376
|
-
f"{_site_validated}-SST-Structure-D",
|
|
377
|
-
]
|
|
378
|
-
)
|
|
379
|
-
|
|
380
|
-
_pars.update(
|
|
381
|
-
self.read_mongo_db(
|
|
382
|
-
db_name,
|
|
383
|
-
_tel,
|
|
384
|
-
model_version,
|
|
385
|
-
run_location=None,
|
|
386
|
-
write_files=False,
|
|
387
|
-
only_applicable=_select_only_applicable,
|
|
388
|
-
)
|
|
389
|
-
)
|
|
390
|
-
|
|
391
|
-
return _pars
|
|
392
|
-
|
|
393
|
-
def read_mongo_db(
|
|
394
|
-
self,
|
|
395
|
-
db_name,
|
|
396
|
-
telescope_model_name_db,
|
|
397
|
-
model_version,
|
|
398
|
-
run_location,
|
|
399
|
-
collection_name="telescopes",
|
|
400
|
-
write_files=True,
|
|
401
|
-
only_applicable=False,
|
|
402
|
-
):
|
|
403
|
-
"""
|
|
404
|
-
Build and execute query to Read the MongoDB for a specific telescope.
|
|
405
|
-
Also writes the files listed in the parameter values into the sim_telarray run location
|
|
406
|
-
|
|
407
|
-
Parameters
|
|
408
|
-
----------
|
|
409
|
-
db_name: str
|
|
410
|
-
the name of the DB
|
|
411
|
-
telescope_model_name_db: str
|
|
412
|
-
Name of the telescope model (e.g. MST-FlashCam-D ...)
|
|
413
|
-
model_version: str
|
|
414
|
-
Version of the model.
|
|
415
|
-
run_location: Path or str
|
|
416
|
-
The sim_telarray run location to write the tabulated data files into.
|
|
417
|
-
collection_name: str
|
|
418
|
-
The name of the collection to read from.
|
|
419
|
-
write_files: bool
|
|
420
|
-
If true, write the files to the run_location.
|
|
421
|
-
only_applicable: bool
|
|
422
|
-
If True, only applicable parameters will be read.
|
|
423
|
-
|
|
424
|
-
Returns
|
|
425
|
-
-------
|
|
426
|
-
dict containing the parameters
|
|
427
|
-
|
|
428
|
-
Raises
|
|
429
|
-
------
|
|
430
|
-
ValueError
|
|
431
|
-
if query returned zero results.
|
|
432
|
-
|
|
433
|
-
"""
|
|
434
|
-
|
|
435
|
-
collection = DatabaseHandler.db_client[db_name][collection_name]
|
|
436
|
-
_parameters = {}
|
|
437
|
-
|
|
438
|
-
_model_version = self._convert_version_to_tagged(
|
|
439
|
-
model_version, DatabaseHandler.DB_CTA_SIMULATION_MODEL
|
|
440
|
-
)
|
|
441
|
-
|
|
442
|
-
query = {
|
|
443
|
-
"Telescope": telescope_model_name_db,
|
|
444
|
-
"Version": _model_version,
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
self._logger.debug(f"Trying the following query: {query}")
|
|
448
|
-
if only_applicable:
|
|
449
|
-
query["Applicable"] = True
|
|
450
|
-
if collection.count_documents(query) < 1:
|
|
451
|
-
raise ValueError(
|
|
452
|
-
"The following query returned zero results! Check the input data and rerun.\n",
|
|
453
|
-
query,
|
|
454
|
-
)
|
|
455
|
-
for post in collection.find(query):
|
|
456
|
-
par_now = post["Parameter"]
|
|
457
|
-
_parameters[par_now] = post
|
|
458
|
-
_parameters[par_now].pop("Parameter", None)
|
|
459
|
-
_parameters[par_now].pop("Telescope", None)
|
|
460
|
-
_parameters[par_now]["entry_date"] = ObjectId(post["_id"]).generation_time
|
|
461
|
-
if _parameters[par_now]["File"] and write_files:
|
|
462
|
-
file = self._get_file_mongo_db(db_name, _parameters[par_now]["Value"])
|
|
463
|
-
|
|
464
|
-
self._write_file_from_mongo_to_disk(db_name, run_location, file)
|
|
465
|
-
|
|
466
|
-
return _parameters
|
|
467
|
-
|
|
468
|
-
def _get_all_model_parameters_yaml(self, telescope_name_yaml):
|
|
469
|
-
"""
|
|
470
|
-
Get all parameters from yaml DB for one specific type.
|
|
471
|
-
No selection is applied.
|
|
472
|
-
|
|
473
|
-
Parameters
|
|
474
|
-
----------
|
|
475
|
-
telescope_name_yaml: str
|
|
476
|
-
Telescope name as required by the yaml files.
|
|
477
|
-
|
|
478
|
-
Returns
|
|
479
|
-
-------
|
|
480
|
-
dict containing the parameters
|
|
481
|
-
|
|
482
|
-
"""
|
|
483
|
-
|
|
484
|
-
_file_name_db = f"parValues-{telescope_name_yaml}.yml"
|
|
485
|
-
_yaml_file = gen.find_file(_file_name_db, self.io_handler.model_path)
|
|
486
|
-
self._logger.debug(f"Reading DB file {_yaml_file}")
|
|
487
|
-
with open(_yaml_file, "r", encoding="utf-8") as stream:
|
|
488
|
-
_all_pars = yaml.safe_load(stream)
|
|
489
|
-
return _all_pars
|
|
490
|
-
|
|
491
|
-
def get_site_parameters(
|
|
492
|
-
self,
|
|
493
|
-
site,
|
|
494
|
-
model_version,
|
|
495
|
-
only_applicable=False,
|
|
496
|
-
):
|
|
497
|
-
"""
|
|
498
|
-
Get parameters from either MongoDB or yaml DB for a specific site.
|
|
499
|
-
|
|
500
|
-
Parameters
|
|
501
|
-
----------
|
|
502
|
-
site: str
|
|
503
|
-
South or North.
|
|
504
|
-
model_version: str
|
|
505
|
-
Version of the model.
|
|
506
|
-
only_applicable: bool
|
|
507
|
-
If True, only applicable parameters will be read.
|
|
508
|
-
|
|
509
|
-
Returns
|
|
510
|
-
-------
|
|
511
|
-
dict containing the parameters
|
|
512
|
-
|
|
513
|
-
"""
|
|
514
|
-
_site = names.validate_site_name(site)
|
|
515
|
-
_model_version = names.validate_model_version_name(model_version)
|
|
516
|
-
|
|
517
|
-
if self.mongo_db_config:
|
|
518
|
-
_pars = self._get_site_parameters_mongo_db(
|
|
519
|
-
DatabaseHandler.DB_CTA_SIMULATION_MODEL,
|
|
520
|
-
_site,
|
|
521
|
-
_model_version,
|
|
522
|
-
only_applicable,
|
|
523
|
-
)
|
|
524
|
-
return _pars
|
|
525
|
-
|
|
526
|
-
return self._get_site_parameters_yaml(_site, _model_version, only_applicable)
|
|
527
|
-
|
|
528
|
-
def _get_site_parameters_yaml(self, site, model_version, only_applicable=False):
|
|
529
|
-
"""
|
|
530
|
-
Get parameters from DB for a specific type.
|
|
531
|
-
|
|
532
|
-
Parameters
|
|
533
|
-
----------
|
|
534
|
-
site: str
|
|
535
|
-
North or South.
|
|
536
|
-
model_version: str
|
|
537
|
-
Version of the model.
|
|
538
|
-
only_applicable: bool
|
|
539
|
-
If True, only applicable parameters will be read.
|
|
540
|
-
|
|
541
|
-
Returns
|
|
542
|
-
-------
|
|
543
|
-
dict containing the parameters
|
|
544
|
-
|
|
545
|
-
"""
|
|
546
|
-
|
|
547
|
-
site_yaml = "lapalma" if site == "North" else "paranal"
|
|
548
|
-
|
|
549
|
-
yaml_file = gen.find_file("parValues-Sites.yml", self.io_handler.model_path)
|
|
550
|
-
self._logger.info(f"Reading DB file {yaml_file}")
|
|
551
|
-
with open(yaml_file, "r", encoding="utf-8") as stream:
|
|
552
|
-
_all_pars_versions = yaml.safe_load(stream)
|
|
553
|
-
|
|
554
|
-
_pars = {}
|
|
555
|
-
for par_name, par_info in _all_pars_versions.items():
|
|
556
|
-
if not par_info["Applicable"] and only_applicable:
|
|
557
|
-
continue
|
|
558
|
-
if site_yaml in par_name:
|
|
559
|
-
par_name_in = "_".join(par_name.split("_")[1:])
|
|
560
|
-
|
|
561
|
-
_pars[par_name_in] = par_info[model_version]
|
|
562
|
-
|
|
563
|
-
return _pars
|
|
564
|
-
|
|
565
|
-
def _get_site_parameters_mongo_db(self, db_name, site, model_version, only_applicable=False):
|
|
566
|
-
"""
|
|
567
|
-
Get parameters from MongoDB for a specific telescope.
|
|
568
|
-
|
|
569
|
-
Parameters
|
|
570
|
-
----------
|
|
571
|
-
db_name: str
|
|
572
|
-
The name of the DB.
|
|
573
|
-
site: str
|
|
574
|
-
South or North.
|
|
575
|
-
model_version: str
|
|
576
|
-
Version of the model.
|
|
577
|
-
only_applicable: bool
|
|
578
|
-
If True, only applicable parameters will be read.
|
|
579
|
-
|
|
580
|
-
Returns
|
|
581
|
-
-------
|
|
582
|
-
dict containing the parameters
|
|
583
|
-
|
|
584
|
-
Raises
|
|
585
|
-
------
|
|
586
|
-
ValueError
|
|
587
|
-
if query returned zero results.
|
|
588
|
-
|
|
589
|
-
"""
|
|
590
|
-
|
|
591
|
-
_site_validated = names.validate_site_name(site)
|
|
592
|
-
collection = DatabaseHandler.db_client[db_name].sites
|
|
593
|
-
_parameters = {}
|
|
594
|
-
|
|
595
|
-
_model_version = self._convert_version_to_tagged(
|
|
596
|
-
model_version, DatabaseHandler.DB_CTA_SIMULATION_MODEL
|
|
597
|
-
)
|
|
598
|
-
|
|
599
|
-
query = {
|
|
600
|
-
"Site": _site_validated,
|
|
601
|
-
"Version": _model_version,
|
|
602
|
-
}
|
|
603
|
-
if only_applicable:
|
|
604
|
-
query["Applicable"] = True
|
|
605
|
-
if collection.count_documents(query) < 1:
|
|
606
|
-
raise ValueError(
|
|
607
|
-
"The following query returned zero results! Check the input data and rerun.\n",
|
|
608
|
-
query,
|
|
609
|
-
)
|
|
610
|
-
for post in collection.find(query):
|
|
611
|
-
par_now = post["Parameter"]
|
|
612
|
-
_parameters[par_now] = post
|
|
613
|
-
_parameters[par_now].pop("Parameter", None)
|
|
614
|
-
_parameters[par_now].pop("Site", None)
|
|
615
|
-
_parameters[par_now]["entry_date"] = ObjectId(post["_id"]).generation_time
|
|
616
|
-
|
|
617
|
-
return _parameters
|
|
618
|
-
|
|
619
|
-
@staticmethod
|
|
620
|
-
def get_descriptions(
|
|
621
|
-
db_name=DB_CTA_SIMULATION_MODEL_DESCRIPTIONS, collection_name="telescopes"
|
|
622
|
-
):
|
|
623
|
-
"""
|
|
624
|
-
Get parameter descriptions from MongoDB
|
|
625
|
-
|
|
626
|
-
Parameters
|
|
627
|
-
----------
|
|
628
|
-
db_name: str
|
|
629
|
-
The name of the DB.
|
|
630
|
-
collection_name: str
|
|
631
|
-
The name of the collection to read from.
|
|
632
|
-
|
|
633
|
-
Returns
|
|
634
|
-
-------
|
|
635
|
-
dict containing the parameters with their descriptions
|
|
636
|
-
|
|
637
|
-
"""
|
|
638
|
-
|
|
639
|
-
collection = DatabaseHandler.db_client[db_name][collection_name]
|
|
640
|
-
|
|
641
|
-
_parameters = {}
|
|
642
|
-
|
|
643
|
-
empty_query = {}
|
|
644
|
-
for post in collection.find(empty_query):
|
|
645
|
-
par_now = post["Parameter"]
|
|
646
|
-
_parameters[par_now] = post
|
|
647
|
-
_parameters[par_now].pop("Parameter", None)
|
|
648
|
-
_parameters[par_now]["entry_date"] = ObjectId(post["_id"]).generation_time
|
|
649
|
-
|
|
650
|
-
return _parameters
|
|
651
|
-
|
|
652
|
-
def get_reference_data(self, site, model_version, only_applicable=False):
|
|
653
|
-
"""
|
|
654
|
-
Get parameters from MongoDB for a specific telescope.
|
|
655
|
-
|
|
656
|
-
Parameters
|
|
657
|
-
----------
|
|
658
|
-
site: str
|
|
659
|
-
South or North.
|
|
660
|
-
model_version: str
|
|
661
|
-
Version of the model.
|
|
662
|
-
only_applicable: bool
|
|
663
|
-
If True, only applicable parameters will be read.
|
|
664
|
-
|
|
665
|
-
Returns
|
|
666
|
-
-------
|
|
667
|
-
dict containing the parameters
|
|
668
|
-
|
|
669
|
-
Raises
|
|
670
|
-
------
|
|
671
|
-
ValueError
|
|
672
|
-
if query returned zero results.
|
|
673
|
-
|
|
674
|
-
"""
|
|
675
|
-
|
|
676
|
-
_site_validated = names.validate_site_name(site)
|
|
677
|
-
collection = DatabaseHandler.db_client[DatabaseHandler.DB_REFERENCE_DATA].reference_values
|
|
678
|
-
_parameters = {}
|
|
679
|
-
|
|
680
|
-
_model_version = self._convert_version_to_tagged(
|
|
681
|
-
names.validate_model_version_name(model_version),
|
|
682
|
-
DatabaseHandler.DB_CTA_SIMULATION_MODEL,
|
|
683
|
-
)
|
|
684
|
-
|
|
685
|
-
query = {
|
|
686
|
-
"Site": _site_validated,
|
|
687
|
-
"Version": _model_version,
|
|
688
|
-
}
|
|
689
|
-
if only_applicable:
|
|
690
|
-
query["Applicable"] = True
|
|
691
|
-
if collection.count_documents(query) < 1:
|
|
692
|
-
raise ValueError(
|
|
693
|
-
"The following query returned zero results! Check the input data and rerun.\n",
|
|
694
|
-
query,
|
|
695
|
-
)
|
|
696
|
-
for post in collection.find(query):
|
|
697
|
-
par_now = post["Parameter"]
|
|
698
|
-
_parameters[par_now] = post
|
|
699
|
-
_parameters[par_now].pop("Parameter", None)
|
|
700
|
-
_parameters[par_now].pop("Site", None)
|
|
701
|
-
_parameters[par_now]["entry_date"] = ObjectId(post["_id"]).generation_time
|
|
702
|
-
|
|
703
|
-
return _parameters
|
|
704
|
-
|
|
705
|
-
def get_derived_values(self, site, telescope_model_name, model_version):
|
|
706
|
-
"""
|
|
707
|
-
Get a derived value from the DB for a specific telescope.
|
|
708
|
-
|
|
709
|
-
Parameters
|
|
710
|
-
----------
|
|
711
|
-
site: str
|
|
712
|
-
South or North.
|
|
713
|
-
telescope_model_name: str
|
|
714
|
-
Name of the telescope model (e.g. MST-FlashCam-D ...)
|
|
715
|
-
model_version: str
|
|
716
|
-
Version of the model.
|
|
717
|
-
|
|
718
|
-
Returns
|
|
719
|
-
-------
|
|
720
|
-
dict containing the parameters
|
|
721
|
-
|
|
722
|
-
"""
|
|
723
|
-
|
|
724
|
-
_site_validated = names.validate_site_name(site)
|
|
725
|
-
_tel_model_name_validated = names.validate_telescope_model_name(telescope_model_name)
|
|
726
|
-
_tel_name_db = self._get_telescope_model_name_for_db(
|
|
727
|
-
_site_validated, _tel_model_name_validated
|
|
728
|
-
)
|
|
729
|
-
_model_version = self._convert_version_to_tagged(
|
|
730
|
-
names.validate_model_version_name(model_version),
|
|
731
|
-
DatabaseHandler.DB_CTA_SIMULATION_MODEL,
|
|
732
|
-
)
|
|
733
|
-
|
|
734
|
-
self._logger.debug(f"Getting derived values for {_tel_name_db} from the DB")
|
|
735
|
-
|
|
736
|
-
_pars = self.read_mongo_db(
|
|
737
|
-
DatabaseHandler.DB_DERIVED_VALUES,
|
|
738
|
-
_tel_name_db,
|
|
739
|
-
_model_version,
|
|
740
|
-
run_location=None,
|
|
741
|
-
collection_name="derived_values",
|
|
742
|
-
write_files=False,
|
|
743
|
-
)
|
|
744
|
-
|
|
745
|
-
return _pars
|
|
746
|
-
|
|
747
|
-
@staticmethod
|
|
748
|
-
def _get_file_mongo_db(db_name, file_name):
|
|
749
|
-
"""
|
|
750
|
-
Extract a file from MongoDB and return GridFS file instance
|
|
751
|
-
|
|
752
|
-
Parameters
|
|
753
|
-
----------
|
|
754
|
-
db_name: str
|
|
755
|
-
the name of the DB with files of tabulated data
|
|
756
|
-
file_name: str
|
|
757
|
-
The name of the file requested
|
|
758
|
-
|
|
759
|
-
Returns
|
|
760
|
-
-------
|
|
761
|
-
GridOut
|
|
762
|
-
A file instance returned by GridFS find_one
|
|
763
|
-
|
|
764
|
-
Raises
|
|
765
|
-
------
|
|
766
|
-
FileNotFoundError
|
|
767
|
-
If the desired file is not found.
|
|
768
|
-
|
|
769
|
-
"""
|
|
770
|
-
|
|
771
|
-
db = DatabaseHandler.db_client[db_name]
|
|
772
|
-
file_system = gridfs.GridFS(db)
|
|
773
|
-
if file_system.exists({"filename": file_name}):
|
|
774
|
-
return file_system.find_one({"filename": file_name})
|
|
775
|
-
|
|
776
|
-
raise FileNotFoundError(f"The file {file_name} does not exist in the database {db_name}")
|
|
777
|
-
|
|
778
|
-
@staticmethod
|
|
779
|
-
def _write_file_from_mongo_to_disk(db_name, path, file):
|
|
780
|
-
"""
|
|
781
|
-
Extract a file from MongoDB and write it to disk
|
|
782
|
-
|
|
783
|
-
Parameters
|
|
784
|
-
----------
|
|
785
|
-
db_name: str
|
|
786
|
-
the name of the DB with files of tabulated data
|
|
787
|
-
path: str or Path
|
|
788
|
-
The path to write the file to
|
|
789
|
-
file: GridOut
|
|
790
|
-
A file instance returned by GridFS find_one
|
|
791
|
-
"""
|
|
792
|
-
|
|
793
|
-
db = DatabaseHandler.db_client[db_name]
|
|
794
|
-
fs_output = gridfs.GridFSBucket(db)
|
|
795
|
-
with open(Path(path).joinpath(file.filename), "wb") as output_file:
|
|
796
|
-
fs_output.download_to_stream_by_name(file.filename, output_file)
|
|
797
|
-
|
|
798
|
-
def copy_telescope(
|
|
799
|
-
self,
|
|
800
|
-
db_name,
|
|
801
|
-
tel_to_copy,
|
|
802
|
-
version_to_copy,
|
|
803
|
-
new_tel_name,
|
|
804
|
-
collection_name="telescopes",
|
|
805
|
-
db_to_copy_to=None,
|
|
806
|
-
collection_to_copy_to=None,
|
|
807
|
-
):
|
|
808
|
-
"""
|
|
809
|
-
Copy a full telescope configuration to a new telescope name.
|
|
810
|
-
Only a specific version is copied.
|
|
811
|
-
(This function should be rarely used, probably only during "construction".)
|
|
812
|
-
|
|
813
|
-
Parameters
|
|
814
|
-
----------
|
|
815
|
-
db_name: str
|
|
816
|
-
the name of the DB to copy from
|
|
817
|
-
tel_to_copy: str
|
|
818
|
-
The telescope to copy
|
|
819
|
-
version_to_copy: str
|
|
820
|
-
The version of the configuration to copy
|
|
821
|
-
new_tel_name: str
|
|
822
|
-
The name of the new telescope
|
|
823
|
-
collection_name: str
|
|
824
|
-
The name of the collection to copy from.
|
|
825
|
-
db_to_copy_to: str
|
|
826
|
-
The name of the DB to copy to.
|
|
827
|
-
collection_to_copy_to: str
|
|
828
|
-
The name of the collection to copy to.
|
|
829
|
-
|
|
830
|
-
Raises
|
|
831
|
-
------
|
|
832
|
-
BulkWriteError
|
|
833
|
-
|
|
834
|
-
"""
|
|
835
|
-
|
|
836
|
-
if db_to_copy_to is None:
|
|
837
|
-
db_to_copy_to = db_name
|
|
838
|
-
|
|
839
|
-
if collection_to_copy_to is None:
|
|
840
|
-
collection_to_copy_to = collection_name
|
|
841
|
-
|
|
842
|
-
self._logger.info(
|
|
843
|
-
f"Copying version {version_to_copy} of {tel_to_copy} "
|
|
844
|
-
f"to the new telescope {new_tel_name} in the {db_to_copy_to} DB"
|
|
845
|
-
)
|
|
846
|
-
|
|
847
|
-
collection = DatabaseHandler.db_client[db_name][collection_name]
|
|
848
|
-
db_entries = []
|
|
849
|
-
|
|
850
|
-
_version_to_copy = self._convert_version_to_tagged(
|
|
851
|
-
version_to_copy, DatabaseHandler.DB_CTA_SIMULATION_MODEL
|
|
852
|
-
)
|
|
853
|
-
|
|
854
|
-
query = {
|
|
855
|
-
"Telescope": tel_to_copy,
|
|
856
|
-
"Version": _version_to_copy,
|
|
857
|
-
}
|
|
858
|
-
for post in collection.find(query):
|
|
859
|
-
post["Telescope"] = new_tel_name
|
|
860
|
-
post.pop("_id", None)
|
|
861
|
-
db_entries.append(post)
|
|
862
|
-
|
|
863
|
-
self._logger.info(f"Creating new telescope {new_tel_name}")
|
|
864
|
-
collection = DatabaseHandler.db_client[db_to_copy_to][collection_to_copy_to]
|
|
865
|
-
try:
|
|
866
|
-
collection.insert_many(db_entries)
|
|
867
|
-
except BulkWriteError as exc:
|
|
868
|
-
raise BulkWriteError(str(exc.details)) from exc
|
|
869
|
-
|
|
870
|
-
def copy_documents(self, db_name, collection, query, db_to_copy_to, collection_to_copy_to=None):
|
|
871
|
-
"""
|
|
872
|
-
Copy the documents matching to "query" to the DB "db_to_copy_to".
|
|
873
|
-
The documents are copied to the same collection as in "db_name".
|
|
874
|
-
(This function should be rarely used, probably only during "construction".)
|
|
875
|
-
|
|
876
|
-
Parameters
|
|
877
|
-
----------
|
|
878
|
-
db_name: str
|
|
879
|
-
the name of the DB to copy from
|
|
880
|
-
collection: str
|
|
881
|
-
the name of the collection to copy from
|
|
882
|
-
query: dict
|
|
883
|
-
A dictionary with a query to search for documents to copy.
|
|
884
|
-
For example, the query below would copy all entries of prod4 version
|
|
885
|
-
from telescope North-LST-1 to "db_to_copy_to".
|
|
886
|
-
|
|
887
|
-
.. code-block:: python
|
|
888
|
-
|
|
889
|
-
query = {
|
|
890
|
-
"Telescope": "North-LST-1",
|
|
891
|
-
"Version": "prod4",
|
|
892
|
-
}
|
|
893
|
-
db_to_copy_to: str
|
|
894
|
-
The name of the DB to copy to.
|
|
895
|
-
|
|
896
|
-
Raises
|
|
897
|
-
------
|
|
898
|
-
BulkWriteError
|
|
899
|
-
|
|
900
|
-
"""
|
|
901
|
-
|
|
902
|
-
_collection = DatabaseHandler.db_client[db_name][collection]
|
|
903
|
-
if collection_to_copy_to is None:
|
|
904
|
-
collection_to_copy_to = collection
|
|
905
|
-
db_entries = []
|
|
906
|
-
|
|
907
|
-
for post in _collection.find(query):
|
|
908
|
-
post.pop("_id", None)
|
|
909
|
-
db_entries.append(post)
|
|
910
|
-
|
|
911
|
-
self._logger.info(
|
|
912
|
-
f"Copying documents matching the following query {query}\nto {db_to_copy_to}"
|
|
913
|
-
)
|
|
914
|
-
_collection = DatabaseHandler.db_client[db_to_copy_to][collection_to_copy_to]
|
|
915
|
-
try:
|
|
916
|
-
_collection.insert_many(db_entries)
|
|
917
|
-
except BulkWriteError as exc:
|
|
918
|
-
raise BulkWriteError(str(exc.details)) from exc
|
|
919
|
-
|
|
920
|
-
def delete_query(self, db_name, collection, query):
|
|
921
|
-
"""
|
|
922
|
-
Delete all entries from the DB which correspond to the provided query.
|
|
923
|
-
(This function should be rarely used, if at all.)
|
|
924
|
-
|
|
925
|
-
Parameters
|
|
926
|
-
----------
|
|
927
|
-
db_name: str
|
|
928
|
-
the name of the DB
|
|
929
|
-
collection: str
|
|
930
|
-
the name of the collection to copy from
|
|
931
|
-
query: dict
|
|
932
|
-
A dictionary listing the fields/values to delete.
|
|
933
|
-
For example, the query below would delete the entire prod5 version
|
|
934
|
-
from telescope North-LST-1.
|
|
935
|
-
|
|
936
|
-
.. code-block:: python
|
|
937
|
-
|
|
938
|
-
query = {
|
|
939
|
-
"Telescope": "North-LST-1",
|
|
940
|
-
"Version": "prod5",
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
"""
|
|
944
|
-
|
|
945
|
-
_collection = DatabaseHandler.db_client[db_name][collection]
|
|
946
|
-
|
|
947
|
-
if "Version" in query:
|
|
948
|
-
query["Version"] = self._convert_version_to_tagged(
|
|
949
|
-
query["Version"], DatabaseHandler.DB_CTA_SIMULATION_MODEL
|
|
950
|
-
)
|
|
951
|
-
|
|
952
|
-
self._logger.info(f"Deleting {_collection.count_documents(query)} entries from {db_name}")
|
|
953
|
-
|
|
954
|
-
_collection.delete_many(query)
|
|
955
|
-
|
|
956
|
-
def update_parameter(
|
|
957
|
-
self,
|
|
958
|
-
db_name,
|
|
959
|
-
telescope,
|
|
960
|
-
version,
|
|
961
|
-
parameter,
|
|
962
|
-
new_value,
|
|
963
|
-
collection_name="telescopes",
|
|
964
|
-
file_prefix=None,
|
|
965
|
-
):
|
|
966
|
-
"""
|
|
967
|
-
Update a parameter value for a specific telescope/version.
|
|
968
|
-
(This function should be rarely used since new values
|
|
969
|
-
should ideally have their own version.)
|
|
970
|
-
|
|
971
|
-
Parameters
|
|
972
|
-
----------
|
|
973
|
-
db_name: str
|
|
974
|
-
the name of the DB
|
|
975
|
-
telescope: str
|
|
976
|
-
Which telescope to update
|
|
977
|
-
version: str
|
|
978
|
-
Which version to update
|
|
979
|
-
parameter: str
|
|
980
|
-
Which parameter to update
|
|
981
|
-
new_value: type identical to the original parameter type
|
|
982
|
-
The new value to set for the parameter
|
|
983
|
-
collection_name: str
|
|
984
|
-
The name of the collection in which to update the parameter.
|
|
985
|
-
file_prefix: str or Path
|
|
986
|
-
where to find files to upload to the DB
|
|
987
|
-
|
|
988
|
-
Raises
|
|
989
|
-
------
|
|
990
|
-
FileNotFoundError
|
|
991
|
-
if file_prefix is None
|
|
992
|
-
|
|
993
|
-
"""
|
|
994
|
-
|
|
995
|
-
collection = DatabaseHandler.db_client[db_name][collection_name]
|
|
996
|
-
|
|
997
|
-
_model_version = self._convert_version_to_tagged(
|
|
998
|
-
version, DatabaseHandler.DB_CTA_SIMULATION_MODEL
|
|
999
|
-
)
|
|
1000
|
-
|
|
1001
|
-
query = {
|
|
1002
|
-
"Telescope": telescope,
|
|
1003
|
-
"Version": _model_version,
|
|
1004
|
-
"Parameter": parameter,
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
par_entry = collection.find_one(query)
|
|
1008
|
-
old_value = par_entry["Value"]
|
|
1009
|
-
|
|
1010
|
-
self._logger.info(
|
|
1011
|
-
f"For telescope {telescope}, version {_model_version}\n"
|
|
1012
|
-
f"replacing {parameter} value from {old_value} to {new_value}"
|
|
1013
|
-
)
|
|
1014
|
-
|
|
1015
|
-
files_to_add_to_db = set()
|
|
1016
|
-
if self._is_file(new_value):
|
|
1017
|
-
file = True
|
|
1018
|
-
if file_prefix is None:
|
|
1019
|
-
raise FileNotFoundError(
|
|
1020
|
-
"The location of the file to upload, "
|
|
1021
|
-
f"corresponding to the {parameter} parameter, must be provided."
|
|
1022
|
-
)
|
|
1023
|
-
file_path = Path(file_prefix).joinpath(new_value)
|
|
1024
|
-
files_to_add_to_db.add(f"{file_path}")
|
|
1025
|
-
self._logger.info(f"Will also add the file {file_path} to the DB")
|
|
1026
|
-
else:
|
|
1027
|
-
file = False
|
|
1028
|
-
|
|
1029
|
-
query_update = {"$set": {"Value": new_value, "File": file}}
|
|
1030
|
-
|
|
1031
|
-
collection.update_one(query, query_update)
|
|
1032
|
-
for file_now in files_to_add_to_db:
|
|
1033
|
-
self.insert_file_to_db(file_now, db_name)
|
|
1034
|
-
|
|
1035
|
-
def update_parameter_field(
|
|
1036
|
-
self,
|
|
1037
|
-
db_name,
|
|
1038
|
-
version,
|
|
1039
|
-
parameter,
|
|
1040
|
-
field,
|
|
1041
|
-
new_value,
|
|
1042
|
-
telescope=None,
|
|
1043
|
-
site=None,
|
|
1044
|
-
collection_name="telescopes",
|
|
1045
|
-
):
|
|
1046
|
-
"""
|
|
1047
|
-
Update a parameter field value for a specific telescope/version.
|
|
1048
|
-
This function only modifies the value of one of the following
|
|
1049
|
-
DB entries: Applicable, units, Type, items, minimum, maximum.
|
|
1050
|
-
These type of changes should be very rare. However they can
|
|
1051
|
-
be done without changing the Object ID of the entry since
|
|
1052
|
-
they are generally "harmless".
|
|
1053
|
-
|
|
1054
|
-
Parameters
|
|
1055
|
-
----------
|
|
1056
|
-
db_name: str
|
|
1057
|
-
the name of the DB
|
|
1058
|
-
version: str
|
|
1059
|
-
Which version to update
|
|
1060
|
-
parameter: str
|
|
1061
|
-
Which parameter to update
|
|
1062
|
-
field: str
|
|
1063
|
-
Field to update (only options are Applicable, units, Type, items, minimum, maximum).
|
|
1064
|
-
If the field does not exist, it will be added.
|
|
1065
|
-
new_value: type identical to the original field type
|
|
1066
|
-
The new value to set to the field given in "field".
|
|
1067
|
-
telescope: str
|
|
1068
|
-
Which telescope to update, if None then update a site parameter
|
|
1069
|
-
site: str, North or South
|
|
1070
|
-
Update a site parameter (the telescope argument must be None)
|
|
1071
|
-
collection_name: str
|
|
1072
|
-
The name of the collection in which to update the parameter.
|
|
1073
|
-
|
|
1074
|
-
Raises
|
|
1075
|
-
------
|
|
1076
|
-
ValueError
|
|
1077
|
-
if field not in allowed fields
|
|
1078
|
-
|
|
1079
|
-
"""
|
|
1080
|
-
|
|
1081
|
-
allowed_fields = ["Applicable", "units", "Type", "items", "minimum", "maximum"]
|
|
1082
|
-
if field not in allowed_fields:
|
|
1083
|
-
raise ValueError(f"The field to change must be one of {', '.join(allowed_fields)}")
|
|
1084
|
-
|
|
1085
|
-
collection = DatabaseHandler.db_client[db_name][collection_name]
|
|
1086
|
-
|
|
1087
|
-
_model_version = self._convert_version_to_tagged(
|
|
1088
|
-
version, DatabaseHandler.DB_CTA_SIMULATION_MODEL
|
|
1089
|
-
)
|
|
1090
|
-
|
|
1091
|
-
query = {
|
|
1092
|
-
"Version": _model_version,
|
|
1093
|
-
"Parameter": parameter,
|
|
1094
|
-
}
|
|
1095
|
-
if telescope is not None:
|
|
1096
|
-
query["Telescope"] = telescope
|
|
1097
|
-
logger_info = f"telescope {telescope}"
|
|
1098
|
-
elif site is not None and site in ["North", "South"]:
|
|
1099
|
-
query["Site"] = site
|
|
1100
|
-
logger_info = f"site {site}"
|
|
1101
|
-
else:
|
|
1102
|
-
raise ValueError("You need to specifiy if to update a telescope or a site.")
|
|
1103
|
-
|
|
1104
|
-
par_entry = collection.find_one(query)
|
|
1105
|
-
if par_entry is None:
|
|
1106
|
-
self._logger.warning(
|
|
1107
|
-
f"The query {query} did not return any results. I will not make any changes."
|
|
1108
|
-
)
|
|
1109
|
-
return
|
|
1110
|
-
|
|
1111
|
-
if field in par_entry:
|
|
1112
|
-
old_field_value = par_entry[field]
|
|
1113
|
-
|
|
1114
|
-
if old_field_value == new_value:
|
|
1115
|
-
self._logger.warning(
|
|
1116
|
-
f"The value of the field {field} is already {new_value}. No changes necessary"
|
|
1117
|
-
)
|
|
1118
|
-
return
|
|
1119
|
-
|
|
1120
|
-
self._logger.info(
|
|
1121
|
-
f"For {logger_info}, version {_model_version}, parameter {parameter}, "
|
|
1122
|
-
f"replacing field {field} value from {old_field_value} to {new_value}"
|
|
1123
|
-
)
|
|
1124
|
-
else:
|
|
1125
|
-
self._logger.info(
|
|
1126
|
-
f"For {logger_info}, version {_model_version}, parameter {parameter}, "
|
|
1127
|
-
f"the field {field} does not exist, adding it"
|
|
1128
|
-
)
|
|
1129
|
-
|
|
1130
|
-
query_update = {"$set": {field: new_value}}
|
|
1131
|
-
|
|
1132
|
-
collection.update_one(query, query_update)
|
|
1133
|
-
|
|
1134
|
-
def add_parameter(
|
|
1135
|
-
self,
|
|
1136
|
-
db_name,
|
|
1137
|
-
telescope,
|
|
1138
|
-
parameter,
|
|
1139
|
-
new_version,
|
|
1140
|
-
new_value,
|
|
1141
|
-
collection_name="telescopes",
|
|
1142
|
-
file_prefix=None,
|
|
1143
|
-
):
|
|
1144
|
-
"""
|
|
1145
|
-
Add a parameter value for a specific telescope.
|
|
1146
|
-
A new document will be added to the DB,
|
|
1147
|
-
with all fields taken from the last entry of this parameter to this telescope,
|
|
1148
|
-
except the ones changed.
|
|
1149
|
-
|
|
1150
|
-
Parameters
|
|
1151
|
-
----------
|
|
1152
|
-
db_name: str
|
|
1153
|
-
the name of the DB
|
|
1154
|
-
telescope: str
|
|
1155
|
-
Which telescope to update
|
|
1156
|
-
parameter: str
|
|
1157
|
-
Which parameter to add
|
|
1158
|
-
new_version: str
|
|
1159
|
-
The version of the new parameter value
|
|
1160
|
-
new_value: type identical to the original parameter type
|
|
1161
|
-
The new value to set for the parameter
|
|
1162
|
-
collection_name: str
|
|
1163
|
-
The name of the collection to which to add a parameter.
|
|
1164
|
-
file_prefix: str or Path
|
|
1165
|
-
where to find files to upload to the DB
|
|
1166
|
-
|
|
1167
|
-
Raises
|
|
1168
|
-
------
|
|
1169
|
-
FileNotFoundError
|
|
1170
|
-
if file_prefix is None
|
|
1171
|
-
|
|
1172
|
-
"""
|
|
1173
|
-
|
|
1174
|
-
collection = DatabaseHandler.db_client[db_name][collection_name]
|
|
1175
|
-
|
|
1176
|
-
_new_version = self._convert_version_to_tagged(
|
|
1177
|
-
new_version, DatabaseHandler.DB_CTA_SIMULATION_MODEL
|
|
1178
|
-
)
|
|
1179
|
-
|
|
1180
|
-
query = {
|
|
1181
|
-
"Telescope": telescope,
|
|
1182
|
-
"Parameter": parameter,
|
|
1183
|
-
}
|
|
1184
|
-
|
|
1185
|
-
par_entry = collection.find(query).sort("_id", pymongo.DESCENDING)[0]
|
|
1186
|
-
par_entry["Value"] = new_value
|
|
1187
|
-
par_entry["Version"] = _new_version
|
|
1188
|
-
par_entry.pop("_id", None)
|
|
1189
|
-
|
|
1190
|
-
files_to_add_to_db = set()
|
|
1191
|
-
if self._is_file(new_value):
|
|
1192
|
-
par_entry["File"] = True
|
|
1193
|
-
if file_prefix is None:
|
|
1194
|
-
raise FileNotFoundError(
|
|
1195
|
-
"The location of the file to upload, "
|
|
1196
|
-
f"corresponding to the {parameter} parameter, must be provided."
|
|
1197
|
-
)
|
|
1198
|
-
file_path = Path(file_prefix).joinpath(new_value)
|
|
1199
|
-
files_to_add_to_db.add(f"{file_path}")
|
|
1200
|
-
else:
|
|
1201
|
-
par_entry["File"] = False
|
|
1202
|
-
|
|
1203
|
-
self._logger.info(f"Will add the following entry to DB:\n{par_entry}")
|
|
1204
|
-
|
|
1205
|
-
collection.insert_one(par_entry)
|
|
1206
|
-
if len(files_to_add_to_db) > 0:
|
|
1207
|
-
self._logger.info(f"Will also add the file {file_path} to the DB")
|
|
1208
|
-
self.insert_file_to_db(files_to_add_to_db, db_name)
|
|
1209
|
-
|
|
1210
|
-
def add_new_parameter(
|
|
1211
|
-
self,
|
|
1212
|
-
db_name,
|
|
1213
|
-
version,
|
|
1214
|
-
parameter,
|
|
1215
|
-
value,
|
|
1216
|
-
telescope=None,
|
|
1217
|
-
site=None,
|
|
1218
|
-
collection_name="telescopes",
|
|
1219
|
-
file_prefix=None,
|
|
1220
|
-
**kwargs,
|
|
1221
|
-
):
|
|
1222
|
-
"""
|
|
1223
|
-
Add a parameter value for a specific telescope.
|
|
1224
|
-
A new document will be added to the DB,
|
|
1225
|
-
with all fields taken from the input parameters.
|
|
1226
|
-
|
|
1227
|
-
Parameters
|
|
1228
|
-
----------
|
|
1229
|
-
db_name: str
|
|
1230
|
-
the name of the DB
|
|
1231
|
-
version: str
|
|
1232
|
-
The version of the new parameter value
|
|
1233
|
-
parameter: str
|
|
1234
|
-
Which parameter to add
|
|
1235
|
-
value: can be any type, preferably given in kwargs
|
|
1236
|
-
The value to set for the new parameter
|
|
1237
|
-
telescope: str
|
|
1238
|
-
The name of the telescope to add a parameter to
|
|
1239
|
-
(only used if collection_name is "telescopes").
|
|
1240
|
-
site: str
|
|
1241
|
-
South or North, ignored if collection_name is "telescopes".
|
|
1242
|
-
collection_name: str
|
|
1243
|
-
The name of the collection to add a parameter to.
|
|
1244
|
-
file_prefix: str or Path
|
|
1245
|
-
where to find files to upload to the DB
|
|
1246
|
-
kwargs: dict
|
|
1247
|
-
Any additional fields to add to the parameter
|
|
1248
|
-
|
|
1249
|
-
Raises
|
|
1250
|
-
------
|
|
1251
|
-
ValueError
|
|
1252
|
-
If key to collection_name is not valid. Valid entries are: 'telescopes' and 'sites'.
|
|
1253
|
-
|
|
1254
|
-
"""
|
|
1255
|
-
|
|
1256
|
-
collection = DatabaseHandler.db_client[db_name][collection_name]
|
|
1257
|
-
|
|
1258
|
-
db_entry = {}
|
|
1259
|
-
if "telescopes" in collection_name:
|
|
1260
|
-
db_entry["Telescope"] = names.validate_telescope_name_db(telescope)
|
|
1261
|
-
elif "sites" in collection_name:
|
|
1262
|
-
db_entry["Site"] = names.validate_site_name(site)
|
|
1263
|
-
else:
|
|
1264
|
-
raise ValueError("Can only add new parameters to the sites or telescopes collections")
|
|
1265
|
-
|
|
1266
|
-
db_entry["Version"] = version
|
|
1267
|
-
db_entry["Parameter"] = parameter
|
|
1268
|
-
|
|
1269
|
-
_base_value, _base_unit, _base_type = gen.get_value_unit_type(value)
|
|
1270
|
-
db_entry["Value"] = _base_value
|
|
1271
|
-
if _base_unit is not None:
|
|
1272
|
-
db_entry["units"] = _base_unit
|
|
1273
|
-
db_entry["Type"] = kwargs["Type"] if "Type" in kwargs else _base_type
|
|
1274
|
-
|
|
1275
|
-
files_to_add_to_db = set()
|
|
1276
|
-
db_entry["File"] = False
|
|
1277
|
-
if self._is_file(value):
|
|
1278
|
-
db_entry["File"] = True
|
|
1279
|
-
if file_prefix is None:
|
|
1280
|
-
raise FileNotFoundError(
|
|
1281
|
-
"The location of the file to upload, "
|
|
1282
|
-
f"corresponding to the {parameter} parameter, must be provided."
|
|
1283
|
-
)
|
|
1284
|
-
file_path = Path(file_prefix).joinpath(value)
|
|
1285
|
-
files_to_add_to_db.add(f"{file_path}")
|
|
1286
|
-
|
|
1287
|
-
kwargs.pop("Type", None)
|
|
1288
|
-
db_entry.update(kwargs)
|
|
1289
|
-
|
|
1290
|
-
self._logger.info(f"Will add the following entry to DB:\n{db_entry}")
|
|
1291
|
-
|
|
1292
|
-
collection.insert_one(db_entry)
|
|
1293
|
-
for file_to_insert_now in files_to_add_to_db:
|
|
1294
|
-
self._logger.info(f"Will also add the file {file_to_insert_now} to the DB")
|
|
1295
|
-
self.insert_file_to_db(file_to_insert_now, db_name)
|
|
1296
|
-
|
|
1297
|
-
def _convert_version_to_tagged(self, model_version, db_name):
|
|
1298
|
-
"""Convert to tagged version, if needed."""
|
|
1299
|
-
if model_version in ["Released", "Latest"]:
|
|
1300
|
-
return self._get_tagged_version(db_name, model_version)
|
|
1301
|
-
|
|
1302
|
-
return model_version
|
|
1303
|
-
|
|
1304
|
-
@staticmethod
|
|
1305
|
-
def _get_tagged_version(db_name, version="Released"):
|
|
1306
|
-
"""
|
|
1307
|
-
Get the tag of the "Released" or "Latest" version of the MC Model.
|
|
1308
|
-
The "Released" is the latest stable MC Model,
|
|
1309
|
-
the latest is the latest tag (not necessarily stable, but can be equivalent to "Released").
|
|
1310
|
-
|
|
1311
|
-
Parameters
|
|
1312
|
-
----------
|
|
1313
|
-
db_name: str
|
|
1314
|
-
the name of the DB
|
|
1315
|
-
version: str
|
|
1316
|
-
Can be "Released" or "Latest" (default: "Released").
|
|
1317
|
-
|
|
1318
|
-
Returns
|
|
1319
|
-
-------
|
|
1320
|
-
str
|
|
1321
|
-
The version name in the Simulation DB of the requested tag
|
|
1322
|
-
|
|
1323
|
-
Raises
|
|
1324
|
-
------
|
|
1325
|
-
ValueError
|
|
1326
|
-
if version not valid. Valid versions are: 'Released' and 'Latest'.
|
|
1327
|
-
|
|
1328
|
-
"""
|
|
1329
|
-
|
|
1330
|
-
if version not in ["Released", "Latest"]:
|
|
1331
|
-
raise ValueError('The only default versions are "Released" or "Latest"')
|
|
1332
|
-
|
|
1333
|
-
collection = DatabaseHandler.db_client[db_name].metadata
|
|
1334
|
-
query = {"Entry": "Simulation-Model-Tags"}
|
|
1335
|
-
|
|
1336
|
-
tags = collection.find(query).sort("_id", pymongo.DESCENDING)[0]
|
|
1337
|
-
|
|
1338
|
-
return tags["Tags"][version]["Value"]
|
|
1339
|
-
|
|
1340
|
-
def insert_file_to_db(self, file_name, db_name=DB_CTA_SIMULATION_MODEL, **kwargs):
|
|
1341
|
-
"""
|
|
1342
|
-
Insert a file to the DB.
|
|
1343
|
-
|
|
1344
|
-
Parameters
|
|
1345
|
-
----------
|
|
1346
|
-
file_name: str or Path
|
|
1347
|
-
The name of the file to insert (full path).
|
|
1348
|
-
db_name: str
|
|
1349
|
-
the name of the DB
|
|
1350
|
-
**kwargs (optional): keyword arguments for file creation.
|
|
1351
|
-
The full list of arguments can be found in, \
|
|
1352
|
-
https://docs.mongodb.com/manual/core/gridfs/#the-files-collection
|
|
1353
|
-
mostly these are unnecessary though.
|
|
1354
|
-
|
|
1355
|
-
Returns
|
|
1356
|
-
-------
|
|
1357
|
-
file_iD: GridOut._id
|
|
1358
|
-
If the file exists, return its GridOut._id, otherwise insert the file and return its"
|
|
1359
|
-
"newly created DB GridOut._id.
|
|
1360
|
-
|
|
1361
|
-
"""
|
|
1362
|
-
|
|
1363
|
-
db = DatabaseHandler.db_client[db_name]
|
|
1364
|
-
file_system = gridfs.GridFS(db)
|
|
1365
|
-
|
|
1366
|
-
if "content_type" not in kwargs:
|
|
1367
|
-
kwargs["content_type"] = "ascii/dat"
|
|
1368
|
-
|
|
1369
|
-
if "filename" not in kwargs:
|
|
1370
|
-
kwargs["filename"] = Path(file_name).name
|
|
1371
|
-
|
|
1372
|
-
if file_system.exists({"filename": kwargs["filename"]}):
|
|
1373
|
-
self._logger.warning(
|
|
1374
|
-
f"The file {kwargs['filename']} exists in the DB. Returning its ID"
|
|
1375
|
-
)
|
|
1376
|
-
return file_system.find_one( # pylint: disable=protected-access
|
|
1377
|
-
{"filename": kwargs["filename"]}
|
|
1378
|
-
)._id
|
|
1379
|
-
with open(file_name, "rb") as data_file:
|
|
1380
|
-
return file_system.put(data_file, **kwargs)
|
|
1381
|
-
|
|
1382
|
-
def get_all_versions(
|
|
1383
|
-
self,
|
|
1384
|
-
db_name,
|
|
1385
|
-
parameter,
|
|
1386
|
-
telescope_model_name=None,
|
|
1387
|
-
site=None,
|
|
1388
|
-
collection_name="telescopes",
|
|
1389
|
-
):
|
|
1390
|
-
"""
|
|
1391
|
-
Get all version entries in the DB of a telescope or site for a specific parameter.
|
|
1392
|
-
|
|
1393
|
-
Parameters
|
|
1394
|
-
----------
|
|
1395
|
-
db_name: str
|
|
1396
|
-
the name of the DB
|
|
1397
|
-
parameter: str
|
|
1398
|
-
Which parameter to get the versions of
|
|
1399
|
-
telescope_model_name: str
|
|
1400
|
-
Which telescope to get the versions of (in case "collection_name" is "telescopes")
|
|
1401
|
-
site: str, North or South
|
|
1402
|
-
In case "collection_name" is "telescopes", the site is used to build the telescope name.
|
|
1403
|
-
In case "collection_name" is "sites",
|
|
1404
|
-
this argument sets which site parameter get the versions of
|
|
1405
|
-
collection_name: str
|
|
1406
|
-
The name of the collection in which to update the parameter.
|
|
1407
|
-
|
|
1408
|
-
Returns
|
|
1409
|
-
-------
|
|
1410
|
-
all_versions: list
|
|
1411
|
-
List of all versions found
|
|
1412
|
-
|
|
1413
|
-
Raises
|
|
1414
|
-
------
|
|
1415
|
-
ValueError
|
|
1416
|
-
If key to collection_name is not valid. Valid entries are: 'telescopes' and 'sites'.
|
|
1417
|
-
|
|
1418
|
-
"""
|
|
1419
|
-
|
|
1420
|
-
collection = DatabaseHandler.db_client[db_name][collection_name]
|
|
1421
|
-
|
|
1422
|
-
query = {
|
|
1423
|
-
"Parameter": parameter,
|
|
1424
|
-
}
|
|
1425
|
-
|
|
1426
|
-
_site_validated = names.validate_site_name(site)
|
|
1427
|
-
if collection_name == "telescopes":
|
|
1428
|
-
_tel_model_name_validated = names.validate_telescope_model_name(telescope_model_name)
|
|
1429
|
-
_tel_name_db = self._get_telescope_model_name_for_db(
|
|
1430
|
-
_site_validated, _tel_model_name_validated
|
|
1431
|
-
)
|
|
1432
|
-
query["Telescope"] = _tel_name_db
|
|
1433
|
-
elif collection_name == "sites":
|
|
1434
|
-
query["Site"] = _site_validated
|
|
1435
|
-
else:
|
|
1436
|
-
raise ValueError("Can only get versions of the telescopes and sites collections.")
|
|
1437
|
-
|
|
1438
|
-
_all_versions = [post["Version"] for post in collection.find(query)]
|
|
1439
|
-
|
|
1440
|
-
if len(_all_versions) == 0:
|
|
1441
|
-
self._logger.warning(f"The query {query} did not return any results. No versions found")
|
|
1442
|
-
|
|
1443
|
-
return _all_versions
|
|
1444
|
-
|
|
1445
|
-
def get_all_available_telescopes(
|
|
1446
|
-
self,
|
|
1447
|
-
db_name=DB_CTA_SIMULATION_MODEL,
|
|
1448
|
-
model_version="Released",
|
|
1449
|
-
):
|
|
1450
|
-
"""
|
|
1451
|
-
Get all available telescope names in the collection "telescopes" in the DB.
|
|
1452
|
-
|
|
1453
|
-
Parameters
|
|
1454
|
-
----------
|
|
1455
|
-
db_name: str
|
|
1456
|
-
the name of the DB
|
|
1457
|
-
model_version: str
|
|
1458
|
-
Which version to get the telescopes of (default: "Released").
|
|
1459
|
-
|
|
1460
|
-
Returns
|
|
1461
|
-
-------
|
|
1462
|
-
all_available_telescopes: list
|
|
1463
|
-
List of all telescope names found
|
|
1464
|
-
|
|
1465
|
-
"""
|
|
1466
|
-
|
|
1467
|
-
collection = DatabaseHandler.db_client[db_name]["telescopes"]
|
|
1468
|
-
|
|
1469
|
-
_model_version = self._convert_version_to_tagged(
|
|
1470
|
-
names.validate_model_version_name(model_version),
|
|
1471
|
-
DatabaseHandler.DB_CTA_SIMULATION_MODEL,
|
|
1472
|
-
)
|
|
1473
|
-
|
|
1474
|
-
query = {
|
|
1475
|
-
"Version": _model_version,
|
|
1476
|
-
}
|
|
1477
|
-
|
|
1478
|
-
_all_available_telescopes = collection.find(query).distinct("Telescope")
|
|
1479
|
-
|
|
1480
|
-
return _all_available_telescopes
|