gammasimtools 0.25.0__py3-none-any.whl → 0.27.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.25.0.dist-info → gammasimtools-0.27.0.dist-info}/METADATA +6 -1
- {gammasimtools-0.25.0.dist-info → gammasimtools-0.27.0.dist-info}/RECORD +135 -130
- {gammasimtools-0.25.0.dist-info → gammasimtools-0.27.0.dist-info}/WHEEL +1 -1
- {gammasimtools-0.25.0.dist-info → gammasimtools-0.27.0.dist-info}/entry_points.txt +3 -2
- {gammasimtools-0.25.0.dist-info → gammasimtools-0.27.0.dist-info}/licenses/LICENSE +1 -1
- simtools/_version.py +2 -2
- simtools/application_control.py +35 -7
- simtools/applications/convert_geo_coordinates_of_array_elements.py +3 -3
- simtools/applications/db_add_file_to_db.py +1 -1
- simtools/applications/db_add_simulation_model_from_repository_to_db.py +1 -1
- simtools/applications/db_add_value_from_json_to_db.py +1 -1
- simtools/applications/db_generate_compound_indexes.py +1 -1
- simtools/applications/db_get_array_layouts_from_db.py +3 -7
- simtools/applications/db_get_file_from_db.py +1 -1
- simtools/applications/db_get_parameter_from_db.py +1 -1
- simtools/applications/db_inspect_databases.py +1 -1
- simtools/applications/db_upload_model_repository.py +1 -1
- simtools/applications/derive_ctao_array_layouts.py +1 -2
- simtools/applications/{calculate_incident_angles.py → derive_incident_angle.py} +16 -18
- simtools/applications/derive_mirror_rnda.py +112 -180
- simtools/applications/derive_psf_parameters.py +0 -1
- simtools/applications/derive_pulse_shape_parameters.py +0 -1
- simtools/applications/derive_trigger_rates.py +1 -1
- simtools/applications/docs_produce_array_element_report.py +2 -8
- simtools/applications/docs_produce_calibration_reports.py +1 -3
- simtools/applications/docs_produce_model_parameter_reports.py +0 -2
- simtools/applications/docs_produce_simulation_configuration_report.py +1 -3
- simtools/applications/generate_array_config.py +0 -1
- simtools/applications/generate_corsika_histograms.py +79 -229
- simtools/applications/generate_regular_arrays.py +76 -69
- simtools/applications/generate_simtel_event_data.py +2 -2
- simtools/applications/maintain_simulation_model_add_production.py +2 -2
- simtools/applications/maintain_simulation_model_write_array_element_positions.py +87 -0
- simtools/applications/plot_array_layout.py +5 -111
- simtools/applications/plot_simulated_event_distributions.py +57 -0
- simtools/applications/plot_tabular_data.py +0 -1
- simtools/applications/plot_tabular_data_for_model_parameter.py +1 -6
- simtools/applications/production_derive_corsika_limits.py +1 -1
- simtools/applications/production_generate_grid.py +0 -1
- simtools/applications/run_application.py +1 -1
- simtools/applications/simulate_flasher.py +3 -15
- simtools/applications/simulate_illuminator.py +2 -11
- simtools/applications/simulate_pedestals.py +1 -5
- simtools/applications/simulate_prod.py +8 -11
- simtools/applications/simulate_prod_htcondor_generator.py +1 -1
- simtools/applications/submit_array_layouts.py +2 -4
- simtools/applications/submit_data_from_external.py +2 -1
- simtools/applications/submit_model_parameter_from_external.py +1 -3
- simtools/applications/validate_camera_efficiency.py +28 -28
- simtools/applications/validate_camera_fov.py +0 -1
- simtools/applications/validate_cumulative_psf.py +1 -5
- simtools/applications/validate_optics.py +2 -14
- simtools/atmosphere.py +83 -0
- simtools/camera/camera_efficiency.py +171 -53
- simtools/camera/single_photon_electron_spectrum.py +8 -7
- simtools/configuration/commandline_parser.py +82 -11
- simtools/configuration/configurator.py +6 -11
- simtools/constants.py +5 -0
- simtools/corsika/corsika_config.py +100 -202
- simtools/corsika/corsika_histograms.py +561 -1708
- simtools/corsika/primary_particle.py +1 -1
- simtools/data_model/metadata_collector.py +5 -2
- simtools/data_model/metadata_model.py +0 -4
- simtools/data_model/model_data_writer.py +59 -64
- simtools/data_model/schema.py +2 -0
- simtools/data_model/validate_data.py +1 -3
- simtools/db/db_handler.py +23 -10
- simtools/db/mongo_db.py +2 -2
- simtools/dependencies.py +81 -38
- simtools/io/ascii_handler.py +55 -5
- simtools/io/io_handler.py +23 -12
- simtools/io/table_handler.py +1 -1
- simtools/job_execution/job_manager.py +154 -79
- simtools/job_execution/process_pool.py +137 -0
- simtools/layout/array_layout.py +4 -13
- simtools/layout/array_layout_utils.py +348 -57
- simtools/model/array_model.py +23 -63
- simtools/model/calibration_model.py +4 -8
- simtools/model/legacy_model_parameter.py +134 -0
- simtools/model/model_parameter.py +147 -86
- simtools/model/model_utils.py +40 -6
- simtools/model/site_model.py +4 -8
- simtools/model/telescope_model.py +10 -16
- simtools/production_configuration/derive_corsika_limits.py +6 -11
- simtools/production_configuration/interpolation_handler.py +16 -16
- simtools/ray_tracing/incident_angles.py +92 -17
- simtools/ray_tracing/mirror_panel_psf.py +338 -222
- simtools/ray_tracing/psf_analysis.py +62 -48
- simtools/ray_tracing/psf_parameter_optimisation.py +3 -3
- simtools/ray_tracing/ray_tracing.py +43 -25
- simtools/reporting/docs_auto_report_generator.py +8 -13
- simtools/reporting/docs_read_parameters.py +2 -8
- simtools/runners/corsika_runner.py +52 -195
- simtools/runners/corsika_simtel_runner.py +77 -108
- simtools/runners/runner_services.py +214 -213
- simtools/runners/simtel_runner.py +27 -160
- simtools/runners/simtools_runner.py +11 -73
- simtools/schemas/application_workflow.metaschema.yml +8 -0
- simtools/settings.py +173 -0
- simtools/{io/eventio_handler.py → sim_events/file_info.py} +3 -3
- simtools/{simtel/simtel_io_event_histograms.py → sim_events/histograms.py} +25 -15
- simtools/{simtel/simtel_io_event_reader.py → sim_events/reader.py} +20 -17
- simtools/{simtel/simtel_io_event_writer.py → sim_events/writer.py} +84 -25
- simtools/simtel/pulse_shapes.py +7 -2
- simtools/simtel/simtel_config_writer.py +79 -91
- simtools/simtel/simtel_seeds.py +184 -0
- simtools/simtel/simtel_table_reader.py +6 -4
- simtools/simtel/simulator_array.py +114 -109
- simtools/simtel/simulator_camera_efficiency.py +68 -46
- simtools/simtel/simulator_light_emission.py +164 -132
- simtools/simtel/simulator_ray_tracing.py +80 -71
- simtools/simulator.py +137 -355
- simtools/telescope_trigger_rates.py +3 -4
- simtools/testing/assertions.py +84 -33
- simtools/testing/configuration.py +1 -2
- simtools/testing/helpers.py +2 -3
- simtools/testing/log_inspector.py +1 -0
- simtools/testing/sim_telarray_metadata.py +14 -12
- simtools/testing/validate_output.py +121 -42
- simtools/utils/general.py +43 -17
- simtools/utils/geometry.py +0 -77
- simtools/utils/names.py +5 -5
- simtools/utils/random.py +36 -0
- simtools/visualization/legend_handlers.py +7 -6
- simtools/visualization/plot_array_layout.py +91 -16
- simtools/visualization/plot_corsika_histograms.py +145 -605
- simtools/visualization/plot_incident_angles.py +48 -1
- simtools/visualization/plot_mirrors.py +1 -4
- simtools/visualization/plot_pixels.py +2 -4
- simtools/visualization/plot_psf.py +160 -19
- simtools/visualization/plot_simtel_event_histograms.py +4 -4
- simtools/visualization/plot_simtel_events.py +6 -11
- simtools/visualization/plot_tables.py +8 -19
- simtools/visualization/visualize.py +22 -2
- simtools/applications/db_development_tools/write_array_elements_positions_to_repository.py +0 -160
- simtools/applications/print_version.py +0 -53
- simtools/io/hdf5_handler.py +0 -139
- {gammasimtools-0.25.0.dist-info → gammasimtools-0.27.0.dist-info}/top_level.txt +0 -0
|
@@ -141,14 +141,10 @@ Plot layout with some telescopes grayed out and others highlighted:
|
|
|
141
141
|
--legend_location "upper right"
|
|
142
142
|
"""
|
|
143
143
|
|
|
144
|
-
import matplotlib as mpl
|
|
145
|
-
import matplotlib.pyplot as plt
|
|
146
|
-
|
|
147
144
|
import simtools.layout.array_layout_utils as layout_utils
|
|
148
145
|
from simtools.application_control import get_application_label, startup_application
|
|
149
146
|
from simtools.configuration import configurator
|
|
150
|
-
from simtools.visualization import
|
|
151
|
-
from simtools.visualization.plot_array_layout import plot_array_layout
|
|
147
|
+
from simtools.visualization.plot_array_layout import plot_array_layouts
|
|
152
148
|
|
|
153
149
|
|
|
154
150
|
def _parse():
|
|
@@ -278,116 +274,14 @@ def _parse():
|
|
|
278
274
|
)
|
|
279
275
|
|
|
280
276
|
|
|
281
|
-
def read_layouts(args_dict, db_config, logger):
|
|
282
|
-
"""
|
|
283
|
-
Read array layouts from the database or parameter file.
|
|
284
|
-
|
|
285
|
-
Parameters
|
|
286
|
-
----------
|
|
287
|
-
args_dict : dict
|
|
288
|
-
Dictionary with command line arguments.
|
|
289
|
-
db_config : dict
|
|
290
|
-
Database configuration.
|
|
291
|
-
logger : logging.app_context.logger
|
|
292
|
-
app_context.logger instance.
|
|
293
|
-
|
|
294
|
-
Returns
|
|
295
|
-
-------
|
|
296
|
-
list
|
|
297
|
-
List of array layouts.
|
|
298
|
-
"""
|
|
299
|
-
if args_dict["array_layout_name"] is not None or args_dict["plot_all_layouts"]:
|
|
300
|
-
logger.info("Plotting array from DB using layout array name(s).")
|
|
301
|
-
layouts = layout_utils.get_array_layouts_from_db(
|
|
302
|
-
args_dict["array_layout_name"],
|
|
303
|
-
args_dict["site"],
|
|
304
|
-
args_dict["model_version"],
|
|
305
|
-
db_config,
|
|
306
|
-
args_dict["coordinate_system"],
|
|
307
|
-
)
|
|
308
|
-
if isinstance(layouts, list):
|
|
309
|
-
return layouts
|
|
310
|
-
return [layouts]
|
|
311
|
-
|
|
312
|
-
if args_dict["array_layout_parameter_file"] is not None:
|
|
313
|
-
logger.info("Plotting array from parameter file(s).")
|
|
314
|
-
return layout_utils.get_array_layouts_from_parameter_file(
|
|
315
|
-
args_dict["array_layout_parameter_file"],
|
|
316
|
-
args_dict["model_version"],
|
|
317
|
-
db_config,
|
|
318
|
-
args_dict["coordinate_system"],
|
|
319
|
-
)
|
|
320
|
-
|
|
321
|
-
if args_dict["array_layout_file"] is not None:
|
|
322
|
-
logger.info("Plotting array from telescope table file(s).")
|
|
323
|
-
return layout_utils.get_array_layouts_from_file(args_dict["array_layout_file"])
|
|
324
|
-
|
|
325
|
-
if args_dict["array_element_list"] is not None:
|
|
326
|
-
logger.info("Plotting array from list of array elements.")
|
|
327
|
-
return layout_utils.get_array_layouts_using_telescope_lists_from_db(
|
|
328
|
-
[args_dict["array_element_list"]],
|
|
329
|
-
args_dict["site"],
|
|
330
|
-
args_dict["model_version"],
|
|
331
|
-
db_config,
|
|
332
|
-
args_dict["coordinate_system"],
|
|
333
|
-
)
|
|
334
|
-
|
|
335
|
-
return []
|
|
336
|
-
|
|
337
|
-
|
|
338
277
|
def main():
|
|
339
278
|
"""Plot array layout application."""
|
|
340
279
|
app_context = startup_application(_parse)
|
|
341
280
|
|
|
342
|
-
layouts = read_layouts(app_context.args
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
app_context.args["array_layout_name_background"],
|
|
347
|
-
app_context.args["site"],
|
|
348
|
-
app_context.args["model_version"],
|
|
349
|
-
app_context.db_config,
|
|
350
|
-
app_context.args["coordinate_system"],
|
|
351
|
-
)["array_elements"]
|
|
352
|
-
else:
|
|
353
|
-
background_layout = None
|
|
354
|
-
|
|
355
|
-
mpl.use("Agg")
|
|
356
|
-
for layout in layouts:
|
|
357
|
-
fig_out = plot_array_layout(
|
|
358
|
-
telescopes=layout["array_elements"],
|
|
359
|
-
show_tel_label=app_context.args["show_labels"],
|
|
360
|
-
axes_range=app_context.args["axes_range"],
|
|
361
|
-
marker_scaling=app_context.args["marker_scaling"],
|
|
362
|
-
background_telescopes=background_layout,
|
|
363
|
-
grayed_out_elements=app_context.args["grayed_out_array_elements"],
|
|
364
|
-
highlighted_elements=app_context.args["highlighted_array_elements"],
|
|
365
|
-
legend_location=app_context.args["legend_location"],
|
|
366
|
-
bounds_mode=app_context.args["bounds"],
|
|
367
|
-
padding=app_context.args["padding"],
|
|
368
|
-
x_lim=tuple(app_context.args["x_lim"]) if app_context.args["x_lim"] else None,
|
|
369
|
-
y_lim=tuple(app_context.args["y_lim"]) if app_context.args["y_lim"] else None,
|
|
370
|
-
)
|
|
371
|
-
site_string = ""
|
|
372
|
-
if layout.get("site") is not None:
|
|
373
|
-
site_string = f"_{layout['site']}"
|
|
374
|
-
elif app_context.args["site"] is not None:
|
|
375
|
-
site_string = f"_{app_context.args['site']}"
|
|
376
|
-
coordinate_system_string = (
|
|
377
|
-
f"_{app_context.args['coordinate_system']}"
|
|
378
|
-
if app_context.args["coordinate_system"] not in layout["name"]
|
|
379
|
-
else ""
|
|
380
|
-
)
|
|
381
|
-
plot_file_name = app_context.args["figure_name"] or (
|
|
382
|
-
f"array_layout_{layout['name']}{site_string}{coordinate_system_string}"
|
|
383
|
-
)
|
|
384
|
-
|
|
385
|
-
visualize.save_figure(
|
|
386
|
-
fig_out,
|
|
387
|
-
app_context.io_handler.get_output_directory() / plot_file_name,
|
|
388
|
-
dpi=400,
|
|
389
|
-
)
|
|
390
|
-
plt.close()
|
|
281
|
+
layouts, background_layout = layout_utils.read_layouts(app_context.args)
|
|
282
|
+
plot_array_layouts(
|
|
283
|
+
app_context.args, app_context.io_handler.get_output_directory(), layouts, background_layout
|
|
284
|
+
)
|
|
391
285
|
|
|
392
286
|
|
|
393
287
|
if __name__ == "__main__":
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/python3
|
|
2
|
+
|
|
3
|
+
r"""
|
|
4
|
+
Plot simulated event distributions for shower and/or triggered event data.
|
|
5
|
+
|
|
6
|
+
Reads reduced event data files and generate histogram plots e.g. for energy or
|
|
7
|
+
core distance distributions.
|
|
8
|
+
|
|
9
|
+
Command line arguments
|
|
10
|
+
----------------------
|
|
11
|
+
input_file (str, required)
|
|
12
|
+
Input file path.
|
|
13
|
+
output_path (str, required)
|
|
14
|
+
Output directory for the generated plots.
|
|
15
|
+
|
|
16
|
+
Examples
|
|
17
|
+
--------
|
|
18
|
+
Generate plots from a given input file:
|
|
19
|
+
|
|
20
|
+
.. code-block:: console
|
|
21
|
+
|
|
22
|
+
simtools-plot-simulated-event-distributions --input_file path/to/simtel_file.hdf5 \
|
|
23
|
+
--output_path simtools_output/
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
from simtools.application_control import get_application_label, startup_application
|
|
29
|
+
from simtools.configuration import configurator
|
|
30
|
+
from simtools.sim_events.histograms import EventDataHistograms
|
|
31
|
+
from simtools.visualization import plot_simtel_event_histograms
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _parse():
|
|
35
|
+
"""Parse command line configuration."""
|
|
36
|
+
config = configurator.Configurator(
|
|
37
|
+
label=get_application_label(__file__),
|
|
38
|
+
description="Plot simulated event distributions for shower and/or triggered event data.",
|
|
39
|
+
)
|
|
40
|
+
config.parser.add_argument("--input_file", type=str, required=True, help="Input file path")
|
|
41
|
+
return config.initialize(db_config=False, output=True)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def main():
|
|
45
|
+
"""Plot simulated event distributions."""
|
|
46
|
+
app_context = startup_application(_parse)
|
|
47
|
+
app_context.logger.info(f"Loading input file from: {app_context.args['input_file']}")
|
|
48
|
+
|
|
49
|
+
histograms = EventDataHistograms(app_context.args["input_file"])
|
|
50
|
+
histograms.fill()
|
|
51
|
+
plot_simtel_event_histograms.plot(
|
|
52
|
+
histograms.histograms, output_path=app_context.io_handler.get_output_directory()
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
if __name__ == "__main__":
|
|
57
|
+
main()
|
|
@@ -81,15 +81,10 @@ def main():
|
|
|
81
81
|
telescope=app_context.args.get("telescope"),
|
|
82
82
|
output_path=app_context.io_handler.get_output_directory(),
|
|
83
83
|
plot_type=app_context.args["plot_type"],
|
|
84
|
-
db_config=app_context.db_config,
|
|
85
84
|
)
|
|
86
85
|
|
|
87
86
|
for plot_config, output_file in zip(plot_configs, output_files):
|
|
88
|
-
plot_tables.plot(
|
|
89
|
-
config=plot_config,
|
|
90
|
-
output_file=output_file,
|
|
91
|
-
db_config=app_context.db_config,
|
|
92
|
-
)
|
|
87
|
+
plot_tables.plot(config=plot_config, output_file=output_file)
|
|
93
88
|
MetadataCollector.dump(app_context.args, output_file=output_file, add_activity_name=True)
|
|
94
89
|
|
|
95
90
|
|
|
@@ -134,7 +134,7 @@ def main():
|
|
|
134
134
|
"""Derive limits for energy, radial distance, and viewcone."""
|
|
135
135
|
app_context = startup_application(_parse)
|
|
136
136
|
|
|
137
|
-
generate_corsika_limits_grid(app_context.args
|
|
137
|
+
generate_corsika_limits_grid(app_context.args)
|
|
138
138
|
|
|
139
139
|
|
|
140
140
|
if __name__ == "__main__":
|
|
@@ -101,7 +101,7 @@ def main():
|
|
|
101
101
|
"""Run several simtools applications using a configuration file."""
|
|
102
102
|
app_context = startup_application(_parse, setup_io_handler=False)
|
|
103
103
|
|
|
104
|
-
simtools_runner.run_applications(app_context.args, app_context.
|
|
104
|
+
simtools_runner.run_applications(app_context.args, app_context.logger)
|
|
105
105
|
|
|
106
106
|
|
|
107
107
|
if __name__ == "__main__":
|
|
@@ -45,8 +45,6 @@ light_source (str, required)
|
|
|
45
45
|
Calibration light source, e.g., MSFx-FlashCam
|
|
46
46
|
number_of_events (int, optional):
|
|
47
47
|
Number of events to simulate (default: 1).
|
|
48
|
-
output_prefix (str, optional):
|
|
49
|
-
Prefix for output files (default: empty).
|
|
50
48
|
model_version (str, optional)
|
|
51
49
|
Version of the simulation model.
|
|
52
50
|
array_layout_name (str, optional)
|
|
@@ -89,13 +87,6 @@ def _parse():
|
|
|
89
87
|
default=1,
|
|
90
88
|
required=False,
|
|
91
89
|
)
|
|
92
|
-
config.parser.add_argument(
|
|
93
|
-
"--output_prefix",
|
|
94
|
-
help="Prefix for output files",
|
|
95
|
-
type=str,
|
|
96
|
-
default=None,
|
|
97
|
-
required=False,
|
|
98
|
-
)
|
|
99
90
|
return config.initialize(
|
|
100
91
|
db_config=True,
|
|
101
92
|
simulation_model=["site", "layout", "telescope", "model_version"],
|
|
@@ -120,19 +111,16 @@ def main():
|
|
|
120
111
|
if app_context.args["run_mode"] == "full_simulation":
|
|
121
112
|
light_source = SimulatorLightEmission(
|
|
122
113
|
light_emission_config=app_context.args,
|
|
123
|
-
db_config=app_context.db_config,
|
|
124
114
|
label=app_context.args.get("label"),
|
|
125
115
|
)
|
|
126
116
|
elif app_context.args["run_mode"] == "direct_injection":
|
|
127
|
-
light_source = Simulator(
|
|
128
|
-
args_dict=app_context.args,
|
|
129
|
-
db_config=app_context.db_config,
|
|
130
|
-
label=app_context.args.get("label"),
|
|
131
|
-
)
|
|
117
|
+
light_source = Simulator(label=app_context.args.get("label"))
|
|
132
118
|
else:
|
|
133
119
|
raise ValueError(f"Unsupported run_mode: {app_context.args['run_mode']}")
|
|
134
120
|
|
|
135
121
|
light_source.simulate()
|
|
122
|
+
light_source.verify_simulations()
|
|
123
|
+
|
|
136
124
|
app_context.logger.info("Flasher simulation completed.")
|
|
137
125
|
|
|
138
126
|
|
|
@@ -49,8 +49,6 @@ light_source_position (float, float, float, optional)
|
|
|
49
49
|
m. If not set, the position from the simulation model is used.
|
|
50
50
|
light_source_pointing (float, float, float, optional)
|
|
51
51
|
Light source pointing direction. If not set, the pointing from the simulation model is used.
|
|
52
|
-
output_prefix (str, optional)
|
|
53
|
-
Prefix for output files (default: empty).
|
|
54
52
|
"""
|
|
55
53
|
|
|
56
54
|
from simtools.application_control import get_application_label, startup_application
|
|
@@ -100,13 +98,6 @@ def _parse():
|
|
|
100
98
|
default=1,
|
|
101
99
|
required=False,
|
|
102
100
|
)
|
|
103
|
-
config.parser.add_argument(
|
|
104
|
-
"--output_prefix",
|
|
105
|
-
help="Prefix for output files (default: empty)",
|
|
106
|
-
type=str,
|
|
107
|
-
default=None,
|
|
108
|
-
required=False,
|
|
109
|
-
)
|
|
110
101
|
return config.initialize(
|
|
111
102
|
db_config=True,
|
|
112
103
|
simulation_model=["telescope", "model_version"],
|
|
@@ -119,11 +110,11 @@ def main():
|
|
|
119
110
|
app_context = startup_application(_parse)
|
|
120
111
|
|
|
121
112
|
light_source = SimulatorLightEmission(
|
|
122
|
-
light_emission_config=app_context.args,
|
|
123
|
-
db_config=app_context.db_config,
|
|
113
|
+
light_emission_config={**app_context.args, "run_mode": "illuminator"},
|
|
124
114
|
label=app_context.args.get("label"),
|
|
125
115
|
)
|
|
126
116
|
light_source.simulate()
|
|
117
|
+
light_source.verify_simulations()
|
|
127
118
|
|
|
128
119
|
|
|
129
120
|
if __name__ == "__main__":
|
|
@@ -108,11 +108,7 @@ def main():
|
|
|
108
108
|
"""Simulate pedestal events."""
|
|
109
109
|
app_context = startup_application(_parse)
|
|
110
110
|
|
|
111
|
-
simulator = Simulator(
|
|
112
|
-
label=app_context.args.get("label"),
|
|
113
|
-
args_dict=app_context.args,
|
|
114
|
-
db_config=app_context.db_config,
|
|
115
|
-
)
|
|
111
|
+
simulator = Simulator(label=app_context.args.get("label"))
|
|
116
112
|
simulator.simulate()
|
|
117
113
|
|
|
118
114
|
|
|
@@ -57,7 +57,8 @@ r"""
|
|
|
57
57
|
"""
|
|
58
58
|
|
|
59
59
|
from simtools.application_control import startup_application
|
|
60
|
-
from simtools.configuration import configurator
|
|
60
|
+
from simtools.configuration import commandline_parser, configurator
|
|
61
|
+
from simtools.constants import CORSIKA_MAX_SEED
|
|
61
62
|
from simtools.simulator import Simulator
|
|
62
63
|
|
|
63
64
|
|
|
@@ -97,11 +98,11 @@ def _parse():
|
|
|
97
98
|
default=False,
|
|
98
99
|
)
|
|
99
100
|
config.parser.add_argument(
|
|
100
|
-
"--
|
|
101
|
-
help="Use
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
"--corsika_seeds",
|
|
102
|
+
help="Use fixed random seeds for CORSIKA for testing purposes.",
|
|
103
|
+
nargs=4,
|
|
104
|
+
type=commandline_parser.CommandLineParser.bounded_int(1, CORSIKA_MAX_SEED),
|
|
105
|
+
metavar=("S1", "S2", "S3", "S4"),
|
|
105
106
|
)
|
|
106
107
|
config.parser.add_argument(
|
|
107
108
|
"--sequential",
|
|
@@ -127,11 +128,7 @@ def main():
|
|
|
127
128
|
"""Run simulations for productions."""
|
|
128
129
|
app_context = startup_application(_parse, setup_io_handler=False)
|
|
129
130
|
|
|
130
|
-
simulator = Simulator(
|
|
131
|
-
label=app_context.args.get("label"),
|
|
132
|
-
args_dict=app_context.args,
|
|
133
|
-
db_config=app_context.db_config,
|
|
134
|
-
)
|
|
131
|
+
simulator = Simulator(label=app_context.args.get("label"))
|
|
135
132
|
|
|
136
133
|
simulator.simulate()
|
|
137
134
|
simulator.validate_metadata()
|
|
@@ -22,7 +22,7 @@ Requirements for the 'simtools-simulate-prod-htcondor-generator' application:
|
|
|
22
22
|
- Environment parameters required to run CORSIKA and sim_telarray, as well as DB access
|
|
23
23
|
credentials. These should be listed similarly to a '.env' file and copied to
|
|
24
24
|
'output_path/env.txt'. Ensure that the path to the simulation software is correctly set to
|
|
25
|
-
'
|
|
25
|
+
'SIMTOOLS_SIM_TELARRAY_PATH=/workdir/sim_telarray'.
|
|
26
26
|
|
|
27
27
|
To submit jobs, change to the output directory and run:
|
|
28
28
|
|
|
@@ -75,7 +75,7 @@ def main():
|
|
|
75
75
|
"""Submit and validate array layouts."""
|
|
76
76
|
app_context = startup_application(_parse)
|
|
77
77
|
|
|
78
|
-
db = db_handler.DatabaseHandler(
|
|
78
|
+
db = db_handler.DatabaseHandler()
|
|
79
79
|
|
|
80
80
|
array_layouts = validate_array_layouts_with_db(
|
|
81
81
|
production_table=db.read_production_table_from_db(
|
|
@@ -84,9 +84,7 @@ def main():
|
|
|
84
84
|
array_layouts=ascii_handler.collect_data_from_file(app_context.args["array_layouts"]),
|
|
85
85
|
)
|
|
86
86
|
|
|
87
|
-
write_array_layouts(
|
|
88
|
-
array_layouts=array_layouts, args_dict=app_context.args, db_config=app_context.db_config
|
|
89
|
-
)
|
|
87
|
+
write_array_layouts(array_layouts=array_layouts, args_dict=app_context.args)
|
|
90
88
|
|
|
91
89
|
|
|
92
90
|
if __name__ == "__main__":
|
|
@@ -95,7 +95,8 @@ def main():
|
|
|
95
95
|
)
|
|
96
96
|
|
|
97
97
|
writer.ModelDataWriter.dump(
|
|
98
|
-
|
|
98
|
+
output_file=app_context.args["output_file"],
|
|
99
|
+
output_file_format=app_context.args.get("output_file_format"),
|
|
99
100
|
metadata=_metadata,
|
|
100
101
|
product_data=data_validator.validate_and_transform(),
|
|
101
102
|
)
|
|
@@ -106,9 +106,7 @@ def main():
|
|
|
106
106
|
),
|
|
107
107
|
output_path=output_path,
|
|
108
108
|
metadata_input_dict=app_context.args,
|
|
109
|
-
|
|
110
|
-
if app_context.args.get("check_parameter_version")
|
|
111
|
-
else None,
|
|
109
|
+
check_db_for_existing_parameter=app_context.args.get("check_parameter_version", False),
|
|
112
110
|
)
|
|
113
111
|
|
|
114
112
|
|
|
@@ -44,12 +44,11 @@ r"""
|
|
|
44
44
|
The output is saved in simtools-output/validate_camera_efficiency.
|
|
45
45
|
"""
|
|
46
46
|
|
|
47
|
-
from pathlib import Path
|
|
48
|
-
|
|
49
|
-
import simtools.data_model.model_data_writer as writer
|
|
50
47
|
from simtools.application_control import get_application_label, startup_application
|
|
51
48
|
from simtools.camera.camera_efficiency import CameraEfficiency
|
|
52
49
|
from simtools.configuration import configurator
|
|
50
|
+
from simtools.io.ascii_handler import write_data_to_file
|
|
51
|
+
from simtools.utils import names
|
|
53
52
|
|
|
54
53
|
|
|
55
54
|
def _parse():
|
|
@@ -106,32 +105,33 @@ def main():
|
|
|
106
105
|
"""Calculate the camera efficiency and NSB pixel rates."""
|
|
107
106
|
app_context = startup_application(_parse)
|
|
108
107
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
)
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
/ "nsb_pixel_rate",
|
|
108
|
+
results = {}
|
|
109
|
+
for efficiency_type in ["Shower", "NSB", "Muon"]:
|
|
110
|
+
ce = CameraEfficiency(
|
|
111
|
+
label=app_context.args.get("label"),
|
|
112
|
+
config_data=app_context.args,
|
|
113
|
+
efficiency_type=efficiency_type,
|
|
114
|
+
)
|
|
115
|
+
ce.simulate()
|
|
116
|
+
ce.analyze(force=True)
|
|
117
|
+
results |= ce.results_summary()
|
|
118
|
+
ce.plot_efficiency(save_fig=True)
|
|
119
|
+
|
|
120
|
+
if ce.efficiency_type == "nsb":
|
|
121
|
+
ce.dump_nsb_pixel_rate()
|
|
122
|
+
if ce.efficiency_type == "muon":
|
|
123
|
+
ce.calc_partial_efficiency()
|
|
124
|
+
|
|
125
|
+
results_file = app_context.io_handler.get_output_directory() / names.generate_file_name(
|
|
126
|
+
file_type="camera_efficiency_summary",
|
|
127
|
+
suffix=".yml",
|
|
128
|
+
site=app_context.args["site"],
|
|
129
|
+
telescope_model_name=app_context.args["telescope"],
|
|
130
|
+
zenith_angle=app_context.args["zenith_angle"].value,
|
|
131
|
+
azimuth_angle=app_context.args["azimuth_angle"].value,
|
|
134
132
|
)
|
|
133
|
+
app_context.logger.info(f"Writing results summary to {results_file}")
|
|
134
|
+
write_data_to_file(results, results_file, unique_lines=True)
|
|
135
135
|
|
|
136
136
|
|
|
137
137
|
if __name__ == "__main__":
|
|
@@ -130,19 +130,15 @@ def main():
|
|
|
130
130
|
|
|
131
131
|
tel_model, site_model, _ = initialize_simulation_models(
|
|
132
132
|
label=app_context.args.get("label"),
|
|
133
|
-
db_config=app_context.db_config,
|
|
134
133
|
site=app_context.args["site"],
|
|
135
134
|
telescope_name=app_context.args["telescope"],
|
|
136
135
|
model_version=app_context.args["model_version"],
|
|
137
136
|
)
|
|
138
137
|
|
|
139
|
-
if app_context.args.get("overwrite_model_parameters"):
|
|
140
|
-
tel_model.overwrite_parameters_from_file(app_context.args["overwrite_model_parameters"])
|
|
141
|
-
|
|
142
138
|
ray = RayTracing(
|
|
143
139
|
telescope_model=tel_model,
|
|
144
140
|
site_model=site_model,
|
|
145
|
-
|
|
141
|
+
label=app_context.args.get("label"),
|
|
146
142
|
zenith_angle=app_context.args["zenith"] * u.deg,
|
|
147
143
|
source_distance=app_context.args["src_distance"] * u.km,
|
|
148
144
|
off_axis_angle=[0.0] * u.deg,
|
|
@@ -122,23 +122,11 @@ def main():
|
|
|
122
122
|
|
|
123
123
|
tel_model, site_model, _ = initialize_simulation_models(
|
|
124
124
|
label=Path(__file__).stem,
|
|
125
|
-
db_config=app_context.db_config,
|
|
126
125
|
site=app_context.args["site"],
|
|
127
126
|
telescope_name=app_context.args["telescope"],
|
|
128
127
|
model_version=app_context.args["model_version"],
|
|
129
128
|
)
|
|
130
129
|
|
|
131
|
-
######################################################################
|
|
132
|
-
# This is here as an example how to change parameters when necessary.
|
|
133
|
-
######################################################################
|
|
134
|
-
# pars_to_change = {
|
|
135
|
-
# 'mirror_focal_length': 1608.3,
|
|
136
|
-
# 'mirror_offset': -177.5,
|
|
137
|
-
# 'camera_body_diameter': 289.7,
|
|
138
|
-
# 'telescope_transmission': 1
|
|
139
|
-
# }
|
|
140
|
-
# tel_model.overwrite_parameters(pars_to_change)
|
|
141
|
-
|
|
142
130
|
app_context.logger.info(
|
|
143
131
|
f"\nValidating telescope optics with ray tracing simulations for {tel_model.name}\n"
|
|
144
132
|
)
|
|
@@ -146,7 +134,7 @@ def main():
|
|
|
146
134
|
ray = RayTracing(
|
|
147
135
|
telescope_model=tel_model,
|
|
148
136
|
site_model=site_model,
|
|
149
|
-
|
|
137
|
+
label=app_context.args.get("label") or Path(__file__).stem,
|
|
150
138
|
zenith_angle=app_context.args["zenith"] * u.deg,
|
|
151
139
|
source_distance=app_context.args["src_distance"] * u.km,
|
|
152
140
|
off_axis_angle=np.linspace(
|
|
@@ -160,7 +148,7 @@ def main():
|
|
|
160
148
|
ray.analyze(force=True)
|
|
161
149
|
|
|
162
150
|
# Plotting
|
|
163
|
-
for key in ["
|
|
151
|
+
for key in ["psf_deg", "psf_cm", "eff_area", "eff_flen"]:
|
|
164
152
|
plt.figure(figsize=(8, 6), tight_layout=True)
|
|
165
153
|
|
|
166
154
|
ray.plot(key, marker="o", linestyle=":", color="k")
|