gammasimtools 0.8.1__py3-none-any.whl → 0.9.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {gammasimtools-0.8.1.dist-info → gammasimtools-0.9.0.dist-info}/METADATA +4 -3
- gammasimtools-0.9.0.dist-info/RECORD +350 -0
- {gammasimtools-0.8.1.dist-info → gammasimtools-0.9.0.dist-info}/WHEEL +1 -1
- {gammasimtools-0.8.1.dist-info → gammasimtools-0.9.0.dist-info}/entry_points.txt +2 -0
- simtools/_dev_version/__init__.py +9 -0
- simtools/_version.py +2 -2
- simtools/applications/convert_all_model_parameters_from_simtel.py +1 -1
- simtools/applications/convert_geo_coordinates_of_array_elements.py +8 -9
- simtools/applications/convert_model_parameter_from_simtel.py +1 -1
- simtools/applications/db_add_model_parameters_from_repository_to_db.py +2 -10
- simtools/applications/db_add_value_from_json_to_db.py +1 -9
- simtools/applications/db_get_array_layouts_from_db.py +3 -1
- simtools/applications/db_get_parameter_from_db.py +1 -1
- simtools/applications/derive_mirror_rnda.py +10 -1
- simtools/applications/derive_psf_parameters.py +1 -1
- simtools/applications/generate_array_config.py +1 -5
- simtools/applications/generate_regular_arrays.py +9 -6
- simtools/applications/generate_simtel_array_histograms.py +1 -1
- simtools/applications/plot_array_layout.py +3 -1
- simtools/applications/plot_tabular_data.py +84 -0
- simtools/applications/production_scale_events.py +1 -2
- simtools/applications/simulate_light_emission.py +2 -2
- simtools/applications/simulate_prod.py +24 -59
- simtools/applications/simulate_prod_htcondor_generator.py +95 -0
- simtools/applications/submit_data_from_external.py +1 -1
- simtools/applications/validate_camera_efficiency.py +1 -1
- simtools/applications/validate_camera_fov.py +4 -8
- simtools/applications/validate_cumulative_psf.py +3 -7
- simtools/applications/validate_file_using_schema.py +31 -23
- simtools/applications/validate_optics.py +3 -4
- simtools/camera_efficiency.py +1 -4
- simtools/configuration/commandline_parser.py +9 -15
- simtools/configuration/configurator.py +6 -19
- simtools/constants.py +3 -3
- simtools/data_model/metadata_collector.py +19 -1
- simtools/data_model/metadata_model.py +18 -5
- simtools/data_model/model_data_writer.py +1 -1
- simtools/data_model/validate_data.py +67 -10
- simtools/db/db_handler.py +92 -315
- simtools/io_operations/legacy_data_handler.py +61 -0
- simtools/job_execution/htcondor_script_generator.py +133 -0
- simtools/job_execution/job_manager.py +77 -50
- simtools/model/array_model.py +30 -26
- simtools/model/calibration_model.py +10 -10
- simtools/model/camera.py +79 -63
- simtools/model/mirrors.py +8 -6
- simtools/model/model_parameter.py +42 -12
- simtools/model/model_utils.py +6 -6
- simtools/model/site_model.py +2 -2
- simtools/model/telescope_model.py +26 -22
- simtools/ray_tracing/mirror_panel_psf.py +47 -27
- simtools/runners/corsika_runner.py +14 -3
- simtools/runners/runner_services.py +3 -3
- simtools/runners/simtel_runner.py +27 -8
- simtools/schemas/integration_tests_config.metaschema.yml +15 -5
- simtools/schemas/model_parameter.metaschema.yml +90 -2
- simtools/schemas/model_parameters/adjust_gain.schema.yml +1 -1
- simtools/schemas/model_parameters/altitude.schema.yml +1 -1
- simtools/schemas/model_parameters/array_coordinates.schema.yml +1 -1
- simtools/schemas/model_parameters/array_coordinates_UTM.schema.yml +1 -1
- simtools/schemas/model_parameters/array_element_position_ground.schema.yml +1 -1
- simtools/schemas/model_parameters/array_element_position_utm.schema.yml +1 -1
- simtools/schemas/model_parameters/array_layouts.schema.yml +1 -1
- simtools/schemas/model_parameters/array_triggers.schema.yml +1 -1
- simtools/schemas/model_parameters/asum_clipping.schema.yml +1 -1
- simtools/schemas/model_parameters/asum_offset.schema.yml +1 -1
- simtools/schemas/model_parameters/asum_shaping.schema.yml +1 -1
- simtools/schemas/model_parameters/asum_threshold.schema.yml +1 -1
- simtools/schemas/model_parameters/atmospheric_profile.schema.yml +1 -1
- simtools/schemas/model_parameters/atmospheric_transmission.schema.yml +1 -1
- simtools/schemas/model_parameters/axes_offsets.schema.yml +1 -1
- simtools/schemas/model_parameters/camera_body_diameter.schema.yml +1 -1
- simtools/schemas/model_parameters/camera_body_shape.schema.yml +1 -1
- simtools/schemas/model_parameters/camera_config_file.schema.yml +1 -1
- simtools/schemas/model_parameters/camera_config_rotate.schema.yml +1 -1
- simtools/schemas/model_parameters/camera_degraded_efficiency.schema.yml +1 -1
- simtools/schemas/model_parameters/camera_degraded_map.schema.yml +1 -1
- simtools/schemas/model_parameters/camera_depth.schema.yml +1 -1
- simtools/schemas/model_parameters/camera_filter.schema.yml +1 -1
- simtools/schemas/model_parameters/camera_filter_incidence_angle.schema.yml +1 -1
- simtools/schemas/model_parameters/camera_pixels.schema.yml +1 -1
- simtools/schemas/model_parameters/camera_transmission.schema.yml +1 -1
- simtools/schemas/model_parameters/channels_per_chip.schema.yml +1 -1
- simtools/schemas/model_parameters/correct_nsb_spectrum_to_telescope_altitude.schema.yml +1 -1
- simtools/schemas/model_parameters/corsika_cherenkov_photon_bunch_size.schema.yml +1 -1
- simtools/schemas/model_parameters/corsika_cherenkov_photon_wavelength_range.schema.yml +1 -1
- simtools/schemas/model_parameters/corsika_first_interaction_height.schema.yml +1 -1
- simtools/schemas/model_parameters/corsika_iact_io_buffer.schema.yml +1 -1
- simtools/schemas/model_parameters/corsika_iact_max_bunches.schema.yml +1 -1
- simtools/schemas/model_parameters/corsika_iact_split_auto.schema.yml +1 -1
- simtools/schemas/model_parameters/corsika_longitudinal_shower_development.schema.yml +1 -1
- simtools/schemas/model_parameters/corsika_observation_level.schema.yml +1 -1
- simtools/schemas/model_parameters/corsika_particle_kinetic_energy_cutoff.schema.yml +1 -1
- simtools/schemas/model_parameters/corsika_starting_grammage.schema.yml +1 -1
- simtools/schemas/model_parameters/dark_events.schema.yml +1 -1
- simtools/schemas/model_parameters/default_trigger.schema.yml +1 -1
- simtools/schemas/model_parameters/design_model.schema.yml +1 -1
- simtools/schemas/model_parameters/disc_ac_coupled.schema.yml +1 -1
- simtools/schemas/model_parameters/disc_bins.schema.yml +1 -1
- simtools/schemas/model_parameters/disc_start.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_amplitude.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_fall_time.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_gate_length.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_hysteresis.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_output_amplitude.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_output_var_percent.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_pulse_shape.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_rise_time.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_scale_threshold.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_sigsum_over_threshold.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_threshold.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_time_over_threshold.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_var_gate_length.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_var_sigsum_over_threshold.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_var_threshold.schema.yml +1 -1
- simtools/schemas/model_parameters/discriminator_var_time_over_threshold.schema.yml +1 -1
- simtools/schemas/model_parameters/dish_shape_length.schema.yml +1 -1
- simtools/schemas/model_parameters/dsum_clipping.schema.yml +1 -1
- simtools/schemas/model_parameters/dsum_ignore_below.schema.yml +1 -1
- simtools/schemas/model_parameters/dsum_offset.schema.yml +1 -1
- simtools/schemas/model_parameters/dsum_pedsub.schema.yml +1 -1
- simtools/schemas/model_parameters/dsum_pre_clipping.schema.yml +1 -1
- simtools/schemas/model_parameters/dsum_prescale.schema.yml +1 -1
- simtools/schemas/model_parameters/dsum_presum_max.schema.yml +1 -1
- simtools/schemas/model_parameters/dsum_presum_shift.schema.yml +1 -1
- simtools/schemas/model_parameters/dsum_shaping.schema.yml +1 -1
- simtools/schemas/model_parameters/dsum_shaping_renormalize.schema.yml +1 -1
- simtools/schemas/model_parameters/dsum_threshold.schema.yml +1 -1
- simtools/schemas/model_parameters/dsum_zero_clip.schema.yml +1 -1
- simtools/schemas/model_parameters/effective_focal_length.schema.yml +32 -2
- simtools/schemas/model_parameters/epsg_code.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_ac_coupled.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_amplitude.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_bins.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_compensate_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_dev_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_err_compensate_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_err_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_lg_amplitude.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_lg_compensate_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_lg_dev_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_lg_err_compensate_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_lg_err_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_lg_max_signal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_lg_max_sum.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_lg_noise.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_lg_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_lg_sensitivity.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_lg_sysvar_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_lg_var_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_lg_var_sensitivity.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_max_signal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_max_sum.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_mhz.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_noise.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_pulse_shape.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_sensitivity.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_sum_bins.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_sum_offset.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_sysvar_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_var_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_var_sensitivity.schema.yml +1 -1
- simtools/schemas/model_parameters/flatfielding.schema.yml +1 -1
- simtools/schemas/model_parameters/focal_length.schema.yml +1 -1
- simtools/schemas/model_parameters/focal_surface_parameters.schema.yml +1 -1
- simtools/schemas/model_parameters/focal_surface_ref_radius.schema.yml +1 -1
- simtools/schemas/model_parameters/focus_offset.schema.yml +1 -1
- simtools/schemas/model_parameters/gain_variation.schema.yml +1 -1
- simtools/schemas/model_parameters/geomag_horizontal.schema.yml +1 -1
- simtools/schemas/model_parameters/geomag_rotation.schema.yml +1 -1
- simtools/schemas/model_parameters/geomag_vertical.schema.yml +1 -1
- simtools/schemas/model_parameters/hg_lg_variation.schema.yml +1 -1
- simtools/schemas/model_parameters/iobuf_maximum.schema.yml +1 -1
- simtools/schemas/model_parameters/iobuf_output_maximum.schema.yml +1 -1
- simtools/schemas/model_parameters/laser_events.schema.yml +1 -1
- simtools/schemas/model_parameters/laser_external_trigger.schema.yml +1 -1
- simtools/schemas/model_parameters/laser_photons.schema.yml +1 -1
- simtools/schemas/model_parameters/laser_pulse_exptime.schema.yml +1 -1
- simtools/schemas/model_parameters/laser_pulse_offset.schema.yml +1 -1
- simtools/schemas/model_parameters/laser_pulse_sigtime.schema.yml +1 -1
- simtools/schemas/model_parameters/laser_pulse_twidth.schema.yml +1 -1
- simtools/schemas/model_parameters/laser_var_photons.schema.yml +1 -1
- simtools/schemas/model_parameters/laser_wavelength.schema.yml +1 -1
- simtools/schemas/model_parameters/led_events.schema.yml +1 -1
- simtools/schemas/model_parameters/led_photons.schema.yml +1 -1
- simtools/schemas/model_parameters/led_pulse_offset.schema.yml +1 -1
- simtools/schemas/model_parameters/led_pulse_sigtime.schema.yml +1 -1
- simtools/schemas/model_parameters/led_var_photons.schema.yml +1 -1
- simtools/schemas/model_parameters/lightguide_efficiency_vs_incidence_angle.schema.yml +1 -1
- simtools/schemas/model_parameters/lightguide_efficiency_vs_wavelength.schema.yml +1 -1
- simtools/schemas/model_parameters/min_photoelectrons.schema.yml +1 -1
- simtools/schemas/model_parameters/min_photons.schema.yml +1 -1
- simtools/schemas/model_parameters/mirror_align_random_distance.schema.yml +1 -1
- simtools/schemas/model_parameters/mirror_align_random_horizontal.schema.yml +1 -1
- simtools/schemas/model_parameters/mirror_align_random_vertical.schema.yml +1 -1
- simtools/schemas/model_parameters/mirror_class.schema.yml +1 -1
- simtools/schemas/model_parameters/mirror_degraded_reflection.schema.yml +1 -1
- simtools/schemas/model_parameters/mirror_focal_length.schema.yml +1 -1
- simtools/schemas/model_parameters/mirror_list.schema.yml +1 -1
- simtools/schemas/model_parameters/mirror_offset.schema.yml +1 -1
- simtools/schemas/model_parameters/mirror_panel_2f_measurements.schema.yml +1 -1
- simtools/schemas/model_parameters/mirror_reflection_random_angle.schema.yml +1 -1
- simtools/schemas/model_parameters/mirror_reflectivity.schema.yml +1 -1
- simtools/schemas/model_parameters/multiplicity_offset.schema.yml +1 -1
- simtools/schemas/model_parameters/nsb_autoscale_airmass.schema.yml +1 -1
- simtools/schemas/model_parameters/nsb_gain_drop_scale.schema.yml +1 -1
- simtools/schemas/model_parameters/nsb_offaxis.schema.yml +1 -1
- simtools/schemas/model_parameters/nsb_pixel_rate.schema.yml +1 -1
- simtools/schemas/model_parameters/nsb_reference_spectrum.schema.yml +1 -1
- simtools/schemas/model_parameters/nsb_reference_value.schema.yml +1 -1
- simtools/schemas/model_parameters/nsb_scaling_factor.schema.yml +1 -1
- simtools/schemas/model_parameters/nsb_skymap.schema.yml +1 -1
- simtools/schemas/model_parameters/nsb_spectrum.schema.yml +1 -1
- simtools/schemas/model_parameters/num_gains.schema.yml +1 -1
- simtools/schemas/model_parameters/only_triggered_telescopes.schema.yml +1 -1
- simtools/schemas/model_parameters/optics_properties.schema.yml +1 -1
- simtools/schemas/model_parameters/parabolic_dish.schema.yml +1 -1
- simtools/schemas/model_parameters/pedestal_events.schema.yml +1 -1
- simtools/schemas/model_parameters/photon_delay.schema.yml +1 -1
- simtools/schemas/model_parameters/photons_per_run.schema.yml +1 -1
- simtools/schemas/model_parameters/pixel_cells.schema.yml +1 -1
- simtools/schemas/model_parameters/pixels_parallel.schema.yml +1 -1
- simtools/schemas/model_parameters/pixeltrg_time_step.schema.yml +1 -1
- simtools/schemas/model_parameters/pm_average_gain.schema.yml +1 -1
- simtools/schemas/model_parameters/pm_collection_efficiency.schema.yml +1 -1
- simtools/schemas/model_parameters/pm_gain_index.schema.yml +1 -1
- simtools/schemas/model_parameters/pm_photoelectron_spectrum.schema.yml +1 -1
- simtools/schemas/model_parameters/pm_transit_time.schema.yml +1 -1
- simtools/schemas/model_parameters/pm_voltage_variation.schema.yml +1 -1
- simtools/schemas/model_parameters/primary_mirror_degraded_map.schema.yml +1 -1
- simtools/schemas/model_parameters/primary_mirror_diameter.schema.yml +1 -1
- simtools/schemas/model_parameters/primary_mirror_hole_diameter.schema.yml +1 -1
- simtools/schemas/model_parameters/primary_mirror_incidence_angle.schema.yml +1 -1
- simtools/schemas/model_parameters/primary_mirror_parameters.schema.yml +1 -1
- simtools/schemas/model_parameters/primary_mirror_ref_radius.schema.yml +1 -1
- simtools/schemas/model_parameters/primary_mirror_segmentation.schema.yml +1 -1
- simtools/schemas/model_parameters/qe_variation.schema.yml +1 -1
- simtools/schemas/model_parameters/quantum_efficiency.schema.yml +1 -1
- simtools/schemas/model_parameters/random_focal_length.schema.yml +1 -1
- simtools/schemas/model_parameters/random_generator.schema.yml +1 -1
- simtools/schemas/model_parameters/reference_point_altitude.schema.yml +1 -1
- simtools/schemas/model_parameters/reference_point_latitude.schema.yml +1 -1
- simtools/schemas/model_parameters/reference_point_longitude.schema.yml +1 -1
- simtools/schemas/model_parameters/reference_point_utm_east.schema.yml +1 -1
- simtools/schemas/model_parameters/reference_point_utm_north.schema.yml +1 -1
- simtools/schemas/model_parameters/sampled_output.schema.yml +1 -1
- simtools/schemas/model_parameters/save_pe_with_amplitude.schema.yml +1 -1
- simtools/schemas/model_parameters/secondary_mirror_baffle.schema.yml +1 -1
- simtools/schemas/model_parameters/secondary_mirror_degraded_map.schema.yml +1 -1
- simtools/schemas/model_parameters/secondary_mirror_degraded_reflection.schema.yml +1 -1
- simtools/schemas/model_parameters/secondary_mirror_diameter.schema.yml +1 -1
- simtools/schemas/model_parameters/secondary_mirror_hole_diameter.schema.yml +1 -1
- simtools/schemas/model_parameters/secondary_mirror_incidence_angle.schema.yml +1 -1
- simtools/schemas/model_parameters/secondary_mirror_parameters.schema.yml +1 -1
- simtools/schemas/model_parameters/secondary_mirror_ref_radius.schema.yml +1 -1
- simtools/schemas/model_parameters/secondary_mirror_reflectivity.schema.yml +1 -1
- simtools/schemas/model_parameters/secondary_mirror_segmentation.schema.yml +1 -1
- simtools/schemas/model_parameters/secondary_mirror_shadow_diameter.schema.yml +1 -1
- simtools/schemas/model_parameters/secondary_mirror_shadow_offset.schema.yml +1 -1
- simtools/schemas/model_parameters/store_photoelectrons.schema.yml +1 -1
- simtools/schemas/model_parameters/tailcut_scale.schema.yml +1 -1
- simtools/schemas/model_parameters/telescope_axis_height.schema.yml +1 -1
- simtools/schemas/model_parameters/telescope_random_angle.schema.yml +1 -1
- simtools/schemas/model_parameters/telescope_random_error.schema.yml +1 -1
- simtools/schemas/model_parameters/telescope_sphere_radius.schema.yml +1 -1
- simtools/schemas/model_parameters/telescope_transmission.schema.yml +1 -1
- simtools/schemas/model_parameters/teltrig_min_sigsum.schema.yml +1 -1
- simtools/schemas/model_parameters/teltrig_min_time.schema.yml +1 -1
- simtools/schemas/model_parameters/transit_time_calib_error.schema.yml +1 -1
- simtools/schemas/model_parameters/transit_time_compensate_error.schema.yml +1 -1
- simtools/schemas/model_parameters/transit_time_compensate_step.schema.yml +1 -1
- simtools/schemas/model_parameters/transit_time_error.schema.yml +1 -1
- simtools/schemas/model_parameters/transit_time_jitter.schema.yml +1 -1
- simtools/schemas/model_parameters/trigger_current_limit.schema.yml +1 -1
- simtools/schemas/model_parameters/trigger_delay_compensation.schema.yml +1 -1
- simtools/schemas/model_parameters/trigger_pixels.schema.yml +1 -1
- simtools/simtel/simtel_table_reader.py +410 -0
- simtools/simtel/simulator_camera_efficiency.py +6 -4
- simtools/simtel/simulator_light_emission.py +2 -2
- simtools/simtel/simulator_ray_tracing.py +1 -2
- simtools/simulator.py +80 -33
- simtools/testing/configuration.py +12 -8
- simtools/testing/helpers.py +5 -5
- simtools/testing/validate_output.py +28 -28
- simtools/utils/general.py +50 -3
- simtools/utils/names.py +3 -4
- simtools/utils/value_conversion.py +9 -1
- simtools/version.py +1 -1
- simtools/visualization/plot_tables.py +106 -0
- simtools/visualization/visualize.py +43 -5
- gammasimtools-0.8.1.dist-info/RECORD +0 -346
- simtools/_dev_version/scm_version.py +0 -10
- simtools/db/db_from_repo_handler.py +0 -106
- {gammasimtools-0.8.1.dist-info → gammasimtools-0.9.0.dist-info}/LICENSE +0 -0
- {gammasimtools-0.8.1.dist-info → gammasimtools-0.9.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
#!/usr/bin/python3
|
|
2
|
+
"""Read tabular data in sim_telarray format and return as astropy table."""
|
|
3
|
+
|
|
4
|
+
import logging
|
|
5
|
+
import re
|
|
6
|
+
|
|
7
|
+
import astropy.units as u
|
|
8
|
+
from astropy.table import Table
|
|
9
|
+
|
|
10
|
+
from simtools.utils import general as gen
|
|
11
|
+
|
|
12
|
+
logger = logging.getLogger(__name__)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _data_columns(parameter_name, n_columns, n_dim):
|
|
16
|
+
"""
|
|
17
|
+
Get column information for a given parameter.
|
|
18
|
+
|
|
19
|
+
Individual functions are adapted to the specific format of the sim_telarray tables.
|
|
20
|
+
|
|
21
|
+
Parameters
|
|
22
|
+
----------
|
|
23
|
+
parameter_name: str
|
|
24
|
+
Model parameter name.
|
|
25
|
+
n_columns: int
|
|
26
|
+
Number of columns in the table.
|
|
27
|
+
n_dim: list
|
|
28
|
+
List of columns for n-dimensional tables defined by RPOL lines.
|
|
29
|
+
|
|
30
|
+
Returns
|
|
31
|
+
-------
|
|
32
|
+
list, str
|
|
33
|
+
List of columns for n-dimensional tables, description.
|
|
34
|
+
"""
|
|
35
|
+
if parameter_name == "mirror_reflectivity":
|
|
36
|
+
return _data_columns_mirror_reflectivity(n_columns, n_dim)
|
|
37
|
+
if parameter_name in ("discriminator_pulse_shape", "fadc_pulse_shape"):
|
|
38
|
+
return _data_columns_pulse_shape(n_columns)
|
|
39
|
+
try:
|
|
40
|
+
return globals()[f"_data_columns_{parameter_name}"]()
|
|
41
|
+
except KeyError as exc:
|
|
42
|
+
raise ValueError(
|
|
43
|
+
f"Unsupported parameter for sim_telarray table reading: {parameter_name}"
|
|
44
|
+
) from exc
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _data_columns_atmospheric_profile():
|
|
48
|
+
"""Column representation for parameter atmospheric_profile."""
|
|
49
|
+
return (
|
|
50
|
+
[
|
|
51
|
+
{"name": "altitude", "description": "Altitude", "unit": "km"},
|
|
52
|
+
{"name": "density", "description": "Density", "unit": "g/cm^3"},
|
|
53
|
+
{"name": "thickness", "description": "Thickness", "unit": "g/cm^2"},
|
|
54
|
+
{
|
|
55
|
+
"name": "refractive_index",
|
|
56
|
+
"description": "Refractive index (n-1)",
|
|
57
|
+
"unit": None,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"name": "temperature",
|
|
61
|
+
"description": "Temperature",
|
|
62
|
+
"unit": "K",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"name": "pressure",
|
|
66
|
+
"description": "Pressure",
|
|
67
|
+
"unit": "mbar",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"name": "pw/w",
|
|
71
|
+
"description": "Partial pressure of water vapor",
|
|
72
|
+
"unit": None,
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
"Atmospheric profile",
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def _data_columns_pm_photoelectron_spectrum():
|
|
80
|
+
"""Column description for parameter pm_photoelectron_spectrum."""
|
|
81
|
+
return (
|
|
82
|
+
[
|
|
83
|
+
{"name": "amplitude", "description": "Signal amplitude", "unit": None},
|
|
84
|
+
{
|
|
85
|
+
"name": "response",
|
|
86
|
+
"description": "response without afterpulsing component",
|
|
87
|
+
"unit": None,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"name": "response_with_ap",
|
|
91
|
+
"description": "response including afterpulsing component",
|
|
92
|
+
"unit": None,
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
"Photoelectron spectrum",
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def _data_columns_quantum_efficiency():
|
|
100
|
+
"""Column description for parameter quantum_efficiency."""
|
|
101
|
+
return (
|
|
102
|
+
[
|
|
103
|
+
{"name": "wavelength", "description": "Wavelength", "unit": "nm"},
|
|
104
|
+
{
|
|
105
|
+
"name": "efficiency",
|
|
106
|
+
"description": "Quantum efficiency",
|
|
107
|
+
"unit": None,
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"name": "efficiency_rms",
|
|
111
|
+
"description": "Quantum efficiency (standard deviation)",
|
|
112
|
+
"unit": None,
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
"Quantum efficiency",
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def _data_columns_camera_filter():
|
|
120
|
+
"""Column description for parameter camera_filter."""
|
|
121
|
+
return (
|
|
122
|
+
[
|
|
123
|
+
{"name": "wavelength", "description": "Wavelength", "unit": "nm"},
|
|
124
|
+
{
|
|
125
|
+
"name": "transmission",
|
|
126
|
+
"description": "Average transmission",
|
|
127
|
+
"unit": None,
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
"Camera window transmission",
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def _data_columns_lightguide_efficiency_vs_wavelength():
|
|
135
|
+
"""Column description for parameter lightguide_efficiency_vs_wavelength."""
|
|
136
|
+
return _data_columns_lightguide_efficiency_vs_incidence_angle()
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def _data_columns_lightguide_efficiency_vs_incidence_angle():
|
|
140
|
+
"""Column description for (parameter lightguide_efficiency_vs_incidence_angle."""
|
|
141
|
+
return (
|
|
142
|
+
[
|
|
143
|
+
{"name": "angle", "description": "Incidence angle", "unit": "deg"},
|
|
144
|
+
{
|
|
145
|
+
"name": "efficiency",
|
|
146
|
+
"description": "Light guide efficiency",
|
|
147
|
+
"unit": None,
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
"Light guide efficiency vs incidence angle",
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def _data_columns_mirror_reflectivity(n_columns, n_dim):
|
|
155
|
+
"""Column description for parameter mirror_reflectivity."""
|
|
156
|
+
_columns = [
|
|
157
|
+
{"name": "wavelength", "description": "Wavelength", "unit": "nm"},
|
|
158
|
+
]
|
|
159
|
+
if n_dim:
|
|
160
|
+
for angle in n_dim:
|
|
161
|
+
_columns.append(
|
|
162
|
+
{
|
|
163
|
+
"name": f"reflectivity_{angle}deg",
|
|
164
|
+
"description": f"Mirror reflectivity at {angle} deg",
|
|
165
|
+
"unit": None,
|
|
166
|
+
},
|
|
167
|
+
)
|
|
168
|
+
else:
|
|
169
|
+
_columns.append(
|
|
170
|
+
{
|
|
171
|
+
"name": "reflectivity",
|
|
172
|
+
"description": "Mirror reflectivity",
|
|
173
|
+
"unit": None,
|
|
174
|
+
},
|
|
175
|
+
)
|
|
176
|
+
if n_columns == 3:
|
|
177
|
+
_columns.append(
|
|
178
|
+
{
|
|
179
|
+
"name": "reflectivity_rms",
|
|
180
|
+
"description": "Mirror reflectivity (standard deviation)",
|
|
181
|
+
"unit": None,
|
|
182
|
+
},
|
|
183
|
+
)
|
|
184
|
+
if n_columns == 4:
|
|
185
|
+
_columns.append(
|
|
186
|
+
{
|
|
187
|
+
"name": "reflectivity_min",
|
|
188
|
+
"description": "Mirror reflectivity (min)",
|
|
189
|
+
"unit": None,
|
|
190
|
+
},
|
|
191
|
+
)
|
|
192
|
+
_columns.append(
|
|
193
|
+
{
|
|
194
|
+
"name": "reflectivity_max",
|
|
195
|
+
"description": "Mirror reflectivity (max)",
|
|
196
|
+
"unit": None,
|
|
197
|
+
},
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
return _columns, "Mirror reflectivity"
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
def _data_columns_pulse_shape(n_columns):
|
|
204
|
+
"""Column description for parameters discriminator_pulse_shape, fadc_pulse_shape."""
|
|
205
|
+
_columns = [
|
|
206
|
+
{"name": "time", "description": "Time", "unit": "ns"},
|
|
207
|
+
{
|
|
208
|
+
"name": "amplitude",
|
|
209
|
+
"description": "Amplitude",
|
|
210
|
+
"unit": None,
|
|
211
|
+
},
|
|
212
|
+
]
|
|
213
|
+
if n_columns == 3:
|
|
214
|
+
_columns.append(
|
|
215
|
+
{
|
|
216
|
+
"name": "amplitude (low gain)",
|
|
217
|
+
"description": "Amplitude (low gain)",
|
|
218
|
+
"unit": None,
|
|
219
|
+
},
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
return _columns, "Pulse shape"
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
def _data_columns_nsb_reference_spectrum():
|
|
226
|
+
"""Column description for parameter nsb_reference_spectrum."""
|
|
227
|
+
return (
|
|
228
|
+
[
|
|
229
|
+
{"name": "wavelength", "description": "Wavelength", "unit": "nm"},
|
|
230
|
+
{
|
|
231
|
+
"name": "differential photon rate",
|
|
232
|
+
"description": "Differential photon rate",
|
|
233
|
+
"unit": "1.e9 / (nm s m^2 sr)",
|
|
234
|
+
},
|
|
235
|
+
],
|
|
236
|
+
"NSB reference spectrum",
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
def read_simtel_table(parameter_name, file_path):
|
|
241
|
+
"""
|
|
242
|
+
Read sim_telarray table file for a given parameter.
|
|
243
|
+
|
|
244
|
+
Parameters
|
|
245
|
+
----------
|
|
246
|
+
parameter_name: str
|
|
247
|
+
Model parameter name.
|
|
248
|
+
file_path: Path
|
|
249
|
+
Name (full path) of the sim_telarray table file.
|
|
250
|
+
|
|
251
|
+
Returns
|
|
252
|
+
-------
|
|
253
|
+
Table
|
|
254
|
+
Astropy table.
|
|
255
|
+
"""
|
|
256
|
+
if parameter_name == "atmospheric_transmission":
|
|
257
|
+
return _read_simtel_data_for_atmospheric_transmission(file_path)
|
|
258
|
+
|
|
259
|
+
rows, meta_from_simtel, n_columns, n_dim = _read_simtel_data(file_path)
|
|
260
|
+
columns_info, description = _data_columns(parameter_name, n_columns, n_dim)
|
|
261
|
+
|
|
262
|
+
rows = _adjust_columns_length(rows, len(columns_info))
|
|
263
|
+
|
|
264
|
+
metadata = {
|
|
265
|
+
"Name": parameter_name,
|
|
266
|
+
"File": str(file_path),
|
|
267
|
+
"Description:": description,
|
|
268
|
+
"Context_from_sim_telarray": meta_from_simtel,
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
table = Table(rows=rows, names=[col["name"] for col in columns_info])
|
|
272
|
+
for col, info in zip(table.colnames, columns_info):
|
|
273
|
+
table[col].unit = info.get("unit")
|
|
274
|
+
table[col].description = info.get("description")
|
|
275
|
+
table.meta.update(metadata)
|
|
276
|
+
|
|
277
|
+
return table
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
def _adjust_columns_length(rows, n_columns):
|
|
281
|
+
"""
|
|
282
|
+
Adjust row lengths to match the specified column count.
|
|
283
|
+
|
|
284
|
+
- Truncate rows with extra columns beyond the specified count 'n_columns'.
|
|
285
|
+
- Pad shorter rows with zeros.
|
|
286
|
+
"""
|
|
287
|
+
return [row[:n_columns] + [0.0] * max(0, n_columns - len(row)) for row in rows]
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
def _read_simtel_data(file_path):
|
|
291
|
+
"""
|
|
292
|
+
Read data, comments, and (if available) axis definition from sim_telarray table.
|
|
293
|
+
|
|
294
|
+
Parameters
|
|
295
|
+
----------
|
|
296
|
+
file_path: Path
|
|
297
|
+
Path to the sim_telarray table file.
|
|
298
|
+
|
|
299
|
+
Returns
|
|
300
|
+
-------
|
|
301
|
+
str, str, int, str
|
|
302
|
+
data, metadata (comments), number of columns (max value), n-dimensional axis description.
|
|
303
|
+
"""
|
|
304
|
+
logger.debug(f"Reading sim_telarray table from {file_path}")
|
|
305
|
+
meta_lines = []
|
|
306
|
+
data_lines = []
|
|
307
|
+
n_dim_axis = None
|
|
308
|
+
r_pol_axis = None
|
|
309
|
+
|
|
310
|
+
lines = gen.read_file_encoded_in_utf_or_latin(file_path)
|
|
311
|
+
|
|
312
|
+
for line in lines:
|
|
313
|
+
stripped = line.strip()
|
|
314
|
+
if "@RPOL@" in stripped: # RPOL description for N-dimensional tables
|
|
315
|
+
match = re.search(r"#@RPOL@\[(\w+)=\]", stripped)
|
|
316
|
+
if match:
|
|
317
|
+
r_pol_axis = match.group(1)
|
|
318
|
+
elif r_pol_axis and r_pol_axis in stripped: # N-dimensional axis description
|
|
319
|
+
n_dim_axis = stripped.split("=")[1].split()
|
|
320
|
+
elif stripped.startswith("#"): # Metadata
|
|
321
|
+
meta_lines.append(stripped.lstrip("#").strip())
|
|
322
|
+
elif stripped: # Data
|
|
323
|
+
data_lines.append(stripped.split("%%%")[0].split("#")[0].strip()) # Remove comments
|
|
324
|
+
|
|
325
|
+
rows = [[float(part) for part in line.split()] for line in data_lines]
|
|
326
|
+
n_columns = max(len(row) for row in rows) if rows else 0
|
|
327
|
+
|
|
328
|
+
return rows, "\n".join(meta_lines), n_columns, n_dim_axis
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
def _read_simtel_data_for_atmospheric_transmission(file_path):
|
|
332
|
+
"""
|
|
333
|
+
Read data and comments from sim_telarray table for atmospheric_transmission.
|
|
334
|
+
|
|
335
|
+
Parameters
|
|
336
|
+
----------
|
|
337
|
+
file_path: Path
|
|
338
|
+
Path to the sim_telarray table file.
|
|
339
|
+
|
|
340
|
+
Returns
|
|
341
|
+
-------
|
|
342
|
+
astropy table
|
|
343
|
+
Table with atmospheric transmission.
|
|
344
|
+
"""
|
|
345
|
+
lines = lines = gen.read_file_encoded_in_utf_or_latin(file_path)
|
|
346
|
+
|
|
347
|
+
observatory_level, height_bins = _read_header_line_for_atmospheric_transmission(
|
|
348
|
+
lines, file_path
|
|
349
|
+
)
|
|
350
|
+
|
|
351
|
+
wavelengths = []
|
|
352
|
+
heights = []
|
|
353
|
+
extinctions = []
|
|
354
|
+
meta_lines = []
|
|
355
|
+
|
|
356
|
+
for line in lines:
|
|
357
|
+
if line.startswith("#") or not line.strip():
|
|
358
|
+
meta_lines.append(line.lstrip("#").strip())
|
|
359
|
+
continue
|
|
360
|
+
parts = line.split()
|
|
361
|
+
try:
|
|
362
|
+
wl = float(parts[0])
|
|
363
|
+
for i, height in enumerate(height_bins):
|
|
364
|
+
extinction_value = float(parts[i + 1])
|
|
365
|
+
if extinction_value == 99999.0:
|
|
366
|
+
continue
|
|
367
|
+
wavelengths.append(wl)
|
|
368
|
+
heights.append(height)
|
|
369
|
+
extinctions.append(extinction_value)
|
|
370
|
+
except (ValueError, IndexError):
|
|
371
|
+
logger.debug(f"Skipping malformed line: {line.strip()}")
|
|
372
|
+
|
|
373
|
+
table = Table()
|
|
374
|
+
table["wavelength"] = wavelengths
|
|
375
|
+
table["altitude"] = heights
|
|
376
|
+
table["extinction"] = extinctions
|
|
377
|
+
|
|
378
|
+
table.meta.update(
|
|
379
|
+
{
|
|
380
|
+
"Name": "atmospheric_transmission",
|
|
381
|
+
"File": str(file_path),
|
|
382
|
+
"Description": "Atmospheric transmission",
|
|
383
|
+
"Context_from_sim_telarray": "\n".join(meta_lines),
|
|
384
|
+
"observatory_level": observatory_level,
|
|
385
|
+
}
|
|
386
|
+
)
|
|
387
|
+
|
|
388
|
+
return table
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
def _read_header_line_for_atmospheric_transmission(lines, file_path):
|
|
392
|
+
"""Reader observatory level and height bins from header line for atmospheric transmission."""
|
|
393
|
+
header_line = None
|
|
394
|
+
observatory_level = None
|
|
395
|
+
for line in lines:
|
|
396
|
+
if "H2=" in line and "H1=" in line:
|
|
397
|
+
match_h2 = re.search(r"H2=\s*([\d.]+)", line)
|
|
398
|
+
if match_h2:
|
|
399
|
+
observatory_level = float(match_h2.group(1)) * u.km
|
|
400
|
+
|
|
401
|
+
if "H1=" in line:
|
|
402
|
+
header_line = line.split("H1=")[-1].strip()
|
|
403
|
+
break
|
|
404
|
+
|
|
405
|
+
if header_line is None:
|
|
406
|
+
raise ValueError(f"Header with 'H1=' not found file {file_path}")
|
|
407
|
+
|
|
408
|
+
height_bins = [float(x.replace(",", "")) for x in header_line.split()]
|
|
409
|
+
|
|
410
|
+
return observatory_level, height_bins
|
|
@@ -154,10 +154,12 @@ class SimulatorCameraEfficiency(SimtelRunner):
|
|
|
154
154
|
command += " 300" # Xmax
|
|
155
155
|
command += f" {self._telescope_model.get_parameter_value('atmospheric_profile')}"
|
|
156
156
|
command += f" {self.zenith_angle}"
|
|
157
|
-
command += f" 2>{self._file_log}"
|
|
158
|
-
command += f" >{self._file_simtel}"
|
|
159
157
|
|
|
160
|
-
return
|
|
158
|
+
return (
|
|
159
|
+
f"cd {self._simtel_path.joinpath('sim_telarray')} && {command}",
|
|
160
|
+
self._file_simtel,
|
|
161
|
+
self._file_log,
|
|
162
|
+
)
|
|
161
163
|
|
|
162
164
|
def _check_run_result(self, run_number=None): # pylint: disable=unused-argument
|
|
163
165
|
"""Check run results.
|
|
@@ -169,7 +171,7 @@ class SimulatorCameraEfficiency(SimtelRunner):
|
|
|
169
171
|
"""
|
|
170
172
|
# Checking run
|
|
171
173
|
if not self._file_simtel.exists():
|
|
172
|
-
msg = "Camera efficiency simulation results file does not exist"
|
|
174
|
+
msg = f"Camera efficiency simulation results file does not exist ({self._file_simtel})."
|
|
173
175
|
self._logger.error(msg)
|
|
174
176
|
raise RuntimeError(msg)
|
|
175
177
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Simulation using the light emission package for calibration."""
|
|
2
2
|
|
|
3
3
|
import logging
|
|
4
|
-
import
|
|
4
|
+
import stat
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
|
|
7
7
|
import astropy.units as u
|
|
@@ -469,5 +469,5 @@ class SimulatorLightEmission(SimtelRunner):
|
|
|
469
469
|
file.write(f"{command_plot}\n\n")
|
|
470
470
|
file.write("# End\n\n")
|
|
471
471
|
|
|
472
|
-
|
|
472
|
+
_script_file.chmod(_script_file.stat().st_mode | stat.S_IXUSR | stat.S_IXGRP)
|
|
473
473
|
return _script_file
|
|
@@ -191,9 +191,8 @@ class SimulatorRayTracing(SimtelRunner):
|
|
|
191
191
|
command += super().get_config_option("mirror_align_random_distance", "0.")
|
|
192
192
|
command += super().get_config_option("mirror_align_random_vertical", "0.,28.,0.,0.")
|
|
193
193
|
command += " " + str(self._corsika_file)
|
|
194
|
-
command += f" 2>&1 > {self._log_file} 2>&1"
|
|
195
194
|
|
|
196
|
-
return command
|
|
195
|
+
return command, self._log_file, self._log_file
|
|
197
196
|
|
|
198
197
|
def _check_run_result(self, run_number=None): # pylint: disable=unused-argument
|
|
199
198
|
"""
|
simtools/simulator.py
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import logging
|
|
4
4
|
import re
|
|
5
|
+
import shutil
|
|
6
|
+
import tarfile
|
|
5
7
|
from collections import defaultdict
|
|
6
8
|
from pathlib import Path
|
|
7
9
|
|
|
@@ -68,7 +70,7 @@ class Simulator:
|
|
|
68
70
|
self.runs = self._initialize_run_list()
|
|
69
71
|
self._results = defaultdict(list)
|
|
70
72
|
self._test = self.args_dict.get("test", False)
|
|
71
|
-
self.
|
|
73
|
+
self.submit_engine = self.args_dict.get("submit_engine", "local")
|
|
72
74
|
self._submit_options = self.args_dict.get("submit_options", None)
|
|
73
75
|
self._extra_commands = extra_commands
|
|
74
76
|
|
|
@@ -265,7 +267,7 @@ class Simulator:
|
|
|
265
267
|
input_file_list: str or list of str
|
|
266
268
|
Single file or list of files of shower simulations.
|
|
267
269
|
"""
|
|
268
|
-
self._logger.info(f"Submission command: {self.
|
|
270
|
+
self._logger.info(f"Submission command: {self.submit_engine}")
|
|
269
271
|
|
|
270
272
|
runs_and_files_to_submit = self._get_runs_and_files_to_submit(
|
|
271
273
|
input_file_list=input_file_list
|
|
@@ -281,7 +283,7 @@ class Simulator:
|
|
|
281
283
|
)
|
|
282
284
|
|
|
283
285
|
job_manager = JobManager(
|
|
284
|
-
submit_engine=self.
|
|
286
|
+
submit_engine=self.submit_engine,
|
|
285
287
|
submit_options=self._submit_options,
|
|
286
288
|
test=self._test,
|
|
287
289
|
)
|
|
@@ -389,50 +391,46 @@ class Simulator:
|
|
|
389
391
|
run number
|
|
390
392
|
|
|
391
393
|
"""
|
|
392
|
-
|
|
393
|
-
|
|
394
|
+
keys = ["output", "sub_out", "log", "input", "hist", "corsika_log"]
|
|
395
|
+
defaults = {key: None for key in keys}
|
|
396
|
+
results = {key: defaults[key] for key in keys}
|
|
397
|
+
results["output"] = str(
|
|
398
|
+
self._simulation_runner.get_file_name(file_type="output", run_number=run_number)
|
|
394
399
|
)
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
file_type="sub_log", run_number=run_number, mode="out"
|
|
399
|
-
)
|
|
400
|
+
results["sub_out"] = str(
|
|
401
|
+
self._simulation_runner.get_file_name(
|
|
402
|
+
file_type="sub_log", mode="out", run_number=run_number
|
|
400
403
|
)
|
|
401
404
|
)
|
|
402
405
|
|
|
403
|
-
if
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
simulation_software="simtel", file_type="log", run_number=run_number
|
|
408
|
-
)
|
|
406
|
+
if "simtel" in self.simulation_software:
|
|
407
|
+
results["log"] = str(
|
|
408
|
+
self._simulation_runner.get_file_name(
|
|
409
|
+
file_type="log", simulation_software="simtel", run_number=run_number
|
|
409
410
|
)
|
|
410
411
|
)
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
simulation_software="simtel", file_type="histogram", run_number=run_number
|
|
416
|
-
)
|
|
412
|
+
results["input"] = str(file)
|
|
413
|
+
results["hist"] = str(
|
|
414
|
+
self._simulation_runner.get_file_name(
|
|
415
|
+
file_type="histogram", simulation_software="simtel", run_number=run_number
|
|
417
416
|
)
|
|
418
417
|
)
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
)
|
|
418
|
+
|
|
419
|
+
if "corsika" in self.simulation_software:
|
|
420
|
+
results["corsika_log"] = str(
|
|
421
|
+
self._simulation_runner.get_file_name(
|
|
422
|
+
file_type="corsika_log", simulation_software="corsika", run_number=run_number
|
|
425
423
|
)
|
|
426
424
|
)
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
self._results[
|
|
425
|
+
|
|
426
|
+
for key in keys:
|
|
427
|
+
self._results[key].append(results[key])
|
|
430
428
|
|
|
431
429
|
def get_file_list(self, file_type="output"):
|
|
432
430
|
"""
|
|
433
431
|
Get list of files generated by simulations.
|
|
434
432
|
|
|
435
|
-
Options are "input", "output", "hist", "log".
|
|
433
|
+
Options are "input", "output", "hist", "log", "corsika_log".
|
|
436
434
|
Not all file types are available for all simulation types.
|
|
437
435
|
Returns an empty list for an unknown file type.
|
|
438
436
|
|
|
@@ -548,7 +546,7 @@ class Simulator:
|
|
|
548
546
|
|
|
549
547
|
def save_file_lists(self):
|
|
550
548
|
"""Save files lists for output and log files."""
|
|
551
|
-
for file_type in ["output", "log", "hist"]:
|
|
549
|
+
for file_type in ["output", "log", "corsika_log", "hist"]:
|
|
552
550
|
file_name = self.io_handler.get_output_directory(label=self.label).joinpath(
|
|
553
551
|
f"{file_type}_files.txt"
|
|
554
552
|
)
|
|
@@ -560,3 +558,52 @@ class Simulator:
|
|
|
560
558
|
f.write(f"{line}\n")
|
|
561
559
|
else:
|
|
562
560
|
self._logger.debug(f"No files to save for {file_type} files.")
|
|
561
|
+
|
|
562
|
+
def pack_for_register(self, directory_for_grid_upload=None):
|
|
563
|
+
"""
|
|
564
|
+
Pack simulation output files for registering on the grid.
|
|
565
|
+
|
|
566
|
+
Parameters
|
|
567
|
+
----------
|
|
568
|
+
directory_for_grid_upload: str
|
|
569
|
+
Directory for the tarball with output files.
|
|
570
|
+
|
|
571
|
+
"""
|
|
572
|
+
self._logger.info(
|
|
573
|
+
f"Packing the output files for registering on the grid ({directory_for_grid_upload})"
|
|
574
|
+
)
|
|
575
|
+
output_files = self.get_file_list(file_type="output")
|
|
576
|
+
log_files = self.get_file_list(file_type="log")
|
|
577
|
+
corsika_log_files = self.get_file_list(file_type="corsika_log")
|
|
578
|
+
histogram_files = self.get_file_list(file_type="hist")
|
|
579
|
+
tar_file_name = Path(log_files[0]).name.replace("log.gz", "log_hist.tar.gz")
|
|
580
|
+
directory_for_grid_upload = (
|
|
581
|
+
Path(directory_for_grid_upload)
|
|
582
|
+
if directory_for_grid_upload
|
|
583
|
+
else self.io_handler.get_output_directory(label=self.label).joinpath(
|
|
584
|
+
"directory_for_grid_upload"
|
|
585
|
+
)
|
|
586
|
+
)
|
|
587
|
+
directory_for_grid_upload.mkdir(parents=True, exist_ok=True)
|
|
588
|
+
|
|
589
|
+
tar_file_name = directory_for_grid_upload.joinpath(tar_file_name)
|
|
590
|
+
|
|
591
|
+
with tarfile.open(tar_file_name, "w:gz") as tar:
|
|
592
|
+
files_to_tar = (
|
|
593
|
+
(log_files[:1] if log_files else [])
|
|
594
|
+
+ (histogram_files[:1] if histogram_files else [])
|
|
595
|
+
+ (corsika_log_files[:1] if corsika_log_files else [])
|
|
596
|
+
)
|
|
597
|
+
for file_to_tar in files_to_tar:
|
|
598
|
+
tar.add(file_to_tar, arcname=Path(file_to_tar).name)
|
|
599
|
+
|
|
600
|
+
for file_to_move in [*output_files]:
|
|
601
|
+
source_file = Path(file_to_move)
|
|
602
|
+
destination_file = directory_for_grid_upload / source_file.name
|
|
603
|
+
if destination_file.exists():
|
|
604
|
+
self._logger.warning(f"Overwriting existing file: {destination_file}")
|
|
605
|
+
# Note that this will overwrite previous files which exist in the directory
|
|
606
|
+
# It should be fine for normal production since each run is on a separate node
|
|
607
|
+
# so no files are expected there.
|
|
608
|
+
shutil.move(source_file, destination_file)
|
|
609
|
+
self._logger.info(f"Output files for the grid placed in {directory_for_grid_upload!s}")
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import logging
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
|
|
6
|
-
import pytest
|
|
7
6
|
import yaml
|
|
8
7
|
|
|
9
8
|
import simtools.utils.general as gen
|
|
@@ -11,6 +10,10 @@ import simtools.utils.general as gen
|
|
|
11
10
|
_logger = logging.getLogger(__name__)
|
|
12
11
|
|
|
13
12
|
|
|
13
|
+
class VersionError(Exception):
|
|
14
|
+
"""Raise if model version requested is not supported."""
|
|
15
|
+
|
|
16
|
+
|
|
14
17
|
def get_list_of_test_configurations(config_files):
|
|
15
18
|
"""
|
|
16
19
|
Return list of test configuration dictionaries or test names.
|
|
@@ -121,7 +124,7 @@ def _skip_test_for_model_version(config, model_version_requested):
|
|
|
121
124
|
return
|
|
122
125
|
model_version_config = config["CONFIGURATION"]["MODEL_VERSION"]
|
|
123
126
|
if model_version_requested != model_version_config:
|
|
124
|
-
|
|
127
|
+
raise VersionError(
|
|
125
128
|
f"Model version requested {model_version_requested} not supported for this test"
|
|
126
129
|
)
|
|
127
130
|
|
|
@@ -158,13 +161,14 @@ def _prepare_test_options(config, output_path, model_version=None):
|
|
|
158
161
|
|
|
159
162
|
tmp_config_file = output_path / "tmp_config.yml"
|
|
160
163
|
config_file_model_version = config.get("MODEL_VERSION")
|
|
161
|
-
if model_version
|
|
164
|
+
if model_version and "MODEL_VERSION" in config:
|
|
162
165
|
config.update({"MODEL_VERSION": model_version})
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
config
|
|
166
|
-
|
|
167
|
-
|
|
166
|
+
|
|
167
|
+
for key in ["OUTPUT_PATH", "DATA_DIRECTORY", "PACK_FOR_GRID_REGISTER"]:
|
|
168
|
+
if key in config:
|
|
169
|
+
config[key] = str(Path(output_path).joinpath(config[key]))
|
|
170
|
+
if key == "OUTPUT_PATH":
|
|
171
|
+
config["USE_PLAIN_OUTPUT_PATH"] = True
|
|
168
172
|
|
|
169
173
|
_logger.info(f"Writing config file: {tmp_config_file}")
|
|
170
174
|
with open(tmp_config_file, "w", encoding="utf-8") as file:
|