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
|
@@ -1,450 +0,0 @@
|
|
|
1
|
-
import logging
|
|
2
|
-
import os
|
|
3
|
-
from copy import copy
|
|
4
|
-
from pathlib import Path
|
|
5
|
-
|
|
6
|
-
from simtools.corsika.corsika_config import (
|
|
7
|
-
CorsikaConfig,
|
|
8
|
-
MissingRequiredInputInCorsikaConfigData,
|
|
9
|
-
)
|
|
10
|
-
from simtools.io_operations import io_handler
|
|
11
|
-
from simtools.utils import names
|
|
12
|
-
from simtools.utils.general import collect_data_from_file_or_dict
|
|
13
|
-
|
|
14
|
-
__all__ = ["CorsikaRunner", "MissingRequiredEntryInCorsikaConfig"]
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class MissingRequiredEntryInCorsikaConfig(Exception):
|
|
18
|
-
"""Exception for missing required entry in corsika config."""
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class CorsikaRunner:
|
|
22
|
-
"""
|
|
23
|
-
CorsikaRunner is responsible for running CORSIKA, through the corsika_autoinputs program \
|
|
24
|
-
provided by the sim_telarray package. It provides shell scripts to be run externally or by \
|
|
25
|
-
the module simulator. Same instance can be used to generate scripts for any given run number.
|
|
26
|
-
|
|
27
|
-
It uses CorsikaConfig to manage the CORSIKA configuration. User parameters must be given by the\
|
|
28
|
-
corsika_config_data or corsika_config_file arguments. An example of corsika_config_data follows\
|
|
29
|
-
below.
|
|
30
|
-
|
|
31
|
-
.. code-block:: python
|
|
32
|
-
|
|
33
|
-
corsika_config_data = {
|
|
34
|
-
'data_directory': .
|
|
35
|
-
'primary': 'proton',
|
|
36
|
-
'nshow': 10000,
|
|
37
|
-
'nrun': 1,
|
|
38
|
-
'zenith': 20 * u.deg,
|
|
39
|
-
'viewcone': 5 * u.deg,
|
|
40
|
-
'erange': [10 * u.GeV, 100 * u.TeV],
|
|
41
|
-
'eslope': -2,
|
|
42
|
-
'phi': 0 * u.deg,
|
|
43
|
-
'cscat': [10, 1500 * u.m, 0]
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
The remaining CORSIKA parameters can be set as a yaml file, using the argument \
|
|
47
|
-
corsika_parameters_file. When not given, corsika_parameters will be loaded from \
|
|
48
|
-
data/parameters/corsika_parameters.yml.
|
|
49
|
-
|
|
50
|
-
The CORSIKA output directory must be set by the data_directory entry. The following directories\
|
|
51
|
-
will be created to store the logs and input file:
|
|
52
|
-
{data_directory}/corsika/$site/$primary/logs
|
|
53
|
-
{data_directory}/corsika/$site/$primary/scripts
|
|
54
|
-
|
|
55
|
-
Parameters
|
|
56
|
-
----------
|
|
57
|
-
mongo_db_config: dict
|
|
58
|
-
MongoDB configuration.
|
|
59
|
-
site: str
|
|
60
|
-
South or North.
|
|
61
|
-
layout_name: str
|
|
62
|
-
Name of the layout.
|
|
63
|
-
label: str
|
|
64
|
-
Instance label.
|
|
65
|
-
keep_seeds: bool
|
|
66
|
-
Use seeds based on run number and primary particle. If False, use sim_telarray seeds.
|
|
67
|
-
simtel_source_path: str or Path
|
|
68
|
-
Location of source of the sim_telarray/CORSIKA package.
|
|
69
|
-
corsika_config_data: dict
|
|
70
|
-
Dict with CORSIKA config data.
|
|
71
|
-
corsika_config_file: str or Path
|
|
72
|
-
Path to yaml file containing CORSIKA config data.
|
|
73
|
-
corsika_parameters_file: str or Path
|
|
74
|
-
Path to yaml file containing CORSIKA parameters.
|
|
75
|
-
"""
|
|
76
|
-
|
|
77
|
-
def __init__(
|
|
78
|
-
self,
|
|
79
|
-
mongo_db_config,
|
|
80
|
-
site,
|
|
81
|
-
layout_name,
|
|
82
|
-
simtel_source_path,
|
|
83
|
-
label=None,
|
|
84
|
-
keep_seeds=False,
|
|
85
|
-
corsika_parameters_file=None,
|
|
86
|
-
corsika_config_data=None,
|
|
87
|
-
corsika_config_file=None,
|
|
88
|
-
use_multipipe=False,
|
|
89
|
-
):
|
|
90
|
-
"""
|
|
91
|
-
CorsikaRunner init.
|
|
92
|
-
"""
|
|
93
|
-
|
|
94
|
-
self._logger = logging.getLogger(__name__)
|
|
95
|
-
self._logger.debug("Init CorsikaRunner")
|
|
96
|
-
|
|
97
|
-
self.label = label
|
|
98
|
-
self.site = names.validate_site_name(site)
|
|
99
|
-
self.layout_name = names.validate_array_layout_name(layout_name)
|
|
100
|
-
|
|
101
|
-
self._keep_seeds = keep_seeds
|
|
102
|
-
|
|
103
|
-
self._simtel_source_path = Path(simtel_source_path)
|
|
104
|
-
self.io_handler = io_handler.IOHandler()
|
|
105
|
-
_runner_directory = "corsika_simtel" if use_multipipe else "corsika"
|
|
106
|
-
self._output_directory = self.io_handler.get_output_directory(self.label, _runner_directory)
|
|
107
|
-
self._logger.debug(f"Creating output dir {self._output_directory}, if needed,")
|
|
108
|
-
|
|
109
|
-
self._corsika_parameters_file = corsika_parameters_file
|
|
110
|
-
corsika_config_data = collect_data_from_file_or_dict(
|
|
111
|
-
corsika_config_file, corsika_config_data
|
|
112
|
-
)
|
|
113
|
-
self._load_corsika_config_data(corsika_config_data)
|
|
114
|
-
self._define_corsika_config(mongo_db_config, use_multipipe)
|
|
115
|
-
|
|
116
|
-
self._load_corsika_data_directories()
|
|
117
|
-
|
|
118
|
-
def _load_corsika_config_data(self, corsika_config_data):
|
|
119
|
-
"""Reads corsika_config_data, creates corsika_config and corsika_input_file."""
|
|
120
|
-
|
|
121
|
-
corsika_data_directory_from_config = corsika_config_data.get("data_directory", None)
|
|
122
|
-
if corsika_data_directory_from_config is None:
|
|
123
|
-
# corsika_data_directory not given (or None).
|
|
124
|
-
msg = (
|
|
125
|
-
"data_directory not given in corsika_config "
|
|
126
|
-
"- default output directory will be set."
|
|
127
|
-
)
|
|
128
|
-
self._logger.warning(msg)
|
|
129
|
-
self._corsika_data_directory = self._output_directory
|
|
130
|
-
else:
|
|
131
|
-
# corsika_data_directory given and not None.
|
|
132
|
-
self._corsika_data_directory = Path(corsika_data_directory_from_config)
|
|
133
|
-
|
|
134
|
-
self._corsika_data_directory = self._corsika_data_directory.joinpath("corsika-data")
|
|
135
|
-
|
|
136
|
-
# Copying corsika_config_data and removing corsika_data_directory
|
|
137
|
-
# (it does not go to CorsikaConfig)
|
|
138
|
-
self._corsika_config_data = copy(corsika_config_data)
|
|
139
|
-
self._corsika_config_data.pop("data_directory", None)
|
|
140
|
-
|
|
141
|
-
def _define_corsika_config(self, mongo_db_config, use_multipipe=False):
|
|
142
|
-
"""
|
|
143
|
-
Create the CORSIKA config instance.
|
|
144
|
-
This validates the input given in corsika_config_data as well.
|
|
145
|
-
"""
|
|
146
|
-
|
|
147
|
-
try:
|
|
148
|
-
self.corsika_config = CorsikaConfig(
|
|
149
|
-
mongo_db_config=mongo_db_config,
|
|
150
|
-
site=self.site,
|
|
151
|
-
label=self.label,
|
|
152
|
-
layout_name=self.layout_name,
|
|
153
|
-
corsika_config_data=self._corsika_config_data,
|
|
154
|
-
simtel_source_path=self._simtel_source_path,
|
|
155
|
-
corsika_parameters_file=self._corsika_parameters_file,
|
|
156
|
-
)
|
|
157
|
-
# CORSIKA input file used as template for all runs
|
|
158
|
-
self._corsika_input_file = self.corsika_config.get_input_file(use_multipipe)
|
|
159
|
-
except MissingRequiredInputInCorsikaConfigData:
|
|
160
|
-
msg = "corsika_config_data is missing required entries."
|
|
161
|
-
self._logger.error(msg)
|
|
162
|
-
raise
|
|
163
|
-
|
|
164
|
-
def _load_corsika_data_directories(self):
|
|
165
|
-
"""Create CORSIKA directories for data, log and input."""
|
|
166
|
-
corsika_base_dir = self._corsika_data_directory.joinpath(self.site)
|
|
167
|
-
corsika_base_dir = corsika_base_dir.joinpath(self.corsika_config.primary)
|
|
168
|
-
corsika_base_dir = corsika_base_dir.absolute()
|
|
169
|
-
|
|
170
|
-
self._corsika_data_dir = corsika_base_dir.joinpath("data")
|
|
171
|
-
self._corsika_data_dir.mkdir(parents=True, exist_ok=True)
|
|
172
|
-
self._corsika_input_dir = corsika_base_dir.joinpath("input")
|
|
173
|
-
self._corsika_input_dir.mkdir(parents=True, exist_ok=True)
|
|
174
|
-
self._corsika_log_dir = corsika_base_dir.joinpath("log")
|
|
175
|
-
self._corsika_log_dir.mkdir(parents=True, exist_ok=True)
|
|
176
|
-
|
|
177
|
-
def prepare_run_script(self, use_pfp=True, **kwargs):
|
|
178
|
-
"""
|
|
179
|
-
Get the full path of the run script file for a given run number.
|
|
180
|
-
|
|
181
|
-
Parameters
|
|
182
|
-
----------
|
|
183
|
-
use_pfp: bool
|
|
184
|
-
Whether to use the preprocessor in preparing the CORSIKA input file
|
|
185
|
-
kwargs: dict
|
|
186
|
-
The following optional parameters can be provided:
|
|
187
|
-
run_number: int
|
|
188
|
-
Run number.
|
|
189
|
-
extra_commands: str
|
|
190
|
-
Additional commands for running simulations.
|
|
191
|
-
|
|
192
|
-
Returns
|
|
193
|
-
-------
|
|
194
|
-
Path:
|
|
195
|
-
Full path of the run script file.
|
|
196
|
-
"""
|
|
197
|
-
kwargs = {
|
|
198
|
-
"run_number": None,
|
|
199
|
-
"extra_commands": None,
|
|
200
|
-
**kwargs,
|
|
201
|
-
}
|
|
202
|
-
run_number = self._validate_run_number(kwargs["run_number"])
|
|
203
|
-
|
|
204
|
-
script_file_path = self.get_file_name(
|
|
205
|
-
file_type="script", **self.get_info_for_file_name(run_number)
|
|
206
|
-
)
|
|
207
|
-
|
|
208
|
-
# CORSIKA input file for a specific run, created by the preprocessor pfp
|
|
209
|
-
corsika_input_tmp_name = self.corsika_config.get_file_name(
|
|
210
|
-
file_type="config_tmp", run_number=run_number
|
|
211
|
-
)
|
|
212
|
-
corsika_input_tmp_file = self._corsika_input_dir.joinpath(corsika_input_tmp_name)
|
|
213
|
-
|
|
214
|
-
if use_pfp:
|
|
215
|
-
pfp_command = self._get_pfp_command(corsika_input_tmp_file)
|
|
216
|
-
autoinputs_command = self._get_autoinputs_command(run_number, corsika_input_tmp_file)
|
|
217
|
-
|
|
218
|
-
extra_commands = kwargs["extra_commands"]
|
|
219
|
-
self._logger.debug(f"Extra commands to be added to the run script {extra_commands}")
|
|
220
|
-
|
|
221
|
-
with open(script_file_path, "w", encoding="utf-8") as file:
|
|
222
|
-
# shebang
|
|
223
|
-
file.write("#!/usr/bin/env bash\n")
|
|
224
|
-
|
|
225
|
-
# Make sure to exit on failed commands and report their error code
|
|
226
|
-
file.write("set -e\n")
|
|
227
|
-
file.write("set -o pipefail\n")
|
|
228
|
-
|
|
229
|
-
# Setting SECONDS variable to measure runtime
|
|
230
|
-
file.write("\nSECONDS=0\n")
|
|
231
|
-
|
|
232
|
-
if extra_commands is not None:
|
|
233
|
-
file.write("\n# Writing extras\n")
|
|
234
|
-
file.write(f"{extra_commands}\n")
|
|
235
|
-
file.write("# End of extras\n\n")
|
|
236
|
-
|
|
237
|
-
file.write(f"export CORSIKA_DATA={self._corsika_data_dir}\n")
|
|
238
|
-
file.write("\n# Creating CORSIKA_DATA\n")
|
|
239
|
-
file.write(f"mkdir -p {self._corsika_data_dir}\n")
|
|
240
|
-
file.write(f"cd {self._corsika_data_dir} || exit 2\n")
|
|
241
|
-
if use_pfp:
|
|
242
|
-
file.write("\n# Running pfp\n")
|
|
243
|
-
file.write(pfp_command)
|
|
244
|
-
file.write("\n# Replacing the XXXXXX placeholder with the run number\n")
|
|
245
|
-
file.write(f"sed -i 's/XXXXXX/{run_number:06}/g' {corsika_input_tmp_file}\n")
|
|
246
|
-
else:
|
|
247
|
-
file.write("\n# Copying CORSIKA input file to run location\n")
|
|
248
|
-
file.write(f"cp {self._corsika_input_file} {corsika_input_tmp_file}")
|
|
249
|
-
file.write("\n# Running corsika_autoinputs\n")
|
|
250
|
-
file.write(autoinputs_command)
|
|
251
|
-
|
|
252
|
-
# Printing out runtime
|
|
253
|
-
file.write('\necho "RUNTIME: $SECONDS"\n')
|
|
254
|
-
|
|
255
|
-
# Changing permissions
|
|
256
|
-
os.system(f"chmod ug+x {script_file_path}")
|
|
257
|
-
|
|
258
|
-
return script_file_path
|
|
259
|
-
|
|
260
|
-
def _get_pfp_command(self, input_tmp_file):
|
|
261
|
-
"""Get pfp pre-processor command."""
|
|
262
|
-
cmd = self._simtel_source_path.joinpath("sim_telarray/bin/pfp")
|
|
263
|
-
cmd = str(cmd) + f" -V -DWITHOUT_MULTIPIPE - < {self._corsika_input_file}"
|
|
264
|
-
cmd += f" > {input_tmp_file} || exit\n"
|
|
265
|
-
return cmd
|
|
266
|
-
|
|
267
|
-
def _get_autoinputs_command(self, run_number, input_tmp_file):
|
|
268
|
-
"""Get autoinputs command."""
|
|
269
|
-
corsika_bin_path = self._simtel_source_path.joinpath("corsika-run/corsika")
|
|
270
|
-
|
|
271
|
-
log_file = self.get_file_name(
|
|
272
|
-
file_type="corsika_autoinputs_log", **self.get_info_for_file_name(run_number)
|
|
273
|
-
)
|
|
274
|
-
|
|
275
|
-
cmd = self._simtel_source_path.joinpath("sim_telarray/bin/corsika_autoinputs")
|
|
276
|
-
cmd = str(cmd) + f" --run {corsika_bin_path}"
|
|
277
|
-
cmd += f" -R {run_number}"
|
|
278
|
-
cmd += f" -p {self._corsika_data_dir}"
|
|
279
|
-
if self._keep_seeds:
|
|
280
|
-
cmd += " --keep-seeds"
|
|
281
|
-
cmd += f" {input_tmp_file} | gzip > {log_file} 2>&1"
|
|
282
|
-
cmd += " || exit 1\n"
|
|
283
|
-
return cmd
|
|
284
|
-
|
|
285
|
-
def get_info_for_file_name(self, run_number):
|
|
286
|
-
"""
|
|
287
|
-
Get a dictionary with the info necessary for building the CORSIKA runner file names.
|
|
288
|
-
|
|
289
|
-
Returns
|
|
290
|
-
-------
|
|
291
|
-
dict
|
|
292
|
-
Dictionary with the keys necessary for building the CORSIKA runner file names.
|
|
293
|
-
"""
|
|
294
|
-
run_number = self._validate_run_number(run_number)
|
|
295
|
-
return {
|
|
296
|
-
"run": run_number,
|
|
297
|
-
"primary": self.corsika_config.primary,
|
|
298
|
-
"array_name": self.layout_name,
|
|
299
|
-
"site": self.site,
|
|
300
|
-
"label": self.label,
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
def get_file_name(self, file_type, **kwargs):
|
|
304
|
-
"""
|
|
305
|
-
Get a CORSIKA style file name for various file types.
|
|
306
|
-
|
|
307
|
-
Parameters
|
|
308
|
-
----------
|
|
309
|
-
file_type: str
|
|
310
|
-
The type of file (determines the file suffix).
|
|
311
|
-
Choices are corsika_autoinputs_log, corsika_log, script, output or sub_log.
|
|
312
|
-
kwargs: dict
|
|
313
|
-
The dictionary must include the following parameters (unless listed as optional):
|
|
314
|
-
run: int
|
|
315
|
-
Run number.
|
|
316
|
-
primary: str
|
|
317
|
-
Primary particle (e.g gamma, proton etc).
|
|
318
|
-
site: str
|
|
319
|
-
Site name (usually North/South or Paranal/LaPalma).
|
|
320
|
-
array_name: str
|
|
321
|
-
Array name.
|
|
322
|
-
label: str
|
|
323
|
-
Instance label (optional).
|
|
324
|
-
mode: str
|
|
325
|
-
out or err (optional, relevant only for sub_log).
|
|
326
|
-
|
|
327
|
-
Returns
|
|
328
|
-
-------
|
|
329
|
-
str
|
|
330
|
-
File name with full path.
|
|
331
|
-
|
|
332
|
-
Raises
|
|
333
|
-
------
|
|
334
|
-
ValueError
|
|
335
|
-
If file_type is unknown.
|
|
336
|
-
"""
|
|
337
|
-
|
|
338
|
-
file_label = (
|
|
339
|
-
f"_{kwargs['label']}" if "label" in kwargs and kwargs["label"] is not None else ""
|
|
340
|
-
)
|
|
341
|
-
file_name = (
|
|
342
|
-
f"corsika_run{kwargs['run']:06}_{kwargs['primary']}_"
|
|
343
|
-
f"{kwargs['site']}_{kwargs['array_name']}{file_label}"
|
|
344
|
-
)
|
|
345
|
-
|
|
346
|
-
if file_type == "corsika_autoinputs_log":
|
|
347
|
-
return self._corsika_log_dir.joinpath(f"log_{file_name}.log.gz")
|
|
348
|
-
if file_type == "corsika_log":
|
|
349
|
-
run_dir = self._get_run_directory(kwargs["run"])
|
|
350
|
-
return self._corsika_data_dir.joinpath(run_dir).joinpath(f"run{kwargs['run']}.log")
|
|
351
|
-
if file_type == "script":
|
|
352
|
-
script_file_dir = self._output_directory.joinpath("scripts")
|
|
353
|
-
script_file_dir.mkdir(parents=True, exist_ok=True)
|
|
354
|
-
return script_file_dir.joinpath(f"{file_name}.sh")
|
|
355
|
-
if file_type == "output":
|
|
356
|
-
zenith = self.corsika_config.get_user_parameter("THETAP")[0]
|
|
357
|
-
azimuth = self.corsika_config.get_user_parameter("AZM")[0]
|
|
358
|
-
file_name = (
|
|
359
|
-
f"corsika_run{kwargs['run']:06}_{kwargs['primary']}_"
|
|
360
|
-
f"za{round(zenith):03}deg_azm{round(azimuth):03}deg_"
|
|
361
|
-
f"{kwargs['site']}_{kwargs['array_name']}{file_label}"
|
|
362
|
-
)
|
|
363
|
-
run_dir = self._get_run_directory(kwargs["run"])
|
|
364
|
-
return self._corsika_data_dir.joinpath(run_dir).joinpath(f"{file_name}.zst")
|
|
365
|
-
if file_type == "sub_log":
|
|
366
|
-
suffix = ".log"
|
|
367
|
-
if "mode" in kwargs and kwargs["mode"] != "":
|
|
368
|
-
suffix = f".{kwargs['mode']}"
|
|
369
|
-
sub_log_file_dir = self._output_directory.joinpath("logs")
|
|
370
|
-
sub_log_file_dir.mkdir(parents=True, exist_ok=True)
|
|
371
|
-
return sub_log_file_dir.joinpath(f"log_sub_{file_name}{suffix}")
|
|
372
|
-
|
|
373
|
-
raise ValueError(f"The requested file type ({file_type}) is unknown")
|
|
374
|
-
|
|
375
|
-
def has_file(self, file_type, run_number=None, mode="out"):
|
|
376
|
-
"""
|
|
377
|
-
Checks that the file of file_type for the specified run number exists.
|
|
378
|
-
|
|
379
|
-
Parameters
|
|
380
|
-
----------
|
|
381
|
-
file_type: str
|
|
382
|
-
File type to check.
|
|
383
|
-
Choices are corsika_autoinputs_log, corsika_log, script, output or sub_log.
|
|
384
|
-
run_number: int
|
|
385
|
-
Run number.
|
|
386
|
-
|
|
387
|
-
"""
|
|
388
|
-
|
|
389
|
-
info_for_file_name = self.get_info_for_file_name(run_number)
|
|
390
|
-
run_sub_file = self.get_file_name(file_type, **info_for_file_name, mode=mode)
|
|
391
|
-
return Path(run_sub_file).is_file()
|
|
392
|
-
|
|
393
|
-
def get_resources(self, run_number=None):
|
|
394
|
-
"""
|
|
395
|
-
Read run time of job from last line of submission log file.
|
|
396
|
-
|
|
397
|
-
Parameters
|
|
398
|
-
----------
|
|
399
|
-
run_number: int
|
|
400
|
-
Run number.
|
|
401
|
-
|
|
402
|
-
Returns
|
|
403
|
-
-------
|
|
404
|
-
dict
|
|
405
|
-
run time and number of simulated events
|
|
406
|
-
|
|
407
|
-
"""
|
|
408
|
-
|
|
409
|
-
sub_log_file = self.get_file_name(
|
|
410
|
-
file_type="sub_log", **self.get_info_for_file_name(run_number), mode="out"
|
|
411
|
-
)
|
|
412
|
-
|
|
413
|
-
self._logger.debug(f"Reading resources from {sub_log_file}")
|
|
414
|
-
|
|
415
|
-
_resources = {}
|
|
416
|
-
|
|
417
|
-
_resources["runtime"] = None
|
|
418
|
-
with open(sub_log_file, "r", encoding="utf-8") as file:
|
|
419
|
-
for line in reversed(list(file)):
|
|
420
|
-
if "RUNTIME" in line:
|
|
421
|
-
_resources["runtime"] = int(line.split()[1])
|
|
422
|
-
break
|
|
423
|
-
|
|
424
|
-
if _resources["runtime"] is None:
|
|
425
|
-
self._logger.debug("RUNTIME was not found in run log file")
|
|
426
|
-
|
|
427
|
-
# Calculating number of events
|
|
428
|
-
_resources["n_events"] = int(self.corsika_config.get_user_parameter("NSHOW"))
|
|
429
|
-
|
|
430
|
-
return _resources
|
|
431
|
-
|
|
432
|
-
@staticmethod
|
|
433
|
-
def _get_run_directory(run_number):
|
|
434
|
-
"""Get run directory created by sim_telarray (ex. run000014)."""
|
|
435
|
-
nn = str(run_number)
|
|
436
|
-
return "run" + nn.zfill(6)
|
|
437
|
-
|
|
438
|
-
def _validate_run_number(self, run_number):
|
|
439
|
-
"""
|
|
440
|
-
Returns the run number from corsika_config in case run_number is None, Raise ValueError if\
|
|
441
|
-
run_number is not valid (< 1) or returns run_number if it is a valid value.
|
|
442
|
-
"""
|
|
443
|
-
if run_number is None:
|
|
444
|
-
return self.corsika_config.get_user_parameter("RUNNR")
|
|
445
|
-
if not float(run_number).is_integer() or run_number < 1:
|
|
446
|
-
msg = f"Invalid type of run number ({run_number}) - it must be an uint."
|
|
447
|
-
self._logger.error(msg)
|
|
448
|
-
raise ValueError(msg)
|
|
449
|
-
|
|
450
|
-
return run_number
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import stat
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
|
|
4
|
-
from simtools.corsika.corsika_runner import CorsikaRunner
|
|
5
|
-
from simtools.simtel.simtel_runner_array import SimtelRunnerArray
|
|
6
|
-
|
|
7
|
-
__all__ = ["CorsikaSimtelRunner"]
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class CorsikaSimtelRunner(CorsikaRunner, SimtelRunnerArray):
|
|
11
|
-
"""
|
|
12
|
-
CorsikaSimtelRunner is responsible for running CORSIKA and piping it to sim_telarray
|
|
13
|
-
using the multipipe functionality. CORSIKA is set up using corsika_autoinputs program
|
|
14
|
-
provided by the sim_telarray package. It creates the multipipe script and sim_telarray command
|
|
15
|
-
corresponding to the requested configuration.
|
|
16
|
-
|
|
17
|
-
It uses CorsikaConfig to manage the CORSIKA configuration and SimtelRunnerArray
|
|
18
|
-
for the sim_telarray configuration. User parameters must be given by the
|
|
19
|
-
common_args, corsika_args and simtel_args arguments.
|
|
20
|
-
The corsika_args and simtel_args are explained in
|
|
21
|
-
CorsikaRunner and SimtelRunnerArray respectively.
|
|
22
|
-
An example of the common_args is given below.
|
|
23
|
-
|
|
24
|
-
.. code-block:: python
|
|
25
|
-
|
|
26
|
-
common_args = {
|
|
27
|
-
'label': 'test-production',
|
|
28
|
-
'simtel_source_path': '/workdir/sim_telarray/',
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
Parameters
|
|
32
|
-
----------
|
|
33
|
-
common_args: dict
|
|
34
|
-
Arguments common to both CORSIKA and sim_telarray runners
|
|
35
|
-
corsika_args: dict
|
|
36
|
-
Arguments for the CORSIKA runner (see full list in CorsikaRunner documentation).
|
|
37
|
-
simtel_args: dict
|
|
38
|
-
Arguments for the sim_telarray runner (see full list in SimtelRunnerArray documentation).
|
|
39
|
-
"""
|
|
40
|
-
|
|
41
|
-
def __init__(self, common_args=None, corsika_args=None, simtel_args=None):
|
|
42
|
-
CorsikaRunner.__init__(self, use_multipipe=True, **(common_args | corsika_args))
|
|
43
|
-
SimtelRunnerArray.__init__(self, **(common_args | simtel_args))
|
|
44
|
-
|
|
45
|
-
def prepare_run_script(self, use_pfp=False, **kwargs):
|
|
46
|
-
"""
|
|
47
|
-
Get the full path of the run script file for a given run number.
|
|
48
|
-
|
|
49
|
-
Parameters
|
|
50
|
-
----------
|
|
51
|
-
use_pfp: bool
|
|
52
|
-
Whether to use the preprocessor in preparing the CORSIKA input file
|
|
53
|
-
kwargs: dict
|
|
54
|
-
The following optional parameters can be provided:
|
|
55
|
-
run_number: int
|
|
56
|
-
Run number.
|
|
57
|
-
|
|
58
|
-
Returns
|
|
59
|
-
-------
|
|
60
|
-
Path:
|
|
61
|
-
Full path of the run script file.
|
|
62
|
-
"""
|
|
63
|
-
self.export_multipipe_script(**kwargs)
|
|
64
|
-
return CorsikaRunner.prepare_run_script(self, use_pfp=use_pfp, **kwargs)
|
|
65
|
-
|
|
66
|
-
def export_multipipe_script(self, **kwargs):
|
|
67
|
-
"""
|
|
68
|
-
Write the multipipe script used in piping CORSIKA to sim_telarray.
|
|
69
|
-
|
|
70
|
-
Parameters
|
|
71
|
-
----------
|
|
72
|
-
kwargs: dict
|
|
73
|
-
The following optional parameters can be provided:
|
|
74
|
-
run_number: int
|
|
75
|
-
Run number.
|
|
76
|
-
|
|
77
|
-
Returns
|
|
78
|
-
-------
|
|
79
|
-
Path:
|
|
80
|
-
Full path of the run script file.
|
|
81
|
-
"""
|
|
82
|
-
|
|
83
|
-
kwargs = {
|
|
84
|
-
"run_number": None,
|
|
85
|
-
**kwargs,
|
|
86
|
-
}
|
|
87
|
-
run_number = self._validate_run_number(kwargs["run_number"])
|
|
88
|
-
|
|
89
|
-
run_command = self._make_run_command(
|
|
90
|
-
run_number=run_number,
|
|
91
|
-
input_file="-", # Tell sim_telarray to take the input from standard output
|
|
92
|
-
)
|
|
93
|
-
multipipe_file = Path(self.corsika_config.config_file_path.parent).joinpath(
|
|
94
|
-
self.corsika_config.get_file_name("multipipe")
|
|
95
|
-
)
|
|
96
|
-
with open(multipipe_file, "w", encoding="utf-8") as file:
|
|
97
|
-
file.write(f"{run_command}")
|
|
98
|
-
self._export_multipipe_executable(multipipe_file)
|
|
99
|
-
|
|
100
|
-
def _export_multipipe_executable(self, multipipe_file):
|
|
101
|
-
"""
|
|
102
|
-
Write the multipipe executable used to call the multipipe_corsika command.
|
|
103
|
-
|
|
104
|
-
Parameters
|
|
105
|
-
----------
|
|
106
|
-
multipipe_file: str or Path
|
|
107
|
-
The name of the multipipe file which contains all of the multipipe commands.
|
|
108
|
-
"""
|
|
109
|
-
|
|
110
|
-
multipipe_executable = Path(self.corsika_config.config_file_path.parent).joinpath(
|
|
111
|
-
"run_cta_multipipe"
|
|
112
|
-
)
|
|
113
|
-
with open(multipipe_executable, "w", encoding="utf-8") as file:
|
|
114
|
-
multipipe_command = Path(self._simtel_source_path).joinpath(
|
|
115
|
-
"sim_telarray/bin/multipipe_corsika "
|
|
116
|
-
f"-c {multipipe_file}"
|
|
117
|
-
" || echo 'Fan-out failed'"
|
|
118
|
-
)
|
|
119
|
-
file.write(f"{multipipe_command}")
|
|
120
|
-
|
|
121
|
-
multipipe_executable.chmod(multipipe_executable.stat().st_mode | stat.S_IEXEC)
|
|
122
|
-
|
|
123
|
-
def _make_run_command(self, **kwargs):
|
|
124
|
-
"""
|
|
125
|
-
Builds and returns the command to run simtel_array.
|
|
126
|
-
|
|
127
|
-
Parameters
|
|
128
|
-
----------
|
|
129
|
-
kwargs: dict
|
|
130
|
-
The dictionary must include the following parameters (unless listed as optional):
|
|
131
|
-
input_file: str
|
|
132
|
-
Full path of the input CORSIKA file.
|
|
133
|
-
Use '-' to tell sim_telarray to read from standard output
|
|
134
|
-
run_number: int
|
|
135
|
-
run number
|
|
136
|
-
|
|
137
|
-
"""
|
|
138
|
-
|
|
139
|
-
info_for_file_name = SimtelRunnerArray.get_info_for_file_name(self, kwargs["run_number"])
|
|
140
|
-
weak_pointing = any(pointing in self.label for pointing in ["divergent", "convergent"])
|
|
141
|
-
|
|
142
|
-
command = str(self._simtel_source_path.joinpath("sim_telarray/bin/sim_telarray"))
|
|
143
|
-
command += f" -c {self.array_model.get_config_file()}"
|
|
144
|
-
command += f" -I{self.array_model.get_config_directory()}"
|
|
145
|
-
command += super()._config_option(
|
|
146
|
-
"telescope_theta", self.config.zenith_angle, weak_option=weak_pointing
|
|
147
|
-
)
|
|
148
|
-
command += super()._config_option(
|
|
149
|
-
"telescope_phi", self.config.azimuth_angle, weak_option=weak_pointing
|
|
150
|
-
)
|
|
151
|
-
command += super()._config_option("power_law", abs(self.corsika_config.eslope))
|
|
152
|
-
command += super()._config_option(
|
|
153
|
-
"histogram_file", self.get_file_name("histogram", **info_for_file_name)
|
|
154
|
-
)
|
|
155
|
-
command += super()._config_option(
|
|
156
|
-
"output_file", self.get_file_name("output", **info_for_file_name)
|
|
157
|
-
)
|
|
158
|
-
command += super()._config_option("random_state", "none")
|
|
159
|
-
command += super()._config_option("show", "all")
|
|
160
|
-
command += f" {kwargs['input_file']}"
|
|
161
|
-
command += f" | gzip > {self.get_file_name('log', **info_for_file_name)} 2>&1 || exit"
|
|
162
|
-
|
|
163
|
-
return command
|
|
164
|
-
|
|
165
|
-
def get_file_name(self, file_type, run_number=None, **kwargs):
|
|
166
|
-
"""
|
|
167
|
-
Get a CORSIKA or sim_telarray style file name for various file types.
|
|
168
|
-
See the implementations in CorsikaRunner and SimtelRunnerArray for details.
|
|
169
|
-
"""
|
|
170
|
-
|
|
171
|
-
if file_type in ["output", "log", "histogram"]:
|
|
172
|
-
return SimtelRunnerArray.get_file_name(self, file_type=file_type, **kwargs)
|
|
173
|
-
return CorsikaRunner.get_file_name(
|
|
174
|
-
self, file_type=file_type, run_number=run_number, **kwargs
|
|
175
|
-
)
|
|
176
|
-
|
|
177
|
-
def get_info_for_file_name(self, run_number):
|
|
178
|
-
"""
|
|
179
|
-
Get a dictionary with the info necessary for building
|
|
180
|
-
a CORSIKA or sim_telarray runner file names.
|
|
181
|
-
|
|
182
|
-
Returns
|
|
183
|
-
-------
|
|
184
|
-
dict
|
|
185
|
-
Dictionary with the keys necessary for building
|
|
186
|
-
a CORSIKA or sim_telarray runner file names.
|
|
187
|
-
"""
|
|
188
|
-
run_number = self._validate_run_number(run_number)
|
|
189
|
-
return {
|
|
190
|
-
"run": run_number,
|
|
191
|
-
"primary": self.corsika_config.primary,
|
|
192
|
-
"array_name": self.layout_name,
|
|
193
|
-
"site": self.site,
|
|
194
|
-
"label": self.label,
|
|
195
|
-
"zenith": self.config.zenith_angle,
|
|
196
|
-
"azimuth": self.config.azimuth_angle,
|
|
197
|
-
}
|