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/applications/{print_array_elements.py → convert_geo_coordinates_of_array_elements.py}
RENAMED
|
@@ -1,68 +1,54 @@
|
|
|
1
1
|
#!/usr/bin/python3
|
|
2
|
-
"""
|
|
3
|
-
Summary
|
|
4
|
-
-------
|
|
5
|
-
Convert and print a list of array element positions in different coordinate \
|
|
6
|
-
systems relevant for CTAO.
|
|
2
|
+
"""Convert and print a list of array element positions in different coordinate systems.
|
|
7
3
|
|
|
8
4
|
Description
|
|
9
5
|
-----------
|
|
10
6
|
|
|
11
|
-
|
|
12
|
-
coordinate systems.
|
|
13
|
-
|
|
7
|
+
Convert array element positions in different CTAO coordinate systems.
|
|
14
8
|
Available coordinate systems are:
|
|
15
9
|
|
|
16
10
|
1. UTM system
|
|
17
|
-
2. ground system (similar to sim_telarray system with x-axis pointing toward
|
|
18
|
-
|
|
11
|
+
2. ground system (similar to sim_telarray system with x-axis pointing toward geographic north
|
|
12
|
+
and y-axis pointing towards the west); altitude relative to the CORSIKA observation level.
|
|
13
|
+
Altitude is the height of the elevation rotation axis (plus some possible mirror offset).
|
|
19
14
|
3. Mercator system
|
|
20
15
|
|
|
21
16
|
Command line arguments
|
|
22
17
|
----------------------
|
|
23
18
|
input (str)
|
|
24
|
-
File name with list of array element positions
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
File name with list of array element positions.
|
|
20
|
+
Input can be given as astropy table file (ecsv) or a single array element in
|
|
21
|
+
a json file.
|
|
22
|
+
print (str)
|
|
23
|
+
Print in requested coordinate system; possible are ground, utm, mercator
|
|
27
24
|
export (str)
|
|
28
|
-
Export array element list to file in requested coordinate system;
|
|
29
|
-
|
|
30
|
-
use_corsika_telescope_height (bool)
|
|
31
|
-
Use CORSIKA coordinates for telescope heights (requires CORSIKA observation level)
|
|
25
|
+
Export array element list to file in requested coordinate system;
|
|
26
|
+
possible are ground, utm, mercator
|
|
32
27
|
select_assets (str)
|
|
33
28
|
Select a subset of array elements / telescopes (e.g., MSTN, LSTN)
|
|
34
29
|
|
|
35
|
-
|
|
36
30
|
Example
|
|
37
31
|
-------
|
|
38
|
-
|
|
32
|
+
Convert a list of array elements using a list of telescope positions in UTM coordinates.
|
|
39
33
|
|
|
40
34
|
.. code-block:: console
|
|
41
35
|
|
|
42
|
-
simtools-
|
|
43
|
-
--input tests/resources/telescope_positions-
|
|
44
|
-
--
|
|
45
|
-
|
|
46
|
-
Expected final print-out message:
|
|
36
|
+
simtools-convert-geo-coordinates-of-array-elements
|
|
37
|
+
--input tests/resources/telescope_positions-North-utm.ecsv
|
|
38
|
+
--print ground
|
|
47
39
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
telescope_name pos_x pos_y altitude
|
|
51
|
-
MST-01 -0.02 -0.00 2162.00
|
|
52
|
-
MST-02 1.43 151.02 2163.00
|
|
53
|
-
MST-03 -1.47 -151.02 2169.00
|
|
54
|
-
MST-04 150.72 73.57 2159.00
|
|
40
|
+
The converted list of telescope positions in ground coordinates is printed to the screen.
|
|
55
41
|
|
|
56
|
-
The following example converts a list of telescope positions in UTM coordinates
|
|
57
|
-
and writes the output to a file in ground (sim_telarray) coordinates. Also selects
|
|
42
|
+
The following example converts a list of telescope positions in UTM coordinates
|
|
43
|
+
and writes the output to a file in ground (sim_telarray) coordinates. Also selects
|
|
58
44
|
only a subset of the array elements (telescopes; ignore calibration devices):
|
|
59
45
|
|
|
60
46
|
.. code-block:: console
|
|
61
47
|
|
|
62
|
-
simtools-
|
|
63
|
-
--input tests/resources/telescope_positions-North-utm.ecsv
|
|
64
|
-
--export ground
|
|
65
|
-
--select_assets LSTN
|
|
48
|
+
simtools-convert-geo-coordinates-of-array-elements
|
|
49
|
+
--input tests/resources/telescope_positions-North-utm.ecsv
|
|
50
|
+
--export ground
|
|
51
|
+
--select_assets LSTN
|
|
66
52
|
|
|
67
53
|
Expected output is a ecsv file in the directory printed to the screen.
|
|
68
54
|
|
|
@@ -80,7 +66,7 @@ from simtools.layout import array_layout
|
|
|
80
66
|
|
|
81
67
|
def _parse(label=None, description=None):
|
|
82
68
|
"""
|
|
83
|
-
Parse command line configuration
|
|
69
|
+
Parse command line configuration.
|
|
84
70
|
|
|
85
71
|
Parameters
|
|
86
72
|
----------
|
|
@@ -93,15 +79,13 @@ def _parse(label=None, description=None):
|
|
|
93
79
|
-------
|
|
94
80
|
CommandLineParser
|
|
95
81
|
Command line parser object
|
|
96
|
-
|
|
97
82
|
"""
|
|
98
|
-
|
|
99
83
|
config = configurator.Configurator(label=label, description=description)
|
|
100
84
|
|
|
101
85
|
config.parser.add_argument(
|
|
102
86
|
"--input",
|
|
103
87
|
help="list of array element positions",
|
|
104
|
-
required=
|
|
88
|
+
required=True,
|
|
105
89
|
)
|
|
106
90
|
config.parser.add_argument(
|
|
107
91
|
"--input_meta",
|
|
@@ -110,8 +94,8 @@ def _parse(label=None, description=None):
|
|
|
110
94
|
required=False,
|
|
111
95
|
)
|
|
112
96
|
config.parser.add_argument(
|
|
113
|
-
"--
|
|
114
|
-
help="
|
|
97
|
+
"--print",
|
|
98
|
+
help="print list of positions in requested coordinate system",
|
|
115
99
|
required=False,
|
|
116
100
|
default="",
|
|
117
101
|
choices=[
|
|
@@ -131,13 +115,6 @@ def _parse(label=None, description=None):
|
|
|
131
115
|
"mercator",
|
|
132
116
|
],
|
|
133
117
|
)
|
|
134
|
-
config.parser.add_argument(
|
|
135
|
-
"--use_corsika_telescope_height",
|
|
136
|
-
help="Use CORSIKA coordinates for telescope heights (requires CORSIKA observation level)",
|
|
137
|
-
required=False,
|
|
138
|
-
default=False,
|
|
139
|
-
action="store_true",
|
|
140
|
-
)
|
|
141
118
|
config.parser.add_argument(
|
|
142
119
|
"--select_assets",
|
|
143
120
|
help="select a subset of assets (e.g., MSTN, LSTN)",
|
|
@@ -152,21 +129,39 @@ def _parse(label=None, description=None):
|
|
|
152
129
|
required=False,
|
|
153
130
|
action="store_true",
|
|
154
131
|
)
|
|
155
|
-
return config.initialize(
|
|
132
|
+
return config.initialize(
|
|
133
|
+
output=True, require_command_line=True, db_config=True, simulation_model=["version", "site"]
|
|
134
|
+
)
|
|
156
135
|
|
|
157
136
|
|
|
158
137
|
def main():
|
|
138
|
+
"""Print a list of array elements."""
|
|
159
139
|
label = Path(__file__).stem
|
|
160
140
|
data_model_name = "array_coordinates"
|
|
161
|
-
args_dict,
|
|
141
|
+
args_dict, db_config = _parse(
|
|
162
142
|
label,
|
|
163
143
|
description=f"Print a list of array element positions ({data_model_name})",
|
|
164
144
|
)
|
|
165
145
|
|
|
166
|
-
|
|
167
|
-
|
|
146
|
+
logger = logging.getLogger()
|
|
147
|
+
logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
|
|
148
|
+
|
|
149
|
+
json_type = args_dict.get("input", "").endswith(".json")
|
|
150
|
+
# simplified metadata treatment for model parameter json files
|
|
151
|
+
if json_type:
|
|
152
|
+
site = args_dict.get("site", None)
|
|
153
|
+
top_level_meta = None
|
|
154
|
+
validate_schema_file = None
|
|
155
|
+
else:
|
|
156
|
+
metadata = MetadataCollector(args_dict=args_dict, data_model_name=data_model_name)
|
|
157
|
+
site = metadata.get_site(from_input_meta=True)
|
|
158
|
+
top_level_meta = metadata.top_level_meta
|
|
159
|
+
validate_schema_file = metadata.get_data_model_schema_file_name()
|
|
168
160
|
|
|
169
161
|
layout = array_layout.ArrayLayout(
|
|
162
|
+
mongo_db_config=db_config,
|
|
163
|
+
model_version=args_dict["model_version"],
|
|
164
|
+
site=site,
|
|
170
165
|
telescope_list_file=args_dict["input"],
|
|
171
166
|
telescope_list_metadata_file=args_dict["input_meta"],
|
|
172
167
|
validate=not args_dict["skip_input_validation"],
|
|
@@ -175,20 +170,20 @@ def main():
|
|
|
175
170
|
layout.convert_coordinates()
|
|
176
171
|
|
|
177
172
|
if args_dict["export"] is not None:
|
|
178
|
-
|
|
173
|
+
product_data = (
|
|
174
|
+
layout.export_one_telescope_as_json(crs_name=args_dict["export"])
|
|
175
|
+
if json_type
|
|
176
|
+
else layout.export_telescope_list_table(crs_name=args_dict["export"])
|
|
177
|
+
)
|
|
179
178
|
writer.ModelDataWriter.dump(
|
|
180
179
|
args_dict=args_dict,
|
|
181
|
-
metadata=
|
|
182
|
-
product_data=
|
|
183
|
-
|
|
184
|
-
corsika_z=args_dict["use_corsika_telescope_height"],
|
|
185
|
-
),
|
|
186
|
-
validate_schema_file=_metadata.get_data_model_schema_file_name(),
|
|
180
|
+
metadata=top_level_meta,
|
|
181
|
+
product_data=product_data,
|
|
182
|
+
validate_schema_file=validate_schema_file,
|
|
187
183
|
)
|
|
188
184
|
else:
|
|
189
185
|
layout.print_telescope_list(
|
|
190
|
-
|
|
191
|
-
corsika_z=args_dict["use_corsika_telescope_height"],
|
|
186
|
+
crs_name=args_dict["print"],
|
|
192
187
|
)
|
|
193
188
|
|
|
194
189
|
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
#!/usr/bin/python3
|
|
2
|
+
r"""
|
|
3
|
+
Convert simulation model parameter from sim_telarray format using the corresponding schema file.
|
|
4
|
+
|
|
5
|
+
Check value, type, and range and write a json file ready to be submitted to the model database.
|
|
6
|
+
|
|
7
|
+
Command line arguments
|
|
8
|
+
----------------------
|
|
9
|
+
parameter (str, required)
|
|
10
|
+
Parameter name (as used in simtools)
|
|
11
|
+
|
|
12
|
+
simtel_cfg_file (str)
|
|
13
|
+
File name of sim_telarray configuration file containing all simulation model parameters.
|
|
14
|
+
|
|
15
|
+
simtel_telescope_name (str)
|
|
16
|
+
Name of the telescope in the sim_telarray configuration file.
|
|
17
|
+
|
|
18
|
+
telescope (str, optional)
|
|
19
|
+
Telescope model name (e.g. LST-1, SST-D, ...)
|
|
20
|
+
|
|
21
|
+
Example
|
|
22
|
+
-------
|
|
23
|
+
|
|
24
|
+
Extract the num_gains parameter from a sim_telarray configuration file for LSTN-01
|
|
25
|
+
and write a json file in the same format as the model parameter database:
|
|
26
|
+
|
|
27
|
+
.. code-block:: console
|
|
28
|
+
|
|
29
|
+
simtools-convert-model-parameter-from-simtel \\
|
|
30
|
+
--simtel_telescope_name CT1 \\
|
|
31
|
+
--telescope LSTN-01 \\
|
|
32
|
+
--schema tests/resources/num_gains.schema.yml \\
|
|
33
|
+
--simtel_cfg_file tests/resources/simtel_config_test_la_palma.cfg \\
|
|
34
|
+
--output_file num_gains.json
|
|
35
|
+
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
import logging
|
|
39
|
+
from pathlib import Path
|
|
40
|
+
|
|
41
|
+
import simtools.data_model.model_data_writer as writer
|
|
42
|
+
import simtools.utils.general as gen
|
|
43
|
+
from simtools.configuration import configurator
|
|
44
|
+
from simtools.simtel.simtel_config_reader import SimtelConfigReader
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _parse(label=None, description=None):
|
|
48
|
+
"""
|
|
49
|
+
Parse command line configuration.
|
|
50
|
+
|
|
51
|
+
Parameters
|
|
52
|
+
----------
|
|
53
|
+
label: str
|
|
54
|
+
Label describing application.
|
|
55
|
+
description: str
|
|
56
|
+
Description of application.
|
|
57
|
+
|
|
58
|
+
Returns
|
|
59
|
+
-------
|
|
60
|
+
CommandLineParser
|
|
61
|
+
Command line parser object
|
|
62
|
+
|
|
63
|
+
"""
|
|
64
|
+
config = configurator.Configurator(label=label, description=description)
|
|
65
|
+
|
|
66
|
+
config.parser.add_argument(
|
|
67
|
+
"--schema", help="Schema file for model parameter validation", required=True
|
|
68
|
+
)
|
|
69
|
+
config.parser.add_argument(
|
|
70
|
+
"--simtel_cfg_file",
|
|
71
|
+
help="File name for simtel_array configuration",
|
|
72
|
+
type=str,
|
|
73
|
+
required=True,
|
|
74
|
+
)
|
|
75
|
+
config.parser.add_argument(
|
|
76
|
+
"--simtel_telescope_name",
|
|
77
|
+
help="Name of the telescope in the sim_telarray configuration file",
|
|
78
|
+
type=str,
|
|
79
|
+
required=True,
|
|
80
|
+
)
|
|
81
|
+
return config.initialize(simulation_model="telescope", output=True)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def main(): # noqa: D103
|
|
85
|
+
|
|
86
|
+
args_dict, _ = _parse(
|
|
87
|
+
label=Path(__file__).stem,
|
|
88
|
+
description="Convert simulation model parameter from sim_telarray to simtools format.",
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
logger = logging.getLogger()
|
|
92
|
+
logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
|
|
93
|
+
|
|
94
|
+
simtel_config_reader = SimtelConfigReader(
|
|
95
|
+
schema_file=args_dict["schema"],
|
|
96
|
+
simtel_config_file=args_dict["simtel_cfg_file"],
|
|
97
|
+
simtel_telescope_name=args_dict["simtel_telescope_name"],
|
|
98
|
+
)
|
|
99
|
+
logger.info(f"Simtel parameter: {simtel_config_reader.parameter_dict}")
|
|
100
|
+
if simtel_config_reader.parameter_dict is None or len(simtel_config_reader.parameter_dict) == 0:
|
|
101
|
+
logger.error("Parameter not found in sim_telarray configuration file.")
|
|
102
|
+
return
|
|
103
|
+
|
|
104
|
+
simtel_config_reader.compare_simtel_config_with_schema()
|
|
105
|
+
|
|
106
|
+
_json_dict = writer.ModelDataWriter.dump_model_parameter(
|
|
107
|
+
parameter_name=simtel_config_reader.parameter_name,
|
|
108
|
+
value=simtel_config_reader.parameter_dict.get(args_dict["simtel_telescope_name"]),
|
|
109
|
+
instrument=args_dict["telescope"],
|
|
110
|
+
model_version=args_dict["model_version"],
|
|
111
|
+
output_file=args_dict["output_file"],
|
|
112
|
+
output_path=args_dict.get("output_path"),
|
|
113
|
+
use_plain_output_path=args_dict.get("use_plain_output_path"),
|
|
114
|
+
)
|
|
115
|
+
logger.info(f"Validated parameter: {_json_dict}")
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
if __name__ == "__main__":
|
|
119
|
+
main()
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/python3
|
|
2
2
|
|
|
3
3
|
"""
|
|
4
|
-
|
|
5
|
-
-------
|
|
6
|
-
This application adds a file to a DB.
|
|
4
|
+
Add a file to a DB.
|
|
7
5
|
|
|
8
6
|
The name and location of the file are required.
|
|
9
7
|
This application should complement the ones for updating parameters, \
|
|
@@ -14,7 +12,7 @@
|
|
|
14
12
|
file_name (str or list of str, required)
|
|
15
13
|
Name of the file to upload including the full path. \
|
|
16
14
|
A list of files is also allowed, in which case only one -file_name is necessary, \
|
|
17
|
-
i.e., python applications/
|
|
15
|
+
i.e., python applications/db_add_file_to_db.py -file_name file_1.dat file_2.dat file_3.dat \
|
|
18
16
|
If no path is given, the file is assumed to be in the CWD.
|
|
19
17
|
input_path (str, required if file_name is not given)
|
|
20
18
|
A directory with files to upload to the DB. \
|
|
@@ -22,8 +20,6 @@
|
|
|
22
20
|
db (str)
|
|
23
21
|
The DB to insert the files to. \
|
|
24
22
|
The choices are either the default CTA simulation DB or a sandbox for testing.
|
|
25
|
-
verbosity (str, optional)
|
|
26
|
-
Log level to print.
|
|
27
23
|
|
|
28
24
|
Example
|
|
29
25
|
-------
|
|
@@ -31,7 +27,7 @@
|
|
|
31
27
|
|
|
32
28
|
.. code-block:: console
|
|
33
29
|
|
|
34
|
-
simtools-add-file-to-db --file_name test_application.dat --db test-data
|
|
30
|
+
simtools-db-add-file-to-db --file_name test_application.dat --db test-data
|
|
35
31
|
|
|
36
32
|
Expected final print-out message:
|
|
37
33
|
|
|
@@ -46,78 +42,64 @@ import logging
|
|
|
46
42
|
from pathlib import Path
|
|
47
43
|
|
|
48
44
|
import simtools.utils.general as gen
|
|
49
|
-
from simtools import db_handler
|
|
50
45
|
from simtools.configuration import configurator
|
|
46
|
+
from simtools.db import db_handler
|
|
51
47
|
|
|
52
48
|
|
|
53
|
-
def
|
|
54
|
-
"""
|
|
55
|
-
Ask the user to enter y or n (case-insensitive).
|
|
56
|
-
|
|
57
|
-
Returns
|
|
58
|
-
-------
|
|
59
|
-
bool: True if the answer is Y/y.
|
|
60
|
-
"""
|
|
61
|
-
|
|
62
|
-
answer = ""
|
|
63
|
-
while answer not in ["y", "n"]:
|
|
64
|
-
try:
|
|
65
|
-
answer = input("Is this OK? [y/n]").lower()
|
|
66
|
-
return answer == "y"
|
|
67
|
-
except EOFError:
|
|
68
|
-
return False
|
|
69
|
-
return False
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
def main():
|
|
73
|
-
_db_tmp = db_handler.DatabaseHandler(mongo_db_config=None)
|
|
49
|
+
def _parse():
|
|
74
50
|
|
|
75
51
|
config = configurator.Configurator(
|
|
76
52
|
description="Add file to the DB.",
|
|
77
53
|
usage="simtools-add-file-to-db --file_name test_application.dat --db test-data",
|
|
78
54
|
)
|
|
55
|
+
|
|
79
56
|
group = config.parser.add_mutually_exclusive_group(required=True)
|
|
80
57
|
group.add_argument(
|
|
81
58
|
"--file_name",
|
|
82
|
-
help=(
|
|
83
|
-
"The file name to upload. "
|
|
84
|
-
"A list of files is also allowed, in which case only one -f is necessary, "
|
|
85
|
-
"i.e., python applications/add_file_to_db.py --file_name file_1.dat file_2.dat "
|
|
86
|
-
"file_3.dat. If no path is given, the file is assumed to be in the CWD."
|
|
87
|
-
),
|
|
59
|
+
help=("The file name to upload. A list of files is also allowed."),
|
|
88
60
|
type=str,
|
|
89
61
|
nargs="+",
|
|
90
62
|
)
|
|
91
63
|
group.add_argument(
|
|
92
64
|
"--input_path",
|
|
93
|
-
help=(
|
|
94
|
-
"A directory with files to upload to the DB. "
|
|
95
|
-
"All files in the directory with the following extensions "
|
|
96
|
-
f"will be uploaded: {', '.join(_db_tmp.ALLOWED_FILE_EXTENSIONS)}"
|
|
97
|
-
),
|
|
65
|
+
help=("A directory with files to upload to the DB."),
|
|
98
66
|
type=Path,
|
|
99
67
|
)
|
|
68
|
+
|
|
100
69
|
config.parser.add_argument(
|
|
101
70
|
"--db",
|
|
102
71
|
type=str,
|
|
103
|
-
default=_db_tmp.DB_TABULATED_DATA,
|
|
104
|
-
choices=[
|
|
105
|
-
_db_tmp.DB_TABULATED_DATA,
|
|
106
|
-
_db_tmp.DB_DERIVED_VALUES,
|
|
107
|
-
_db_tmp.DB_REFERENCE_DATA,
|
|
108
|
-
"sandbox",
|
|
109
|
-
"test-data",
|
|
110
|
-
],
|
|
111
72
|
help=("The database to insert the files to."),
|
|
112
73
|
)
|
|
113
|
-
args_dict, db_config = config.initialize(paths=False, db_config=True)
|
|
114
74
|
|
|
115
|
-
|
|
116
|
-
logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
|
|
75
|
+
return config.initialize(paths=False, db_config=True)
|
|
117
76
|
|
|
118
|
-
db = db_handler.DatabaseHandler(mongo_db_config=db_config)
|
|
119
77
|
|
|
78
|
+
def collect_files_to_insert(args_dict, logger, db):
|
|
79
|
+
"""
|
|
80
|
+
Collect the files to insert into the database based on the provided arguments.
|
|
81
|
+
|
|
82
|
+
Parameters
|
|
83
|
+
----------
|
|
84
|
+
args_dict : dict
|
|
85
|
+
Dictionary of parsed command-line arguments.
|
|
86
|
+
logger : logging.Logger
|
|
87
|
+
Logger object for logging messages.
|
|
88
|
+
db : DatabaseHandler
|
|
89
|
+
Database handler object.
|
|
90
|
+
|
|
91
|
+
Returns
|
|
92
|
+
-------
|
|
93
|
+
list
|
|
94
|
+
List of files to be inserted into the database.
|
|
95
|
+
|
|
96
|
+
Raises
|
|
97
|
+
------
|
|
98
|
+
ValueError
|
|
99
|
+
If no valid files are provided for uploading.
|
|
100
|
+
"""
|
|
120
101
|
files_to_insert = []
|
|
102
|
+
|
|
121
103
|
if args_dict.get("file_name", None) is not None:
|
|
122
104
|
for file_now in args_dict["file_name"]:
|
|
123
105
|
if Path(file_now).suffix in db.ALLOWED_FILE_EXTENSIONS:
|
|
@@ -131,23 +113,51 @@ def main():
|
|
|
131
113
|
for ext_now in db.ALLOWED_FILE_EXTENSIONS:
|
|
132
114
|
files_to_insert.extend(Path(args_dict["input_path"]).glob(f"*{ext_now}"))
|
|
133
115
|
|
|
134
|
-
|
|
135
|
-
if len(files_to_insert) < 1:
|
|
116
|
+
if not files_to_insert:
|
|
136
117
|
raise ValueError("No files were provided to upload")
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
118
|
+
|
|
119
|
+
return files_to_insert
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def confirm_and_insert_files(files_to_insert, args_dict, db, logger):
|
|
123
|
+
"""
|
|
124
|
+
Confirm the files to be inserted and insert them into the database.
|
|
125
|
+
|
|
126
|
+
Parameters
|
|
127
|
+
----------
|
|
128
|
+
files_to_insert : list
|
|
129
|
+
List of files to be inserted into the database.
|
|
130
|
+
args_dict : dict
|
|
131
|
+
Dictionary of parsed command-line arguments.
|
|
132
|
+
db : DatabaseHandler
|
|
133
|
+
Database handler object.
|
|
134
|
+
logger : logging.Logger
|
|
135
|
+
Logger object for logging messages.
|
|
136
|
+
"""
|
|
137
|
+
plural = "" if len(files_to_insert) == 1 else "s"
|
|
141
138
|
|
|
142
139
|
print(f"Should the following file{plural} be inserted to the {args_dict['db']} DB?:\n")
|
|
143
140
|
print(*files_to_insert, sep="\n")
|
|
144
141
|
print()
|
|
145
|
-
|
|
142
|
+
|
|
143
|
+
if gen.user_confirm():
|
|
146
144
|
for file_to_insert_now in files_to_insert:
|
|
147
145
|
db.insert_file_to_db(file_to_insert_now, args_dict["db"])
|
|
148
146
|
logger.info(f"File {file_to_insert_now} inserted to {args_dict['db']} DB")
|
|
149
147
|
else:
|
|
150
|
-
logger.info(f"Aborted, did not insert file
|
|
148
|
+
logger.info(f"Aborted, did not insert file{plural} to the {args_dict['db']} DB")
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def main(): # noqa: D103
|
|
152
|
+
args_dict, db_config = _parse()
|
|
153
|
+
|
|
154
|
+
logger = logging.getLogger()
|
|
155
|
+
logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
|
|
156
|
+
|
|
157
|
+
db = db_handler.DatabaseHandler(mongo_db_config=db_config)
|
|
158
|
+
|
|
159
|
+
files_to_insert = collect_files_to_insert(args_dict, logger, db)
|
|
160
|
+
confirm_and_insert_files(files_to_insert, args_dict, db, logger)
|
|
151
161
|
|
|
152
162
|
|
|
153
163
|
if __name__ == "__main__":
|