gammasimtools 0.22.0__py3-none-any.whl → 0.23.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.22.0.dist-info → gammasimtools-0.23.0.dist-info}/METADATA +2 -1
- {gammasimtools-0.22.0.dist-info → gammasimtools-0.23.0.dist-info}/RECORD +114 -112
- simtools/_version.py +2 -2
- simtools/application_control.py +118 -0
- simtools/applications/calculate_incident_angles.py +17 -22
- simtools/applications/convert_all_model_parameters_from_simtel.py +28 -43
- simtools/applications/convert_geo_coordinates_of_array_elements.py +26 -45
- simtools/applications/convert_model_parameter_from_simtel.py +21 -41
- simtools/applications/db_add_file_to_db.py +12 -13
- simtools/applications/db_add_simulation_model_from_repository_to_db.py +20 -33
- simtools/applications/db_add_value_from_json_to_db.py +28 -23
- simtools/applications/db_development_tools/write_array_elements_positions_to_repository.py +19 -34
- simtools/applications/db_generate_compound_indexes.py +11 -13
- simtools/applications/db_get_array_layouts_from_db.py +19 -39
- simtools/applications/db_get_file_from_db.py +15 -17
- simtools/applications/db_get_parameter_from_db.py +33 -35
- simtools/applications/db_inspect_databases.py +10 -11
- simtools/applications/db_upload_model_repository.py +13 -31
- simtools/applications/derive_ctao_array_layouts.py +16 -21
- simtools/applications/derive_mirror_rnda.py +9 -14
- simtools/applications/derive_photon_electron_spectrum.py +7 -10
- simtools/applications/derive_psf_parameters.py +13 -20
- simtools/applications/derive_trigger_rates.py +6 -9
- simtools/applications/docs_produce_array_element_report.py +22 -23
- simtools/applications/docs_produce_calibration_reports.py +26 -24
- simtools/applications/docs_produce_model_parameter_reports.py +15 -22
- simtools/applications/docs_produce_simulation_configuration_report.py +21 -22
- simtools/applications/generate_array_config.py +14 -33
- simtools/applications/generate_corsika_histograms.py +22 -43
- simtools/applications/generate_default_metadata.py +15 -36
- simtools/applications/generate_regular_arrays.py +11 -15
- simtools/applications/generate_simtel_event_data.py +23 -33
- simtools/applications/maintain_simulation_model_add_production.py +12 -19
- simtools/applications/maintain_simulation_model_compare_productions.py +10 -12
- simtools/applications/maintain_simulation_model_verify_production_tables.py +8 -11
- simtools/applications/merge_tables.py +14 -23
- simtools/applications/plot_array_layout.py +77 -54
- simtools/applications/plot_simtel_events.py +11 -13
- simtools/applications/plot_tabular_data.py +17 -38
- simtools/applications/plot_tabular_data_for_model_parameter.py +16 -23
- simtools/applications/print_version.py +14 -42
- simtools/applications/production_derive_corsika_limits.py +5 -9
- simtools/applications/production_derive_statistics.py +12 -25
- simtools/applications/production_generate_grid.py +20 -48
- simtools/applications/production_merge_corsika_limits.py +17 -21
- simtools/applications/run_application.py +12 -32
- simtools/applications/simulate_flasher.py +21 -25
- simtools/applications/simulate_illuminator.py +7 -14
- simtools/applications/simulate_pedestals.py +13 -13
- simtools/applications/simulate_prod.py +21 -33
- simtools/applications/simulate_prod_htcondor_generator.py +11 -25
- simtools/applications/submit_array_layouts.py +15 -18
- simtools/applications/submit_data_from_external.py +18 -34
- simtools/applications/submit_model_parameter_from_external.py +27 -40
- simtools/applications/validate_camera_efficiency.py +23 -21
- simtools/applications/validate_camera_fov.py +21 -26
- simtools/applications/validate_cumulative_psf.py +27 -35
- simtools/applications/validate_file_using_schema.py +15 -33
- simtools/applications/validate_optics.py +26 -32
- simtools/camera/camera_efficiency.py +0 -2
- simtools/configuration/commandline_parser.py +32 -4
- simtools/configuration/configurator.py +0 -5
- simtools/corsika/corsika_config.py +0 -5
- simtools/data_model/data_reader.py +0 -2
- simtools/data_model/metadata_collector.py +0 -2
- simtools/data_model/model_data_writer.py +0 -2
- simtools/data_model/validate_data.py +0 -2
- simtools/db/db_handler.py +0 -2
- simtools/io/hdf5_handler.py +0 -5
- simtools/io/legacy_data_handler.py +0 -5
- simtools/job_execution/job_manager.py +0 -3
- simtools/layout/array_layout.py +0 -2
- simtools/layout/telescope_position.py +0 -2
- simtools/model/array_model.py +2 -4
- simtools/model/calibration_model.py +0 -2
- simtools/model/camera.py +0 -2
- simtools/model/mirrors.py +0 -2
- simtools/model/model_parameter.py +30 -7
- simtools/model/model_utils.py +0 -5
- simtools/model/site_model.py +0 -2
- simtools/model/telescope_model.py +0 -2
- simtools/production_configuration/calculate_statistical_uncertainties_grid_point.py +0 -2
- simtools/production_configuration/derive_production_statistics.py +0 -2
- simtools/production_configuration/interpolation_handler.py +0 -2
- simtools/ray_tracing/psf_analysis.py +0 -2
- simtools/ray_tracing/ray_tracing.py +0 -2
- simtools/reporting/docs_auto_report_generator.py +108 -0
- simtools/reporting/docs_read_parameters.py +1 -7
- simtools/runners/corsika_runner.py +0 -2
- simtools/runners/corsika_simtel_runner.py +0 -2
- simtools/runners/simtel_runner.py +0 -2
- simtools/schemas/model_parameters/transit_time_random.schema.yml +29 -0
- simtools/simtel/simtel_config_reader.py +0 -2
- simtools/simtel/simtel_config_writer.py +31 -13
- simtools/simtel/simtel_io_metadata.py +3 -3
- simtools/simtel/simulator_array.py +9 -21
- simtools/simtel/simulator_camera_efficiency.py +0 -2
- simtools/simtel/simulator_light_emission.py +1 -3
- simtools/simtel/simulator_ray_tracing.py +0 -2
- simtools/simulator.py +0 -5
- simtools/testing/assertions.py +2 -2
- simtools/testing/configuration.py +17 -4
- simtools/utils/general.py +5 -13
- simtools/utils/geometry.py +0 -5
- simtools/utils/names.py +1 -13
- simtools/version.py +61 -0
- simtools/visualization/plot_array_layout.py +129 -23
- simtools/visualization/plot_incident_angles.py +0 -2
- simtools/visualization/plot_simtel_events.py +0 -11
- simtools/visualization/visualize.py +0 -12
- {gammasimtools-0.22.0.dist-info → gammasimtools-0.23.0.dist-info}/WHEEL +0 -0
- {gammasimtools-0.22.0.dist-info → gammasimtools-0.23.0.dist-info}/entry_points.txt +0 -0
- {gammasimtools-0.22.0.dist-info → gammasimtools-0.23.0.dist-info}/licenses/LICENSE +0 -0
- {gammasimtools-0.22.0.dist-info → gammasimtools-0.23.0.dist-info}/top_level.txt +0 -0
|
@@ -47,19 +47,16 @@ r"""
|
|
|
47
47
|
|
|
48
48
|
"""
|
|
49
49
|
|
|
50
|
-
import
|
|
51
|
-
from pathlib import Path
|
|
52
|
-
|
|
53
|
-
import simtools.utils.general as gen
|
|
50
|
+
from simtools.application_control import get_application_label, startup_application
|
|
54
51
|
from simtools.configuration import configurator
|
|
55
|
-
from simtools.io import io_handler
|
|
56
52
|
from simtools.model.telescope_model import TelescopeModel
|
|
57
53
|
from simtools.visualization import plot_camera, visualize
|
|
58
54
|
|
|
59
55
|
|
|
60
56
|
def _parse():
|
|
57
|
+
"""Parse command line configuration."""
|
|
61
58
|
config = configurator.Configurator(
|
|
62
|
-
label=
|
|
59
|
+
label=get_application_label(__file__),
|
|
63
60
|
description=(
|
|
64
61
|
"Calculate the camera FoV of the telescope requested. "
|
|
65
62
|
"Plot the camera, as seen for an observer facing the camera."
|
|
@@ -86,51 +83,49 @@ def _parse():
|
|
|
86
83
|
return config.initialize(db_config=True, simulation_model=["telescope", "model_version"])
|
|
87
84
|
|
|
88
85
|
|
|
89
|
-
def main():
|
|
90
|
-
|
|
86
|
+
def main():
|
|
87
|
+
"""Validate camera field of view."""
|
|
88
|
+
app_context = startup_application(_parse)
|
|
91
89
|
|
|
92
90
|
label = "validate_camera_fov"
|
|
93
91
|
|
|
94
|
-
logger = logging.getLogger()
|
|
95
|
-
logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
|
|
96
|
-
|
|
97
|
-
_io_handler = io_handler.IOHandler()
|
|
98
|
-
output_dir = _io_handler.get_output_directory()
|
|
99
|
-
|
|
100
92
|
tel_model = TelescopeModel(
|
|
101
|
-
site=
|
|
102
|
-
telescope_name=
|
|
103
|
-
mongo_db_config=db_config,
|
|
104
|
-
model_version=
|
|
93
|
+
site=app_context.args["site"],
|
|
94
|
+
telescope_name=app_context.args["telescope"],
|
|
95
|
+
mongo_db_config=app_context.db_config,
|
|
96
|
+
model_version=app_context.args["model_version"],
|
|
105
97
|
label=label,
|
|
106
98
|
)
|
|
107
99
|
tel_model.export_model_files()
|
|
108
100
|
|
|
109
|
-
|
|
101
|
+
app_context.logger.info(f"\nValidating the camera FoV of {tel_model.name}\n")
|
|
110
102
|
|
|
111
103
|
focal_length = tel_model.get_telescope_effective_focal_length("cm")
|
|
112
104
|
camera = tel_model.camera
|
|
113
105
|
|
|
114
106
|
fov, r_edge_avg = camera.calc_fov()
|
|
115
107
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
108
|
+
app_context.logger.info(f"\nEffective focal length = {focal_length:.3f} cm")
|
|
109
|
+
app_context.logger.info(f"{tel_model.name} FoV = {fov:.3f} deg")
|
|
110
|
+
app_context.logger.info(f"Avg. edge radius = {r_edge_avg:.3f} cm\n")
|
|
119
111
|
|
|
120
112
|
# Now plot the camera as well
|
|
121
113
|
try:
|
|
122
|
-
pixel_ids_to_print = int(
|
|
114
|
+
pixel_ids_to_print = int(app_context.args["print_pixels_id"])
|
|
123
115
|
if pixel_ids_to_print == 0:
|
|
124
116
|
pixel_ids_to_print = -1 # so not print the zero pixel
|
|
125
117
|
except ValueError as exc:
|
|
126
|
-
if
|
|
118
|
+
if app_context.args["print_pixels_id"].lower() == "all":
|
|
127
119
|
pixel_ids_to_print = camera.get_number_of_pixels()
|
|
128
120
|
else:
|
|
129
121
|
raise ValueError(
|
|
130
|
-
f"The value provided to --print_pixels_id ({
|
|
122
|
+
f"The value provided to --print_pixels_id ({app_context.args['print_pixels_id']}) "
|
|
131
123
|
"should be an integer or All"
|
|
132
124
|
) from exc
|
|
133
|
-
fig = plot_camera.plot_pixel_layout(
|
|
125
|
+
fig = plot_camera.plot_pixel_layout(
|
|
126
|
+
camera, app_context.args["camera_in_sky_coor"], pixel_ids_to_print
|
|
127
|
+
)
|
|
128
|
+
output_dir = app_context.io_handler.get_output_directory()
|
|
134
129
|
plot_file_prefix = output_dir.joinpath(f"{label}_{tel_model.name}_pixel_layout")
|
|
135
130
|
visualize.save_figure(fig, f"{plot_file_prefix!s}", log_title="camera")
|
|
136
131
|
|
|
@@ -69,25 +69,24 @@
|
|
|
69
69
|
|
|
70
70
|
"""
|
|
71
71
|
|
|
72
|
-
import logging
|
|
73
72
|
from collections import OrderedDict
|
|
74
|
-
from pathlib import Path
|
|
75
73
|
|
|
76
74
|
import astropy.units as u
|
|
77
75
|
import matplotlib.pyplot as plt
|
|
78
76
|
import numpy as np
|
|
79
77
|
|
|
80
78
|
import simtools.utils.general as gen
|
|
79
|
+
from simtools.application_control import get_application_label, startup_application
|
|
81
80
|
from simtools.configuration import configurator
|
|
82
|
-
from simtools.io import io_handler
|
|
83
81
|
from simtools.model.model_utils import initialize_simulation_models
|
|
84
82
|
from simtools.ray_tracing.ray_tracing import RayTracing
|
|
85
83
|
from simtools.visualization import visualize
|
|
86
84
|
|
|
87
85
|
|
|
88
|
-
def _parse(
|
|
86
|
+
def _parse():
|
|
87
|
+
"""Parse command line configuration."""
|
|
89
88
|
config = configurator.Configurator(
|
|
90
|
-
label=
|
|
89
|
+
label=get_application_label(__file__),
|
|
91
90
|
description=(
|
|
92
91
|
"Calculate and plot the PSF and eff. mirror area as a function of off-axis angle "
|
|
93
92
|
"of the telescope requested."
|
|
@@ -125,54 +124,47 @@ def load_data(datafile):
|
|
|
125
124
|
return data
|
|
126
125
|
|
|
127
126
|
|
|
128
|
-
def main():
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
logger = logging.getLogger()
|
|
133
|
-
logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
|
|
134
|
-
|
|
135
|
-
_io_handler = io_handler.IOHandler()
|
|
136
|
-
output_dir = _io_handler.get_output_directory()
|
|
127
|
+
def main():
|
|
128
|
+
"""Validate the cumulative PSF of a telescope model against data."""
|
|
129
|
+
app_context = startup_application(_parse)
|
|
137
130
|
|
|
138
131
|
tel_model, site_model, _ = initialize_simulation_models(
|
|
139
|
-
label=label,
|
|
140
|
-
db_config=db_config,
|
|
141
|
-
site=
|
|
142
|
-
telescope_name=
|
|
143
|
-
model_version=
|
|
132
|
+
label=app_context.args.get("label"),
|
|
133
|
+
db_config=app_context.db_config,
|
|
134
|
+
site=app_context.args["site"],
|
|
135
|
+
telescope_name=app_context.args["telescope"],
|
|
136
|
+
model_version=app_context.args["model_version"],
|
|
144
137
|
)
|
|
145
138
|
|
|
146
|
-
if
|
|
147
|
-
tel_model.change_multiple_parameters_from_file(
|
|
139
|
+
if app_context.args.get("telescope_model_file"):
|
|
140
|
+
tel_model.change_multiple_parameters_from_file(app_context.args["telescope_model_file"])
|
|
148
141
|
|
|
149
142
|
ray = RayTracing(
|
|
150
143
|
telescope_model=tel_model,
|
|
151
144
|
site_model=site_model,
|
|
152
|
-
simtel_path=
|
|
153
|
-
zenith_angle=
|
|
154
|
-
source_distance=
|
|
145
|
+
simtel_path=app_context.args["simtel_path"],
|
|
146
|
+
zenith_angle=app_context.args["zenith"] * u.deg,
|
|
147
|
+
source_distance=app_context.args["src_distance"] * u.km,
|
|
155
148
|
off_axis_angle=[0.0] * u.deg,
|
|
156
149
|
)
|
|
157
150
|
|
|
158
|
-
ray.simulate(test=
|
|
151
|
+
ray.simulate(test=app_context.args["test"], force=False)
|
|
159
152
|
ray.analyze(force=False)
|
|
160
153
|
|
|
161
154
|
# Plotting cumulative PSF
|
|
162
155
|
im = ray.images()[0]
|
|
163
156
|
|
|
164
|
-
|
|
157
|
+
app_context.logger.info(f"d80 in cm = {im.get_psf()}")
|
|
165
158
|
|
|
166
|
-
# Plotting cumulative PSF
|
|
167
|
-
# Measured cumulative PSF
|
|
159
|
+
# Plotting measured cumulative PSF
|
|
168
160
|
data_to_plot = OrderedDict()
|
|
169
161
|
radius = None
|
|
170
|
-
if
|
|
171
|
-
data_file = gen.find_file(
|
|
162
|
+
if app_context.args.get("data", None):
|
|
163
|
+
data_file = gen.find_file(app_context.args["data"], app_context.args["model_path"])
|
|
172
164
|
data_to_plot["measured"] = load_data(data_file)
|
|
173
165
|
radius = data_to_plot["measured"]["Radius [cm]"]
|
|
174
166
|
|
|
175
|
-
#
|
|
167
|
+
# Plotting simulated cumulative PSF
|
|
176
168
|
if radius is not None:
|
|
177
169
|
data_to_plot[r"sim$\_$telarray"] = im.get_cumulative_data(radius * u.cm)
|
|
178
170
|
else:
|
|
@@ -181,8 +173,8 @@ def main(): # noqa: D103
|
|
|
181
173
|
fig = visualize.plot_1d(data_to_plot)
|
|
182
174
|
fig.gca().set_ylim(0, 1.05)
|
|
183
175
|
|
|
184
|
-
plot_file_name = label + "_" + tel_model.name + "_cumulative_PSF"
|
|
185
|
-
plot_file =
|
|
176
|
+
plot_file_name = app_context.args.get("label") + "_" + tel_model.name + "_cumulative_PSF"
|
|
177
|
+
plot_file = app_context.io_handler.get_output_file(plot_file_name)
|
|
186
178
|
visualize.save_figure(fig, plot_file)
|
|
187
179
|
|
|
188
180
|
# Plotting image
|
|
@@ -192,8 +184,8 @@ def main(): # noqa: D103
|
|
|
192
184
|
fig.gca().add_artist(circle)
|
|
193
185
|
fig.gca().set_aspect("equal")
|
|
194
186
|
|
|
195
|
-
plot_file_name = label + "_" + tel_model.name + "_image"
|
|
196
|
-
plot_file =
|
|
187
|
+
plot_file_name = app_context.args.get("label") + "_" + tel_model.name + "_image"
|
|
188
|
+
plot_file = app_context.io_handler.get_output_file(plot_file_name)
|
|
197
189
|
visualize.save_figure(fig, plot_file)
|
|
198
190
|
|
|
199
191
|
|
|
@@ -32,35 +32,22 @@ r"""
|
|
|
32
32
|
|
|
33
33
|
"""
|
|
34
34
|
|
|
35
|
-
import logging
|
|
36
35
|
import re
|
|
37
36
|
from pathlib import Path
|
|
38
37
|
|
|
39
|
-
|
|
38
|
+
from simtools.application_control import get_application_label, startup_application
|
|
40
39
|
from simtools.configuration import configurator
|
|
41
40
|
from simtools.constants import MODEL_PARAMETER_SCHEMA_PATH
|
|
42
41
|
from simtools.data_model import metadata_collector, schema, validate_data
|
|
43
42
|
from simtools.io import ascii_handler
|
|
44
43
|
|
|
45
44
|
|
|
46
|
-
def _parse(
|
|
47
|
-
"""
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
label (str)
|
|
53
|
-
application label
|
|
54
|
-
description (str)
|
|
55
|
-
application description
|
|
56
|
-
|
|
57
|
-
Returns
|
|
58
|
-
-------
|
|
59
|
-
config (Configurator)
|
|
60
|
-
application configuration
|
|
61
|
-
|
|
62
|
-
"""
|
|
63
|
-
config = configurator.Configurator(label=label, description=description)
|
|
45
|
+
def _parse():
|
|
46
|
+
"""Parse command line configuration."""
|
|
47
|
+
config = configurator.Configurator(
|
|
48
|
+
label=get_application_label(__file__),
|
|
49
|
+
description="Validate a file (metadata, schema, or data file) using a schema.",
|
|
50
|
+
)
|
|
64
51
|
config.parser.add_argument(
|
|
65
52
|
"--file_name",
|
|
66
53
|
help="File to be validated (full path or name pattern, e.g., '*.json')",
|
|
@@ -200,21 +187,16 @@ def validate_metadata(args_dict, logger):
|
|
|
200
187
|
logger.info(f"Successful validation of metadata {args_dict['file_name']}")
|
|
201
188
|
|
|
202
189
|
|
|
203
|
-
def main():
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
label, description="Validate a file (metadata, schema, or data file) using a schema."
|
|
207
|
-
)
|
|
208
|
-
|
|
209
|
-
logger = logging.getLogger()
|
|
210
|
-
logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
|
|
190
|
+
def main():
|
|
191
|
+
"""Validate a file or files in a directory using a schema."""
|
|
192
|
+
app_context = startup_application(_parse)
|
|
211
193
|
|
|
212
|
-
if
|
|
213
|
-
validate_metadata(
|
|
214
|
-
elif
|
|
215
|
-
validate_dict_using_schema(
|
|
194
|
+
if app_context.args["data_type"].lower() == "metadata":
|
|
195
|
+
validate_metadata(app_context.args, app_context.logger)
|
|
196
|
+
elif app_context.args["data_type"].lower() == "schema":
|
|
197
|
+
validate_dict_using_schema(app_context.args, app_context.logger)
|
|
216
198
|
else:
|
|
217
|
-
validate_data_files(
|
|
199
|
+
validate_data_files(app_context.args, app_context.logger)
|
|
218
200
|
|
|
219
201
|
|
|
220
202
|
if __name__ == "__main__":
|
|
@@ -65,7 +65,6 @@ r"""
|
|
|
65
65
|
|
|
66
66
|
"""
|
|
67
67
|
|
|
68
|
-
import logging
|
|
69
68
|
from pathlib import Path
|
|
70
69
|
|
|
71
70
|
import astropy.units as u
|
|
@@ -73,18 +72,17 @@ import matplotlib.pyplot as plt
|
|
|
73
72
|
import numpy as np
|
|
74
73
|
from matplotlib.backends.backend_pdf import PdfPages
|
|
75
74
|
|
|
76
|
-
|
|
75
|
+
from simtools.application_control import get_application_label, startup_application
|
|
77
76
|
from simtools.configuration import configurator
|
|
78
|
-
from simtools.io import io_handler
|
|
79
77
|
from simtools.model.model_utils import initialize_simulation_models
|
|
80
78
|
from simtools.ray_tracing.ray_tracing import RayTracing
|
|
81
79
|
from simtools.visualization import visualize
|
|
82
80
|
|
|
83
81
|
|
|
84
|
-
def _parse(
|
|
82
|
+
def _parse():
|
|
85
83
|
"""Parse command line configuration."""
|
|
86
84
|
config = configurator.Configurator(
|
|
87
|
-
label=
|
|
85
|
+
label=get_application_label(__file__),
|
|
88
86
|
description=(
|
|
89
87
|
"Calculate and plot the PSF and effective mirror area as a function of off-axis angle "
|
|
90
88
|
"of the telescope requested."
|
|
@@ -118,22 +116,16 @@ def _parse(label):
|
|
|
118
116
|
return config.initialize(db_config=True, simulation_model=["telescope", "model_version"])
|
|
119
117
|
|
|
120
118
|
|
|
121
|
-
def main():
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
logger = logging.getLogger()
|
|
126
|
-
logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
|
|
127
|
-
|
|
128
|
-
_io_handler = io_handler.IOHandler()
|
|
129
|
-
output_dir = _io_handler.get_output_directory()
|
|
119
|
+
def main():
|
|
120
|
+
"""Validate the optical model parameters through ray tracing simulations."""
|
|
121
|
+
app_context = startup_application(_parse, setup_io_handler=True)
|
|
130
122
|
|
|
131
123
|
tel_model, site_model, _ = initialize_simulation_models(
|
|
132
|
-
label=
|
|
133
|
-
db_config=db_config,
|
|
134
|
-
site=
|
|
135
|
-
telescope_name=
|
|
136
|
-
model_version=
|
|
124
|
+
label=Path(__file__).stem,
|
|
125
|
+
db_config=app_context.db_config,
|
|
126
|
+
site=app_context.args["site"],
|
|
127
|
+
telescope_name=app_context.args["telescope"],
|
|
128
|
+
model_version=app_context.args["model_version"],
|
|
137
129
|
)
|
|
138
130
|
|
|
139
131
|
######################################################################
|
|
@@ -147,22 +139,24 @@ def main(): # noqa: D103
|
|
|
147
139
|
# }
|
|
148
140
|
# tel_model.change_multiple_parameters(**pars_to_change)
|
|
149
141
|
|
|
150
|
-
|
|
142
|
+
app_context.logger.info(
|
|
143
|
+
f"\nValidating telescope optics with ray tracing simulations for {tel_model.name}\n"
|
|
144
|
+
)
|
|
151
145
|
|
|
152
146
|
ray = RayTracing(
|
|
153
147
|
telescope_model=tel_model,
|
|
154
148
|
site_model=site_model,
|
|
155
|
-
simtel_path=
|
|
156
|
-
zenith_angle=
|
|
157
|
-
source_distance=
|
|
149
|
+
simtel_path=app_context.args["simtel_path"],
|
|
150
|
+
zenith_angle=app_context.args["zenith"] * u.deg,
|
|
151
|
+
source_distance=app_context.args["src_distance"] * u.km,
|
|
158
152
|
off_axis_angle=np.linspace(
|
|
159
153
|
0,
|
|
160
|
-
|
|
161
|
-
int(
|
|
154
|
+
app_context.args["max_offset"],
|
|
155
|
+
int(app_context.args["max_offset"] / app_context.args["offset_steps"]) + 1,
|
|
162
156
|
)
|
|
163
157
|
* u.deg,
|
|
164
158
|
)
|
|
165
|
-
ray.simulate(test=
|
|
159
|
+
ray.simulate(test=app_context.args["test"], force=False)
|
|
166
160
|
ray.analyze(force=True)
|
|
167
161
|
|
|
168
162
|
# Plotting
|
|
@@ -171,17 +165,17 @@ def main(): # noqa: D103
|
|
|
171
165
|
|
|
172
166
|
ray.plot(key, marker="o", linestyle=":", color="k")
|
|
173
167
|
|
|
174
|
-
plot_file_name = "_".join((label, tel_model.name, key))
|
|
175
|
-
plot_file =
|
|
168
|
+
plot_file_name = "_".join((app_context.args.get("label"), tel_model.name, key))
|
|
169
|
+
plot_file = app_context.io_handler.get_output_file(plot_file_name)
|
|
176
170
|
visualize.save_figure(plt, plot_file)
|
|
177
171
|
|
|
178
172
|
# Plotting images
|
|
179
|
-
if
|
|
180
|
-
plot_file_name = "_".join((label, tel_model.name, "images.pdf"))
|
|
181
|
-
plot_file =
|
|
173
|
+
if app_context.args["plot_images"]:
|
|
174
|
+
plot_file_name = "_".join((app_context.args.get("label"), tel_model.name, "images.pdf"))
|
|
175
|
+
plot_file = app_context.io_handler.get_output_file(plot_file_name)
|
|
182
176
|
pdf_pages = PdfPages(plot_file)
|
|
183
177
|
|
|
184
|
-
logger.info(f"Plotting images into {plot_file}")
|
|
178
|
+
app_context.logger.info(f"Plotting images into {plot_file}")
|
|
185
179
|
|
|
186
180
|
for image in ray.images():
|
|
187
181
|
fig = plt.figure(figsize=(8, 6), tight_layout=True)
|
|
@@ -10,10 +10,6 @@ import astropy.units as u
|
|
|
10
10
|
import simtools.version
|
|
11
11
|
from simtools.utils import names
|
|
12
12
|
|
|
13
|
-
__all__ = [
|
|
14
|
-
"CommandLineParser",
|
|
15
|
-
]
|
|
16
|
-
|
|
17
13
|
|
|
18
14
|
class CommandLineParser(argparse.ArgumentParser):
|
|
19
15
|
"""
|
|
@@ -561,6 +557,38 @@ class CommandLineParser(argparse.ArgumentParser):
|
|
|
561
557
|
)
|
|
562
558
|
return job_group
|
|
563
559
|
|
|
560
|
+
@staticmethod
|
|
561
|
+
def scientific_int(value):
|
|
562
|
+
"""
|
|
563
|
+
Convert string (including scientific notation) to integer.
|
|
564
|
+
|
|
565
|
+
Parameters
|
|
566
|
+
----------
|
|
567
|
+
value: str or int or float
|
|
568
|
+
Value to convert to integer. Can be a regular integer,
|
|
569
|
+
float, or string in scientific notation (e.g., '1e7').
|
|
570
|
+
|
|
571
|
+
Returns
|
|
572
|
+
-------
|
|
573
|
+
int
|
|
574
|
+
Converted integer value
|
|
575
|
+
|
|
576
|
+
Raises
|
|
577
|
+
------
|
|
578
|
+
argparse.ArgumentTypeError
|
|
579
|
+
If the value cannot be converted to an integer
|
|
580
|
+
"""
|
|
581
|
+
try:
|
|
582
|
+
f = float(value)
|
|
583
|
+
if not f.is_integer():
|
|
584
|
+
raise ValueError
|
|
585
|
+
return int(f)
|
|
586
|
+
except (ValueError, TypeError) as exc:
|
|
587
|
+
raise argparse.ArgumentTypeError(
|
|
588
|
+
f"Invalid integer value: '{value}'. "
|
|
589
|
+
"Expected an integer or scientific notation like '1e7'."
|
|
590
|
+
) from exc
|
|
591
|
+
|
|
564
592
|
@staticmethod
|
|
565
593
|
def site(value):
|
|
566
594
|
"""
|
|
@@ -14,11 +14,6 @@ from simtools.db.db_handler import jsonschema_db_dict
|
|
|
14
14
|
from simtools.io import ascii_handler, io_handler
|
|
15
15
|
from simtools.utils import general as gen
|
|
16
16
|
|
|
17
|
-
__all__ = [
|
|
18
|
-
"Configurator",
|
|
19
|
-
"InvalidConfigurationParameterError",
|
|
20
|
-
]
|
|
21
|
-
|
|
22
17
|
|
|
23
18
|
class InvalidConfigurationParameterError(Exception):
|
|
24
19
|
"""Exception for Invalid configuration parameter."""
|
|
@@ -10,11 +10,6 @@ from simtools.corsika.primary_particle import PrimaryParticle
|
|
|
10
10
|
from simtools.io import io_handler
|
|
11
11
|
from simtools.model.model_parameter import ModelParameter
|
|
12
12
|
|
|
13
|
-
__all__ = [
|
|
14
|
-
"CorsikaConfig",
|
|
15
|
-
"InvalidCorsikaInputError",
|
|
16
|
-
]
|
|
17
|
-
|
|
18
13
|
|
|
19
14
|
class InvalidCorsikaInputError(Exception):
|
|
20
15
|
"""Exception for invalid corsika input."""
|
|
@@ -10,8 +10,6 @@ from simtools.data_model import validate_data
|
|
|
10
10
|
from simtools.data_model.metadata_collector import MetadataCollector
|
|
11
11
|
from simtools.io import ascii_handler
|
|
12
12
|
|
|
13
|
-
__all__ = ["read_table_from_file", "read_value_from_file"]
|
|
14
|
-
|
|
15
13
|
_logger = logging.getLogger(__name__)
|
|
16
14
|
|
|
17
15
|
|
simtools/db/db_handler.py
CHANGED
|
@@ -19,8 +19,6 @@ from simtools.simtel import simtel_table_reader
|
|
|
19
19
|
from simtools.utils import names, value_conversion
|
|
20
20
|
from simtools.version import resolve_version_to_latest_patch
|
|
21
21
|
|
|
22
|
-
__all__ = ["DatabaseHandler"]
|
|
23
|
-
|
|
24
22
|
logging.getLogger("pymongo").setLevel(logging.WARNING)
|
|
25
23
|
|
|
26
24
|
|
simtools/io/hdf5_handler.py
CHANGED
simtools/layout/array_layout.py
CHANGED
|
@@ -17,8 +17,6 @@ from simtools.model.site_model import SiteModel
|
|
|
17
17
|
from simtools.model.telescope_model import TelescopeModel
|
|
18
18
|
from simtools.utils import names, value_conversion
|
|
19
19
|
|
|
20
|
-
__all__ = ["ArrayLayout", "InvalidTelescopeListFileError"]
|
|
21
|
-
|
|
22
20
|
|
|
23
21
|
class InvalidTelescopeListFileError(Exception):
|
|
24
22
|
"""Exception for invalid telescope list file."""
|
simtools/model/array_model.py
CHANGED
|
@@ -15,8 +15,6 @@ from simtools.model.telescope_model import TelescopeModel
|
|
|
15
15
|
from simtools.simtel.simtel_config_writer import SimtelConfigWriter
|
|
16
16
|
from simtools.utils import general, names
|
|
17
17
|
|
|
18
|
-
__all__ = ["ArrayModel"]
|
|
19
|
-
|
|
20
18
|
|
|
21
19
|
class ArrayModel:
|
|
22
20
|
"""
|
|
@@ -367,8 +365,8 @@ class ArrayModel:
|
|
|
367
365
|
self._logger.warning("No model files found to pack.")
|
|
368
366
|
return None
|
|
369
367
|
|
|
370
|
-
archive_name = self.get_config_directory() / "
|
|
371
|
-
general.pack_tar_file(archive_name, model_files)
|
|
368
|
+
archive_name = self.get_config_directory() / f"model_files_{self.model_version}.tar.gz"
|
|
369
|
+
general.pack_tar_file(archive_name, model_files, sub_dir=f"model/{self.model_version}")
|
|
372
370
|
self._logger.info(f"Packed model files into {archive_name}")
|
|
373
371
|
return archive_name
|
|
374
372
|
|
simtools/model/camera.py
CHANGED
simtools/model/mirrors.py
CHANGED