gammasimtools 0.6.1__py3-none-any.whl → 0.8.2__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.2.dist-info/METADATA +173 -0
- gammasimtools-0.8.2.dist-info/RECORD +345 -0
- {gammasimtools-0.6.1.dist-info → gammasimtools-0.8.2.dist-info}/WHEEL +1 -1
- gammasimtools-0.8.2.dist-info/entry_points.txt +31 -0
- simtools/_dev_version/__init__.py +9 -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 +111 -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 +211 -185
- 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 +312 -259
- simtools/model/calibration_model.py +50 -0
- simtools/model/camera.py +277 -523
- simtools/model/mirrors.py +68 -49
- simtools/model/model_parameter.py +602 -0
- simtools/model/model_utils.py +11 -39
- simtools/model/site_model.py +161 -0
- simtools/model/telescope_model.py +143 -633
- 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 +257 -644
- simtools/utils/value_conversion.py +176 -0
- simtools/version.py +3 -1
- 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/_dev_version/scm_version.py +0 -10
- 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.2.dist-info}/LICENSE +0 -0
- {gammasimtools-0.6.1.dist-info → gammasimtools-0.8.2.dist-info}/top_level.txt +0 -0
- /simtools/{corsika_simtel → db}/__init__.py +0 -0
simtools/simulator.py
CHANGED
|
@@ -1,277 +1,160 @@
|
|
|
1
|
+
"""Simulator class for managing simulations of showers and array of telescopes."""
|
|
2
|
+
|
|
1
3
|
import logging
|
|
2
4
|
import re
|
|
3
5
|
from collections import defaultdict
|
|
4
|
-
from copy import copy
|
|
5
6
|
from pathlib import Path
|
|
6
7
|
|
|
7
|
-
import astropy.units as u
|
|
8
8
|
import numpy as np
|
|
9
9
|
|
|
10
10
|
import simtools.utils.general as gen
|
|
11
|
-
from simtools.corsika.
|
|
12
|
-
from simtools.corsika_simtel.corsika_simtel_runner import CorsikaSimtelRunner
|
|
11
|
+
from simtools.corsika.corsika_config import CorsikaConfig
|
|
13
12
|
from simtools.io_operations import io_handler
|
|
14
13
|
from simtools.job_execution.job_manager import JobManager
|
|
15
14
|
from simtools.model.array_model import ArrayModel
|
|
16
|
-
from simtools.
|
|
17
|
-
from simtools.
|
|
15
|
+
from simtools.runners.corsika_runner import CorsikaRunner
|
|
16
|
+
from simtools.runners.corsika_simtel_runner import CorsikaSimtelRunner
|
|
17
|
+
from simtools.simtel.simulator_array import SimulatorArray
|
|
18
18
|
|
|
19
19
|
__all__ = [
|
|
20
|
+
"InvalidRunsToSimulateError",
|
|
20
21
|
"Simulator",
|
|
21
|
-
"InvalidRunsToSimulate",
|
|
22
22
|
]
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
class
|
|
25
|
+
class InvalidRunsToSimulateError(Exception):
|
|
26
26
|
"""Exception for invalid runs to simulate."""
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
class Simulator:
|
|
30
30
|
"""
|
|
31
|
-
Simulator is
|
|
32
|
-
It interfaces with simulation software-specific packages, like CORSIKA or sim_telarray.
|
|
33
|
-
|
|
34
|
-
The configuration is set as a dict config_data or a yaml \
|
|
35
|
-
file config_file.
|
|
36
|
-
|
|
37
|
-
Example of config_data for shower simulations:
|
|
38
|
-
|
|
39
|
-
.. code-block:: python
|
|
40
|
-
|
|
41
|
-
config_data = {
|
|
42
|
-
'data_directory': '.',
|
|
43
|
-
'site': 'South',
|
|
44
|
-
'layout_name': 'Prod5',
|
|
45
|
-
'run_range': [1, 100],
|
|
46
|
-
'nshow': 10,
|
|
47
|
-
'primary': 'gamma',
|
|
48
|
-
'erange': [100 * u.GeV, 1 * u.TeV],
|
|
49
|
-
'eslope': -2,
|
|
50
|
-
'zenith': 20 * u.deg,
|
|
51
|
-
'azimuth': 0 * u.deg,
|
|
52
|
-
'viewcone': 0 * u.deg,
|
|
53
|
-
'cscat': [10, 1500 * u.m, 0]
|
|
54
|
-
}
|
|
31
|
+
Simulator is managing the simulation of showers and of the array of telescopes.
|
|
55
32
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
config_data = {
|
|
61
|
-
'data_directory': '(..)/data',
|
|
62
|
-
'primary': 'gamma',
|
|
63
|
-
'zenith': 20 * u.deg,
|
|
64
|
-
'azimuth': 0 * u.deg,
|
|
65
|
-
'viewcone': 0 * u.deg,
|
|
66
|
-
# ArrayModel
|
|
67
|
-
'site': 'North',
|
|
68
|
-
'layout_name': '1LST',
|
|
69
|
-
'model_version': 'Prod5',
|
|
70
|
-
'default': {
|
|
71
|
-
'LST': '1'
|
|
72
|
-
},
|
|
73
|
-
'MST-01': 'FlashCam-D'
|
|
74
|
-
}
|
|
33
|
+
It interfaces with simulation software packages (e.g., CORSIKA or sim_telarray).
|
|
34
|
+
|
|
35
|
+
The configuration is set as a dict corresponding to the command line configuration groups
|
|
36
|
+
(especially simulation_software, simulation_model, simulation_parameters).
|
|
75
37
|
|
|
76
38
|
Parameters
|
|
77
39
|
----------
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
Location of executables for simulation software \
|
|
82
|
-
(e.g. path with CORSIKA or sim_telarray)
|
|
40
|
+
args_dict : dict
|
|
41
|
+
Configuration dictionary
|
|
42
|
+
(includes simulation_software, simulation_model, simulation_parameters groups).
|
|
83
43
|
label: str
|
|
84
44
|
Instance label.
|
|
85
|
-
config_data: dict
|
|
86
|
-
Dict with shower or array model configuration data.
|
|
87
|
-
config_file: str or Path
|
|
88
|
-
Path to yaml file containing configurable data.
|
|
89
|
-
submit_command: str
|
|
90
|
-
Job submission command.
|
|
91
45
|
extra_commands: str or list of str
|
|
92
|
-
Extra commands to be added to the run script before the run command
|
|
46
|
+
Extra commands to be added to the run script before the run command.
|
|
93
47
|
mongo_db_config: dict
|
|
94
48
|
MongoDB configuration.
|
|
95
|
-
test: bool
|
|
96
|
-
If True, no jobs are submitted; only run scripts are prepared
|
|
97
49
|
"""
|
|
98
50
|
|
|
99
51
|
def __init__(
|
|
100
52
|
self,
|
|
101
|
-
|
|
102
|
-
simulator_source_path,
|
|
53
|
+
args_dict,
|
|
103
54
|
label=None,
|
|
104
|
-
config_data=None,
|
|
105
|
-
config_file=None,
|
|
106
|
-
submit_command=None,
|
|
107
55
|
extra_commands=None,
|
|
108
56
|
mongo_db_config=None,
|
|
109
|
-
test=False,
|
|
110
57
|
):
|
|
111
|
-
"""
|
|
112
|
-
Initialize Simulator class.
|
|
113
|
-
"""
|
|
58
|
+
"""Initialize Simulator class."""
|
|
114
59
|
self._logger = logging.getLogger(__name__)
|
|
115
|
-
self.
|
|
60
|
+
self.args_dict = args_dict
|
|
116
61
|
|
|
62
|
+
self.simulation_software = self.args_dict["simulation_software"]
|
|
63
|
+
self._logger.debug(f"Init Simulator {self.simulation_software}")
|
|
117
64
|
self.label = label
|
|
118
|
-
self.simulator = simulator
|
|
119
|
-
self.runs = []
|
|
120
|
-
self._results = defaultdict(list)
|
|
121
|
-
self.test = test
|
|
122
|
-
|
|
123
|
-
self._corsika_config_data = None
|
|
124
|
-
self.site = None
|
|
125
|
-
self.layout_name = None
|
|
126
|
-
self._corsika_parameters_file = None
|
|
127
|
-
self.config = None
|
|
128
|
-
self.array_model = None
|
|
129
|
-
self._simulation_runner = None
|
|
130
65
|
|
|
131
66
|
self.io_handler = io_handler.IOHandler()
|
|
132
|
-
self._output_directory = self.io_handler.get_output_directory(self.label, self.simulator)
|
|
133
|
-
self._simulator_source_path = Path(simulator_source_path)
|
|
134
|
-
self._submit_command = submit_command
|
|
135
|
-
self._extra_commands = extra_commands
|
|
136
|
-
self._mongo_db_config = mongo_db_config
|
|
137
67
|
|
|
138
|
-
self.
|
|
68
|
+
self.runs = self._initialize_run_list()
|
|
69
|
+
self._results = defaultdict(list)
|
|
70
|
+
self._test = self.args_dict.get("test", False)
|
|
71
|
+
self._submit_engine = self.args_dict.get("submit_engine", "local")
|
|
72
|
+
self._submit_options = self.args_dict.get("submit_options", None)
|
|
73
|
+
self._extra_commands = extra_commands
|
|
139
74
|
|
|
140
|
-
self.
|
|
75
|
+
self.array_model = self._initialize_array_model(mongo_db_config)
|
|
76
|
+
self._simulation_runner = self._initialize_simulation_runner(mongo_db_config)
|
|
141
77
|
|
|
142
78
|
@property
|
|
143
|
-
def
|
|
144
|
-
"""The attribute
|
|
145
|
-
return self.
|
|
79
|
+
def simulation_software(self):
|
|
80
|
+
"""The attribute simulation_software."""
|
|
81
|
+
return self._simulation_software
|
|
146
82
|
|
|
147
|
-
@
|
|
148
|
-
def
|
|
83
|
+
@simulation_software.setter
|
|
84
|
+
def simulation_software(self, simulation_software):
|
|
149
85
|
"""
|
|
150
|
-
Set and test
|
|
86
|
+
Set and test simulation_software type.
|
|
151
87
|
|
|
152
88
|
Parameters
|
|
153
89
|
----------
|
|
154
|
-
|
|
90
|
+
simulation_software: choices: [simtel, corsika, corsika_simtel]
|
|
155
91
|
implemented are sim_telarray and CORSIKA or corsika_simtel
|
|
156
92
|
(running CORSIKA and piping it directly to sim_telarray)
|
|
157
93
|
|
|
158
94
|
Raises
|
|
159
95
|
------
|
|
160
|
-
gen.
|
|
161
|
-
|
|
162
|
-
"""
|
|
163
|
-
|
|
164
|
-
if simulator not in ["simtel", "corsika", "corsika_simtel"]:
|
|
165
|
-
raise gen.InvalidConfigData
|
|
166
|
-
self._simulator = simulator.lower()
|
|
167
|
-
|
|
168
|
-
def _load_configuration_and_simulation_model(self, config_data=None, config_file=None):
|
|
169
|
-
"""
|
|
170
|
-
Load configuration data and initialize simulation models.
|
|
171
|
-
|
|
172
|
-
Parameters
|
|
173
|
-
----------
|
|
174
|
-
config_data: dict
|
|
175
|
-
Dict with simulator configuration data.
|
|
176
|
-
config_file: str or Path
|
|
177
|
-
Path to yaml file containing configurable data.
|
|
178
|
-
|
|
179
|
-
"""
|
|
180
|
-
simulator_config_data = gen.collect_data_from_file_or_dict(config_file, config_data)
|
|
181
|
-
if self.simulator == "corsika":
|
|
182
|
-
self._load_corsika_config_and_model(simulator_config_data)
|
|
183
|
-
if self.simulator == "simtel":
|
|
184
|
-
self._load_sim_tel_config_and_model(simulator_config_data)
|
|
185
|
-
if self.simulator == "corsika_simtel":
|
|
186
|
-
config_showers, config_arrays = self._separate_corsika_and_simtel_config_data(
|
|
187
|
-
simulator_config_data
|
|
188
|
-
)
|
|
189
|
-
self._load_corsika_config_and_model(config_showers)
|
|
190
|
-
self._load_sim_tel_config_and_model(config_arrays)
|
|
96
|
+
gen.InvalidConfigDataError
|
|
191
97
|
|
|
192
|
-
def _load_corsika_config_and_model(self, config_data):
|
|
193
98
|
"""
|
|
194
|
-
|
|
195
|
-
|
|
99
|
+
if simulation_software not in ["simtel", "corsika", "corsika_simtel"]:
|
|
100
|
+
self._logger.error(f"Invalid simulation software: {simulation_software}")
|
|
101
|
+
raise gen.InvalidConfigDataError
|
|
102
|
+
self._simulation_software = simulation_software.lower()
|
|
196
103
|
|
|
197
|
-
|
|
198
|
-
----------
|
|
199
|
-
config_data: dict
|
|
200
|
-
Dict with simulator configuration data.
|
|
201
|
-
|
|
202
|
-
"""
|
|
203
|
-
|
|
204
|
-
self._corsika_config_data = copy(config_data)
|
|
205
|
-
|
|
206
|
-
try:
|
|
207
|
-
self.site = names.validate_site_name(self._corsika_config_data.pop("site"))
|
|
208
|
-
self.layout_name = names.validate_array_layout_name(
|
|
209
|
-
self._corsika_config_data.pop("layout_name")
|
|
210
|
-
)
|
|
211
|
-
except KeyError:
|
|
212
|
-
self._logger.error("Missing parameter in simulation configuration data")
|
|
213
|
-
raise
|
|
214
|
-
|
|
215
|
-
self.runs = self._validate_run_list_and_range(
|
|
216
|
-
self._corsika_config_data.pop("run_list", None),
|
|
217
|
-
self._corsika_config_data.pop("run_range", None),
|
|
218
|
-
)
|
|
219
|
-
|
|
220
|
-
self._corsika_parameters_file = self._corsika_config_data.pop(
|
|
221
|
-
"corsika_parameters_file", None
|
|
222
|
-
)
|
|
223
|
-
|
|
224
|
-
def _load_sim_tel_config_and_model(self, config_data):
|
|
104
|
+
def _initialize_array_model(self, mongo_db_config):
|
|
225
105
|
"""
|
|
226
|
-
|
|
106
|
+
Initialize array simulation model.
|
|
227
107
|
|
|
228
108
|
Parameters
|
|
229
109
|
----------
|
|
230
|
-
|
|
231
|
-
|
|
110
|
+
mongo_db_config: dict
|
|
111
|
+
Database configuration.
|
|
232
112
|
|
|
113
|
+
Returns
|
|
114
|
+
-------
|
|
115
|
+
ArrayModel
|
|
116
|
+
ArrayModel object.
|
|
233
117
|
"""
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
_parameter_file = self.io_handler.get_input_data_file(
|
|
237
|
-
"parameters", "array-simulator_parameters.yml"
|
|
238
|
-
)
|
|
239
|
-
_parameters = gen.collect_data_from_file_or_dict(_parameter_file, None)
|
|
240
|
-
self.config = gen.validate_config_data(_rest_config, _parameters, ignore_unidentified=True)
|
|
241
|
-
|
|
242
|
-
self.array_model = ArrayModel(
|
|
118
|
+
return ArrayModel(
|
|
243
119
|
label=self.label,
|
|
244
|
-
|
|
245
|
-
|
|
120
|
+
site=self.args_dict.get("site"),
|
|
121
|
+
layout_name=self.args_dict.get("array_layout_name"),
|
|
122
|
+
mongo_db_config=mongo_db_config,
|
|
123
|
+
model_version=self.args_dict.get("model_version", None),
|
|
246
124
|
)
|
|
247
125
|
|
|
248
|
-
def
|
|
126
|
+
def _initialize_run_list(self):
|
|
249
127
|
"""
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
Parameters
|
|
253
|
-
----------
|
|
254
|
-
config_data: dict
|
|
255
|
-
Dictionary with both the CORSIKA and sim_telarray simulation configuration data.
|
|
128
|
+
Initialize run list using the configuration values 'run_number_start' and 'number_of_runs'.
|
|
256
129
|
|
|
257
130
|
Returns
|
|
258
131
|
-------
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
dict
|
|
262
|
-
Configuration of array simulations.
|
|
132
|
+
list
|
|
133
|
+
List of run numbers.
|
|
263
134
|
|
|
135
|
+
Raises
|
|
136
|
+
------
|
|
137
|
+
KeyError
|
|
138
|
+
If 'run_number_start' or 'number_of_runs' are not found in the configuration.
|
|
264
139
|
"""
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
140
|
+
try:
|
|
141
|
+
return self._validate_run_list_and_range(
|
|
142
|
+
run_list=None,
|
|
143
|
+
run_range=[
|
|
144
|
+
self.args_dict["run_number_start"],
|
|
145
|
+
self.args_dict["run_number_start"] + self.args_dict["number_of_runs"],
|
|
146
|
+
],
|
|
147
|
+
)
|
|
148
|
+
except KeyError as exc:
|
|
149
|
+
self._logger.error(
|
|
150
|
+
"Error in initializing run list (missing 'run_number_start' or 'number_of_runs')"
|
|
151
|
+
)
|
|
152
|
+
raise exc
|
|
271
153
|
|
|
272
154
|
def _validate_run_list_and_range(self, run_list, run_range):
|
|
273
155
|
"""
|
|
274
|
-
|
|
156
|
+
Prepare list of run numbers from a list or from a range.
|
|
157
|
+
|
|
275
158
|
If both arguments are given, they will be merged into a single list.
|
|
276
159
|
|
|
277
160
|
Attributes
|
|
@@ -298,118 +181,72 @@ class Simulator:
|
|
|
298
181
|
if not all(isinstance(r, int) for r in run_list):
|
|
299
182
|
msg = "run_list must contain only integers."
|
|
300
183
|
self._logger.error(msg)
|
|
301
|
-
raise
|
|
302
|
-
|
|
303
|
-
self._logger.debug(f"run_list: {run_list}")
|
|
184
|
+
raise InvalidRunsToSimulateError
|
|
304
185
|
validated_runs = list(run_list)
|
|
305
186
|
|
|
306
187
|
if run_range is not None:
|
|
307
188
|
if not all(isinstance(r, int) for r in run_range) or len(run_range) != 2:
|
|
308
189
|
msg = "run_range must contain two integers only."
|
|
309
190
|
self._logger.error(msg)
|
|
310
|
-
raise
|
|
191
|
+
raise InvalidRunsToSimulateError
|
|
311
192
|
|
|
312
|
-
run_range = np.arange(run_range[0], run_range[1]
|
|
193
|
+
run_range = np.arange(run_range[0], run_range[1])
|
|
313
194
|
self._logger.debug(f"run_range: {run_range}")
|
|
314
195
|
validated_runs.extend(list(run_range))
|
|
315
196
|
|
|
316
197
|
validated_runs_unique = sorted(set(validated_runs))
|
|
198
|
+
self._logger.info(f"run_list: {validated_runs_unique}")
|
|
317
199
|
return list(validated_runs_unique)
|
|
318
200
|
|
|
319
|
-
def
|
|
201
|
+
def _initialize_simulation_runner(self, db_config):
|
|
320
202
|
"""
|
|
321
|
-
|
|
203
|
+
Initialize corsika configuration and simulation runners.
|
|
322
204
|
|
|
323
205
|
Parameters
|
|
324
206
|
----------
|
|
325
|
-
|
|
326
|
-
|
|
207
|
+
db_config: dict
|
|
208
|
+
Database configuration.
|
|
327
209
|
|
|
210
|
+
Returns
|
|
211
|
+
-------
|
|
212
|
+
CorsikaRunner or SimulatorArray or CorsikaSimtelRunner
|
|
213
|
+
Simulation runner object.
|
|
328
214
|
"""
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
_rest_data.pop("layout_name")
|
|
336
|
-
)
|
|
337
|
-
_array_model_data["model_version"] = _rest_data.pop("model_version")
|
|
338
|
-
_array_model_data["default"] = _rest_data.pop("default")
|
|
339
|
-
except KeyError:
|
|
340
|
-
self._logger.error("Missing parameter in simulation configuration data")
|
|
341
|
-
raise
|
|
342
|
-
|
|
343
|
-
# Reading telescope keys
|
|
344
|
-
tel_keys = [k for k in _rest_data.keys() if k[1:4] in ["ST-", "CT-"]]
|
|
345
|
-
for key in tel_keys:
|
|
346
|
-
_array_model_data[key] = _rest_data.pop(key)
|
|
215
|
+
corsika_config = CorsikaConfig(
|
|
216
|
+
array_model=self.array_model,
|
|
217
|
+
label=self.label,
|
|
218
|
+
args_dict=self.args_dict,
|
|
219
|
+
db_config=db_config,
|
|
220
|
+
)
|
|
347
221
|
|
|
348
|
-
|
|
222
|
+
runner_class = {
|
|
223
|
+
"corsika": CorsikaRunner,
|
|
224
|
+
"simtel": SimulatorArray,
|
|
225
|
+
"corsika_simtel": CorsikaSimtelRunner,
|
|
226
|
+
}.get(self.simulation_software)
|
|
349
227
|
|
|
350
|
-
|
|
351
|
-
"""
|
|
352
|
-
Set simulation runners
|
|
353
|
-
|
|
354
|
-
"""
|
|
355
|
-
common_args = {
|
|
228
|
+
runner_args = {
|
|
356
229
|
"label": self.label,
|
|
357
|
-
"
|
|
230
|
+
"corsika_config": corsika_config,
|
|
231
|
+
"simtel_path": self.args_dict.get("simtel_path"),
|
|
232
|
+
"use_multipipe": runner_class is CorsikaSimtelRunner,
|
|
358
233
|
}
|
|
359
|
-
corsika_args = {
|
|
360
|
-
"mongo_db_config": self._mongo_db_config,
|
|
361
|
-
"site": self.site,
|
|
362
|
-
"layout_name": self.layout_name,
|
|
363
|
-
"corsika_parameters_file": self._corsika_parameters_file,
|
|
364
|
-
"corsika_config_data": self._corsika_config_data,
|
|
365
|
-
}
|
|
366
|
-
if self.simulator in ["simtel", "corsika_simtel"]:
|
|
367
|
-
simtel_args = {
|
|
368
|
-
"array_model": self.array_model,
|
|
369
|
-
"config_data": {
|
|
370
|
-
"simtel_data_directory": self.config.data_directory,
|
|
371
|
-
"primary": self.config.primary,
|
|
372
|
-
"zenith_angle": self.config.zenith_angle * u.deg,
|
|
373
|
-
"azimuth_angle": self.config.azimuth_angle * u.deg,
|
|
374
|
-
},
|
|
375
|
-
}
|
|
376
|
-
if self.simulator == "corsika":
|
|
377
|
-
self._set_corsika_runner(common_args | corsika_args)
|
|
378
|
-
if self.simulator == "simtel":
|
|
379
|
-
self._set_simtel_runner(common_args | simtel_args)
|
|
380
|
-
if self.simulator == "corsika_simtel":
|
|
381
|
-
self._set_corsika_simtel_runner(common_args, corsika_args, simtel_args)
|
|
382
|
-
|
|
383
|
-
def _set_corsika_runner(self, simulator_args):
|
|
384
|
-
"""
|
|
385
|
-
Creating CorsikaRunner.
|
|
386
|
-
|
|
387
|
-
"""
|
|
388
|
-
self._simulation_runner = CorsikaRunner(**simulator_args)
|
|
389
234
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
"""
|
|
395
|
-
self._simulation_runner = SimtelRunnerArray(**simulator_args)
|
|
396
|
-
|
|
397
|
-
def _set_corsika_simtel_runner(self, common_args, corsika_args, simtel_args):
|
|
398
|
-
"""
|
|
399
|
-
Creating CorsikaRunner.
|
|
235
|
+
if runner_class is not SimulatorArray:
|
|
236
|
+
runner_args["keep_seeds"] = self.args_dict.get("corsika_test_seeds", False)
|
|
237
|
+
if runner_class is not CorsikaRunner:
|
|
238
|
+
runner_args["sim_telarray_seeds"] = self.args_dict.get("sim_telarray_seeds")
|
|
400
239
|
|
|
401
|
-
|
|
402
|
-
self._simulation_runner = CorsikaSimtelRunner(common_args, corsika_args, simtel_args)
|
|
240
|
+
return runner_class(**runner_args)
|
|
403
241
|
|
|
404
242
|
def _fill_results_without_run(self, input_file_list):
|
|
405
243
|
"""
|
|
406
|
-
Fill
|
|
244
|
+
Fill results dict without calling submit (e.g., for testing).
|
|
407
245
|
|
|
408
246
|
Parameters
|
|
409
247
|
----------
|
|
410
248
|
input_file_list: str or list of str
|
|
411
249
|
Single file or list of files of shower simulations.
|
|
412
|
-
|
|
413
250
|
"""
|
|
414
251
|
input_file_list = self._enforce_list_type(input_file_list)
|
|
415
252
|
|
|
@@ -427,10 +264,8 @@ class Simulator:
|
|
|
427
264
|
----------
|
|
428
265
|
input_file_list: str or list of str
|
|
429
266
|
Single file or list of files of shower simulations.
|
|
430
|
-
|
|
431
267
|
"""
|
|
432
|
-
|
|
433
|
-
self._logger.info(f"Submission command: {self._submit_command}")
|
|
268
|
+
self._logger.info(f"Submission command: {self._submit_engine}")
|
|
434
269
|
|
|
435
270
|
runs_and_files_to_submit = self._get_runs_and_files_to_submit(
|
|
436
271
|
input_file_list=input_file_list
|
|
@@ -440,50 +275,67 @@ class Simulator:
|
|
|
440
275
|
f"run{'s' if len(runs_and_files_to_submit) > 1 else ''}"
|
|
441
276
|
)
|
|
442
277
|
|
|
443
|
-
for
|
|
278
|
+
for run_number, input_file in runs_and_files_to_submit.items():
|
|
444
279
|
run_script = self._simulation_runner.prepare_run_script(
|
|
445
|
-
run_number=
|
|
280
|
+
run_number=run_number, input_file=input_file, extra_commands=self._extra_commands
|
|
446
281
|
)
|
|
447
282
|
|
|
448
|
-
job_manager = JobManager(
|
|
283
|
+
job_manager = JobManager(
|
|
284
|
+
submit_engine=self._submit_engine,
|
|
285
|
+
submit_options=self._submit_options,
|
|
286
|
+
test=self._test,
|
|
287
|
+
)
|
|
449
288
|
job_manager.submit(
|
|
450
289
|
run_script=run_script,
|
|
451
290
|
run_out_file=self._simulation_runner.get_file_name(
|
|
452
|
-
file_type="sub_log",
|
|
291
|
+
file_type="sub_log", run_number=run_number
|
|
453
292
|
),
|
|
454
293
|
log_file=self._simulation_runner.get_file_name(
|
|
455
|
-
file_type="
|
|
456
|
-
**self._simulation_runner.get_info_for_file_name(run),
|
|
294
|
+
file_type=("log"), run_number=run_number
|
|
457
295
|
),
|
|
458
296
|
)
|
|
459
297
|
|
|
460
|
-
self._fill_results(
|
|
298
|
+
self._fill_results(input_file, run_number)
|
|
461
299
|
|
|
462
|
-
def
|
|
300
|
+
def _get_runs_and_files_to_submit(self, input_file_list=None):
|
|
463
301
|
"""
|
|
464
|
-
|
|
302
|
+
Return a dictionary with run numbers and simulation files.
|
|
303
|
+
|
|
304
|
+
The latter are expected to be given for the simtel simulator.
|
|
465
305
|
|
|
466
306
|
Parameters
|
|
467
307
|
----------
|
|
468
308
|
input_file_list: str or list of str
|
|
469
309
|
Single file or list of files of shower simulations.
|
|
470
310
|
|
|
471
|
-
|
|
311
|
+
Returns
|
|
312
|
+
-------
|
|
313
|
+
runs_and_files: dict
|
|
314
|
+
dictionary with run number as key and (if available) simulation
|
|
315
|
+
file name as value
|
|
472
316
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
317
|
+
Raises
|
|
318
|
+
------
|
|
319
|
+
ValueError
|
|
320
|
+
If no runs are to be submitted.
|
|
476
321
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
322
|
+
"""
|
|
323
|
+
_runs_and_files = {}
|
|
324
|
+
self._logger.debug(f"Getting runs and files to submit ({input_file_list})")
|
|
325
|
+
|
|
326
|
+
if self.simulation_software == "simtel":
|
|
327
|
+
input_file_list = self._enforce_list_type(input_file_list)
|
|
328
|
+
_runs_and_files = {self._guess_run_from_file(file): file for file in input_file_list}
|
|
329
|
+
elif self.simulation_software in ["corsika", "corsika_simtel"]:
|
|
330
|
+
_runs_and_files = {run: None for run in self._get_runs_to_simulate()}
|
|
331
|
+
if len(_runs_and_files) == 0:
|
|
332
|
+
raise ValueError("No runs to submit.")
|
|
333
|
+
return _runs_and_files
|
|
482
334
|
|
|
483
|
-
|
|
335
|
+
@staticmethod
|
|
336
|
+
def _enforce_list_type(input_file_list):
|
|
484
337
|
"""
|
|
485
|
-
|
|
486
|
-
files. The latter are expected to be given for the simtel simulator.
|
|
338
|
+
Enforce the input list to be a list.
|
|
487
339
|
|
|
488
340
|
Parameters
|
|
489
341
|
----------
|
|
@@ -492,91 +344,75 @@ class Simulator:
|
|
|
492
344
|
|
|
493
345
|
Returns
|
|
494
346
|
-------
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
file name as value
|
|
498
|
-
|
|
347
|
+
list
|
|
348
|
+
List of input files.
|
|
499
349
|
"""
|
|
500
|
-
|
|
501
|
-
_runs_and_files = {}
|
|
502
|
-
|
|
503
|
-
if self.simulator == "simtel":
|
|
504
|
-
_file_list = self._enforce_list_type(input_file_list)
|
|
505
|
-
for file in _file_list:
|
|
506
|
-
_runs_and_files[self._guess_run_from_file(file)] = file
|
|
507
|
-
if self.simulator in ["corsika", "corsika_simtel"]:
|
|
508
|
-
_run_list = self._get_runs_to_simulate()
|
|
509
|
-
for run in _run_list:
|
|
510
|
-
_runs_and_files[run] = None
|
|
511
|
-
|
|
512
|
-
return _runs_and_files
|
|
513
|
-
|
|
514
|
-
@staticmethod
|
|
515
|
-
def _enforce_list_type(input_file_list):
|
|
516
|
-
"""Enforce the input list to be a list."""
|
|
517
350
|
if not input_file_list:
|
|
518
351
|
return []
|
|
519
|
-
if
|
|
520
|
-
return [input_file_list]
|
|
521
|
-
|
|
522
|
-
return input_file_list
|
|
352
|
+
return input_file_list if isinstance(input_file_list, list) else [input_file_list]
|
|
523
353
|
|
|
524
354
|
def _guess_run_from_file(self, file):
|
|
525
355
|
"""
|
|
526
|
-
|
|
356
|
+
Extract the run number from the given file name.
|
|
357
|
+
|
|
527
358
|
Input file names can follow any pattern with the
|
|
528
359
|
string 'run' followed by the run number.
|
|
529
|
-
If not found, returns 1.
|
|
530
360
|
|
|
531
361
|
Parameters
|
|
532
362
|
----------
|
|
533
363
|
file: Path
|
|
534
364
|
Simulation file name
|
|
535
365
|
|
|
366
|
+
Returns
|
|
367
|
+
-------
|
|
368
|
+
int
|
|
369
|
+
The extracted run number. If extraction fails, returns 1 and logs a warning.
|
|
536
370
|
"""
|
|
537
371
|
file_name = str(Path(file).name)
|
|
538
372
|
|
|
539
373
|
try:
|
|
540
|
-
run_str = re.search("run
|
|
374
|
+
run_str = re.search(r"run\d*", file_name).group()
|
|
541
375
|
return int(run_str[3:])
|
|
542
376
|
except (ValueError, AttributeError):
|
|
543
|
-
|
|
544
|
-
self._logger.warning(msg)
|
|
377
|
+
self._logger.warning(f"Run number could not be guessed from {file_name} using run = 1")
|
|
545
378
|
return 1
|
|
546
379
|
|
|
547
|
-
def _fill_results(self, file,
|
|
380
|
+
def _fill_results(self, file, run_number):
|
|
548
381
|
"""
|
|
549
|
-
Fill the results dict with input, output and log files.
|
|
382
|
+
Fill the results dict with input, output, hist, and log files.
|
|
550
383
|
|
|
551
384
|
Parameters
|
|
552
385
|
----------
|
|
553
386
|
file: str
|
|
554
387
|
input file name
|
|
555
|
-
|
|
388
|
+
run_number: int
|
|
556
389
|
run number
|
|
557
390
|
|
|
558
391
|
"""
|
|
559
|
-
|
|
560
|
-
info_for_file_name = self._simulation_runner.get_info_for_file_name(run)
|
|
561
392
|
self._results["output"].append(
|
|
562
|
-
str(self._simulation_runner.get_file_name(file_type="output",
|
|
393
|
+
str(self._simulation_runner.get_file_name(file_type="output", run_number=run_number))
|
|
563
394
|
)
|
|
564
395
|
self._results["sub_out"].append(
|
|
565
396
|
str(
|
|
566
397
|
self._simulation_runner.get_file_name(
|
|
567
|
-
file_type="sub_log",
|
|
398
|
+
file_type="sub_log", run_number=run_number, mode="out"
|
|
568
399
|
)
|
|
569
400
|
)
|
|
570
401
|
)
|
|
571
|
-
|
|
402
|
+
|
|
403
|
+
if self.simulation_software in ["simtel", "corsika_simtel"]:
|
|
572
404
|
self._results["log"].append(
|
|
573
|
-
str(
|
|
405
|
+
str(
|
|
406
|
+
self._simulation_runner.get_file_name(
|
|
407
|
+
simulation_software="simtel", file_type="log", run_number=run_number
|
|
408
|
+
)
|
|
409
|
+
)
|
|
574
410
|
)
|
|
575
411
|
self._results["input"].append(str(file))
|
|
576
412
|
self._results["hist"].append(
|
|
577
413
|
str(
|
|
578
414
|
self._simulation_runner.get_file_name(
|
|
579
|
-
file_type="histogram",
|
|
415
|
+
simulation_software="simtel", file_type="histogram", run_number=run_number
|
|
580
416
|
)
|
|
581
417
|
)
|
|
582
418
|
)
|
|
@@ -584,7 +420,7 @@ class Simulator:
|
|
|
584
420
|
self._results["corsika_autoinputs_log"].append(
|
|
585
421
|
str(
|
|
586
422
|
self._simulation_runner.get_file_name(
|
|
587
|
-
file_type="
|
|
423
|
+
simulation_software="corsika", file_type="log", run_number=run_number
|
|
588
424
|
)
|
|
589
425
|
)
|
|
590
426
|
)
|
|
@@ -592,101 +428,47 @@ class Simulator:
|
|
|
592
428
|
self._results["hist"].append(None)
|
|
593
429
|
self._results["log"].append(None)
|
|
594
430
|
|
|
595
|
-
def
|
|
431
|
+
def get_file_list(self, file_type="output"):
|
|
596
432
|
"""
|
|
597
|
-
Get list of
|
|
433
|
+
Get list of files generated by simulations.
|
|
434
|
+
|
|
435
|
+
Options are "input", "output", "hist", "log".
|
|
436
|
+
Not all file types are available for all simulation types.
|
|
437
|
+
Returns an empty list for an unknown file type.
|
|
598
438
|
|
|
599
439
|
Parameters
|
|
600
440
|
----------
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
run_range: list
|
|
604
|
-
List of len 2 with the limits of the range of the run numbers.
|
|
441
|
+
file_type : str
|
|
442
|
+
File type to be listed.
|
|
605
443
|
|
|
606
444
|
Returns
|
|
607
445
|
-------
|
|
608
446
|
list
|
|
609
|
-
List with the full path of all
|
|
610
|
-
|
|
611
|
-
"""
|
|
612
|
-
self._logger.info("Getting list of output files")
|
|
613
|
-
|
|
614
|
-
if run_list or run_range or len(self._results["output"]) == 0:
|
|
615
|
-
runs_to_list = self._get_runs_to_simulate(run_list=run_list, run_range=run_range)
|
|
616
|
-
|
|
617
|
-
for run in runs_to_list:
|
|
618
|
-
output_file_name = self._simulation_runner.get_file_name(
|
|
619
|
-
file_type="output", **self._simulation_runner.get_info_for_file_name(run)
|
|
620
|
-
)
|
|
621
|
-
self._results["output"].append(str(output_file_name))
|
|
622
|
-
return self._results["output"]
|
|
447
|
+
List with the full path of all output files.
|
|
623
448
|
|
|
624
|
-
def get_list_of_histogram_files(self):
|
|
625
449
|
"""
|
|
626
|
-
|
|
627
|
-
|
|
450
|
+
self._logger.info(f"Getting list of {file_type} files")
|
|
451
|
+
return self._results[file_type]
|
|
628
452
|
|
|
629
|
-
|
|
630
|
-
-------
|
|
631
|
-
list
|
|
632
|
-
List with the full path of all the histogram files.
|
|
453
|
+
def print_list_of_files(self, file_type="output"):
|
|
633
454
|
"""
|
|
634
|
-
|
|
635
|
-
return self._results["hist"]
|
|
455
|
+
Print list of output files generated by simulations.
|
|
636
456
|
|
|
637
|
-
|
|
638
|
-
"""
|
|
639
|
-
Get list of input files.
|
|
457
|
+
Options are "input", "output", "hist", "log".
|
|
640
458
|
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
"""
|
|
646
|
-
self._logger.info("Getting list of input files")
|
|
647
|
-
return self._results["input"]
|
|
459
|
+
Parameters
|
|
460
|
+
----------
|
|
461
|
+
file_type : str
|
|
462
|
+
File type to be listed.
|
|
648
463
|
|
|
649
|
-
def get_list_of_log_files(self):
|
|
650
464
|
"""
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
-------
|
|
655
|
-
list
|
|
656
|
-
List with the full path of all the log files.
|
|
657
|
-
"""
|
|
658
|
-
self._logger.info("Getting list of log files")
|
|
659
|
-
if self.simulator in ["simtel", "corsika_simtel"]:
|
|
660
|
-
return self._results["log"]
|
|
661
|
-
return self._results["corsika_autoinputs_log"]
|
|
662
|
-
|
|
663
|
-
def print_list_of_output_files(self):
|
|
664
|
-
"""Print list of output files."""
|
|
665
|
-
self._logger.info("Printing list of output files")
|
|
666
|
-
self._print_list_of_files(which="output")
|
|
667
|
-
|
|
668
|
-
def print_list_of_histogram_files(self):
|
|
669
|
-
"""Print list of histogram files."""
|
|
670
|
-
self._logger.info("Printing list of histogram files")
|
|
671
|
-
self._print_list_of_files(which="hist")
|
|
672
|
-
|
|
673
|
-
def print_list_of_input_files(self):
|
|
674
|
-
"""Print list of output files."""
|
|
675
|
-
self._logger.info("Printing list of input files")
|
|
676
|
-
self._print_list_of_files(which="input")
|
|
677
|
-
|
|
678
|
-
def print_list_of_log_files(self):
|
|
679
|
-
"""Print list of log files."""
|
|
680
|
-
self._logger.info("Printing list of log files")
|
|
681
|
-
if self.simulator in ["simtel", "corsika_simtel"]:
|
|
682
|
-
self._print_list_of_files(which="log")
|
|
683
|
-
else:
|
|
684
|
-
self._print_list_of_files(which="corsika_autoinputs_log")
|
|
465
|
+
self._logger.info(f"Printing list of {file_type} files")
|
|
466
|
+
for file in self._results[file_type]:
|
|
467
|
+
print(file)
|
|
685
468
|
|
|
686
469
|
def _make_resources_report(self, input_file_list):
|
|
687
470
|
"""
|
|
688
|
-
Prepare a simple report on computing
|
|
689
|
-
(includes wall clock time per run only at this point)
|
|
471
|
+
Prepare a simple report on computing wall clock time used in the simulations.
|
|
690
472
|
|
|
691
473
|
Parameters
|
|
692
474
|
----------
|
|
@@ -699,10 +481,9 @@ class Simulator:
|
|
|
699
481
|
Dictionary with reports on computing resources
|
|
700
482
|
|
|
701
483
|
"""
|
|
702
|
-
|
|
703
484
|
if len(self._results["sub_out"]) == 0:
|
|
704
485
|
if input_file_list is None:
|
|
705
|
-
return {"
|
|
486
|
+
return {"Wall time/run [sec]": np.nan}
|
|
706
487
|
self._fill_results_without_run(input_file_list)
|
|
707
488
|
|
|
708
489
|
runtime = []
|
|
@@ -710,16 +491,16 @@ class Simulator:
|
|
|
710
491
|
_resources = {}
|
|
711
492
|
for run in self.runs:
|
|
712
493
|
_resources = self._simulation_runner.get_resources(run_number=run)
|
|
713
|
-
if
|
|
494
|
+
if _resources.get("runtime"):
|
|
714
495
|
runtime.append(_resources["runtime"])
|
|
715
496
|
|
|
716
497
|
mean_runtime = np.mean(runtime)
|
|
717
498
|
|
|
718
499
|
resource_summary = {}
|
|
719
|
-
resource_summary["
|
|
500
|
+
resource_summary["Wall time/run [sec]"] = mean_runtime
|
|
720
501
|
if "n_events" in _resources and _resources["n_events"] > 0:
|
|
721
502
|
resource_summary["#events/run"] = _resources["n_events"]
|
|
722
|
-
resource_summary["
|
|
503
|
+
resource_summary["Wall time/1000 events [sec]"] = (
|
|
723
504
|
mean_runtime * 1000 / _resources["n_events"]
|
|
724
505
|
)
|
|
725
506
|
|
|
@@ -727,8 +508,9 @@ class Simulator:
|
|
|
727
508
|
|
|
728
509
|
def resources(self, input_file_list=None):
|
|
729
510
|
"""
|
|
730
|
-
Print a simple report on computing resources used
|
|
731
|
-
|
|
511
|
+
Print a simple report on computing resources used.
|
|
512
|
+
|
|
513
|
+
Includes run time per run only at this point.
|
|
732
514
|
|
|
733
515
|
Parameters
|
|
734
516
|
----------
|
|
@@ -738,7 +520,7 @@ class Simulator:
|
|
|
738
520
|
"""
|
|
739
521
|
resources = self._make_resources_report(input_file_list)
|
|
740
522
|
print("-----------------------------")
|
|
741
|
-
print(f"Computing Resources Report - {self.
|
|
523
|
+
print(f"Computing Resources Report - {self.simulation_software} Simulations")
|
|
742
524
|
for key, value in resources.items():
|
|
743
525
|
print(f"{key} = {value:.2f}")
|
|
744
526
|
print("-----------------------------")
|
|
@@ -761,28 +543,20 @@ class Simulator:
|
|
|
761
543
|
|
|
762
544
|
"""
|
|
763
545
|
if run_list is None and run_range is None:
|
|
764
|
-
if self.runs is None
|
|
765
|
-
msg = "Runs to simulate were not given as arguments nor in config_data - aborting"
|
|
766
|
-
self._logger.error(msg)
|
|
767
|
-
return []
|
|
768
|
-
|
|
769
|
-
return self.runs
|
|
770
|
-
|
|
546
|
+
return [] if self.runs is None else self.runs
|
|
771
547
|
return self._validate_run_list_and_range(run_list, run_range)
|
|
772
548
|
|
|
773
|
-
def
|
|
774
|
-
"""
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
for file in self._results[which]:
|
|
788
|
-
print(file)
|
|
549
|
+
def save_file_lists(self):
|
|
550
|
+
"""Save files lists for output and log files."""
|
|
551
|
+
for file_type in ["output", "log", "hist"]:
|
|
552
|
+
file_name = self.io_handler.get_output_directory(label=self.label).joinpath(
|
|
553
|
+
f"{file_type}_files.txt"
|
|
554
|
+
)
|
|
555
|
+
file_list = self.get_file_list(file_type=file_type)
|
|
556
|
+
if all(element is not None for element in file_list) and len(file_list) > 0:
|
|
557
|
+
self._logger.info(f"Saving list of {file_type} files to {file_name}")
|
|
558
|
+
with open(file_name, "w", encoding="utf-8") as f:
|
|
559
|
+
for line in self.get_file_list(file_type=file_type):
|
|
560
|
+
f.write(f"{line}\n")
|
|
561
|
+
else:
|
|
562
|
+
self._logger.debug(f"No files to save for {file_type} files.")
|