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
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
"""Retrieve, merge, and write layouts from CTAO common identifiers repository."""
|
|
2
|
-
|
|
3
|
-
import logging
|
|
4
|
-
from pathlib import Path
|
|
5
|
-
|
|
6
|
-
import simtools.utils.general as gen
|
|
7
|
-
from simtools.data_model.metadata_collector import MetadataCollector
|
|
8
|
-
from simtools.data_model.model_data_writer import ModelDataWriter
|
|
9
|
-
from simtools.io_operations import io_handler
|
|
10
|
-
from simtools.utils import names
|
|
11
|
-
|
|
12
|
-
_logger = logging.getLogger(__name__)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def retrieve_array_layouts(site, repository_url, branch_name="main"):
|
|
16
|
-
"""
|
|
17
|
-
Retrieve array layouts from CTAO common identifiers repository.
|
|
18
|
-
|
|
19
|
-
Parameters
|
|
20
|
-
----------
|
|
21
|
-
site : str
|
|
22
|
-
Site identifier.
|
|
23
|
-
repository_url : str
|
|
24
|
-
URL or path to CTAO common identifiers
|
|
25
|
-
branch_name : str
|
|
26
|
-
Repository branch to use for CTAO common identifiers.
|
|
27
|
-
|
|
28
|
-
Returns
|
|
29
|
-
-------
|
|
30
|
-
dict
|
|
31
|
-
Array layouts for all CTAO sites.
|
|
32
|
-
"""
|
|
33
|
-
_logger.info(f"Retrieving array layouts from {repository_url} on branch {branch_name}.")
|
|
34
|
-
|
|
35
|
-
if gen.is_url(repository_url):
|
|
36
|
-
array_element_ids = gen.collect_data_from_http(
|
|
37
|
-
url=f"{repository_url}/{branch_name}/array-element-ids.json"
|
|
38
|
-
)
|
|
39
|
-
sub_arrays = gen.collect_data_from_http(
|
|
40
|
-
url=f"{repository_url}/{branch_name}/subarray-ids.json"
|
|
41
|
-
)
|
|
42
|
-
else:
|
|
43
|
-
array_element_ids = gen.collect_data_from_file(
|
|
44
|
-
Path(repository_url) / "array-element-ids.json"
|
|
45
|
-
)
|
|
46
|
-
sub_arrays = gen.collect_data_from_file(Path(repository_url) / "subarray-ids.json")
|
|
47
|
-
|
|
48
|
-
return _get_layouts_per_site(site, sub_arrays, array_element_ids)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
def _get_layouts_per_site(site, sub_arrays, array_element_ids):
|
|
52
|
-
"""
|
|
53
|
-
Get array layouts for CTAO sites.
|
|
54
|
-
|
|
55
|
-
Parameters
|
|
56
|
-
----------
|
|
57
|
-
site : str
|
|
58
|
-
Site identifier.
|
|
59
|
-
sub_arrays : dict
|
|
60
|
-
Sub-array definitions.
|
|
61
|
-
array_element_ids : dict
|
|
62
|
-
Array element definitions.
|
|
63
|
-
|
|
64
|
-
Returns
|
|
65
|
-
-------
|
|
66
|
-
dict
|
|
67
|
-
Array layouts for CTAO sites.
|
|
68
|
-
"""
|
|
69
|
-
layouts_per_site = []
|
|
70
|
-
|
|
71
|
-
for array in sub_arrays.get("subarrays", []):
|
|
72
|
-
elements = []
|
|
73
|
-
for ids in array.get("array_element_ids", []):
|
|
74
|
-
element_name = _get_array_element_name(ids, array_element_ids)
|
|
75
|
-
if names.get_site_from_array_element_name(element_name) != site:
|
|
76
|
-
break
|
|
77
|
-
elements.append(element_name)
|
|
78
|
-
if len(elements) > 0:
|
|
79
|
-
array_layout = {
|
|
80
|
-
"name": array.get("name"),
|
|
81
|
-
"elements": elements,
|
|
82
|
-
}
|
|
83
|
-
layouts_per_site.append(array_layout)
|
|
84
|
-
|
|
85
|
-
_logger.info(f"CTAO array layout definition: {layouts_per_site}")
|
|
86
|
-
return layouts_per_site
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
def _get_array_element_name(ids, array_element_ids):
|
|
90
|
-
"""Return array element name for common identifier."""
|
|
91
|
-
for element in array_element_ids.get("array_elements", []):
|
|
92
|
-
if element.get("id") == ids:
|
|
93
|
-
return element.get("name")
|
|
94
|
-
return None
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
def merge_array_layouts(layouts_1, layouts_2):
|
|
98
|
-
"""
|
|
99
|
-
Compare array layout dictionaries and merge them.
|
|
100
|
-
|
|
101
|
-
Parameters
|
|
102
|
-
----------
|
|
103
|
-
layouts_1 : dict
|
|
104
|
-
Array layout dictionary 1.
|
|
105
|
-
layouts_2 : dict
|
|
106
|
-
Array layout dictionary 2.
|
|
107
|
-
|
|
108
|
-
Returns
|
|
109
|
-
-------
|
|
110
|
-
dict
|
|
111
|
-
Merged array layout dictionary based on layout_1.
|
|
112
|
-
"""
|
|
113
|
-
merged_layout = layouts_1
|
|
114
|
-
for layout_2 in layouts_2:
|
|
115
|
-
layout_found = False
|
|
116
|
-
for layout_1 in layouts_1.get("value", {}):
|
|
117
|
-
if sorted(layout_1["elements"]) == sorted(layout_2["elements"]):
|
|
118
|
-
print(
|
|
119
|
-
f"Equal telescope list: simtools '{layout_1['name']}' "
|
|
120
|
-
f"and CTAO '{layout_2['name']}'"
|
|
121
|
-
)
|
|
122
|
-
layout_1["name"] = layout_2["name"]
|
|
123
|
-
layout_found = True
|
|
124
|
-
if not layout_found:
|
|
125
|
-
merged_layout["value"].append(
|
|
126
|
-
{
|
|
127
|
-
"name": layout_2["name"],
|
|
128
|
-
"elements": layout_2["elements"],
|
|
129
|
-
}
|
|
130
|
-
)
|
|
131
|
-
_logger.info(f"Adding {layout_2['name']} with {layout_2['elements']}")
|
|
132
|
-
return merged_layout
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
def write_array_layouts(array_layouts, args_dict, db_config):
|
|
136
|
-
"""
|
|
137
|
-
Write array layouts as model parameter.
|
|
138
|
-
|
|
139
|
-
Parameters
|
|
140
|
-
----------
|
|
141
|
-
args_dict : dict
|
|
142
|
-
Command line arguments.
|
|
143
|
-
array_layouts : dict
|
|
144
|
-
Array layouts to be written.
|
|
145
|
-
db_config : dict
|
|
146
|
-
Database configuration.
|
|
147
|
-
"""
|
|
148
|
-
_logger.info(f"Writing updated array layouts to the database for site {args_dict['site']}.")
|
|
149
|
-
|
|
150
|
-
io_handler_instance = io_handler.IOHandler()
|
|
151
|
-
io_handler_instance.set_paths(
|
|
152
|
-
output_path=args_dict["output_path"],
|
|
153
|
-
use_plain_output_path=args_dict["use_plain_output_path"],
|
|
154
|
-
)
|
|
155
|
-
output_file = io_handler_instance.get_output_file(
|
|
156
|
-
f"array-layouts-{args_dict['updated_parameter_version']}.json"
|
|
157
|
-
)
|
|
158
|
-
|
|
159
|
-
ModelDataWriter.dump_model_parameter(
|
|
160
|
-
parameter_name="array_layouts",
|
|
161
|
-
value=array_layouts["value"],
|
|
162
|
-
instrument=args_dict["site"],
|
|
163
|
-
parameter_version=args_dict.get("updated_parameter_version"),
|
|
164
|
-
output_file=output_file,
|
|
165
|
-
use_plain_output_path=args_dict["use_plain_output_path"],
|
|
166
|
-
db_config=db_config,
|
|
167
|
-
)
|
|
168
|
-
MetadataCollector.dump(
|
|
169
|
-
args_dict,
|
|
170
|
-
output_file,
|
|
171
|
-
add_activity_name=True,
|
|
172
|
-
)
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Calculate the scaled number of events based on metrics.
|
|
3
|
-
|
|
4
|
-
Module for scaling events based on statistical error metrics. Contains the `EventScaler` class,
|
|
5
|
-
which scales the number of events for both the entire dataset and specific grid points.
|
|
6
|
-
Scaling factors are calculated using error metrics and the evaluator's results.
|
|
7
|
-
"""
|
|
8
|
-
|
|
9
|
-
import astropy.units as u
|
|
10
|
-
import numpy as np
|
|
11
|
-
|
|
12
|
-
__all__ = ["EventScaler"]
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class EventScaler:
|
|
16
|
-
"""
|
|
17
|
-
Scales the number of events based on statistical error metrics.
|
|
18
|
-
|
|
19
|
-
Supports scaling both the entire dataset and specific grid points like energy values.
|
|
20
|
-
"""
|
|
21
|
-
|
|
22
|
-
def __init__(self, evaluator, metrics: dict):
|
|
23
|
-
"""
|
|
24
|
-
Initialize the EventScaler with the evaluator and metrics.
|
|
25
|
-
|
|
26
|
-
Parameters
|
|
27
|
-
----------
|
|
28
|
-
evaluator : StatisticalErrorEvaluator
|
|
29
|
-
The evaluator responsible for calculating metrics and handling event data.
|
|
30
|
-
metrics : dict
|
|
31
|
-
Dictionary containing metrics, including target error for effective area.
|
|
32
|
-
"""
|
|
33
|
-
self.evaluator = evaluator
|
|
34
|
-
self.metrics = metrics
|
|
35
|
-
|
|
36
|
-
def scale_events(self, return_sum: bool = True) -> u.Quantity:
|
|
37
|
-
"""
|
|
38
|
-
Calculate the scaled number of events based on statistical error metrics.
|
|
39
|
-
|
|
40
|
-
Parameters
|
|
41
|
-
----------
|
|
42
|
-
return_sum : bool, optional
|
|
43
|
-
If True, returns the sum of scaled events for the entire set of MC events. If False,
|
|
44
|
-
returns the scaled events for each grid point along the energy axis. Default is True.
|
|
45
|
-
|
|
46
|
-
Returns
|
|
47
|
-
-------
|
|
48
|
-
u.Quantity
|
|
49
|
-
If 'return_sum' is True, returns the total scaled number of events as a u.Quantity.
|
|
50
|
-
If 'return_sum' is False, returns an array of scaled events along the energy axis as
|
|
51
|
-
a u.Quantity.
|
|
52
|
-
"""
|
|
53
|
-
scaling_factor = self._compute_scaling_factor()
|
|
54
|
-
|
|
55
|
-
base_events = self._number_of_simulated_events()
|
|
56
|
-
|
|
57
|
-
if return_sum:
|
|
58
|
-
return np.sum(base_events * scaling_factor)
|
|
59
|
-
return base_events * scaling_factor
|
|
60
|
-
|
|
61
|
-
def _compute_scaling_factor(self) -> float:
|
|
62
|
-
"""
|
|
63
|
-
Compute the scaling factor based on the error metrics.
|
|
64
|
-
|
|
65
|
-
Returns
|
|
66
|
-
-------
|
|
67
|
-
float
|
|
68
|
-
The scaling factor.
|
|
69
|
-
"""
|
|
70
|
-
metric_results = self.evaluator.calculate_metrics()
|
|
71
|
-
uncertainty_effective_area = metric_results.get("uncertainty_effective_area")
|
|
72
|
-
current_max_error = uncertainty_effective_area.get("max_error")
|
|
73
|
-
target_max_error = self.metrics.get("uncertainty_effective_area").get("target_error")[
|
|
74
|
-
"value"
|
|
75
|
-
]
|
|
76
|
-
|
|
77
|
-
return (current_max_error / target_max_error) ** 2
|
|
78
|
-
|
|
79
|
-
def _number_of_simulated_events(self) -> u.Quantity:
|
|
80
|
-
"""
|
|
81
|
-
Fetch the number of simulated events from the evaluator's data.
|
|
82
|
-
|
|
83
|
-
Returns
|
|
84
|
-
-------
|
|
85
|
-
u.Quantity
|
|
86
|
-
The number of simulated events.
|
|
87
|
-
"""
|
|
88
|
-
return self.evaluator.data.get("simulated_event_histogram")
|
|
89
|
-
|
|
90
|
-
def calculate_scaled_events_at_grid_point(
|
|
91
|
-
self,
|
|
92
|
-
grid_point: tuple,
|
|
93
|
-
) -> u.Quantity:
|
|
94
|
-
"""
|
|
95
|
-
Calculate the scaled number of events for a specific energy grid point.
|
|
96
|
-
|
|
97
|
-
Parameters
|
|
98
|
-
----------
|
|
99
|
-
grid_point : tuple
|
|
100
|
-
The grid point specifying energy, azimuth, zenith, NSB, and offset.
|
|
101
|
-
|
|
102
|
-
Returns
|
|
103
|
-
-------
|
|
104
|
-
float
|
|
105
|
-
The scaled number of events at the specified grid point (energy).
|
|
106
|
-
"""
|
|
107
|
-
energy = grid_point[0]
|
|
108
|
-
bin_edges = self.evaluator.create_bin_edges()
|
|
109
|
-
bin_idx = np.digitize(energy, bin_edges) - 1
|
|
110
|
-
|
|
111
|
-
scaling_factor = self._compute_scaling_factor()
|
|
112
|
-
|
|
113
|
-
simulated_event_histogram = self.evaluator.data.get("simulated_event_histogram", [])
|
|
114
|
-
|
|
115
|
-
if bin_idx < 0 or bin_idx >= len(simulated_event_histogram):
|
|
116
|
-
raise ValueError(f"Energy {energy} is outside the range of the simulated events data.")
|
|
117
|
-
|
|
118
|
-
base_events = self._number_of_simulated_events()
|
|
119
|
-
base_event_at_energy = base_events[bin_idx]
|
|
120
|
-
return base_event_at_energy * scaling_factor
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
"""Derives simulation configuration parameters for a grid point based on several metrics."""
|
|
2
|
-
|
|
3
|
-
from simtools.production_configuration.calculate_statistical_errors_grid_point import (
|
|
4
|
-
StatisticalErrorEvaluator,
|
|
5
|
-
)
|
|
6
|
-
from simtools.production_configuration.event_scaler import EventScaler
|
|
7
|
-
|
|
8
|
-
__all__ = ["SimulationConfig"]
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class SimulationConfig:
|
|
12
|
-
"""
|
|
13
|
-
Configures simulation parameters for a specific grid point.
|
|
14
|
-
|
|
15
|
-
Parameters
|
|
16
|
-
----------
|
|
17
|
-
grid_point : dict
|
|
18
|
-
Dictionary representing a grid point with azimuth, elevation, and night sky background.
|
|
19
|
-
file_path : str
|
|
20
|
-
Path to the DL2 MC event file for statistical uncertainty evaluation.
|
|
21
|
-
file_type : str
|
|
22
|
-
Type of the DL2 MC event file ('point-like' or 'cone').
|
|
23
|
-
metrics : dict, optional
|
|
24
|
-
Dictionary of metrics to evaluate.
|
|
25
|
-
"""
|
|
26
|
-
|
|
27
|
-
def __init__(
|
|
28
|
-
self,
|
|
29
|
-
grid_point: dict[str, float],
|
|
30
|
-
file_path: str,
|
|
31
|
-
file_type: str,
|
|
32
|
-
metrics: dict[str, float] | None = None,
|
|
33
|
-
):
|
|
34
|
-
"""Initialize the simulation configuration for a grid point."""
|
|
35
|
-
self.grid_point = grid_point
|
|
36
|
-
self.file_path = file_path
|
|
37
|
-
self.file_type = file_type
|
|
38
|
-
self.metrics = metrics or {}
|
|
39
|
-
self.evaluator = StatisticalErrorEvaluator(file_path, file_type, metrics)
|
|
40
|
-
self.event_scaler = EventScaler(self.evaluator, self.metrics)
|
|
41
|
-
self.simulation_params = {}
|
|
42
|
-
|
|
43
|
-
def configure_simulation(self) -> dict[str, float]:
|
|
44
|
-
"""
|
|
45
|
-
Configure the simulation parameters for the grid point.
|
|
46
|
-
|
|
47
|
-
Returns
|
|
48
|
-
-------
|
|
49
|
-
dict
|
|
50
|
-
A dictionary with simulation parameters such as core scatter area,
|
|
51
|
-
viewcone, and number of simulated events.
|
|
52
|
-
"""
|
|
53
|
-
self.simulation_params = {
|
|
54
|
-
"core_scatter_area": self._calculate_core_scatter_area(),
|
|
55
|
-
"viewcone": self._calculate_viewcone(),
|
|
56
|
-
"number_of_events": self.calculate_required_events(),
|
|
57
|
-
}
|
|
58
|
-
return self.simulation_params
|
|
59
|
-
|
|
60
|
-
def calculate_required_events(self) -> int:
|
|
61
|
-
"""
|
|
62
|
-
Calculate the required number of simulated events based on statistical error metrics.
|
|
63
|
-
|
|
64
|
-
Uses the EventScaler to scale the events.
|
|
65
|
-
|
|
66
|
-
Returns
|
|
67
|
-
-------
|
|
68
|
-
int
|
|
69
|
-
The number of simulated events required.
|
|
70
|
-
"""
|
|
71
|
-
return self.event_scaler.scale_events()
|
|
72
|
-
|
|
73
|
-
def _calculate_core_scatter_area(self) -> float:
|
|
74
|
-
"""
|
|
75
|
-
Calculate the core scatter area based on the grid point.
|
|
76
|
-
|
|
77
|
-
Returns
|
|
78
|
-
-------
|
|
79
|
-
float
|
|
80
|
-
The core scatter area.
|
|
81
|
-
"""
|
|
82
|
-
base_area = self._fetch_simulated_core_scatter_area()
|
|
83
|
-
area_factor = self._get_area_factor_from_grid_point()
|
|
84
|
-
return base_area * area_factor
|
|
85
|
-
|
|
86
|
-
def _calculate_viewcone(self) -> float:
|
|
87
|
-
"""
|
|
88
|
-
Calculate the viewcone based on the grid point conditions.
|
|
89
|
-
|
|
90
|
-
Returns
|
|
91
|
-
-------
|
|
92
|
-
float
|
|
93
|
-
The viewcone value.
|
|
94
|
-
"""
|
|
95
|
-
base_viewcone = self._fetch_simulated_viewcone()
|
|
96
|
-
viewcone_factor = self._get_viewcone_factor_from_grid_point()
|
|
97
|
-
|
|
98
|
-
return base_viewcone * viewcone_factor
|
|
99
|
-
|
|
100
|
-
def _get_area_factor_from_grid_point(self) -> float:
|
|
101
|
-
"""
|
|
102
|
-
Determine the area factor.
|
|
103
|
-
|
|
104
|
-
The area factor is based on the grid point's azimuth,
|
|
105
|
-
elevation, and night sky background.
|
|
106
|
-
|
|
107
|
-
Returns
|
|
108
|
-
-------
|
|
109
|
-
float
|
|
110
|
-
The area factor.
|
|
111
|
-
"""
|
|
112
|
-
azimuth = self.grid_point.get("azimuth", 0)
|
|
113
|
-
elevation = self.grid_point.get("elevation", 0)
|
|
114
|
-
night_sky_background = self.grid_point.get("night_sky_background", 0)
|
|
115
|
-
|
|
116
|
-
# Implement reading of factor from LUT
|
|
117
|
-
return azimuth + elevation + night_sky_background
|
|
118
|
-
|
|
119
|
-
def _get_viewcone_factor_from_grid_point(self) -> float:
|
|
120
|
-
"""
|
|
121
|
-
Determine the viewcone factor.
|
|
122
|
-
|
|
123
|
-
The factor is based on the grid point's azimuth,
|
|
124
|
-
elevation, and night sky background.
|
|
125
|
-
|
|
126
|
-
Returns
|
|
127
|
-
-------
|
|
128
|
-
float
|
|
129
|
-
The viewcone factor.
|
|
130
|
-
"""
|
|
131
|
-
azimuth = self.grid_point.get("azimuth", 0)
|
|
132
|
-
elevation = self.grid_point.get("elevation", 0)
|
|
133
|
-
night_sky_background = self.grid_point.get("night_sky_background", 0)
|
|
134
|
-
|
|
135
|
-
# Implement reading of factor from LUT
|
|
136
|
-
return azimuth + elevation + night_sky_background
|
|
137
|
-
|
|
138
|
-
def _fetch_simulated_core_scatter_area(self) -> float:
|
|
139
|
-
"""
|
|
140
|
-
Fetch the core scatter area from existing simulated files based on grid point conditions.
|
|
141
|
-
|
|
142
|
-
Returns
|
|
143
|
-
-------
|
|
144
|
-
float
|
|
145
|
-
The fetched core scatter outer bound.
|
|
146
|
-
"""
|
|
147
|
-
return self.evaluator.data["core_range"]
|
|
148
|
-
|
|
149
|
-
def _fetch_simulated_viewcone(self) -> float:
|
|
150
|
-
"""
|
|
151
|
-
Fetch the viewcone from existing simulated files based on grid point conditions.
|
|
152
|
-
|
|
153
|
-
Returns
|
|
154
|
-
-------
|
|
155
|
-
float
|
|
156
|
-
The fetched viewcone outer bound.
|
|
157
|
-
"""
|
|
158
|
-
return self.evaluator.data["viewcone"]
|
|
File without changes
|
|
File without changes
|