gammasimtools 0.15.0__py3-none-any.whl → 0.17.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.15.0.dist-info → gammasimtools-0.17.0.dist-info}/METADATA +5 -33
- {gammasimtools-0.15.0.dist-info → gammasimtools-0.17.0.dist-info}/RECORD +243 -229
- {gammasimtools-0.15.0.dist-info → gammasimtools-0.17.0.dist-info}/WHEEL +1 -1
- {gammasimtools-0.15.0.dist-info → gammasimtools-0.17.0.dist-info}/entry_points.txt +8 -3
- simtools/_version.py +2 -2
- simtools/applications/calculate_trigger_rate.py +10 -10
- simtools/applications/convert_all_model_parameters_from_simtel.py +16 -16
- simtools/applications/convert_model_parameter_from_simtel.py +1 -1
- simtools/applications/derive_ctao_array_layouts.py +5 -5
- simtools/applications/derive_psf_parameters.py +12 -9
- simtools/applications/docs_produce_array_element_report.py +3 -3
- simtools/applications/docs_produce_calibration_reports.py +49 -0
- simtools/applications/docs_produce_simulation_configuration_report.py +50 -0
- simtools/applications/{generate_simtel_array_histograms.py → generate_sim_telarray_histograms.py} +2 -2
- simtools/applications/generate_simtel_event_data.py +36 -46
- simtools/applications/merge_tables.py +104 -0
- simtools/applications/plot_array_layout.py +145 -258
- simtools/applications/production_derive_corsika_limits.py +35 -167
- simtools/applications/production_derive_statistics.py +159 -0
- simtools/applications/production_generate_grid.py +197 -0
- simtools/applications/simulate_light_emission.py +6 -13
- simtools/applications/simulate_prod.py +45 -21
- simtools/applications/simulate_prod_htcondor_generator.py +0 -1
- simtools/applications/submit_array_layouts.py +93 -0
- simtools/applications/validate_cumulative_psf.py +6 -4
- simtools/applications/validate_file_using_schema.py +7 -3
- simtools/applications/validate_optics.py +5 -4
- simtools/applications/verify_simulation_model_production_tables.py +52 -0
- simtools/camera/camera_efficiency.py +17 -42
- simtools/configuration/commandline_parser.py +32 -37
- simtools/configuration/configurator.py +10 -4
- simtools/corsika/corsika_config.py +120 -17
- simtools/corsika/primary_particle.py +46 -13
- simtools/data_model/format_checkers.py +9 -0
- simtools/data_model/metadata_collector.py +7 -3
- simtools/data_model/model_data_writer.py +3 -0
- simtools/data_model/schema.py +27 -16
- simtools/data_model/validate_data.py +27 -7
- simtools/db/db_handler.py +21 -15
- simtools/db/db_model_upload.py +2 -2
- simtools/io_operations/io_handler.py +2 -2
- simtools/io_operations/io_table_handler.py +345 -0
- simtools/job_execution/htcondor_script_generator.py +2 -2
- simtools/job_execution/job_manager.py +7 -121
- simtools/layout/array_layout.py +1 -0
- simtools/layout/array_layout_utils.py +385 -0
- simtools/model/array_model.py +68 -29
- simtools/model/model_parameter.py +76 -51
- simtools/model/model_repository.py +134 -0
- simtools/model/model_utils.py +43 -1
- simtools/model/site_model.py +3 -2
- simtools/model/telescope_model.py +4 -4
- simtools/production_configuration/{calculate_statistical_errors_grid_point.py → calculate_statistical_uncertainties_grid_point.py} +101 -116
- simtools/production_configuration/derive_corsika_limits.py +239 -111
- simtools/production_configuration/derive_corsika_limits_grid.py +189 -0
- simtools/production_configuration/derive_production_statistics.py +155 -0
- simtools/production_configuration/derive_production_statistics_handler.py +152 -0
- simtools/production_configuration/generate_production_grid.py +364 -0
- simtools/production_configuration/interpolation_handler.py +303 -96
- simtools/ray_tracing/mirror_panel_psf.py +16 -20
- simtools/ray_tracing/psf_analysis.py +2 -2
- simtools/ray_tracing/ray_tracing.py +12 -7
- simtools/reporting/docs_read_parameters.py +426 -81
- simtools/runners/corsika_runner.py +11 -1
- simtools/runners/corsika_simtel_runner.py +84 -90
- simtools/runners/runner_services.py +22 -8
- simtools/runners/simtel_runner.py +27 -10
- simtools/schemas/model_parameter.metaschema.yml +4 -0
- simtools/schemas/model_parameter_and_data_schema.metaschema.yml +1 -0
- simtools/schemas/model_parameters/adjust_gain.schema.yml +2 -2
- simtools/schemas/model_parameters/array_element_position_ground.schema.yml +2 -2
- simtools/schemas/model_parameters/array_element_position_utm.schema.yml +2 -2
- simtools/schemas/model_parameters/array_window.schema.yml +2 -2
- simtools/schemas/model_parameters/asum_offset.schema.yml +2 -2
- simtools/schemas/model_parameters/asum_shaping.schema.yml +2 -2
- simtools/schemas/model_parameters/asum_threshold.schema.yml +2 -2
- simtools/schemas/model_parameters/axes_offsets.schema.yml +2 -2
- simtools/schemas/model_parameters/camera_body_diameter.schema.yml +2 -2
- simtools/schemas/model_parameters/camera_body_shape.schema.yml +2 -2
- simtools/schemas/model_parameters/camera_config_file.schema.yml +2 -2
- simtools/schemas/model_parameters/camera_config_rotate.schema.yml +2 -2
- simtools/schemas/model_parameters/camera_degraded_efficiency.schema.yml +2 -2
- simtools/schemas/model_parameters/camera_degraded_map.schema.yml +2 -2
- simtools/schemas/model_parameters/camera_depth.schema.yml +2 -2
- simtools/schemas/model_parameters/camera_filter.schema.yml +2 -2
- simtools/schemas/model_parameters/camera_pixels.schema.yml +2 -2
- simtools/schemas/model_parameters/camera_transmission.schema.yml +2 -2
- simtools/schemas/model_parameters/channels_per_chip.schema.yml +2 -2
- simtools/schemas/model_parameters/correct_nsb_spectrum_to_telescope_altitude.schema.yml +2 -2
- simtools/schemas/model_parameters/corsika_starting_grammage.schema.yml +90 -1
- simtools/schemas/model_parameters/default_trigger.schema.yml +2 -2
- simtools/schemas/model_parameters/design_model.schema.yml +2 -2
- simtools/schemas/model_parameters/disc_ac_coupled.schema.yml +2 -2
- simtools/schemas/model_parameters/disc_bins.schema.yml +2 -2
- simtools/schemas/model_parameters/disc_start.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_amplitude.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_fall_time.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_gate_length.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_hysteresis.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_output_amplitude.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_output_var_percent.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_pulse_shape.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_rise_time.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_scale_threshold.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_sigsum_over_threshold.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_threshold.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_time_over_threshold.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_var_gate_length.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_var_sigsum_over_threshold.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_var_threshold.schema.yml +2 -2
- simtools/schemas/model_parameters/discriminator_var_time_over_threshold.schema.yml +2 -2
- simtools/schemas/model_parameters/dish_shape_length.schema.yml +2 -2
- simtools/schemas/model_parameters/dsum_clipping.schema.yml +2 -2
- simtools/schemas/model_parameters/dsum_ignore_below.schema.yml +2 -2
- simtools/schemas/model_parameters/dsum_offset.schema.yml +2 -2
- simtools/schemas/model_parameters/dsum_pedsub.schema.yml +2 -2
- simtools/schemas/model_parameters/dsum_pre_clipping.schema.yml +2 -2
- simtools/schemas/model_parameters/dsum_prescale.schema.yml +2 -2
- simtools/schemas/model_parameters/dsum_presum_max.schema.yml +2 -2
- simtools/schemas/model_parameters/dsum_presum_shift.schema.yml +2 -2
- simtools/schemas/model_parameters/dsum_shaping.schema.yml +2 -2
- simtools/schemas/model_parameters/dsum_shaping_renormalize.schema.yml +2 -2
- simtools/schemas/model_parameters/dsum_threshold.schema.yml +44 -3
- simtools/schemas/model_parameters/dsum_zero_clip.schema.yml +2 -2
- simtools/schemas/model_parameters/effective_focal_length.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_ac_coupled.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_amplitude.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_bins.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_compensate_pedestal.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_err_compensate_pedestal.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_err_pedestal.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_lg_amplitude.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_lg_compensate_pedestal.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_lg_err_compensate_pedestal.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_lg_err_pedestal.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_lg_max_signal.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_lg_noise.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_lg_pedestal.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_lg_sensitivity.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_lg_sysvar_pedestal.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_lg_var_pedestal.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_lg_var_sensitivity.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_max_signal.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_mhz.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_noise.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_pedestal.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_pulse_shape.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_sensitivity.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_sum_bins.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_sum_offset.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_sysvar_pedestal.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_var_pedestal.schema.yml +2 -2
- simtools/schemas/model_parameters/fadc_var_sensitivity.schema.yml +2 -2
- simtools/schemas/model_parameters/fake_mirror_list.schema.yml +1 -1
- simtools/schemas/model_parameters/flatfielding.schema.yml +2 -2
- simtools/schemas/model_parameters/focal_length.schema.yml +2 -2
- simtools/schemas/model_parameters/focus_offset.schema.yml +2 -2
- simtools/schemas/model_parameters/gain_variation.schema.yml +2 -2
- simtools/schemas/model_parameters/hg_lg_variation.schema.yml +2 -2
- simtools/schemas/model_parameters/iobuf_maximum.schema.yml +2 -2
- simtools/schemas/model_parameters/iobuf_output_maximum.schema.yml +2 -2
- simtools/schemas/model_parameters/laser_events.schema.yml +1 -1
- simtools/schemas/model_parameters/lightguide_efficiency_vs_incidence_angle.schema.yml +2 -2
- simtools/schemas/model_parameters/lightguide_efficiency_vs_wavelength.schema.yml +2 -2
- simtools/schemas/model_parameters/min_photoelectrons.schema.yml +2 -2
- simtools/schemas/model_parameters/min_photons.schema.yml +2 -2
- simtools/schemas/model_parameters/mirror_align_random_distance.schema.yml +2 -2
- simtools/schemas/model_parameters/mirror_align_random_horizontal.schema.yml +2 -2
- simtools/schemas/model_parameters/mirror_align_random_vertical.schema.yml +2 -2
- simtools/schemas/model_parameters/mirror_class.schema.yml +2 -2
- simtools/schemas/model_parameters/mirror_degraded_reflection.schema.yml +2 -2
- simtools/schemas/model_parameters/mirror_focal_length.schema.yml +2 -2
- simtools/schemas/model_parameters/mirror_list.schema.yml +2 -2
- simtools/schemas/model_parameters/mirror_offset.schema.yml +2 -2
- simtools/schemas/model_parameters/mirror_reflection_random_angle.schema.yml +2 -2
- simtools/schemas/model_parameters/mirror_reflectivity.schema.yml +2 -2
- simtools/schemas/model_parameters/multiplicity_offset.schema.yml +2 -2
- simtools/schemas/model_parameters/muon_mono_threshold.schema.yml +2 -2
- simtools/schemas/model_parameters/nsb_autoscale_airmass.schema.yml +2 -2
- simtools/schemas/model_parameters/nsb_offaxis.schema.yml +2 -2
- simtools/schemas/model_parameters/nsb_pixel_rate.schema.yml +2 -2
- simtools/schemas/model_parameters/num_gains.schema.yml +2 -2
- simtools/schemas/model_parameters/only_triggered_telescopes.schema.yml +2 -2
- simtools/schemas/model_parameters/optics_properties.schema.yml +2 -2
- simtools/schemas/model_parameters/pedestal_events.schema.yml +7 -3
- simtools/schemas/model_parameters/photon_delay.schema.yml +2 -2
- simtools/schemas/model_parameters/pixeltrg_time_step.schema.yml +2 -2
- simtools/schemas/model_parameters/pm_average_gain.schema.yml +2 -2
- simtools/schemas/model_parameters/pm_collection_efficiency.schema.yml +2 -2
- simtools/schemas/model_parameters/pm_gain_index.schema.yml +2 -2
- simtools/schemas/model_parameters/pm_photoelectron_spectrum.schema.yml +2 -2
- simtools/schemas/model_parameters/pm_transit_time.schema.yml +2 -2
- simtools/schemas/model_parameters/pm_voltage_variation.schema.yml +2 -2
- simtools/schemas/model_parameters/primary_mirror_degraded_map.schema.yml +2 -2
- simtools/schemas/model_parameters/qe_variation.schema.yml +2 -2
- simtools/schemas/model_parameters/quantum_efficiency.schema.yml +2 -2
- simtools/schemas/model_parameters/random_focal_length.schema.yml +2 -2
- simtools/schemas/model_parameters/random_generator.schema.yml +2 -2
- simtools/schemas/model_parameters/random_mono_probability.schema.yml +2 -2
- simtools/schemas/model_parameters/sampled_output.schema.yml +2 -2
- simtools/schemas/model_parameters/save_pe_with_amplitude.schema.yml +2 -2
- simtools/schemas/model_parameters/store_photoelectrons.schema.yml +2 -2
- simtools/schemas/model_parameters/tailcut_scale.schema.yml +2 -2
- simtools/schemas/model_parameters/telescope_axis_height.schema.yml +2 -2
- simtools/schemas/model_parameters/telescope_random_angle.schema.yml +2 -2
- simtools/schemas/model_parameters/telescope_random_error.schema.yml +2 -2
- simtools/schemas/model_parameters/telescope_sphere_radius.schema.yml +2 -2
- simtools/schemas/model_parameters/telescope_transmission.schema.yml +2 -2
- simtools/schemas/model_parameters/teltrig_min_sigsum.schema.yml +2 -2
- simtools/schemas/model_parameters/teltrig_min_time.schema.yml +2 -2
- simtools/schemas/model_parameters/transit_time_calib_error.schema.yml +2 -2
- simtools/schemas/model_parameters/transit_time_compensate_error.schema.yml +2 -2
- simtools/schemas/model_parameters/transit_time_compensate_step.schema.yml +2 -2
- simtools/schemas/model_parameters/transit_time_error.schema.yml +2 -2
- simtools/schemas/model_parameters/transit_time_jitter.schema.yml +2 -2
- simtools/schemas/model_parameters/trigger_current_limit.schema.yml +2 -2
- simtools/schemas/model_parameters/trigger_delay_compensation.schema.yml +2 -2
- simtools/schemas/model_parameters/trigger_pixels.schema.yml +2 -2
- simtools/schemas/production_configuration_metrics.schema.yml +2 -2
- simtools/simtel/simtel_config_reader.py +21 -17
- simtools/simtel/simtel_config_writer.py +258 -66
- simtools/simtel/simtel_io_event_reader.py +301 -194
- simtools/simtel/simtel_io_event_writer.py +207 -227
- simtools/simtel/simtel_io_file_info.py +62 -0
- simtools/simtel/simtel_io_histogram.py +10 -14
- simtools/simtel/simtel_io_histograms.py +2 -2
- simtools/simtel/simtel_io_metadata.py +106 -0
- simtools/simtel/simulator_array.py +28 -14
- simtools/simtel/simulator_camera_efficiency.py +12 -6
- simtools/simtel/simulator_light_emission.py +85 -45
- simtools/simtel/simulator_ray_tracing.py +16 -6
- simtools/simulator.py +286 -89
- simtools/testing/configuration.py +5 -0
- simtools/testing/helpers.py +18 -0
- simtools/testing/sim_telarray_metadata.py +212 -0
- simtools/testing/validate_output.py +16 -6
- simtools/utils/general.py +18 -27
- simtools/utils/names.py +32 -10
- simtools/visualization/plot_array_layout.py +242 -0
- simtools/visualization/plot_pixels.py +681 -0
- simtools/visualization/visualize.py +5 -221
- simtools/applications/production_generate_simulation_config.py +0 -162
- simtools/applications/production_scale_events.py +0 -185
- simtools/layout/ctao_array_layouts.py +0 -172
- simtools/production_configuration/event_scaler.py +0 -120
- simtools/production_configuration/generate_simulation_config.py +0 -158
- {gammasimtools-0.15.0.dist-info → gammasimtools-0.17.0.dist-info}/licenses/LICENSE +0 -0
- {gammasimtools-0.15.0.dist-info → gammasimtools-0.17.0.dist-info}/top_level.txt +0 -0
|
@@ -24,7 +24,7 @@ __all__ = [
|
|
|
24
24
|
|
|
25
25
|
class SimtelIOHistograms:
|
|
26
26
|
"""
|
|
27
|
-
Read the content of either multiple histogram (.hdata, or .hdata.zst) or
|
|
27
|
+
Read the content of either multiple histogram (.hdata, or .hdata.zst) or sim_telarray files.
|
|
28
28
|
|
|
29
29
|
Allow both the .hdata.zst histogram and the .simtel.zst output file type.
|
|
30
30
|
It uses the SimtelIOHistogram class to deal with individual files.
|
|
@@ -159,7 +159,7 @@ class SimtelIOHistograms:
|
|
|
159
159
|
if sim_hist is None or trig_hist is None:
|
|
160
160
|
msg = (
|
|
161
161
|
"Simulated and triggered histograms were not found in the stacked histograms."
|
|
162
|
-
" Please check your
|
|
162
|
+
" Please check your sim_telarray files!"
|
|
163
163
|
)
|
|
164
164
|
self._logger.error(msg)
|
|
165
165
|
raise HistogramIdNotFoundError
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#!/usr/bin/python3
|
|
2
|
+
"""Read metadata from sim_telarray files."""
|
|
3
|
+
|
|
4
|
+
import logging
|
|
5
|
+
from functools import cache
|
|
6
|
+
|
|
7
|
+
from eventio import EventIOFile
|
|
8
|
+
from eventio.simtel import HistoryMeta
|
|
9
|
+
|
|
10
|
+
_logger = logging.getLogger(__name__)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@cache
|
|
14
|
+
def read_sim_telarray_metadata(file, encoding="utf8"):
|
|
15
|
+
"""
|
|
16
|
+
Return global and per-telescope metadata from sim_telarray file.
|
|
17
|
+
|
|
18
|
+
Cached to avoid re-reading the file multiple times.
|
|
19
|
+
|
|
20
|
+
Parameters
|
|
21
|
+
----------
|
|
22
|
+
file: str
|
|
23
|
+
Path to the sim_telarray file.
|
|
24
|
+
encoding: str
|
|
25
|
+
Encoding to use for decoding metadata. Default is 'utf8'.
|
|
26
|
+
|
|
27
|
+
Returns
|
|
28
|
+
-------
|
|
29
|
+
global_meta: dict
|
|
30
|
+
Global metadata dictionary.
|
|
31
|
+
telescope_meta: dict
|
|
32
|
+
Dictionary of telescope metadata, keyed by telescope ID.
|
|
33
|
+
"""
|
|
34
|
+
global_meta = None
|
|
35
|
+
telescope_meta = {}
|
|
36
|
+
|
|
37
|
+
with EventIOFile(file) as f:
|
|
38
|
+
found_meta = False
|
|
39
|
+
for o in f:
|
|
40
|
+
if isinstance(o, HistoryMeta):
|
|
41
|
+
found_meta = True
|
|
42
|
+
else:
|
|
43
|
+
if found_meta:
|
|
44
|
+
break
|
|
45
|
+
continue
|
|
46
|
+
|
|
47
|
+
meta = _decode_dictionary(o.parse(), encoding=encoding)
|
|
48
|
+
if o.header.id == -1:
|
|
49
|
+
global_meta = meta
|
|
50
|
+
else:
|
|
51
|
+
telescope_meta[o.header.id] = meta
|
|
52
|
+
|
|
53
|
+
def clean_meta(meta):
|
|
54
|
+
"""Clean metadata dictionary."""
|
|
55
|
+
meta = {k.lower().lstrip("*"): v for k, v in meta.items()}
|
|
56
|
+
return {k: v.strip() if isinstance(v, str) else v for k, v in meta.items()}
|
|
57
|
+
|
|
58
|
+
# keys to lower case and strip leading '*', trailing spaces
|
|
59
|
+
return clean_meta(global_meta), {
|
|
60
|
+
tel_id: clean_meta(meta) for tel_id, meta in telescope_meta.items()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _decode_dictionary(meta, encoding="utf8"):
|
|
65
|
+
"""Decode metadata dictionary."""
|
|
66
|
+
|
|
67
|
+
def safe_decode(byte_str, encoding, errors="ignore"):
|
|
68
|
+
return byte_str.decode(encoding, errors=errors)
|
|
69
|
+
|
|
70
|
+
try:
|
|
71
|
+
return {k.decode(encoding, errors="ignore"): v.decode(encoding) for k, v in meta.items()}
|
|
72
|
+
except UnicodeDecodeError as e:
|
|
73
|
+
_logger.warning(
|
|
74
|
+
f"Failed to decode metadata with encoding {encoding}: {e}. "
|
|
75
|
+
"Falling back to 'utf-8' with errors='ignore'."
|
|
76
|
+
)
|
|
77
|
+
return {safe_decode(k, encoding): safe_decode(v, encoding) for k, v in meta.items()}
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def get_sim_telarray_telescope_id(telescope_name, file):
|
|
81
|
+
"""
|
|
82
|
+
Return the telescope ID for a given telescope name in a sim_telarray file.
|
|
83
|
+
|
|
84
|
+
Translates e.g. 'LSTN-01' to the corresponding telescope ID.
|
|
85
|
+
|
|
86
|
+
Parameters
|
|
87
|
+
----------
|
|
88
|
+
telescope_name: str
|
|
89
|
+
Name of the telescope.
|
|
90
|
+
file: str
|
|
91
|
+
Path to the sim_telarray file.
|
|
92
|
+
|
|
93
|
+
Returns
|
|
94
|
+
-------
|
|
95
|
+
int, None
|
|
96
|
+
Telescope ID. Returns None if not found.
|
|
97
|
+
"""
|
|
98
|
+
_, telescope_meta = read_sim_telarray_metadata(file)
|
|
99
|
+
telescope_name_to_sim_telarray_id = {}
|
|
100
|
+
for tel_id in telescope_meta.keys():
|
|
101
|
+
_optics_name = telescope_meta[tel_id].get("optics_config_name", None)
|
|
102
|
+
_camera_name = telescope_meta[tel_id].get("camera_config_name", None)
|
|
103
|
+
if _optics_name == _camera_name and _optics_name == telescope_name:
|
|
104
|
+
telescope_name_to_sim_telarray_id[telescope_name] = tel_id
|
|
105
|
+
|
|
106
|
+
return telescope_name_to_sim_telarray_id.get(telescope_name, None)
|
|
@@ -23,6 +23,8 @@ class SimulatorArray(SimtelRunner):
|
|
|
23
23
|
Instance label.
|
|
24
24
|
use_multipipe: bool
|
|
25
25
|
Use multipipe to run CORSIKA and sim_telarray.
|
|
26
|
+
sim_telarray_seeds: dict
|
|
27
|
+
Dictionary with configuration for sim_telarray random instrument setup.
|
|
26
28
|
"""
|
|
27
29
|
|
|
28
30
|
def __init__(
|
|
@@ -48,9 +50,9 @@ class SimulatorArray(SimtelRunner):
|
|
|
48
50
|
self.io_handler = io_handler.IOHandler()
|
|
49
51
|
self._log_file = None
|
|
50
52
|
|
|
51
|
-
def
|
|
53
|
+
def make_run_command(self, run_number=None, input_file=None, weak_pointing=None):
|
|
52
54
|
"""
|
|
53
|
-
Build and return the command to run
|
|
55
|
+
Build and return the command to run sim_telarray.
|
|
54
56
|
|
|
55
57
|
Parameters
|
|
56
58
|
----------
|
|
@@ -58,22 +60,29 @@ class SimulatorArray(SimtelRunner):
|
|
|
58
60
|
Full path of the input CORSIKA file
|
|
59
61
|
run_number: int (optional)
|
|
60
62
|
run number
|
|
63
|
+
weak_pointing: bool (optional)
|
|
64
|
+
Specify weak pointing option for sim_telarray.
|
|
61
65
|
|
|
62
66
|
Returns
|
|
63
67
|
-------
|
|
64
68
|
str
|
|
65
69
|
Command to run sim_telarray.
|
|
66
70
|
"""
|
|
71
|
+
config_dir = self.corsika_config.array_model.get_config_directory()
|
|
67
72
|
self._log_file = self.get_file_name(file_type="log", run_number=run_number)
|
|
68
73
|
histogram_file = self.get_file_name(file_type="histogram", run_number=run_number)
|
|
69
|
-
output_file = self.get_file_name(file_type="
|
|
74
|
+
output_file = self.get_file_name(file_type="simtel_output", run_number=run_number)
|
|
75
|
+
self.corsika_config.array_model.export_all_simtel_config_files()
|
|
70
76
|
|
|
71
|
-
# Array
|
|
72
77
|
command = str(self._simtel_path.joinpath("sim_telarray/bin/sim_telarray"))
|
|
73
|
-
command += f" -c {self.corsika_config.array_model.
|
|
74
|
-
command += f" -I{
|
|
75
|
-
command += super().get_config_option(
|
|
76
|
-
|
|
78
|
+
command += f" -c {self.corsika_config.array_model.config_file_path}"
|
|
79
|
+
command += f" -I{config_dir}"
|
|
80
|
+
command += super().get_config_option(
|
|
81
|
+
"telescope_theta", self.corsika_config.zenith_angle, weak_pointing
|
|
82
|
+
)
|
|
83
|
+
command += super().get_config_option(
|
|
84
|
+
"telescope_phi", self.corsika_config.azimuth_angle, weak_pointing
|
|
85
|
+
)
|
|
77
86
|
command += super().get_config_option(
|
|
78
87
|
"power_law",
|
|
79
88
|
SimulatorArray.get_power_law_for_sim_telarray_histograms(
|
|
@@ -81,13 +90,18 @@ class SimulatorArray(SimtelRunner):
|
|
|
81
90
|
),
|
|
82
91
|
)
|
|
83
92
|
command += super().get_config_option("histogram_file", histogram_file)
|
|
84
|
-
command += super().get_config_option("output_file", output_file)
|
|
85
93
|
command += super().get_config_option("random_state", "none")
|
|
86
|
-
if self.sim_telarray_seeds:
|
|
87
|
-
command += super().get_config_option(
|
|
94
|
+
if self.sim_telarray_seeds and self.sim_telarray_seeds.get("random_instrument_instances"):
|
|
95
|
+
command += super().get_config_option(
|
|
96
|
+
"random_seed",
|
|
97
|
+
f"file-by-run:{config_dir}/{self.sim_telarray_seeds['seed_file_name']},auto",
|
|
98
|
+
)
|
|
99
|
+
elif self.sim_telarray_seeds and self.sim_telarray_seeds.get("seed"):
|
|
100
|
+
command += super().get_config_option("random_seed", self.sim_telarray_seeds["seed"])
|
|
88
101
|
command += super().get_config_option("show", "all")
|
|
102
|
+
command += super().get_config_option("output_file", output_file)
|
|
89
103
|
command += f" {input_file}"
|
|
90
|
-
command += f" > {self._log_file} 2>&1 || exit"
|
|
104
|
+
command += f" | gzip > {self._log_file} 2>&1 || exit"
|
|
91
105
|
|
|
92
106
|
return clear_default_sim_telarray_cfg_directories(command)
|
|
93
107
|
|
|
@@ -110,12 +124,12 @@ class SimulatorArray(SimtelRunner):
|
|
|
110
124
|
InvalidOutputFileError
|
|
111
125
|
If simtel output file does not exist.
|
|
112
126
|
"""
|
|
113
|
-
output_file = self.get_file_name(file_type="
|
|
127
|
+
output_file = self.get_file_name(file_type="simtel_output", run_number=run_number)
|
|
114
128
|
if not output_file.exists():
|
|
115
129
|
msg = f"sim_telarray output file {output_file} does not exist."
|
|
116
130
|
self._logger.error(msg)
|
|
117
131
|
raise InvalidOutputFileError(msg)
|
|
118
|
-
self._logger.debug(f"
|
|
132
|
+
self._logger.debug(f"sim_telarray output file {output_file} exists.")
|
|
119
133
|
return True
|
|
120
134
|
|
|
121
135
|
@staticmethod
|
|
@@ -16,8 +16,10 @@ class SimulatorCameraEfficiency(SimtelRunner):
|
|
|
16
16
|
|
|
17
17
|
Parameters
|
|
18
18
|
----------
|
|
19
|
-
telescope_model:
|
|
19
|
+
telescope_model: TelescopeModel
|
|
20
20
|
Instance of TelescopeModel class.
|
|
21
|
+
site_model: SiteModel
|
|
22
|
+
Instance of SiteModel class.
|
|
21
23
|
label: str
|
|
22
24
|
Instance label. Important for output file naming.
|
|
23
25
|
simtel_path: str or Path
|
|
@@ -28,11 +30,14 @@ class SimulatorCameraEfficiency(SimtelRunner):
|
|
|
28
30
|
Zenith angle given in the config to CameraEfficiency.
|
|
29
31
|
nsb_spectrum: str or Path
|
|
30
32
|
Path to the nsb spectrum file.
|
|
33
|
+
skip_correction_to_nsb_spectrum: bool
|
|
34
|
+
If True, skip the correction to the original altitude where the NSB spectrum was derived.
|
|
31
35
|
"""
|
|
32
36
|
|
|
33
37
|
def __init__(
|
|
34
38
|
self,
|
|
35
39
|
telescope_model,
|
|
40
|
+
site_model,
|
|
36
41
|
label=None,
|
|
37
42
|
simtel_path=None,
|
|
38
43
|
file_simtel=None,
|
|
@@ -48,6 +53,7 @@ class SimulatorCameraEfficiency(SimtelRunner):
|
|
|
48
53
|
super().__init__(label=label, simtel_path=simtel_path)
|
|
49
54
|
|
|
50
55
|
self._telescope_model = telescope_model
|
|
56
|
+
self._site_model = site_model
|
|
51
57
|
self.label = label if label is not None else self._telescope_model.label
|
|
52
58
|
|
|
53
59
|
self._file_simtel = file_simtel
|
|
@@ -68,8 +74,8 @@ class SimulatorCameraEfficiency(SimtelRunner):
|
|
|
68
74
|
self._nsb_spectrum = self._validate_or_fix_nsb_spectrum_file_format(nsb_spectrum)
|
|
69
75
|
else:
|
|
70
76
|
self._nsb_spectrum = (
|
|
71
|
-
self.
|
|
72
|
-
/ Path(self.
|
|
77
|
+
self._site_model.config_file_directory
|
|
78
|
+
/ Path(self._site_model.get_parameter_value("nsb_reference_spectrum")).name
|
|
73
79
|
)
|
|
74
80
|
|
|
75
81
|
def _make_run_command(self, run_number=None, input_file=None): # pylint: disable=unused-argument
|
|
@@ -127,8 +133,8 @@ class SimulatorCameraEfficiency(SimtelRunner):
|
|
|
127
133
|
if self.nsb_spectrum is not None:
|
|
128
134
|
command += f" -fnsb {self.nsb_spectrum}"
|
|
129
135
|
command += " -nm -nsb-extra"
|
|
130
|
-
command += f" -alt {self.
|
|
131
|
-
command += f" -fatm {self.
|
|
136
|
+
command += f" -alt {self._site_model.get_parameter_value('corsika_observation_level')}"
|
|
137
|
+
command += f" -fatm {self._site_model.get_parameter_value('atmospheric_transmission')}"
|
|
132
138
|
command += f" -flen {focal_length}"
|
|
133
139
|
command += f" {pixel_shape_cmd} {pixel_diameter}"
|
|
134
140
|
if mirror_class == 0:
|
|
@@ -152,7 +158,7 @@ class SimulatorCameraEfficiency(SimtelRunner):
|
|
|
152
158
|
command += f" -fqe {self._telescope_model.get_parameter_value('quantum_efficiency')}"
|
|
153
159
|
command += " 200 1000" # lmin and lmax
|
|
154
160
|
command += " 300" # Xmax
|
|
155
|
-
command += f" {self.
|
|
161
|
+
command += f" {self._site_model.get_parameter_value('atmospheric_profile')}"
|
|
156
162
|
command += f" {self.zenith_angle}"
|
|
157
163
|
|
|
158
164
|
# Remove the default sim_telarray configuration directories
|
|
@@ -46,6 +46,7 @@ class SimulatorLightEmission(SimtelRunner):
|
|
|
46
46
|
self._telescope_model = telescope_model
|
|
47
47
|
|
|
48
48
|
self.label = label if label is not None else self._telescope_model.label
|
|
49
|
+
self.test = test
|
|
49
50
|
|
|
50
51
|
self._calibration_model = calibration_model
|
|
51
52
|
self._site_model = site_model
|
|
@@ -56,15 +57,16 @@ class SimulatorLightEmission(SimtelRunner):
|
|
|
56
57
|
self._rep_number = 0
|
|
57
58
|
self.runs = 1
|
|
58
59
|
self.photons_per_run = (
|
|
59
|
-
self._calibration_model.get_parameter_value("photons_per_run")
|
|
60
|
+
(self._calibration_model.get_parameter_value("photons_per_run"))
|
|
61
|
+
if not self.test
|
|
62
|
+
else 1e8
|
|
60
63
|
)
|
|
61
64
|
|
|
62
65
|
self.le_application = le_application
|
|
63
66
|
self.light_emission_config = light_emission_config
|
|
64
67
|
self.distance = None
|
|
65
68
|
self.light_source_type = light_source_type
|
|
66
|
-
self._telescope_model.
|
|
67
|
-
self.test = test
|
|
69
|
+
self._telescope_model.write_sim_telarray_config_file(additional_model=site_model)
|
|
68
70
|
|
|
69
71
|
@staticmethod
|
|
70
72
|
def light_emission_default_configuration():
|
|
@@ -119,14 +121,15 @@ class SimulatorLightEmission(SimtelRunner):
|
|
|
119
121
|
list
|
|
120
122
|
The pointing vector from the calibration device to the telescope.
|
|
121
123
|
"""
|
|
122
|
-
|
|
123
|
-
x_cal, y_cal, z_cal = self._calibration_model.get_parameter_value(
|
|
124
|
+
x_cal, y_cal, z_cal = self._calibration_model.get_parameter_value_with_unit(
|
|
124
125
|
"array_element_position_ground"
|
|
125
126
|
)
|
|
127
|
+
x_cal, y_cal, z_cal = [coord.to(u.m).value for coord in (x_cal, y_cal, z_cal)]
|
|
126
128
|
cal_vect = np.array([x_cal, y_cal, z_cal])
|
|
127
|
-
x_tel, y_tel, z_tel = self._telescope_model.
|
|
129
|
+
x_tel, y_tel, z_tel = self._telescope_model.get_parameter_value_with_unit(
|
|
128
130
|
"array_element_position_ground"
|
|
129
131
|
)
|
|
132
|
+
x_tel, y_tel, z_tel = [coord.to(u.m).value for coord in (x_tel, y_tel, z_tel)]
|
|
130
133
|
|
|
131
134
|
tel_vect = np.array([x_tel, y_tel, z_tel])
|
|
132
135
|
|
|
@@ -153,6 +156,30 @@ class SimulatorLightEmission(SimtelRunner):
|
|
|
153
156
|
)
|
|
154
157
|
return pointing_vector.tolist(), [tel_theta, tel_phi, laser_theta, laser_phi]
|
|
155
158
|
|
|
159
|
+
def _write_telpos_file(self):
|
|
160
|
+
"""
|
|
161
|
+
Write the telescope positions to a telpos file.
|
|
162
|
+
|
|
163
|
+
The file will contain lines in the format: x y z r in cm
|
|
164
|
+
|
|
165
|
+
Returns
|
|
166
|
+
-------
|
|
167
|
+
Path
|
|
168
|
+
The path to the generated telpos file.
|
|
169
|
+
"""
|
|
170
|
+
telpos_file = self.output_directory.joinpath("telpos.dat")
|
|
171
|
+
x_tel, y_tel, z_tel = self._telescope_model.get_parameter_value_with_unit(
|
|
172
|
+
"array_element_position_ground"
|
|
173
|
+
)
|
|
174
|
+
x_tel, y_tel, z_tel = [coord.to(u.cm).value for coord in (x_tel, y_tel, z_tel)]
|
|
175
|
+
|
|
176
|
+
radius = self._telescope_model.get_parameter_value_with_unit("telescope_sphere_radius")
|
|
177
|
+
radius = radius.to(u.cm).value # Convert radius to cm
|
|
178
|
+
with telpos_file.open("w", encoding="utf-8") as file:
|
|
179
|
+
file.write(f"{x_tel} {y_tel} {z_tel} {radius}\n")
|
|
180
|
+
|
|
181
|
+
return telpos_file
|
|
182
|
+
|
|
156
183
|
def _make_light_emission_script(self):
|
|
157
184
|
"""
|
|
158
185
|
Create the light emission script to run the light emission package.
|
|
@@ -165,17 +192,28 @@ class SimulatorLightEmission(SimtelRunner):
|
|
|
165
192
|
str
|
|
166
193
|
The commands to run the Light Emission package
|
|
167
194
|
"""
|
|
168
|
-
x_cal, y_cal, z_cal = (
|
|
169
|
-
|
|
195
|
+
x_cal, y_cal, z_cal = self._calibration_model.get_parameter_value_with_unit(
|
|
196
|
+
"array_element_position_ground"
|
|
197
|
+
)
|
|
198
|
+
x_tel, y_tel, z_tel = self._telescope_model.get_parameter_value_with_unit(
|
|
199
|
+
"array_element_position_ground"
|
|
170
200
|
)
|
|
171
|
-
|
|
172
|
-
|
|
201
|
+
|
|
202
|
+
config_directory = self.io_handler.get_output_directory(
|
|
203
|
+
label=self.label, sub_dir=f"model/{self._site_model.model_version}"
|
|
173
204
|
)
|
|
174
|
-
|
|
175
|
-
|
|
205
|
+
|
|
206
|
+
telpos_file = self._write_telpos_file()
|
|
207
|
+
|
|
208
|
+
command = f"rm {self.output_directory}/"
|
|
176
209
|
command += f"{self.le_application[0]}_{self.le_application[1]}.simtel.gz\n"
|
|
177
210
|
command += str(self._simtel_path.joinpath("sim_telarray/LightEmission/"))
|
|
178
211
|
command += f"/{self.le_application[0]}"
|
|
212
|
+
corsika_observation_level = self._site_model.get_parameter_value_with_unit(
|
|
213
|
+
"corsika_observation_level"
|
|
214
|
+
)
|
|
215
|
+
command += f" -h {corsika_observation_level.to(u.m).value}"
|
|
216
|
+
command += f" --telpos-file {telpos_file}"
|
|
179
217
|
|
|
180
218
|
if self.light_source_type == "led":
|
|
181
219
|
if self.le_application[1] == "variable":
|
|
@@ -188,28 +226,27 @@ class SimulatorLightEmission(SimtelRunner):
|
|
|
188
226
|
command += f" -n {self.photons_per_run}"
|
|
189
227
|
|
|
190
228
|
elif self.le_application[1] == "layout":
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
# light_source coordinates relative to telescope
|
|
195
|
-
command += f" -x {x_origin.to(u.cm).value}"
|
|
196
|
-
command += f" -y {y_origin.to(u.cm).value}"
|
|
197
|
-
command += f" -z {z_origin.to(u.cm).value}"
|
|
229
|
+
command += f" -x {x_cal.to(u.cm).value}"
|
|
230
|
+
command += f" -y {y_cal.to(u.cm).value}"
|
|
231
|
+
command += f" -z {z_cal.to(u.cm).value}"
|
|
198
232
|
pointing_vector = self.calibration_pointing_direction()[0]
|
|
199
233
|
command += f" -d {','.join(map(str, pointing_vector))}"
|
|
200
234
|
|
|
201
235
|
command += f" -n {self.photons_per_run}"
|
|
236
|
+
self._logger.info(f"Photons per run: {self.photons_per_run} ")
|
|
202
237
|
|
|
203
|
-
|
|
204
|
-
|
|
238
|
+
laser_wavelength = self._calibration_model.get_parameter_value_with_unit(
|
|
239
|
+
"laser_wavelength"
|
|
240
|
+
)
|
|
241
|
+
command += f" -s {int(laser_wavelength.to(u.nm).value)}"
|
|
205
242
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
f" -p Gauss:{self._calibration_model.get_parameter_value('led_pulse_sigtime')}"
|
|
243
|
+
led_pulse_sigtime = self._calibration_model.get_parameter_value_with_unit(
|
|
244
|
+
"led_pulse_sigtime"
|
|
209
245
|
)
|
|
210
|
-
command += " -
|
|
246
|
+
command += f" -p Gauss:{led_pulse_sigtime.to(u.ns).value}"
|
|
247
|
+
command += " -a isotropic"
|
|
211
248
|
|
|
212
|
-
command += f" -A {
|
|
249
|
+
command += f" -A {config_directory}/"
|
|
213
250
|
command += f"{self._telescope_model.get_parameter_value('atmospheric_profile')}"
|
|
214
251
|
|
|
215
252
|
elif self.light_source_type == "laser":
|
|
@@ -217,11 +254,13 @@ class SimulatorLightEmission(SimtelRunner):
|
|
|
217
254
|
command += " --bunches 2500000"
|
|
218
255
|
command += " --step 0.1"
|
|
219
256
|
command += " --bunchsize 1"
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
)
|
|
257
|
+
spectrum = self._calibration_model.get_parameter_value_with_unit("laser_wavelength")
|
|
258
|
+
command += f" --spectrum {int(spectrum.to(u.nm).value)}"
|
|
223
259
|
command += " --lightpulse Gauss:"
|
|
224
|
-
|
|
260
|
+
pulse_sigtime = self._calibration_model.get_parameter_value_with_unit(
|
|
261
|
+
"laser_pulse_sigtime"
|
|
262
|
+
)
|
|
263
|
+
command += f"{pulse_sigtime.to(u.ns).value}"
|
|
225
264
|
x_origin = x_cal - x_tel
|
|
226
265
|
y_origin = y_cal - y_tel
|
|
227
266
|
z_origin = z_cal - z_tel
|
|
@@ -234,8 +273,8 @@ class SimulatorLightEmission(SimtelRunner):
|
|
|
234
273
|
command += f" --telescope-theta {angle_theta}"
|
|
235
274
|
command += f" --telescope-phi {angle_phi}"
|
|
236
275
|
command += f" --laser-theta {90 - angles[2]}"
|
|
237
|
-
command += f" --laser-phi {angles[3]}"
|
|
238
|
-
command += f" --atmosphere {
|
|
276
|
+
command += f" --laser-phi {angles[3]}"
|
|
277
|
+
command += f" --atmosphere {config_directory}/"
|
|
239
278
|
command += f"{self._telescope_model.get_parameter_value('atmospheric_profile')}"
|
|
240
279
|
command += f" -o {self.output_directory}/{self.le_application[0]}.iact.gz"
|
|
241
280
|
command += "\n"
|
|
@@ -244,12 +283,12 @@ class SimulatorLightEmission(SimtelRunner):
|
|
|
244
283
|
|
|
245
284
|
def _make_simtel_script(self):
|
|
246
285
|
"""
|
|
247
|
-
Return the command to run
|
|
286
|
+
Return the command to run sim_telarray using the output from the previous step.
|
|
248
287
|
|
|
249
288
|
Returns
|
|
250
289
|
-------
|
|
251
290
|
str
|
|
252
|
-
The command to run
|
|
291
|
+
The command to run sim_telarray
|
|
253
292
|
"""
|
|
254
293
|
# LightEmission
|
|
255
294
|
_, angles = self.calibration_pointing_direction()
|
|
@@ -257,19 +296,17 @@ class SimulatorLightEmission(SimtelRunner):
|
|
|
257
296
|
command = f"{self._simtel_path.joinpath('sim_telarray/bin/sim_telarray/')}"
|
|
258
297
|
command += " -I"
|
|
259
298
|
command += f" -I{self._telescope_model.config_file_directory}"
|
|
260
|
-
command += f" -c {self._telescope_model.
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
self._telescope_model.get_config_file(no_export=True), "array_triggers"
|
|
264
|
-
)
|
|
265
|
-
self._remove_line_from_config(
|
|
266
|
-
self._telescope_model.get_config_file(no_export=True), "axes_offsets"
|
|
267
|
-
)
|
|
299
|
+
command += f" -c {self._telescope_model.config_file_path}"
|
|
300
|
+
self._remove_line_from_config(self._telescope_model.config_file_path, "array_triggers")
|
|
301
|
+
self._remove_line_from_config(self._telescope_model.config_file_path, "axes_offsets")
|
|
268
302
|
|
|
269
303
|
command += " -DNUM_TELESCOPES=1"
|
|
270
304
|
|
|
271
305
|
command += super().get_config_option(
|
|
272
|
-
"altitude",
|
|
306
|
+
"altitude",
|
|
307
|
+
self._site_model.get_parameter_value_with_unit("corsika_observation_level")
|
|
308
|
+
.to(u.m)
|
|
309
|
+
.value,
|
|
273
310
|
)
|
|
274
311
|
command += super().get_config_option(
|
|
275
312
|
"atmospheric_transmission",
|
|
@@ -531,15 +568,18 @@ class SimulatorLightEmission(SimtelRunner):
|
|
|
531
568
|
"""
|
|
532
569
|
if not self.light_emission_config:
|
|
533
570
|
# Layout positions: Use DB coordinates
|
|
534
|
-
x_cal, y_cal, z_cal = self._calibration_model.
|
|
571
|
+
x_cal, y_cal, z_cal = self._calibration_model.get_parameter_value_with_unit(
|
|
535
572
|
"array_element_position_ground"
|
|
536
573
|
)
|
|
537
|
-
|
|
574
|
+
x_cal, y_cal, z_cal = [coord.to(u.m).value for coord in (x_cal, y_cal, z_cal)]
|
|
575
|
+
x_tel, y_tel, z_tel = self._telescope_model.get_parameter_value_with_unit(
|
|
538
576
|
"array_element_position_ground"
|
|
539
577
|
)
|
|
578
|
+
x_tel, y_tel, z_tel = [coord.to(u.m).value for coord in (x_tel, y_tel, z_tel)]
|
|
540
579
|
tel_vect = np.array([x_tel, y_tel, z_tel])
|
|
541
580
|
cal_vect = np.array([x_cal, y_cal, z_cal])
|
|
542
581
|
distance = np.linalg.norm(cal_vect - tel_vect)
|
|
582
|
+
print("Distance between telescope and calibration device:", distance * u.m)
|
|
543
583
|
return [distance * u.m]
|
|
544
584
|
|
|
545
585
|
# Variable positions: Calculate distances for all positions
|
|
@@ -25,6 +25,8 @@ class SimulatorRayTracing(SimtelRunner):
|
|
|
25
25
|
----------
|
|
26
26
|
telescope_model: TelescopeModel
|
|
27
27
|
telescope model
|
|
28
|
+
site_model: SiteModel
|
|
29
|
+
site model
|
|
28
30
|
label: str
|
|
29
31
|
label used for output file naming.
|
|
30
32
|
simtel_path: str or Path
|
|
@@ -41,6 +43,7 @@ class SimulatorRayTracing(SimtelRunner):
|
|
|
41
43
|
def __init__(
|
|
42
44
|
self,
|
|
43
45
|
telescope_model,
|
|
46
|
+
site_model,
|
|
44
47
|
label=None,
|
|
45
48
|
simtel_path=None,
|
|
46
49
|
config_data=None,
|
|
@@ -54,10 +57,11 @@ class SimulatorRayTracing(SimtelRunner):
|
|
|
54
57
|
super().__init__(label=label, simtel_path=simtel_path)
|
|
55
58
|
|
|
56
59
|
self.telescope_model = telescope_model
|
|
60
|
+
self.site_model = site_model
|
|
57
61
|
self.label = label if label is not None else self.telescope_model.label
|
|
58
62
|
|
|
59
63
|
self.io_handler = io_handler.IOHandler()
|
|
60
|
-
self._base_directory = self.io_handler.get_output_directory(self.label, "
|
|
64
|
+
self._base_directory = self.io_handler.get_output_directory(self.label, "ray_tracing")
|
|
61
65
|
|
|
62
66
|
self.config = (
|
|
63
67
|
self._config_to_namedtuple(config_data)
|
|
@@ -89,7 +93,7 @@ class SimulatorRayTracing(SimtelRunner):
|
|
|
89
93
|
# Files will be named _base_file = self.__dict__['_' + base + 'File']
|
|
90
94
|
for base_name in ["stars", "photons", "log"]:
|
|
91
95
|
file_name = names.generate_file_name(
|
|
92
|
-
file_type=base_name,
|
|
96
|
+
file_type=f"ray_tracing_{base_name}",
|
|
93
97
|
suffix=".log" if base_name == "log" else ".lis",
|
|
94
98
|
site=self.telescope_model.site,
|
|
95
99
|
telescope_model_name=self.telescope_model.name,
|
|
@@ -115,7 +119,7 @@ class SimulatorRayTracing(SimtelRunner):
|
|
|
115
119
|
file.write(f"#{50 * '='}\n")
|
|
116
120
|
file.write("# List of photons for RayTracing simulations\n")
|
|
117
121
|
file.write(f"#{50 * '='}\n")
|
|
118
|
-
file.write(f"# config_file = {self.telescope_model.
|
|
122
|
+
file.write(f"# config_file = {self.telescope_model.config_file_path}\n")
|
|
119
123
|
file.write(f"# zenith_angle [deg] = {self.config.zenith_angle}\n")
|
|
120
124
|
file.write(f"# off_axis_angle [deg] = {self.config.off_axis_angle}\n")
|
|
121
125
|
file.write(f"# source_distance [km] = {self.config.source_distance}\n")
|
|
@@ -137,7 +141,13 @@ class SimulatorRayTracing(SimtelRunner):
|
|
|
137
141
|
self._write_out_single_pixel_camera_file()
|
|
138
142
|
|
|
139
143
|
def _make_run_command(self, run_number=None, input_file=None): # pylint: disable=unused-argument
|
|
140
|
-
"""
|
|
144
|
+
"""
|
|
145
|
+
Generate sim_telarray run command. Export sim_telarray configuration file(s).
|
|
146
|
+
|
|
147
|
+
The run_number and input_file parameters are not relevant for the ray tracing simulation.
|
|
148
|
+
"""
|
|
149
|
+
self.telescope_model.write_sim_telarray_config_file(additional_model=self.site_model)
|
|
150
|
+
|
|
141
151
|
if self.config.single_mirror_mode:
|
|
142
152
|
# Note: no mirror length defined for dual-mirror telescopes
|
|
143
153
|
_mirror_focal_length = float(
|
|
@@ -146,13 +156,13 @@ class SimulatorRayTracing(SimtelRunner):
|
|
|
146
156
|
|
|
147
157
|
# RayTracing
|
|
148
158
|
command = str(self._simtel_path.joinpath("sim_telarray/bin/sim_telarray"))
|
|
149
|
-
command += f" -c {self.telescope_model.
|
|
159
|
+
command += f" -c {self.telescope_model.config_file_path}"
|
|
150
160
|
command += f" -I{self.telescope_model.config_file_directory}"
|
|
151
161
|
command += super().get_config_option("random_state", "none")
|
|
152
162
|
command += super().get_config_option("IMAGING_LIST", str(self._photons_file))
|
|
153
163
|
command += super().get_config_option("stars", str(self._stars_file))
|
|
154
164
|
command += super().get_config_option(
|
|
155
|
-
"altitude", self.
|
|
165
|
+
"altitude", self.site_model.get_parameter_value("corsika_observation_level")
|
|
156
166
|
)
|
|
157
167
|
command += super().get_config_option(
|
|
158
168
|
"telescope_theta",
|