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/model/array_model.py
CHANGED
|
@@ -1,340 +1,233 @@
|
|
|
1
|
+
"""Definition of the ArrayModel class."""
|
|
2
|
+
|
|
1
3
|
import logging
|
|
2
|
-
from
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
import astropy.units as u
|
|
7
|
+
from astropy.table import QTable
|
|
3
8
|
|
|
4
|
-
from simtools import
|
|
9
|
+
from simtools.data_model import data_reader
|
|
10
|
+
from simtools.db import db_array_elements, db_handler
|
|
5
11
|
from simtools.io_operations import io_handler
|
|
6
|
-
from simtools.
|
|
12
|
+
from simtools.model.site_model import SiteModel
|
|
7
13
|
from simtools.model.telescope_model import TelescopeModel
|
|
8
14
|
from simtools.simtel.simtel_config_writer import SimtelConfigWriter
|
|
9
|
-
from simtools.utils import names
|
|
10
|
-
from simtools.utils.general import collect_data_from_file_or_dict
|
|
11
|
-
|
|
12
|
-
__all__ = ["ArrayModel", "InvalidArrayConfigData"]
|
|
15
|
+
from simtools.utils import general, names
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
class InvalidArrayConfigData(Exception):
|
|
16
|
-
"""Exception for invalid array configuration data."""
|
|
17
|
+
__all__ = ["ArrayModel"]
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
class ArrayModel:
|
|
20
21
|
"""
|
|
21
|
-
|
|
22
|
-
list of TelescopeModel's and a ArrayLayout.
|
|
22
|
+
Representation of an observatory consisting of site, telescopes, and further devices.
|
|
23
23
|
|
|
24
24
|
Parameters
|
|
25
25
|
----------
|
|
26
26
|
mongo_db_config: dict
|
|
27
27
|
MongoDB configuration.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
array_config_data: dict
|
|
31
|
-
Dict with the array config data.
|
|
28
|
+
model_version: str
|
|
29
|
+
Model version.
|
|
32
30
|
label: str
|
|
33
|
-
Instance label.
|
|
31
|
+
Instance label. Used for output file naming.
|
|
32
|
+
site: str
|
|
33
|
+
Site name.
|
|
34
|
+
layout_name: str
|
|
35
|
+
Layout name.
|
|
36
|
+
array_elements: str, Path, list
|
|
37
|
+
Array element definitions (list of array element or path to file with
|
|
38
|
+
the array element positions).
|
|
34
39
|
"""
|
|
35
40
|
|
|
36
|
-
def __init__(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
def __init__(
|
|
42
|
+
self,
|
|
43
|
+
mongo_db_config,
|
|
44
|
+
model_version,
|
|
45
|
+
label=None,
|
|
46
|
+
site=None,
|
|
47
|
+
layout_name=None,
|
|
48
|
+
array_elements=None,
|
|
49
|
+
):
|
|
50
|
+
"""Initialize ArrayModel."""
|
|
40
51
|
self._logger = logging.getLogger(__name__)
|
|
41
52
|
self._logger.debug("Init ArrayModel")
|
|
42
53
|
self.mongo_db_config = mongo_db_config
|
|
54
|
+
self.model_version = model_version
|
|
43
55
|
self.label = label
|
|
44
|
-
self.
|
|
45
|
-
self.layout = None
|
|
46
|
-
self.layout_name = None
|
|
47
|
-
self.model_version = None
|
|
56
|
+
self.layout_name = layout_name if layout_name else None
|
|
48
57
|
self._config_file_path = None
|
|
58
|
+
self._config_file_directory = None
|
|
49
59
|
self.io_handler = io_handler.IOHandler()
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
self.
|
|
53
|
-
|
|
60
|
+
self.db = db_handler.DatabaseHandler(mongo_db_config=mongo_db_config)
|
|
61
|
+
|
|
62
|
+
self.array_elements, self.site_model, self.telescope_model = self._initialize(
|
|
63
|
+
site, array_elements
|
|
64
|
+
)
|
|
65
|
+
|
|
54
66
|
self._telescope_model_files_exported = False
|
|
55
67
|
self._array_model_file_exported = False
|
|
56
68
|
|
|
57
|
-
|
|
58
|
-
def number_of_telescopes(self):
|
|
59
|
-
"""
|
|
60
|
-
Return the number of telescopes.
|
|
61
|
-
|
|
62
|
-
Returns
|
|
63
|
-
-------
|
|
64
|
-
int
|
|
65
|
-
Number of telescopes.
|
|
69
|
+
def _initialize(self, site, array_elements_config):
|
|
66
70
|
"""
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
def _load_array_data(self, array_config_data):
|
|
70
|
-
"""Load parameters from array_data.
|
|
71
|
+
Initialize ArrayModel taking different configuration options into account.
|
|
71
72
|
|
|
72
73
|
Parameters
|
|
73
74
|
----------
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
# Keys 'site', 'layout_name' and 'default' are mandatory.
|
|
79
|
-
# 'default' must have 'LST', 'MST' and 'SST' (for South site) keys.
|
|
80
|
-
self._validate_array_data(array_config_data)
|
|
81
|
-
|
|
82
|
-
# Site
|
|
83
|
-
self.site = names.validate_site_name(array_config_data["site"])
|
|
75
|
+
site: str
|
|
76
|
+
Site name.
|
|
77
|
+
array_elements_config: str, Path, list
|
|
78
|
+
Array element definitions.
|
|
84
79
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
80
|
+
Returns
|
|
81
|
+
-------
|
|
82
|
+
dict
|
|
83
|
+
Dict with telescope positions.
|
|
84
|
+
SiteModel
|
|
85
|
+
Site model.
|
|
86
|
+
dict
|
|
87
|
+
Dict with telescope models.
|
|
88
|
+
"""
|
|
89
|
+
self._logger.debug(f"Getting site parameters from DB ({site})")
|
|
90
|
+
site_model = SiteModel(
|
|
91
|
+
site=names.validate_site_name(site),
|
|
88
92
|
mongo_db_config=self.mongo_db_config,
|
|
89
|
-
|
|
93
|
+
model_version=self.model_version,
|
|
90
94
|
label=self.label,
|
|
91
95
|
)
|
|
92
96
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
self._logger.warning("model_version not given in array_config_data - using 'Released'")
|
|
99
|
-
self.model_version = "Released"
|
|
100
|
-
else:
|
|
101
|
-
self.model_version = names.validate_model_version_name(
|
|
102
|
-
array_config_data["model_version"]
|
|
97
|
+
array_elements = {}
|
|
98
|
+
# Case 1: array_elements is a file name
|
|
99
|
+
if isinstance(array_elements_config, str | Path):
|
|
100
|
+
array_elements = self._load_array_element_positions_from_file(
|
|
101
|
+
array_elements_config, site
|
|
103
102
|
)
|
|
103
|
+
# Case 2: array elements is a list of elements
|
|
104
|
+
elif isinstance(array_elements_config, list):
|
|
105
|
+
array_elements = self._get_array_elements_from_list(array_elements_config)
|
|
106
|
+
# Case 3: array elements defined in DB by array layout name
|
|
107
|
+
elif self.layout_name is not None:
|
|
108
|
+
array_elements = self._get_array_elements_from_list(
|
|
109
|
+
site_model.get_array_elements_for_layout(self.layout_name)
|
|
110
|
+
)
|
|
111
|
+
if array_elements == {}:
|
|
112
|
+
raise ValueError(
|
|
113
|
+
"No array elements found. "
|
|
114
|
+
"Possibly missing valid layout name or missing telescope list."
|
|
115
|
+
)
|
|
116
|
+
telescope_model = self._build_telescope_models(site_model, array_elements)
|
|
117
|
+
return array_elements, site_model, telescope_model
|
|
104
118
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
k: v
|
|
108
|
-
for (k, v) in array_config_data.items()
|
|
109
|
-
if k not in ["site", "layout_name", "model_version"]
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
def _validate_array_data(self, array_config_data):
|
|
113
|
-
"""
|
|
114
|
-
Validate array_data by checking the existence of the relevant keys. Searching for the keys:\
|
|
115
|
-
'site', 'array' and 'default'.
|
|
119
|
+
@property
|
|
120
|
+
def number_of_telescopes(self):
|
|
116
121
|
"""
|
|
122
|
+
Return the number of telescopes.
|
|
117
123
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
if pp not in all_keys:
|
|
123
|
-
key = pp if parent is None else parent + "." + pp
|
|
124
|
-
msg = (
|
|
125
|
-
f"Key {key} was not found in array_config_data "
|
|
126
|
-
+ "- impossible to build array model"
|
|
127
|
-
)
|
|
128
|
-
self._logger.error(msg)
|
|
129
|
-
raise InvalidArrayConfigData(msg)
|
|
130
|
-
|
|
131
|
-
run_over_pars(["site", "layout_name", "default"], array_config_data)
|
|
132
|
-
|
|
133
|
-
def _set_config_file_directory(self):
|
|
134
|
-
"""Define the variable _config_file_directory and create directories, if needed"""
|
|
135
|
-
self._config_file_directory = self.io_handler.get_output_directory(self.label, "model")
|
|
136
|
-
if not self._config_file_directory.exists():
|
|
137
|
-
self._config_file_directory.mkdir(parents=True, exist_ok=True)
|
|
138
|
-
self._logger.info(f"Creating directory {self._config_file_directory}")
|
|
139
|
-
|
|
140
|
-
def _build_array_model(self):
|
|
124
|
+
Returns
|
|
125
|
+
-------
|
|
126
|
+
int
|
|
127
|
+
Number of telescopes.
|
|
141
128
|
"""
|
|
142
|
-
|
|
143
|
-
including reading the parameters from the DB.
|
|
129
|
+
return len(self.telescope_model)
|
|
144
130
|
|
|
131
|
+
@property
|
|
132
|
+
def site(self):
|
|
145
133
|
"""
|
|
134
|
+
Return site.
|
|
146
135
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
# Building telescope models
|
|
155
|
-
self._telescope_model = [] # List of telescope models
|
|
156
|
-
_all_telescope_model_names = [] # List of telescope names without repetition
|
|
157
|
-
_all_pars_to_change = {}
|
|
158
|
-
for tel in self.layout:
|
|
159
|
-
tel_size = names.get_telescope_class(tel.name)
|
|
160
|
-
|
|
161
|
-
# Collecting telescope name and pars to change from array_config_data
|
|
162
|
-
tel_model_name, pars_to_change = self._get_single_telescope_info_from_array_config(
|
|
163
|
-
tel.name, tel_size
|
|
164
|
-
)
|
|
165
|
-
if len(pars_to_change) > 0:
|
|
166
|
-
_all_pars_to_change[tel.name] = pars_to_change
|
|
167
|
-
|
|
168
|
-
self._logger.debug(f"tel_model_name: {tel_model_name}")
|
|
169
|
-
|
|
170
|
-
# Building the basic models - no pars to change yet
|
|
171
|
-
if tel_model_name not in _all_telescope_model_names:
|
|
172
|
-
# First time a telescope name is built
|
|
173
|
-
_all_telescope_model_names.append(tel_model_name)
|
|
174
|
-
tel_model = TelescopeModel(
|
|
175
|
-
site=self.site,
|
|
176
|
-
telescope_model_name=tel_model_name,
|
|
177
|
-
model_version=self.model_version,
|
|
178
|
-
label=self.label,
|
|
179
|
-
db=db,
|
|
180
|
-
)
|
|
181
|
-
else:
|
|
182
|
-
# Telescope name already exists.
|
|
183
|
-
# Finding the TelescopeModel and copying it.
|
|
184
|
-
for tel_now in self._telescope_model:
|
|
185
|
-
if tel_now.name != tel_model_name:
|
|
186
|
-
continue
|
|
187
|
-
self._logger.debug(f"Copying tel model {tel_now.name} already loaded from DB")
|
|
188
|
-
tel_model = copy(tel_now)
|
|
189
|
-
break
|
|
190
|
-
|
|
191
|
-
self._telescope_model.append(tel_model)
|
|
192
|
-
|
|
193
|
-
# Checking whether the size of the telescope list and the layout match
|
|
194
|
-
if len(self._telescope_model) != len(self.layout):
|
|
195
|
-
self._logger.warning(
|
|
196
|
-
"Number of telescopes in the list of telescope models does "
|
|
197
|
-
"not match the number of telescopes in the ArrayLayout - something is wrong!"
|
|
198
|
-
)
|
|
199
|
-
|
|
200
|
-
# Changing parameters, if there are any in all_pars_to_change
|
|
201
|
-
if len(_all_pars_to_change) > 0:
|
|
202
|
-
for tel_data, tel_model in zip(self.layout, self._telescope_model):
|
|
203
|
-
if tel_data.name not in _all_pars_to_change:
|
|
204
|
-
continue
|
|
205
|
-
self._logger.debug(
|
|
206
|
-
f"Changing {len(_all_pars_to_change[tel_data.name])} pars of a "
|
|
207
|
-
f"{tel_data.name}: {*_all_pars_to_change[tel_data.name],}, ..."
|
|
208
|
-
)
|
|
209
|
-
tel_model.change_multiple_parameters(**_all_pars_to_change[tel_data.name])
|
|
210
|
-
tel_model.set_extra_label(tel_data.name)
|
|
136
|
+
Returns
|
|
137
|
+
-------
|
|
138
|
+
str
|
|
139
|
+
Site name.
|
|
140
|
+
"""
|
|
141
|
+
return self.site_model.site
|
|
211
142
|
|
|
212
|
-
def
|
|
143
|
+
def _build_telescope_models(self, site_model, array_elements):
|
|
213
144
|
"""
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
145
|
+
Build the the telescope models for all telescopes of this array.
|
|
146
|
+
|
|
147
|
+
Includes reading of telescope model parameters from the DB.
|
|
148
|
+
The array is defined in the telescopes dictionary. Array element positions
|
|
149
|
+
are read from the database if no values are given in this dictionary.
|
|
218
150
|
|
|
219
151
|
Parameters
|
|
220
152
|
----------
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
"""
|
|
153
|
+
site_model: str
|
|
154
|
+
Site model.
|
|
155
|
+
array_elements: dict
|
|
156
|
+
Dict with array elements.
|
|
226
157
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
if
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
self.
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
pars_to_change = {k: v for (k, v) in data.items() if k != "name"}
|
|
243
|
-
self._logger.debug(
|
|
244
|
-
"Grabbing tel data as dict - "
|
|
245
|
-
f"name: {tel_name}, "
|
|
246
|
-
f"{len(pars_to_change)} pars to change"
|
|
158
|
+
Returns
|
|
159
|
+
-------
|
|
160
|
+
dict
|
|
161
|
+
Dictionary with telescope models.
|
|
162
|
+
"""
|
|
163
|
+
telescope_model = {}
|
|
164
|
+
for element_name, _ in array_elements.items():
|
|
165
|
+
collection = names.get_collection_name_from_array_element_name(element_name)
|
|
166
|
+
if collection == "telescopes":
|
|
167
|
+
telescope_model[element_name] = TelescopeModel(
|
|
168
|
+
site=site_model.site,
|
|
169
|
+
telescope_name=element_name,
|
|
170
|
+
model_version=self.model_version,
|
|
171
|
+
mongo_db_config=self.mongo_db_config,
|
|
172
|
+
label=self.label,
|
|
247
173
|
)
|
|
248
|
-
|
|
249
|
-
if isinstance(data, str):
|
|
250
|
-
# Case 1: data is string (only name)
|
|
251
|
-
tel_name = tel_size + "-" + data
|
|
252
|
-
return tel_name, {}
|
|
253
|
-
|
|
254
|
-
# Case 2: data has a wrong type
|
|
255
|
-
msg = "ArrayConfig has wrong input for a telescope"
|
|
256
|
-
self._logger.error(msg)
|
|
257
|
-
raise InvalidArrayConfigData(msg)
|
|
258
|
-
|
|
259
|
-
if tel_name in self._array_config_data.keys():
|
|
260
|
-
# Specific info for this telescope
|
|
261
|
-
return _proccess_single_telescope(self._array_config_data[tel_name])
|
|
262
|
-
|
|
263
|
-
# Checking if default option exists in array_config_data
|
|
264
|
-
not_contains_default_key = (
|
|
265
|
-
"default" not in self._array_config_data.keys()
|
|
266
|
-
or tel_size not in self._array_config_data["default"].keys()
|
|
267
|
-
)
|
|
268
|
-
|
|
269
|
-
if not_contains_default_key:
|
|
270
|
-
msg = (
|
|
271
|
-
"default option was not given in array_config_data "
|
|
272
|
-
+ f"for the telescope {tel_name}"
|
|
273
|
-
)
|
|
274
|
-
self._logger.error(msg)
|
|
275
|
-
raise InvalidArrayConfigData(msg)
|
|
276
|
-
|
|
277
|
-
# Grabbing the default option
|
|
278
|
-
return _proccess_single_telescope(self._array_config_data["default"][tel_size])
|
|
174
|
+
return telescope_model
|
|
279
175
|
|
|
280
176
|
def print_telescope_list(self):
|
|
281
|
-
"""Print
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
print(f"Name: {tel_data.name}\t Model: {tel_model.name}")
|
|
177
|
+
"""Print list of telescopes."""
|
|
178
|
+
for tel_name, data in self.telescope_model.items():
|
|
179
|
+
print(f"Name: {tel_name}\t Model: {data.name}")
|
|
285
180
|
|
|
286
181
|
def export_simtel_telescope_config_files(self):
|
|
287
|
-
"""
|
|
288
|
-
Export sim_telarray config files for all the telescopes into the output model directory.
|
|
289
|
-
"""
|
|
290
|
-
|
|
182
|
+
"""Export sim_telarray configuration files for all telescopes into the model directory."""
|
|
291
183
|
exported_models = []
|
|
292
|
-
for tel_model in self.
|
|
184
|
+
for _, tel_model in self.telescope_model.items():
|
|
293
185
|
name = tel_model.name + (
|
|
294
186
|
"_" + tel_model.extra_label if tel_model.extra_label != "" else ""
|
|
295
187
|
)
|
|
296
188
|
if name not in exported_models:
|
|
297
|
-
self._logger.debug(f"Exporting
|
|
189
|
+
self._logger.debug(f"Exporting configuration file for telescope {name}")
|
|
298
190
|
tel_model.export_config_file()
|
|
299
191
|
exported_models.append(name)
|
|
300
192
|
else:
|
|
301
|
-
self._logger.debug(
|
|
193
|
+
self._logger.debug(
|
|
194
|
+
f"Configuration file for telescope {name} already exists - skipping"
|
|
195
|
+
)
|
|
302
196
|
|
|
303
197
|
self._telescope_model_files_exported = True
|
|
304
198
|
|
|
305
199
|
def export_simtel_array_config_file(self):
|
|
306
|
-
"""
|
|
307
|
-
Export sim_telarray config file for the array into the output model directory.
|
|
308
|
-
"""
|
|
309
|
-
|
|
200
|
+
"""Export sim_telarray configuration file for the array into the model directory."""
|
|
310
201
|
# Setting file name and the location
|
|
311
|
-
config_file_name = names.
|
|
312
|
-
self.layout_name,
|
|
202
|
+
config_file_name = names.simtel_config_file_name(
|
|
203
|
+
array_name=self.layout_name,
|
|
204
|
+
site=self.site_model.site,
|
|
205
|
+
model_version=self.model_version,
|
|
206
|
+
label=self.label,
|
|
313
207
|
)
|
|
314
|
-
self._config_file_path = self.
|
|
208
|
+
self._config_file_path = self.get_config_directory().joinpath(config_file_name)
|
|
315
209
|
|
|
316
210
|
# Writing parameters to the file
|
|
317
|
-
self._logger.info(f"Writing array
|
|
211
|
+
self._logger.info(f"Writing array configuration file into {self._config_file_path}")
|
|
318
212
|
simtel_writer = SimtelConfigWriter(
|
|
319
|
-
site=self.site,
|
|
213
|
+
site=self.site_model.site,
|
|
320
214
|
layout_name=self.layout_name,
|
|
321
215
|
model_version=self.model_version,
|
|
322
216
|
label=self.label,
|
|
323
217
|
)
|
|
324
218
|
simtel_writer.write_array_config_file(
|
|
325
219
|
config_file_path=self._config_file_path,
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
site_parameters=self._site_parameters,
|
|
220
|
+
telescope_model=self.telescope_model,
|
|
221
|
+
site_model=self.site_model,
|
|
329
222
|
)
|
|
330
223
|
self._array_model_file_exported = True
|
|
331
224
|
|
|
332
225
|
def export_all_simtel_config_files(self):
|
|
333
226
|
"""
|
|
334
|
-
Export sim_telarray config file for the array and for each individual telescope
|
|
335
|
-
output model directory.
|
|
336
|
-
"""
|
|
227
|
+
Export sim_telarray config file for the array and for each individual telescope.
|
|
337
228
|
|
|
229
|
+
Config files are exported into the output model directory.
|
|
230
|
+
"""
|
|
338
231
|
if not self._telescope_model_files_exported:
|
|
339
232
|
self.export_simtel_telescope_config_files()
|
|
340
233
|
if not self._array_model_file_exported:
|
|
@@ -342,15 +235,15 @@ class ArrayModel:
|
|
|
342
235
|
|
|
343
236
|
def get_config_file(self):
|
|
344
237
|
"""
|
|
345
|
-
|
|
346
|
-
|
|
238
|
+
Return the path of the array config file for sim_telarray.
|
|
239
|
+
|
|
240
|
+
A new config file is produced if the file is not updated.
|
|
347
241
|
|
|
348
242
|
Returns
|
|
349
243
|
-------
|
|
350
244
|
Path
|
|
351
245
|
Path of the exported config file for sim_telarray.
|
|
352
246
|
"""
|
|
353
|
-
|
|
354
247
|
self.export_all_simtel_config_files()
|
|
355
248
|
return self._config_file_path
|
|
356
249
|
|
|
@@ -363,4 +256,160 @@ class ArrayModel:
|
|
|
363
256
|
Path
|
|
364
257
|
Path of the config directory path for sim_telarray.
|
|
365
258
|
"""
|
|
259
|
+
if self._config_file_directory is None:
|
|
260
|
+
self._config_file_directory = self.io_handler.get_output_directory(self.label, "model")
|
|
366
261
|
return self._config_file_directory
|
|
262
|
+
|
|
263
|
+
def _load_array_element_positions_from_file(self, array_elements_file, site):
|
|
264
|
+
"""
|
|
265
|
+
Load array element (e.g. telescope) positions from a file into a dict.
|
|
266
|
+
|
|
267
|
+
Dictionary format: {telescope_name: {position_x: x, position_y: y, position_z: z}}
|
|
268
|
+
|
|
269
|
+
Parameters
|
|
270
|
+
----------
|
|
271
|
+
array_elements_file: str
|
|
272
|
+
Path to the file with the array element positions.
|
|
273
|
+
site: str
|
|
274
|
+
Site name.
|
|
275
|
+
|
|
276
|
+
Returns
|
|
277
|
+
-------
|
|
278
|
+
dict
|
|
279
|
+
Dict with telescope positions.
|
|
280
|
+
"""
|
|
281
|
+
table = data_reader.read_table_from_file(file_name=array_elements_file)
|
|
282
|
+
|
|
283
|
+
return {
|
|
284
|
+
row["telescope_name"]: self._get_telescope_position_parameter(
|
|
285
|
+
row["telescope_name"], site, row["position_x"], row["position_y"], row["position_z"]
|
|
286
|
+
)
|
|
287
|
+
for row in table
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
def _get_telescope_position_parameter(self, telescope_name, site, x, y, z):
|
|
291
|
+
"""
|
|
292
|
+
Return dictionary with telescope position parameters (following DB model database format).
|
|
293
|
+
|
|
294
|
+
Parameters
|
|
295
|
+
----------
|
|
296
|
+
telescope_name: str
|
|
297
|
+
Name of the telescope.
|
|
298
|
+
site: str
|
|
299
|
+
Site name.
|
|
300
|
+
x: astropy.Quantity
|
|
301
|
+
X ground position.
|
|
302
|
+
y: astropy.Quantity
|
|
303
|
+
Y ground position.
|
|
304
|
+
z: astropy.Quantity
|
|
305
|
+
Z ground position.
|
|
306
|
+
|
|
307
|
+
Returns
|
|
308
|
+
-------
|
|
309
|
+
dict
|
|
310
|
+
Dict with telescope position parameters.
|
|
311
|
+
"""
|
|
312
|
+
return {
|
|
313
|
+
"parameter": "array_element_position_ground",
|
|
314
|
+
"instrument": telescope_name,
|
|
315
|
+
"site": site,
|
|
316
|
+
"version": self.model_version,
|
|
317
|
+
"value": general.convert_list_to_string(
|
|
318
|
+
[x.to("m").value, y.to("m").value, z.to("m").value]
|
|
319
|
+
),
|
|
320
|
+
"unit": "m",
|
|
321
|
+
"type": "float64",
|
|
322
|
+
"applicable": True,
|
|
323
|
+
"file": False,
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
def _get_array_elements_from_list(self, array_elements_list):
|
|
327
|
+
"""
|
|
328
|
+
Return dictionary with array elements from a list of telescope names.
|
|
329
|
+
|
|
330
|
+
Input list can contain telescope names (e.g, LSTN-01) or a telescope
|
|
331
|
+
type (e.g., MSTN). In the latter case, all telescopes of this specific
|
|
332
|
+
type are added.
|
|
333
|
+
|
|
334
|
+
Parameters
|
|
335
|
+
----------
|
|
336
|
+
array_elements_list: list
|
|
337
|
+
List of telescope names.
|
|
338
|
+
|
|
339
|
+
Returns
|
|
340
|
+
-------
|
|
341
|
+
dict
|
|
342
|
+
Dict with array elements.
|
|
343
|
+
"""
|
|
344
|
+
array_elements_dict = {}
|
|
345
|
+
for name in array_elements_list:
|
|
346
|
+
try:
|
|
347
|
+
array_elements_dict[names.validate_array_element_name(name)] = None
|
|
348
|
+
except ValueError:
|
|
349
|
+
array_elements_dict.update(self._get_all_array_elements_of_type(name))
|
|
350
|
+
return array_elements_dict
|
|
351
|
+
|
|
352
|
+
def _get_all_array_elements_of_type(self, array_element_type):
|
|
353
|
+
"""
|
|
354
|
+
Return all array elements of a specific type using the database.
|
|
355
|
+
|
|
356
|
+
Parameters
|
|
357
|
+
----------
|
|
358
|
+
array_element_type : str
|
|
359
|
+
Type of the array element (e.g. LSTN, MSTS)
|
|
360
|
+
|
|
361
|
+
Returns
|
|
362
|
+
-------
|
|
363
|
+
dict
|
|
364
|
+
Dict with array elements.
|
|
365
|
+
"""
|
|
366
|
+
all_elements = db_array_elements.get_array_elements_of_type(
|
|
367
|
+
array_element_type=array_element_type,
|
|
368
|
+
db=self.db,
|
|
369
|
+
model_version=self.model_version,
|
|
370
|
+
collection="telescopes",
|
|
371
|
+
)
|
|
372
|
+
return self._get_array_elements_from_list(all_elements)
|
|
373
|
+
|
|
374
|
+
def export_array_elements_as_table(self, coordinate_system="ground"):
|
|
375
|
+
"""
|
|
376
|
+
Export array elements positions to astropy table.
|
|
377
|
+
|
|
378
|
+
Parameters
|
|
379
|
+
----------
|
|
380
|
+
coordinate_system: str
|
|
381
|
+
Positions are exported in this coordinate system.
|
|
382
|
+
|
|
383
|
+
Returns
|
|
384
|
+
-------
|
|
385
|
+
astropy.table.QTable
|
|
386
|
+
Astropy table with the telescope layout information.
|
|
387
|
+
"""
|
|
388
|
+
table = QTable(meta={"array_name": self.layout_name, "site": self.site_model.site})
|
|
389
|
+
|
|
390
|
+
name, pos_x, pos_y, pos_z, tel_r = [], [], [], [], []
|
|
391
|
+
for tel_name, data in self.telescope_model.items():
|
|
392
|
+
name.append(tel_name)
|
|
393
|
+
xyz = data.position(coordinate_system=coordinate_system)
|
|
394
|
+
pos_x.append(xyz[0])
|
|
395
|
+
pos_y.append(xyz[1])
|
|
396
|
+
pos_z.append(xyz[2])
|
|
397
|
+
try:
|
|
398
|
+
# add tests of KeyError after positions calibration_elements are added to DB
|
|
399
|
+
tel_r.append(data.get_parameter_value_with_unit("telescope_sphere_radius"))
|
|
400
|
+
except KeyError: # not all array elements have a sphere radius
|
|
401
|
+
tel_r.append(0.0 * u.m)
|
|
402
|
+
|
|
403
|
+
table["telescope_name"] = name
|
|
404
|
+
if coordinate_system == "ground":
|
|
405
|
+
table["position_x"] = pos_x
|
|
406
|
+
table["position_y"] = pos_y
|
|
407
|
+
table["position_z"] = pos_z
|
|
408
|
+
elif coordinate_system == "utm":
|
|
409
|
+
table["utm_east"] = pos_x
|
|
410
|
+
table["utm_north"] = pos_y
|
|
411
|
+
table["altitude"] = pos_z
|
|
412
|
+
table["sphere_radius"] = tel_r
|
|
413
|
+
|
|
414
|
+
table.sort("telescope_name")
|
|
415
|
+
return table
|