gammasimtools 0.18.0__py3-none-any.whl → 0.20.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {gammasimtools-0.18.0.dist-info → gammasimtools-0.20.0.dist-info}/METADATA +24 -69
- gammasimtools-0.20.0.dist-info/RECORD +395 -0
- {gammasimtools-0.18.0.dist-info → gammasimtools-0.20.0.dist-info}/entry_points.txt +11 -4
- {gammasimtools-0.18.0.dist-info → gammasimtools-0.20.0.dist-info}/licenses/LICENSE +1 -1
- simtools/_version.py +16 -3
- simtools/applications/calculate_incident_angles.py +182 -0
- simtools/applications/convert_all_model_parameters_from_simtel.py +4 -3
- simtools/applications/convert_geo_coordinates_of_array_elements.py +3 -3
- simtools/applications/db_add_simulation_model_from_repository_to_db.py +17 -14
- simtools/applications/db_add_value_from_json_to_db.py +8 -10
- simtools/applications/db_development_tools/write_array_elements_positions_to_repository.py +8 -13
- simtools/applications/db_generate_compound_indexes.py +65 -0
- simtools/applications/db_get_file_from_db.py +12 -24
- simtools/applications/db_get_parameter_from_db.py +4 -4
- simtools/applications/db_inspect_databases.py +20 -10
- simtools/applications/derive_mirror_rnda.py +17 -11
- simtools/applications/derive_psf_parameters.py +59 -309
- simtools/applications/derive_trigger_rates.py +91 -0
- simtools/applications/docs_produce_array_element_report.py +1 -1
- simtools/applications/docs_produce_calibration_reports.py +1 -1
- simtools/applications/docs_produce_model_parameter_reports.py +1 -1
- simtools/applications/docs_produce_simulation_configuration_report.py +1 -1
- simtools/applications/generate_corsika_histograms.py +1 -1
- simtools/applications/generate_default_metadata.py +8 -24
- simtools/applications/generate_simtel_event_data.py +11 -11
- simtools/applications/maintain_simulation_model_add_production_table.py +71 -0
- simtools/applications/maintain_simulation_model_compare_productions.py +98 -0
- simtools/applications/{verify_simulation_model_production_tables.py → maintain_simulation_model_verify_production_tables.py} +9 -1
- simtools/applications/merge_tables.py +2 -2
- simtools/applications/plot_array_layout.py +3 -3
- simtools/applications/plot_simtel_events.py +421 -0
- simtools/applications/plot_tabular_data.py +9 -2
- simtools/applications/plot_tabular_data_for_model_parameter.py +2 -1
- simtools/applications/print_version.py +8 -9
- simtools/applications/production_derive_corsika_limits.py +6 -7
- simtools/applications/production_derive_statistics.py +1 -1
- simtools/applications/production_generate_grid.py +2 -2
- simtools/applications/production_merge_corsika_limits.py +214 -0
- simtools/applications/run_application.py +47 -113
- simtools/applications/simulate_calibration_events.py +166 -0
- simtools/applications/simulate_flasher.py +141 -0
- simtools/applications/{simulate_light_emission.py → simulate_illuminator.py} +35 -99
- simtools/applications/simulate_prod.py +6 -24
- simtools/applications/simulate_prod_htcondor_generator.py +7 -0
- simtools/applications/submit_array_layouts.py +2 -1
- simtools/applications/submit_model_parameter_from_external.py +1 -1
- simtools/applications/validate_camera_efficiency.py +30 -12
- simtools/applications/validate_camera_fov.py +1 -1
- simtools/applications/validate_cumulative_psf.py +1 -1
- simtools/applications/validate_file_using_schema.py +9 -5
- simtools/applications/validate_optics.py +1 -1
- simtools/camera/camera_efficiency.py +61 -45
- simtools/camera/single_photon_electron_spectrum.py +1 -1
- simtools/configuration/commandline_parser.py +46 -11
- simtools/configuration/configurator.py +4 -4
- simtools/corsika/corsika_config.py +45 -25
- simtools/corsika/corsika_histograms.py +6 -5
- simtools/data_model/data_reader.py +2 -3
- simtools/data_model/metadata_collector.py +32 -36
- simtools/data_model/metadata_model.py +15 -12
- simtools/data_model/model_data_writer.py +13 -32
- simtools/data_model/schema.py +74 -24
- simtools/data_model/validate_data.py +42 -12
- simtools/db/db_handler.py +125 -62
- simtools/db/db_model_upload.py +14 -19
- simtools/dependencies.py +98 -30
- simtools/io/ascii_handler.py +279 -0
- simtools/{io_operations → io}/io_handler.py +25 -3
- simtools/job_execution/htcondor_script_generator.py +15 -4
- simtools/layout/array_layout.py +1 -1
- simtools/layout/array_layout_utils.py +51 -12
- simtools/model/array_model.py +41 -5
- simtools/model/flasher_model.py +106 -0
- simtools/model/model_parameter.py +4 -4
- simtools/model/model_repository.py +197 -2
- simtools/model/site_model.py +25 -0
- simtools/model/telescope_model.py +3 -1
- simtools/production_configuration/derive_corsika_limits.py +336 -427
- simtools/production_configuration/derive_production_statistics_handler.py +7 -6
- simtools/production_configuration/generate_production_grid.py +9 -11
- simtools/production_configuration/merge_corsika_limits.py +528 -0
- simtools/ray_tracing/incident_angles.py +706 -0
- simtools/ray_tracing/mirror_panel_psf.py +1 -0
- simtools/ray_tracing/psf_parameter_optimisation.py +792 -0
- simtools/ray_tracing/ray_tracing.py +6 -2
- simtools/reporting/docs_read_parameters.py +150 -62
- simtools/runners/corsika_runner.py +1 -1
- simtools/runners/corsika_simtel_runner.py +14 -5
- simtools/runners/runner_services.py +10 -5
- simtools/runners/simtools_runner.py +267 -0
- simtools/schemas/application_workflow.metaschema.yml +101 -68
- simtools/schemas/input/MST_mirror_2f_measurements.schema.yml +1 -1
- simtools/schemas/input/single_pe_spectrum.schema.yml +1 -1
- simtools/schemas/metadata.metaschema.yml +577 -3
- simtools/schemas/model_parameter.metaschema.yml +6 -6
- simtools/schemas/model_parameter_and_data_schema.metaschema.yml +4 -4
- simtools/schemas/model_parameters/adjust_gain.schema.yml +1 -1
- simtools/schemas/model_parameters/altitude.schema.yml +1 -1
- simtools/schemas/model_parameters/array_coordinates.schema.yml +1 -1
- simtools/schemas/model_parameters/array_coordinates_UTM.schema.yml +1 -1
- simtools/schemas/model_parameters/array_element_position_ground.schema.yml +1 -1
- simtools/schemas/model_parameters/array_element_position_utm.schema.yml +1 -1
- simtools/schemas/model_parameters/array_layouts.schema.yml +1 -1
- simtools/schemas/model_parameters/array_triggers.schema.yml +1 -1
- simtools/schemas/model_parameters/array_window.schema.yml +1 -1
- simtools/schemas/model_parameters/asum_clipping.schema.yml +1 -1
- simtools/schemas/model_parameters/asum_offset.schema.yml +1 -1
- simtools/schemas/model_parameters/asum_shaping.schema.yml +1 -1
- simtools/schemas/model_parameters/asum_threshold.schema.yml +1 -1
- simtools/schemas/model_parameters/atmospheric_profile.schema.yml +1 -1
- simtools/schemas/model_parameters/atmospheric_transmission.schema.yml +1 -1
- simtools/schemas/model_parameters/axes_offsets.schema.yml +1 -1
- simtools/schemas/model_parameters/camera_body_diameter.schema.yml +1 -1
- simtools/schemas/model_parameters/camera_body_shape.schema.yml +1 -1
- simtools/schemas/model_parameters/camera_config_file.schema.yml +1 -1
- simtools/schemas/model_parameters/camera_config_rotate.schema.yml +1 -1
- simtools/schemas/model_parameters/camera_degraded_efficiency.schema.yml +1 -1
- simtools/schemas/model_parameters/camera_degraded_map.schema.yml +1 -1
- simtools/schemas/model_parameters/camera_depth.schema.yml +1 -1
- simtools/schemas/model_parameters/camera_filter.schema.yml +1 -1
- simtools/schemas/model_parameters/camera_filter_incidence_angle.schema.yml +1 -1
- simtools/schemas/model_parameters/camera_pixels.schema.yml +1 -1
- simtools/schemas/model_parameters/camera_transmission.schema.yml +1 -1
- simtools/schemas/model_parameters/channels_per_chip.schema.yml +1 -1
- simtools/schemas/model_parameters/correct_nsb_spectrum_to_telescope_altitude.schema.yml +1 -1
- simtools/schemas/model_parameters/corsika_cherenkov_photon_bunch_size.schema.yml +1 -1
- simtools/schemas/model_parameters/corsika_cherenkov_photon_wavelength_range.schema.yml +1 -1
- simtools/schemas/model_parameters/corsika_first_interaction_height.schema.yml +1 -1
- simtools/schemas/model_parameters/corsika_iact_io_buffer.schema.yml +1 -1
- simtools/schemas/model_parameters/corsika_iact_max_bunches.schema.yml +1 -1
- simtools/schemas/model_parameters/corsika_iact_split_auto.schema.yml +1 -1
- simtools/schemas/model_parameters/corsika_longitudinal_shower_development.schema.yml +1 -1
- simtools/schemas/model_parameters/corsika_observation_level.schema.yml +1 -1
- simtools/schemas/model_parameters/corsika_particle_kinetic_energy_cutoff.schema.yml +1 -1
- simtools/schemas/model_parameters/corsika_starting_grammage.schema.yml +3 -3
- simtools/schemas/model_parameters/dark_events.schema.yml +1 -1
- simtools/schemas/model_parameters/default_trigger.schema.yml +1 -1
- simtools/schemas/model_parameters/design_model.schema.yml +1 -1
- simtools/schemas/model_parameters/disc_ac_coupled.schema.yml +1 -1
- simtools/schemas/model_parameters/disc_bins.schema.yml +1 -1
- simtools/schemas/model_parameters/disc_start.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_amplitude.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_fall_time.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_gate_length.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_hysteresis.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_output_amplitude.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_output_var_percent.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_pulse_shape.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_rise_time.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_scale_threshold.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_sigsum_over_threshold.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_threshold.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_time_over_threshold.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_var_gate_length.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_var_sigsum_over_threshold.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_var_threshold.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_var_time_over_threshold.schema.yml +1 -1
- simtools/schemas/model_parameters/dish_shape_length.schema.yml +1 -1
- simtools/schemas/model_parameters/dsum_clipping.schema.yml +1 -1
- simtools/schemas/model_parameters/dsum_ignore_below.schema.yml +1 -1
- simtools/schemas/model_parameters/dsum_offset.schema.yml +1 -1
- simtools/schemas/model_parameters/dsum_pedsub.schema.yml +1 -1
- simtools/schemas/model_parameters/dsum_pre_clipping.schema.yml +1 -1
- simtools/schemas/model_parameters/dsum_prescale.schema.yml +1 -1
- simtools/schemas/model_parameters/dsum_presum_max.schema.yml +1 -1
- simtools/schemas/model_parameters/dsum_presum_shift.schema.yml +1 -1
- simtools/schemas/model_parameters/dsum_shaping.schema.yml +1 -1
- simtools/schemas/model_parameters/dsum_shaping_renormalize.schema.yml +1 -1
- simtools/schemas/model_parameters/dsum_threshold.schema.yml +2 -2
- simtools/schemas/model_parameters/dsum_zero_clip.schema.yml +1 -1
- simtools/schemas/model_parameters/effective_focal_length.schema.yml +1 -1
- simtools/schemas/model_parameters/epsg_code.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_ac_coupled.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_amplitude.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_bins.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_compensate_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_dev_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_err_compensate_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_err_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_lg_amplitude.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_lg_compensate_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_lg_dev_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_lg_err_compensate_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_lg_err_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_lg_max_signal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_lg_max_sum.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_lg_noise.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_lg_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_lg_sensitivity.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_lg_sysvar_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_lg_var_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_lg_var_sensitivity.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_long_event_threshold.schema.yml +35 -0
- simtools/schemas/model_parameters/fadc_long_sum_bins.schema.yml +41 -0
- simtools/schemas/model_parameters/fadc_long_sum_offset.schema.yml +38 -0
- simtools/schemas/model_parameters/fadc_max_signal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_max_sum.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_mhz.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_noise.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_pulse_shape.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_sensitivity.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_sum_bins.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_sum_offset.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_sysvar_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_var_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_var_sensitivity.schema.yml +1 -1
- simtools/schemas/model_parameters/fake_mirror_list.schema.yml +1 -1
- simtools/schemas/model_parameters/flatfielding.schema.yml +1 -1
- simtools/schemas/model_parameters/focal_length.schema.yml +1 -1
- simtools/schemas/model_parameters/focal_surface_parameters.schema.yml +1 -1
- simtools/schemas/model_parameters/focal_surface_ref_radius.schema.yml +1 -1
- simtools/schemas/model_parameters/focus_offset.schema.yml +1 -1
- simtools/schemas/model_parameters/gain_variation.schema.yml +1 -1
- simtools/schemas/model_parameters/geomag_horizontal.schema.yml +1 -1
- simtools/schemas/model_parameters/geomag_rotation.schema.yml +1 -1
- simtools/schemas/model_parameters/geomag_vertical.schema.yml +1 -1
- simtools/schemas/model_parameters/hg_lg_variation.schema.yml +1 -1
- simtools/schemas/model_parameters/iobuf_maximum.schema.yml +1 -1
- simtools/schemas/model_parameters/iobuf_output_maximum.schema.yml +1 -1
- simtools/schemas/model_parameters/laser_events.schema.yml +1 -1
- simtools/schemas/model_parameters/laser_external_trigger.schema.yml +1 -1
- simtools/schemas/model_parameters/laser_photons.schema.yml +1 -1
- simtools/schemas/model_parameters/laser_pulse_exptime.schema.yml +1 -1
- simtools/schemas/model_parameters/laser_pulse_offset.schema.yml +1 -1
- simtools/schemas/model_parameters/laser_pulse_sigtime.schema.yml +1 -1
- simtools/schemas/model_parameters/laser_pulse_twidth.schema.yml +1 -1
- simtools/schemas/model_parameters/laser_var_photons.schema.yml +1 -1
- simtools/schemas/model_parameters/laser_wavelength.schema.yml +1 -1
- simtools/schemas/model_parameters/led_events.schema.yml +1 -1
- simtools/schemas/model_parameters/led_photons.schema.yml +1 -1
- simtools/schemas/model_parameters/led_pulse_offset.schema.yml +1 -1
- simtools/schemas/model_parameters/led_pulse_sigtime.schema.yml +1 -1
- simtools/schemas/model_parameters/led_var_photons.schema.yml +1 -1
- simtools/schemas/model_parameters/lightguide_efficiency_vs_incidence_angle.schema.yml +1 -1
- simtools/schemas/model_parameters/lightguide_efficiency_vs_wavelength.schema.yml +50 -1
- simtools/schemas/model_parameters/min_photoelectrons.schema.yml +1 -1
- simtools/schemas/model_parameters/min_photons.schema.yml +1 -1
- simtools/schemas/model_parameters/mirror_align_random_distance.schema.yml +1 -1
- simtools/schemas/model_parameters/mirror_align_random_horizontal.schema.yml +1 -1
- simtools/schemas/model_parameters/mirror_align_random_vertical.schema.yml +1 -1
- simtools/schemas/model_parameters/mirror_class.schema.yml +1 -1
- simtools/schemas/model_parameters/mirror_degraded_reflection.schema.yml +1 -1
- simtools/schemas/model_parameters/mirror_focal_length.schema.yml +1 -1
- simtools/schemas/model_parameters/mirror_list.schema.yml +1 -1
- simtools/schemas/model_parameters/mirror_offset.schema.yml +1 -1
- simtools/schemas/model_parameters/mirror_panel_2f_measurements.schema.yml +1 -1
- simtools/schemas/model_parameters/mirror_reflection_random_angle.schema.yml +1 -1
- simtools/schemas/model_parameters/mirror_reflectivity.schema.yml +1 -1
- simtools/schemas/model_parameters/multiplicity_offset.schema.yml +1 -1
- simtools/schemas/model_parameters/muon_mono_threshold.schema.yml +1 -1
- simtools/schemas/model_parameters/nsb_autoscale_airmass.schema.yml +1 -1
- simtools/schemas/model_parameters/nsb_gain_drop_scale.schema.yml +1 -1
- simtools/schemas/model_parameters/nsb_offaxis.schema.yml +1 -1
- simtools/schemas/model_parameters/nsb_pixel_rate.schema.yml +1 -1
- simtools/schemas/model_parameters/nsb_reference_spectrum.schema.yml +2 -2
- simtools/schemas/model_parameters/nsb_reference_value.schema.yml +1 -1
- simtools/schemas/model_parameters/nsb_scaling_factor.schema.yml +1 -1
- simtools/schemas/model_parameters/nsb_sky_map.schema.yml +1 -1
- simtools/schemas/model_parameters/nsb_spectrum.schema.yml +23 -30
- simtools/schemas/model_parameters/num_gains.schema.yml +1 -1
- simtools/schemas/model_parameters/only_triggered_telescopes.schema.yml +1 -1
- simtools/schemas/model_parameters/optics_properties.schema.yml +1 -1
- simtools/schemas/model_parameters/parabolic_dish.schema.yml +1 -1
- simtools/schemas/model_parameters/pedestal_events.schema.yml +1 -1
- simtools/schemas/model_parameters/photon_delay.schema.yml +1 -1
- simtools/schemas/model_parameters/photons_per_run.schema.yml +1 -1
- simtools/schemas/model_parameters/pixel_cells.schema.yml +1 -1
- simtools/schemas/model_parameters/pixels_parallel.schema.yml +1 -1
- simtools/schemas/model_parameters/pixeltrg_time_step.schema.yml +1 -1
- simtools/schemas/model_parameters/pm_average_gain.schema.yml +1 -1
- simtools/schemas/model_parameters/pm_collection_efficiency.schema.yml +1 -1
- simtools/schemas/model_parameters/pm_gain_index.schema.yml +1 -1
- simtools/schemas/model_parameters/pm_photoelectron_spectrum.schema.yml +1 -1
- simtools/schemas/model_parameters/pm_transit_time.schema.yml +1 -1
- simtools/schemas/model_parameters/pm_voltage_variation.schema.yml +1 -1
- simtools/schemas/model_parameters/primary_mirror_degraded_map.schema.yml +1 -1
- simtools/schemas/model_parameters/primary_mirror_diameter.schema.yml +1 -1
- simtools/schemas/model_parameters/primary_mirror_hole_diameter.schema.yml +1 -1
- simtools/schemas/model_parameters/primary_mirror_incidence_angle.schema.yml +11 -1
- simtools/schemas/model_parameters/primary_mirror_parameters.schema.yml +1 -1
- simtools/schemas/model_parameters/primary_mirror_ref_radius.schema.yml +1 -1
- simtools/schemas/model_parameters/primary_mirror_segmentation.schema.yml +1 -1
- simtools/schemas/model_parameters/qe_variation.schema.yml +1 -1
- simtools/schemas/model_parameters/quantum_efficiency.schema.yml +1 -1
- simtools/schemas/model_parameters/random_focal_length.schema.yml +1 -1
- simtools/schemas/model_parameters/random_generator.schema.yml +1 -1
- simtools/schemas/model_parameters/random_mono_probability.schema.yml +1 -1
- simtools/schemas/model_parameters/reference_point_altitude.schema.yml +1 -1
- simtools/schemas/model_parameters/reference_point_latitude.schema.yml +1 -1
- simtools/schemas/model_parameters/reference_point_longitude.schema.yml +1 -1
- simtools/schemas/model_parameters/reference_point_utm_east.schema.yml +1 -1
- simtools/schemas/model_parameters/reference_point_utm_north.schema.yml +1 -1
- simtools/schemas/model_parameters/sampled_output.schema.yml +1 -1
- simtools/schemas/model_parameters/save_pe_with_amplitude.schema.yml +1 -1
- simtools/schemas/model_parameters/secondary_mirror_baffle.schema.yml +1 -1
- simtools/schemas/model_parameters/secondary_mirror_degraded_map.schema.yml +1 -1
- simtools/schemas/model_parameters/secondary_mirror_degraded_reflection.schema.yml +1 -1
- simtools/schemas/model_parameters/secondary_mirror_diameter.schema.yml +1 -1
- simtools/schemas/model_parameters/secondary_mirror_hole_diameter.schema.yml +1 -1
- simtools/schemas/model_parameters/secondary_mirror_incidence_angle.schema.yml +11 -1
- simtools/schemas/model_parameters/secondary_mirror_parameters.schema.yml +1 -1
- simtools/schemas/model_parameters/secondary_mirror_ref_radius.schema.yml +1 -1
- simtools/schemas/model_parameters/secondary_mirror_reflectivity.schema.yml +11 -1
- simtools/schemas/model_parameters/secondary_mirror_segmentation.schema.yml +1 -1
- simtools/schemas/model_parameters/secondary_mirror_shadow_diameter.schema.yml +1 -1
- simtools/schemas/model_parameters/secondary_mirror_shadow_offset.schema.yml +1 -1
- simtools/schemas/model_parameters/stars.schema.yml +2 -2
- simtools/schemas/model_parameters/store_photoelectrons.schema.yml +1 -1
- simtools/schemas/model_parameters/tailcut_scale.schema.yml +1 -1
- simtools/schemas/model_parameters/telescope_axis_height.schema.yml +1 -1
- simtools/schemas/model_parameters/telescope_random_angle.schema.yml +1 -1
- simtools/schemas/model_parameters/telescope_random_error.schema.yml +1 -1
- simtools/schemas/model_parameters/telescope_sphere_radius.schema.yml +1 -1
- simtools/schemas/model_parameters/telescope_transmission.schema.yml +1 -1
- simtools/schemas/model_parameters/teltrig_min_sigsum.schema.yml +1 -1
- simtools/schemas/model_parameters/teltrig_min_time.schema.yml +1 -1
- simtools/schemas/model_parameters/transit_time_calib_error.schema.yml +1 -1
- simtools/schemas/model_parameters/transit_time_compensate_error.schema.yml +1 -1
- simtools/schemas/model_parameters/transit_time_compensate_step.schema.yml +1 -1
- simtools/schemas/model_parameters/transit_time_error.schema.yml +1 -1
- simtools/schemas/model_parameters/transit_time_jitter.schema.yml +1 -1
- simtools/schemas/model_parameters/trigger_current_limit.schema.yml +1 -1
- simtools/schemas/model_parameters/trigger_delay_compensation.schema.yml +1 -1
- simtools/schemas/model_parameters/trigger_pixels.schema.yml +1 -1
- simtools/schemas/plot_configuration.metaschema.yml +5 -2
- simtools/schemas/production_configuration_metrics.schema.yml +12 -2
- simtools/schemas/production_tables.schema.yml +7 -2
- simtools/simtel/simtel_config_reader.py +2 -2
- simtools/simtel/simtel_config_writer.py +33 -23
- simtools/simtel/simtel_io_event_histograms.py +483 -0
- simtools/simtel/simtel_io_event_reader.py +65 -43
- simtools/simtel/simtel_io_event_writer.py +40 -20
- simtools/simtel/simtel_io_metadata.py +1 -1
- simtools/simtel/simtel_table_reader.py +95 -13
- simtools/simtel/simulator_array.py +138 -10
- simtools/simtel/simulator_camera_efficiency.py +32 -23
- simtools/simtel/simulator_light_emission.py +437 -271
- simtools/simtel/simulator_ray_tracing.py +1 -1
- simtools/simulator.py +105 -147
- simtools/telescope_trigger_rates.py +119 -0
- simtools/testing/configuration.py +24 -26
- simtools/testing/helpers.py +2 -2
- simtools/testing/log_inspector.py +52 -0
- simtools/testing/validate_output.py +87 -37
- simtools/utils/general.py +125 -255
- simtools/utils/geometry.py +56 -0
- simtools/utils/names.py +1 -1
- simtools/visualization/legend_handlers.py +180 -264
- simtools/visualization/plot_array_layout.py +20 -8
- simtools/visualization/plot_incident_angles.py +431 -0
- simtools/visualization/plot_pixels.py +1 -1
- simtools/visualization/plot_simtel_event_histograms.py +376 -0
- simtools/visualization/plot_simtel_events.py +816 -0
- simtools/visualization/plot_tables.py +133 -37
- simtools/visualization/visualize.py +1 -100
- gammasimtools-0.18.0.dist-info/RECORD +0 -376
- simtools/applications/calculate_trigger_rate.py +0 -187
- simtools/applications/generate_sim_telarray_histograms.py +0 -196
- simtools/production_configuration/derive_corsika_limits_grid.py +0 -232
- simtools/simtel/simtel_io_histogram.py +0 -621
- simtools/simtel/simtel_io_histograms.py +0 -552
- {gammasimtools-0.18.0.dist-info → gammasimtools-0.20.0.dist-info}/WHEEL +0 -0
- {gammasimtools-0.18.0.dist-info → gammasimtools-0.20.0.dist-info}/top_level.txt +0 -0
- /simtools/{io_operations → io}/hdf5_handler.py +0 -0
- /simtools/{io_operations → io}/legacy_data_handler.py +0 -0
- /simtools/{io_operations/io_table_handler.py → io/table_handler.py} +0 -0
simtools/dependencies.py
CHANGED
|
@@ -14,46 +14,75 @@ import re
|
|
|
14
14
|
import subprocess
|
|
15
15
|
from pathlib import Path
|
|
16
16
|
|
|
17
|
-
import
|
|
17
|
+
import yaml
|
|
18
|
+
|
|
18
19
|
from simtools.db.db_handler import DatabaseHandler
|
|
20
|
+
from simtools.io import ascii_handler
|
|
19
21
|
|
|
20
22
|
_logger = logging.getLogger(__name__)
|
|
21
23
|
|
|
22
24
|
|
|
23
|
-
def get_version_string(db_config=None):
|
|
24
|
-
"""
|
|
25
|
+
def get_version_string(db_config=None, run_time=None):
|
|
26
|
+
"""
|
|
27
|
+
Print the versions of the dependencies.
|
|
28
|
+
|
|
29
|
+
Parameters
|
|
30
|
+
----------
|
|
31
|
+
db_config : dict, optional
|
|
32
|
+
Database configuration dictionary.
|
|
33
|
+
run_time : list, optional
|
|
34
|
+
Runtime environment command (e.g., Docker).
|
|
35
|
+
|
|
36
|
+
Returns
|
|
37
|
+
-------
|
|
38
|
+
str
|
|
39
|
+
String containing the versions of the dependencies.
|
|
40
|
+
|
|
41
|
+
"""
|
|
25
42
|
return (
|
|
26
|
-
f"Database
|
|
27
|
-
f"
|
|
28
|
-
f"
|
|
43
|
+
f"Database name: {get_database_version_or_name(db_config, version=False)}\n"
|
|
44
|
+
f"Database version: {get_database_version_or_name(db_config, version=True)}\n"
|
|
45
|
+
f"sim_telarray version: {get_sim_telarray_version(run_time)}\n"
|
|
46
|
+
f"CORSIKA version: {get_corsika_version(run_time)}\n"
|
|
47
|
+
f"Build options: {get_build_options(run_time)}\n"
|
|
48
|
+
f"Runtime environment: {run_time if run_time else 'None'}\n"
|
|
29
49
|
)
|
|
30
50
|
|
|
31
51
|
|
|
32
|
-
def
|
|
52
|
+
def get_database_version_or_name(db_config, version=True):
|
|
33
53
|
"""
|
|
34
|
-
Get the version of the simulation model data base used.
|
|
54
|
+
Get the version or name of the simulation model data base used.
|
|
35
55
|
|
|
36
56
|
Parameters
|
|
37
57
|
----------
|
|
38
58
|
db_config : dict
|
|
39
59
|
Dictionary containing the database configuration.
|
|
60
|
+
version : bool
|
|
61
|
+
If True, return the version of the database. If False, return the name.
|
|
40
62
|
|
|
41
63
|
Returns
|
|
42
64
|
-------
|
|
43
65
|
str
|
|
44
|
-
Version of the simulation model data base used.
|
|
66
|
+
Version or name of the simulation model data base used.
|
|
45
67
|
|
|
46
68
|
"""
|
|
47
69
|
if db_config is None:
|
|
48
70
|
return None
|
|
49
71
|
db = DatabaseHandler(db_config)
|
|
50
|
-
return db.mongo_db_config.get(
|
|
72
|
+
return db.mongo_db_config.get(
|
|
73
|
+
"db_simulation_model_version" if version else "db_simulation_model"
|
|
74
|
+
)
|
|
51
75
|
|
|
52
76
|
|
|
53
|
-
def get_sim_telarray_version():
|
|
77
|
+
def get_sim_telarray_version(run_time):
|
|
54
78
|
"""
|
|
55
79
|
Get the version of the sim_telarray package using 'sim_telarray --version'.
|
|
56
80
|
|
|
81
|
+
Parameters
|
|
82
|
+
----------
|
|
83
|
+
run_time : list, optional
|
|
84
|
+
Runtime environment command (e.g., Docker).
|
|
85
|
+
|
|
57
86
|
Returns
|
|
58
87
|
-------
|
|
59
88
|
str
|
|
@@ -65,24 +94,33 @@ def get_sim_telarray_version():
|
|
|
65
94
|
return None
|
|
66
95
|
sim_telarray_path = Path(sim_telarray_path) / "sim_telarray" / "bin" / "sim_telarray"
|
|
67
96
|
|
|
97
|
+
if run_time is None:
|
|
98
|
+
command = [str(sim_telarray_path), "--version"]
|
|
99
|
+
else:
|
|
100
|
+
command = [*run_time, str(sim_telarray_path), "--version"]
|
|
101
|
+
|
|
102
|
+
_logger.debug(f"Running command: {command}")
|
|
103
|
+
result = subprocess.run(command, capture_output=True, text=True, check=False)
|
|
104
|
+
|
|
68
105
|
# expect stdout with e.g. a line 'Release: 2024.271.0 from 2024-09-27'
|
|
69
|
-
result = subprocess.run(
|
|
70
|
-
[sim_telarray_path, "--version"],
|
|
71
|
-
capture_output=True,
|
|
72
|
-
text=True,
|
|
73
|
-
check=False,
|
|
74
|
-
)
|
|
75
106
|
match = re.search(r"^Release:\s+(.+)", result.stdout, re.MULTILINE)
|
|
76
|
-
|
|
77
107
|
if match:
|
|
78
108
|
return match.group(1).split()[0]
|
|
109
|
+
|
|
110
|
+
_logger.debug(f"Command output stdout: {result.stdout} stderr: {result.stderr}")
|
|
111
|
+
|
|
79
112
|
raise ValueError(f"sim_telarray release not found in {result.stdout}")
|
|
80
113
|
|
|
81
114
|
|
|
82
|
-
def get_corsika_version():
|
|
115
|
+
def get_corsika_version(run_time=None):
|
|
83
116
|
"""
|
|
84
117
|
Get the version of the CORSIKA package.
|
|
85
118
|
|
|
119
|
+
Parameters
|
|
120
|
+
----------
|
|
121
|
+
run_time : list, optional
|
|
122
|
+
Runtime environment command (e.g., Docker).
|
|
123
|
+
|
|
86
124
|
Returns
|
|
87
125
|
-------
|
|
88
126
|
str
|
|
@@ -95,10 +133,15 @@ def get_corsika_version():
|
|
|
95
133
|
return None
|
|
96
134
|
corsika_command = Path(sim_telarray_path) / "corsika-run" / "corsika"
|
|
97
135
|
|
|
136
|
+
if run_time is None:
|
|
137
|
+
command = [str(corsika_command)]
|
|
138
|
+
else:
|
|
139
|
+
command = [*run_time, str(corsika_command)]
|
|
140
|
+
|
|
98
141
|
# Below I do not use the standard context manager because
|
|
99
142
|
# it makes mocking in the tests significantly more difficult
|
|
100
143
|
process = subprocess.Popen( # pylint: disable=consider-using-with
|
|
101
|
-
|
|
144
|
+
command,
|
|
102
145
|
stdout=subprocess.PIPE,
|
|
103
146
|
stderr=subprocess.PIPE,
|
|
104
147
|
stdin=subprocess.PIPE,
|
|
@@ -123,25 +166,50 @@ def get_corsika_version():
|
|
|
123
166
|
if version and re.match(r"\d+\.\d+", version):
|
|
124
167
|
return version
|
|
125
168
|
try:
|
|
126
|
-
build_opts = get_build_options()
|
|
127
|
-
except (FileNotFoundError, TypeError):
|
|
169
|
+
build_opts = get_build_options(run_time)
|
|
170
|
+
except (FileNotFoundError, TypeError, ValueError):
|
|
128
171
|
_logger.warning("Could not get CORSIKA version.")
|
|
129
172
|
return None
|
|
130
173
|
_logger.debug("Getting the CORSIKA version from the build options.")
|
|
131
174
|
return build_opts.get("corsika_version")
|
|
132
175
|
|
|
133
176
|
|
|
134
|
-
def get_build_options():
|
|
177
|
+
def get_build_options(run_time=None):
|
|
135
178
|
"""
|
|
136
179
|
Return CORSIKA / sim_telarray build options.
|
|
137
180
|
|
|
138
181
|
Expects a build_opts.yml file in the sim_telarray directory.
|
|
182
|
+
|
|
183
|
+
Parameters
|
|
184
|
+
----------
|
|
185
|
+
run_time : list, optional
|
|
186
|
+
Runtime environment command (e.g., Docker).
|
|
187
|
+
|
|
188
|
+
Returns
|
|
189
|
+
-------
|
|
190
|
+
dict
|
|
191
|
+
Build options from build_opts.yml file.
|
|
139
192
|
"""
|
|
193
|
+
sim_telarray_path = os.getenv("SIMTOOLS_SIMTEL_PATH")
|
|
194
|
+
if sim_telarray_path is None:
|
|
195
|
+
raise ValueError("SIMTOOLS_SIMTEL_PATH not defined.")
|
|
196
|
+
|
|
197
|
+
build_opts_path = Path(sim_telarray_path) / "build_opts.yml"
|
|
198
|
+
|
|
199
|
+
if run_time is None:
|
|
200
|
+
try:
|
|
201
|
+
return ascii_handler.collect_data_from_file(build_opts_path)
|
|
202
|
+
except FileNotFoundError as exc:
|
|
203
|
+
raise FileNotFoundError("No build_opts.yml file found.") from exc
|
|
204
|
+
|
|
205
|
+
command = [*run_time, "cat", str(build_opts_path)]
|
|
206
|
+
_logger.debug(f"Reading build_opts.yml with command: {command}")
|
|
207
|
+
|
|
208
|
+
result = subprocess.run(command, capture_output=True, text=True, check=False)
|
|
209
|
+
if result.returncode:
|
|
210
|
+
raise FileNotFoundError(f"No build_opts.yml file found in container: {result.stderr}")
|
|
211
|
+
|
|
140
212
|
try:
|
|
141
|
-
return
|
|
142
|
-
|
|
143
|
-
)
|
|
144
|
-
except FileNotFoundError as exc:
|
|
145
|
-
raise FileNotFoundError("No build_opts.yml file found.") from exc
|
|
146
|
-
except TypeError as exc:
|
|
147
|
-
raise TypeError("SIMTOOLS_SIMTEL_PATH not defined.") from exc
|
|
213
|
+
return yaml.safe_load(result.stdout)
|
|
214
|
+
except yaml.YAMLError as exc:
|
|
215
|
+
raise ValueError(f"Error parsing build_opts.yml from container: {exc}") from exc
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
"""Helper module for ASCII file operations."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import logging
|
|
5
|
+
import tempfile
|
|
6
|
+
import urllib.request
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
import astropy.units as u
|
|
10
|
+
import numpy as np
|
|
11
|
+
import yaml
|
|
12
|
+
|
|
13
|
+
from simtools.utils.general import is_url
|
|
14
|
+
|
|
15
|
+
_logger = logging.getLogger(__name__)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def collect_data_from_file(file_name, yaml_document=None):
|
|
19
|
+
"""
|
|
20
|
+
Collect data from file based on its extension.
|
|
21
|
+
|
|
22
|
+
Parameters
|
|
23
|
+
----------
|
|
24
|
+
file_name: str
|
|
25
|
+
Name of the yaml/json/ascii file.
|
|
26
|
+
yaml_document: None, int
|
|
27
|
+
Return list of yaml documents or a single document (for yaml files with several documents).
|
|
28
|
+
|
|
29
|
+
Returns
|
|
30
|
+
-------
|
|
31
|
+
data: dict or list
|
|
32
|
+
Data as dict or list.
|
|
33
|
+
"""
|
|
34
|
+
if is_url(file_name):
|
|
35
|
+
return collect_data_from_http(file_name)
|
|
36
|
+
|
|
37
|
+
suffix = Path(file_name).suffix.lower()
|
|
38
|
+
try:
|
|
39
|
+
with open(file_name, encoding="utf-8") as file:
|
|
40
|
+
return _collect_data_from_different_file_types(file, file_name, suffix, yaml_document)
|
|
41
|
+
# broad exception to catch all possible errors in reading the file
|
|
42
|
+
except Exception as exc: # pylint: disable=broad-except
|
|
43
|
+
raise type(exc)(f"Failed to read file {file_name}: {exc}") from exc
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _collect_data_from_different_file_types(file, file_name, suffix, yaml_document):
|
|
47
|
+
"""Collect data from different file types."""
|
|
48
|
+
if suffix == ".json":
|
|
49
|
+
return json.load(file)
|
|
50
|
+
if suffix in (".list", ".txt"):
|
|
51
|
+
return [line.strip() for line in file.readlines()]
|
|
52
|
+
if suffix in [".yml", ".yaml"]:
|
|
53
|
+
return _collect_data_from_yaml_file(file, file_name, yaml_document)
|
|
54
|
+
raise TypeError(f"File type {suffix} not supported.")
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _collect_data_from_yaml_file(file, file_name, yaml_document):
|
|
58
|
+
"""Collect data from a yaml file (allow for multi-document yaml files)."""
|
|
59
|
+
try:
|
|
60
|
+
return yaml.safe_load(file)
|
|
61
|
+
except yaml.constructor.ConstructorError:
|
|
62
|
+
return _load_yaml_using_astropy(file)
|
|
63
|
+
except yaml.composer.ComposerError:
|
|
64
|
+
pass
|
|
65
|
+
file.seek(0)
|
|
66
|
+
if yaml_document is None:
|
|
67
|
+
return list(yaml.safe_load_all(file))
|
|
68
|
+
try:
|
|
69
|
+
return list(yaml.safe_load_all(file))[yaml_document]
|
|
70
|
+
except IndexError as exc:
|
|
71
|
+
raise IndexError(
|
|
72
|
+
f"Failed to read file {file_name}: YAML document index {yaml_document} is out of range."
|
|
73
|
+
) from exc
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _load_yaml_using_astropy(file):
|
|
77
|
+
"""
|
|
78
|
+
Load a yaml file using astropy's yaml loader.
|
|
79
|
+
|
|
80
|
+
Parameters
|
|
81
|
+
----------
|
|
82
|
+
file: file
|
|
83
|
+
File to be loaded.
|
|
84
|
+
|
|
85
|
+
Returns
|
|
86
|
+
-------
|
|
87
|
+
dict
|
|
88
|
+
Dictionary containing the file content.
|
|
89
|
+
"""
|
|
90
|
+
# pylint: disable=import-outside-toplevel
|
|
91
|
+
import astropy.io.misc.yaml as astropy_yaml
|
|
92
|
+
|
|
93
|
+
file.seek(0)
|
|
94
|
+
return astropy_yaml.load(file)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def collect_data_from_http(url):
|
|
98
|
+
"""
|
|
99
|
+
Download yaml or json file from url and return it contents as dict.
|
|
100
|
+
|
|
101
|
+
File is downloaded as a temporary file and deleted afterwards.
|
|
102
|
+
|
|
103
|
+
Parameters
|
|
104
|
+
----------
|
|
105
|
+
url: str
|
|
106
|
+
URL of the yaml/json file.
|
|
107
|
+
|
|
108
|
+
Returns
|
|
109
|
+
-------
|
|
110
|
+
dict
|
|
111
|
+
Dictionary containing the file content.
|
|
112
|
+
|
|
113
|
+
Raises
|
|
114
|
+
------
|
|
115
|
+
TypeError
|
|
116
|
+
If url is not a valid URL.
|
|
117
|
+
FileNotFoundError
|
|
118
|
+
If downloading the yaml file fails.
|
|
119
|
+
|
|
120
|
+
"""
|
|
121
|
+
try:
|
|
122
|
+
with tempfile.NamedTemporaryFile(mode="w+t") as tmp_file:
|
|
123
|
+
urllib.request.urlretrieve(url, tmp_file.name)
|
|
124
|
+
data = _collect_data_from_different_file_types(
|
|
125
|
+
tmp_file, url, Path(url).suffix.lower(), None
|
|
126
|
+
)
|
|
127
|
+
except TypeError as exc:
|
|
128
|
+
raise TypeError(f"Invalid url {url}") from exc
|
|
129
|
+
except urllib.error.HTTPError as exc:
|
|
130
|
+
raise FileNotFoundError(f"Failed to download file from {url}") from exc
|
|
131
|
+
|
|
132
|
+
_logger.debug(f"Downloaded file from {url}")
|
|
133
|
+
return data
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def read_file_encoded_in_utf_or_latin(file_name):
|
|
137
|
+
"""
|
|
138
|
+
Read a file encoded in UTF-8 or Latin-1.
|
|
139
|
+
|
|
140
|
+
Parameters
|
|
141
|
+
----------
|
|
142
|
+
file_name: str
|
|
143
|
+
Name of the file to be read.
|
|
144
|
+
|
|
145
|
+
Returns
|
|
146
|
+
-------
|
|
147
|
+
list
|
|
148
|
+
List of lines read from the file.
|
|
149
|
+
|
|
150
|
+
Raises
|
|
151
|
+
------
|
|
152
|
+
UnicodeDecodeError
|
|
153
|
+
If the file cannot be decoded using UTF-8 or Latin-1.
|
|
154
|
+
"""
|
|
155
|
+
try:
|
|
156
|
+
with open(file_name, encoding="utf-8") as file:
|
|
157
|
+
lines = file.readlines()
|
|
158
|
+
except UnicodeDecodeError:
|
|
159
|
+
_logger.debug("Unable to decode file using UTF-8. Trying Latin-1.")
|
|
160
|
+
try:
|
|
161
|
+
with open(file_name, encoding="latin-1") as file:
|
|
162
|
+
lines = file.readlines()
|
|
163
|
+
except UnicodeDecodeError as exc:
|
|
164
|
+
msg = f"Unable to decode file {file_name} using UTF-8 or Latin-1."
|
|
165
|
+
raise UnicodeDecodeError(exc.encoding, exc.object, exc.start, exc.end, msg) from exc
|
|
166
|
+
|
|
167
|
+
return lines
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def is_utf8_file(file_name):
|
|
171
|
+
"""
|
|
172
|
+
Check if a file is encoded in UTF-8.
|
|
173
|
+
|
|
174
|
+
Parameters
|
|
175
|
+
----------
|
|
176
|
+
file_name: str, Path
|
|
177
|
+
Name of the file to be checked.
|
|
178
|
+
|
|
179
|
+
Returns
|
|
180
|
+
-------
|
|
181
|
+
bool
|
|
182
|
+
True if the file is encoded in UTF-8, False otherwise.
|
|
183
|
+
"""
|
|
184
|
+
try:
|
|
185
|
+
with open(file_name, encoding="utf-8") as file:
|
|
186
|
+
file.read()
|
|
187
|
+
return True
|
|
188
|
+
except UnicodeDecodeError:
|
|
189
|
+
return False
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def write_data_to_file(data, output_file, sort_keys=False, numpy_types=False):
|
|
193
|
+
"""
|
|
194
|
+
Write structured data to JSON or YAML file.
|
|
195
|
+
|
|
196
|
+
The file type is determined by the file extension.
|
|
197
|
+
|
|
198
|
+
Parameters
|
|
199
|
+
----------
|
|
200
|
+
data: dict or list
|
|
201
|
+
Data to be written to the file.
|
|
202
|
+
output_file: str or Path
|
|
203
|
+
Name of the file to be written.
|
|
204
|
+
sort_keys: bool, optional
|
|
205
|
+
If True, sort the keys.
|
|
206
|
+
numpy_types: bool, optional
|
|
207
|
+
If True, convert numpy types to native Python types.
|
|
208
|
+
"""
|
|
209
|
+
output_file = Path(output_file)
|
|
210
|
+
if output_file.suffix.lower() == ".json":
|
|
211
|
+
return _write_to_json(data, output_file, sort_keys, numpy_types)
|
|
212
|
+
if output_file.suffix.lower() in [".yml", ".yaml"]:
|
|
213
|
+
return _write_to_yaml(data, output_file, sort_keys)
|
|
214
|
+
|
|
215
|
+
raise ValueError(
|
|
216
|
+
f"Unsupported file type {output_file.suffix}. Only .json, .yml, and .yaml are supported."
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
def _write_to_json(data, output_file, sort_keys, numpy_types):
|
|
221
|
+
"""
|
|
222
|
+
Write data to a JSON file.
|
|
223
|
+
|
|
224
|
+
Parameters
|
|
225
|
+
----------
|
|
226
|
+
data: dict or list
|
|
227
|
+
Data to be written to the file.
|
|
228
|
+
output_file: Path
|
|
229
|
+
Name of the file to be written.
|
|
230
|
+
sort_keys: bool
|
|
231
|
+
If True, sort the keys.
|
|
232
|
+
numpy_types: bool
|
|
233
|
+
If True, convert numpy types to native Python types.
|
|
234
|
+
"""
|
|
235
|
+
with open(output_file, "w", encoding="utf-8") as file:
|
|
236
|
+
json.dump(
|
|
237
|
+
data,
|
|
238
|
+
file,
|
|
239
|
+
indent=4,
|
|
240
|
+
sort_keys=sort_keys,
|
|
241
|
+
cls=JsonNumpyEncoder if numpy_types else None,
|
|
242
|
+
)
|
|
243
|
+
file.write("\n")
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
def _write_to_yaml(data, output_file, sort_keys):
|
|
247
|
+
"""
|
|
248
|
+
Write data to a YAML file.
|
|
249
|
+
|
|
250
|
+
Parameters
|
|
251
|
+
----------
|
|
252
|
+
data: dict or list
|
|
253
|
+
Data to be written to the file.
|
|
254
|
+
output_file: Path
|
|
255
|
+
Name of the file to be written.
|
|
256
|
+
sort_keys: bool
|
|
257
|
+
If True, sort the keys.
|
|
258
|
+
|
|
259
|
+
"""
|
|
260
|
+
with open(output_file, "w", encoding="utf-8") as file:
|
|
261
|
+
yaml.dump(data, file, indent=4, sort_keys=sort_keys, explicit_start=True)
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
class JsonNumpyEncoder(json.JSONEncoder):
|
|
265
|
+
"""Convert numpy to python types as accepted by json.dump."""
|
|
266
|
+
|
|
267
|
+
def default(self, o):
|
|
268
|
+
"""Return default encoder."""
|
|
269
|
+
if isinstance(o, np.floating):
|
|
270
|
+
return float(o)
|
|
271
|
+
if isinstance(o, np.integer):
|
|
272
|
+
return int(o)
|
|
273
|
+
if isinstance(o, np.ndarray):
|
|
274
|
+
return o.tolist()
|
|
275
|
+
if isinstance(o, u.core.CompositeUnit | u.core.IrreducibleUnit | u.core.Unit):
|
|
276
|
+
return str(o) if o != u.dimensionless_unscaled else None
|
|
277
|
+
if np.issubdtype(type(o), np.bool_):
|
|
278
|
+
return bool(o)
|
|
279
|
+
return super().default(o)
|
|
@@ -97,11 +97,14 @@ class IOHandler(metaclass=IOHandlerSingleton):
|
|
|
97
97
|
path.joinpath(label_dir) if sub_dir is None else path.joinpath(label_dir, sub_dir)
|
|
98
98
|
)
|
|
99
99
|
|
|
100
|
+
return self._mkdir(path)
|
|
101
|
+
|
|
102
|
+
def _mkdir(self, path):
|
|
103
|
+
"""Create a directory and return path."""
|
|
100
104
|
try:
|
|
101
105
|
path.mkdir(parents=True, exist_ok=True)
|
|
102
|
-
except FileNotFoundError:
|
|
103
|
-
|
|
104
|
-
raise
|
|
106
|
+
except FileNotFoundError as exc:
|
|
107
|
+
raise FileNotFoundError(f"Error creating directory {path!s}") from exc
|
|
105
108
|
|
|
106
109
|
return path.absolute()
|
|
107
110
|
|
|
@@ -156,3 +159,22 @@ class IOHandler(metaclass=IOHandlerSingleton):
|
|
|
156
159
|
else:
|
|
157
160
|
raise IncompleteIOHandlerInitError
|
|
158
161
|
return file_prefix.joinpath(file_name).absolute()
|
|
162
|
+
|
|
163
|
+
def get_model_configuration_directory(self, label, model_version):
|
|
164
|
+
"""
|
|
165
|
+
Get path of the simulation model configuration directory.
|
|
166
|
+
|
|
167
|
+
This is the directory where the sim_telarray configuration files will be stored.
|
|
168
|
+
|
|
169
|
+
Parameters
|
|
170
|
+
----------
|
|
171
|
+
label: str
|
|
172
|
+
Instance label.
|
|
173
|
+
model_version: str
|
|
174
|
+
Model version.
|
|
175
|
+
|
|
176
|
+
Returns
|
|
177
|
+
-------
|
|
178
|
+
Path
|
|
179
|
+
"""
|
|
180
|
+
return self._mkdir(self.get_output_directory(label=label).joinpath("model", model_version))
|
|
@@ -17,13 +17,12 @@ def generate_submission_script(args_dict):
|
|
|
17
17
|
args_dict: dict
|
|
18
18
|
Arguments dictionary.
|
|
19
19
|
"""
|
|
20
|
-
_logger.info("Generating HT Condor submission scripts ")
|
|
21
|
-
|
|
22
20
|
work_dir = Path(args_dict["output_path"])
|
|
23
21
|
log_dir = work_dir / "logs"
|
|
24
22
|
work_dir.mkdir(parents=True, exist_ok=True)
|
|
25
23
|
log_dir.mkdir(parents=True, exist_ok=True)
|
|
26
24
|
submit_file_name = "simulate_prod.submit"
|
|
25
|
+
_logger.info(f"Generating HT Condor submission scripts (path: {work_dir})")
|
|
27
26
|
|
|
28
27
|
with open(work_dir / f"{submit_file_name}.condor", "w", encoding="utf-8") as submit_file_handle:
|
|
29
28
|
submit_file_handle.write(
|
|
@@ -101,9 +100,20 @@ def _get_submit_script(args_dict):
|
|
|
101
100
|
)
|
|
102
101
|
core_scatter = args_dict["core_scatter"]
|
|
103
102
|
core_scatter_string = f'"{core_scatter[0]} {core_scatter[1].to(u.m).value} m"'
|
|
103
|
+
view_cone = args_dict["view_cone"]
|
|
104
|
+
view_cone_string = f'"{view_cone[0].to(u.deg)} {view_cone[1].to(u.deg)}"'
|
|
104
105
|
|
|
105
106
|
label = args_dict["label"] if args_dict["label"] else "simulate-prod"
|
|
106
107
|
|
|
108
|
+
array_layout_name = (
|
|
109
|
+
args_dict["array_layout_name"][0]
|
|
110
|
+
if isinstance(args_dict["array_layout_name"], list)
|
|
111
|
+
and len(args_dict["array_layout_name"]) == 1
|
|
112
|
+
else args_dict["array_layout_name"]
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
run_number_offset = args_dict["run_number_offset"] or 1
|
|
116
|
+
|
|
107
117
|
return f"""#!/usr/bin/env bash
|
|
108
118
|
|
|
109
119
|
# Process ID used to generate run number
|
|
@@ -116,15 +126,16 @@ simtools-simulate-prod \\
|
|
|
116
126
|
--label {label} \\
|
|
117
127
|
--model_version {args_dict["model_version"]} \\
|
|
118
128
|
--site {args_dict["site"]} \\
|
|
119
|
-
--array_layout_name {
|
|
129
|
+
--array_layout_name {array_layout_name} \\
|
|
120
130
|
--primary {args_dict["primary"]} \\
|
|
121
131
|
--azimuth_angle {azimuth_angle_string} \\
|
|
122
132
|
--zenith_angle {zenith_angle_string} \\
|
|
123
133
|
--nshow {args_dict["nshow"]} \\
|
|
124
134
|
--energy_range {energy_range_string} \\
|
|
125
135
|
--core_scatter {core_scatter_string} \\
|
|
136
|
+
--view_cone {view_cone_string} \\
|
|
126
137
|
--run_number $((process_id)) \\
|
|
127
|
-
--run_number_offset {
|
|
138
|
+
--run_number_offset {run_number_offset} \\
|
|
128
139
|
--number_of_runs 1 \\
|
|
129
140
|
--data_directory /tmp/simtools-data \\
|
|
130
141
|
--output_path /tmp/simtools-output \\
|
simtools/layout/array_layout.py
CHANGED
|
@@ -10,7 +10,7 @@ from astropy.table import QTable
|
|
|
10
10
|
|
|
11
11
|
import simtools.utils.general as gen
|
|
12
12
|
from simtools.data_model import data_reader, schema
|
|
13
|
-
from simtools.
|
|
13
|
+
from simtools.io import io_handler
|
|
14
14
|
from simtools.layout.geo_coordinates import GeoCoordinates
|
|
15
15
|
from simtools.layout.telescope_position import TelescopePosition
|
|
16
16
|
from simtools.model.site_model import SiteModel
|
|
@@ -7,7 +7,7 @@ import simtools.utils.general as gen
|
|
|
7
7
|
from simtools.data_model import data_reader
|
|
8
8
|
from simtools.data_model.metadata_collector import MetadataCollector
|
|
9
9
|
from simtools.data_model.model_data_writer import ModelDataWriter
|
|
10
|
-
from simtools.
|
|
10
|
+
from simtools.io import ascii_handler, io_handler
|
|
11
11
|
from simtools.model.array_model import ArrayModel
|
|
12
12
|
from simtools.model.site_model import SiteModel
|
|
13
13
|
from simtools.utils import names
|
|
@@ -36,17 +36,19 @@ def retrieve_ctao_array_layouts(site, repository_url, branch_name="main"):
|
|
|
36
36
|
_logger.info(f"Retrieving array layouts from {repository_url} on branch {branch_name}.")
|
|
37
37
|
|
|
38
38
|
if gen.is_url(repository_url):
|
|
39
|
-
array_element_ids =
|
|
39
|
+
array_element_ids = ascii_handler.collect_data_from_http(
|
|
40
40
|
url=f"{repository_url}/{branch_name}/array-element-ids.json"
|
|
41
41
|
)
|
|
42
|
-
sub_arrays =
|
|
42
|
+
sub_arrays = ascii_handler.collect_data_from_http(
|
|
43
43
|
url=f"{repository_url}/{branch_name}/subarray-ids.json"
|
|
44
44
|
)
|
|
45
45
|
else:
|
|
46
|
-
array_element_ids =
|
|
46
|
+
array_element_ids = ascii_handler.collect_data_from_file(
|
|
47
47
|
Path(repository_url) / "array-element-ids.json"
|
|
48
48
|
)
|
|
49
|
-
sub_arrays =
|
|
49
|
+
sub_arrays = ascii_handler.collect_data_from_file(
|
|
50
|
+
Path(repository_url) / "subarray-ids.json"
|
|
51
|
+
)
|
|
50
52
|
|
|
51
53
|
return _get_ctao_layouts_per_site(site, sub_arrays, array_element_ids)
|
|
52
54
|
|
|
@@ -232,7 +234,7 @@ def get_array_layouts_from_parameter_file(
|
|
|
232
234
|
list
|
|
233
235
|
List of dictionaries containing array layout names and their elements.
|
|
234
236
|
"""
|
|
235
|
-
array_layouts =
|
|
237
|
+
array_layouts = ascii_handler.collect_data_from_file(file_path)
|
|
236
238
|
try:
|
|
237
239
|
value = array_layouts["value"]
|
|
238
240
|
except KeyError as exc:
|
|
@@ -243,7 +245,12 @@ def get_array_layouts_from_parameter_file(
|
|
|
243
245
|
for layout in value:
|
|
244
246
|
layouts.append(
|
|
245
247
|
_get_array_layout_dict(
|
|
246
|
-
db_config,
|
|
248
|
+
db_config,
|
|
249
|
+
model_version,
|
|
250
|
+
site,
|
|
251
|
+
layout.get("elements"),
|
|
252
|
+
layout["name"],
|
|
253
|
+
coordinate_system,
|
|
247
254
|
)
|
|
248
255
|
)
|
|
249
256
|
return layouts
|
|
@@ -275,11 +282,7 @@ def get_array_layouts_from_db(
|
|
|
275
282
|
"""
|
|
276
283
|
layout_names = []
|
|
277
284
|
if layout_name:
|
|
278
|
-
layout_names.
|
|
279
|
-
layout_name[0]
|
|
280
|
-
if isinstance(layout_name, list) and len(layout_name) == 1
|
|
281
|
-
else layout_name
|
|
282
|
-
)
|
|
285
|
+
layout_names = gen.ensure_iterable(layout_name)
|
|
283
286
|
else:
|
|
284
287
|
site_model = SiteModel(site=site, model_version=model_version, mongo_db_config=db_config)
|
|
285
288
|
layout_names = site_model.get_list_of_array_layouts()
|
|
@@ -387,3 +390,39 @@ def _get_array_layout_dict(
|
|
|
387
390
|
coordinate_system=coordinate_system
|
|
388
391
|
),
|
|
389
392
|
}
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
def get_array_elements_from_db_for_layouts(layouts, site, model_version, db_config):
|
|
396
|
+
"""
|
|
397
|
+
Get list of array elements from the database for given list of layout names.
|
|
398
|
+
|
|
399
|
+
Structure of the returned dictionary::
|
|
400
|
+
|
|
401
|
+
{
|
|
402
|
+
"layout_name_1": [telescope_id_1, telescope_id_2, ...],
|
|
403
|
+
"layout_name_2": [telescope_id_3, telescope_id_4, ...],
|
|
404
|
+
...
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
Parameters
|
|
408
|
+
----------
|
|
409
|
+
layouts : list[str]
|
|
410
|
+
List of layout names to read. If "all", read all available layouts.
|
|
411
|
+
site : str
|
|
412
|
+
Site name for the array layouts.
|
|
413
|
+
model_version : str
|
|
414
|
+
Model version for the array layouts.
|
|
415
|
+
db_config : dict
|
|
416
|
+
Database configuration dictionary.
|
|
417
|
+
|
|
418
|
+
Returns
|
|
419
|
+
-------
|
|
420
|
+
dict
|
|
421
|
+
Dictionary mapping layout names to telescope IDs.
|
|
422
|
+
"""
|
|
423
|
+
site_model = SiteModel(site=site, model_version=model_version, mongo_db_config=db_config)
|
|
424
|
+
layout_names = site_model.get_list_of_array_layouts() if layouts == ["all"] else layouts
|
|
425
|
+
layout_dict = {}
|
|
426
|
+
for layout_name in layout_names:
|
|
427
|
+
layout_dict[layout_name] = site_model.get_array_elements_for_layout(layout_name)
|
|
428
|
+
return layout_dict
|