gammasimtools 0.5.1__py3-none-any.whl → 0.6.1__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.5.1.dist-info → gammasimtools-0.6.1.dist-info}/METADATA +80 -28
- gammasimtools-0.6.1.dist-info/RECORD +91 -0
- {gammasimtools-0.5.1.dist-info → gammasimtools-0.6.1.dist-info}/WHEEL +1 -1
- {gammasimtools-0.5.1.dist-info → gammasimtools-0.6.1.dist-info}/entry_points.txt +4 -2
- simtools/_version.py +14 -2
- simtools/applications/add_file_to_db.py +2 -1
- simtools/applications/compare_cumulative_psf.py +10 -15
- simtools/applications/db_development_tools/add_new_parameter_to_db.py +12 -6
- simtools/applications/derive_mirror_rnda.py +95 -71
- simtools/applications/generate_corsika_histograms.py +216 -131
- simtools/applications/generate_default_metadata.py +110 -0
- simtools/applications/generate_simtel_array_histograms.py +192 -0
- simtools/applications/get_file_from_db.py +1 -1
- simtools/applications/get_parameter.py +3 -3
- simtools/applications/make_regular_arrays.py +89 -93
- simtools/applications/{plot_layout_array.py → plot_array_layout.py} +15 -14
- simtools/applications/print_array_elements.py +81 -34
- simtools/applications/produce_array_config.py +2 -2
- simtools/applications/production.py +39 -5
- simtools/applications/sim_showers_for_trigger_rates.py +26 -30
- simtools/applications/simulate_prod.py +49 -107
- simtools/applications/submit_data_from_external.py +8 -10
- simtools/applications/tune_psf.py +16 -18
- simtools/applications/validate_camera_efficiency.py +63 -9
- simtools/applications/validate_camera_fov.py +9 -13
- simtools/applications/validate_file_using_schema.py +127 -0
- simtools/applications/validate_optics.py +13 -15
- simtools/camera_efficiency.py +73 -80
- simtools/configuration/commandline_parser.py +52 -22
- simtools/configuration/configurator.py +98 -33
- simtools/constants.py +9 -0
- simtools/corsika/corsika_config.py +28 -22
- simtools/corsika/corsika_default_config.py +282 -0
- simtools/corsika/corsika_histograms.py +328 -282
- simtools/corsika/corsika_histograms_visualize.py +162 -163
- simtools/corsika/corsika_runner.py +8 -4
- simtools/corsika_simtel/corsika_simtel_runner.py +18 -23
- simtools/data_model/data_reader.py +129 -0
- simtools/data_model/metadata_collector.py +346 -118
- simtools/data_model/metadata_model.py +123 -218
- simtools/data_model/model_data_writer.py +79 -22
- simtools/data_model/validate_data.py +96 -46
- simtools/db_handler.py +67 -42
- simtools/io_operations/__init__.py +0 -0
- simtools/io_operations/hdf5_handler.py +112 -0
- simtools/{io_handler.py → io_operations/io_handler.py} +51 -22
- simtools/job_execution/job_manager.py +1 -1
- simtools/layout/{layout_array.py → array_layout.py} +168 -199
- simtools/layout/geo_coordinates.py +196 -0
- simtools/layout/telescope_position.py +12 -12
- simtools/model/array_model.py +16 -14
- simtools/model/camera.py +5 -8
- simtools/model/mirrors.py +136 -73
- simtools/model/model_utils.py +1 -69
- simtools/model/telescope_model.py +32 -25
- simtools/psf_analysis.py +26 -19
- simtools/ray_tracing.py +54 -26
- simtools/schemas/data.metaschema.yml +400 -0
- simtools/schemas/metadata.metaschema.yml +566 -0
- simtools/simtel/simtel_config_writer.py +14 -5
- simtools/simtel/simtel_histograms.py +266 -83
- simtools/simtel/simtel_runner.py +8 -7
- simtools/simtel/simtel_runner_array.py +7 -8
- simtools/simtel/simtel_runner_camera_efficiency.py +48 -2
- simtools/simtel/simtel_runner_ray_tracing.py +61 -25
- simtools/simulator.py +43 -50
- simtools/utils/general.py +232 -286
- simtools/utils/geometry.py +163 -0
- simtools/utils/names.py +294 -142
- simtools/visualization/legend_handlers.py +115 -9
- simtools/visualization/visualize.py +13 -13
- gammasimtools-0.5.1.dist-info/RECORD +0 -83
- simtools/applications/plot_simtel_histograms.py +0 -120
- simtools/applications/validate_schema_files.py +0 -135
- simtools/corsika/corsika_output_visualize.py +0 -345
- simtools/data_model/validate_schema.py +0 -285
- {gammasimtools-0.5.1.dist-info → gammasimtools-0.6.1.dist-info}/LICENSE +0 -0
- {gammasimtools-0.5.1.dist-info → gammasimtools-0.6.1.dist-info}/top_level.txt +0 -0
|
@@ -3,43 +3,64 @@
|
|
|
3
3
|
"""
|
|
4
4
|
Summary
|
|
5
5
|
-------
|
|
6
|
-
|
|
7
|
-
(mirror roughness
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
6
|
+
Derive the simulation model parameter **mirror_reflection_random_angle**
|
|
7
|
+
(sometimes called mirror roughness) to match the measured containment diameter
|
|
8
|
+
of the optical point-spread function (PSF) of individual mirror panels.
|
|
9
|
+
|
|
10
|
+
Description
|
|
11
|
+
-----------
|
|
12
|
+
|
|
13
|
+
This application derives the value of the simulation model parameter
|
|
14
|
+
*mirror_reflection_random_angle* using measurements of the focal length
|
|
15
|
+
and PSF of individual mirror panels.
|
|
16
|
+
|
|
17
|
+
PSF measurements are provided by one of the following options:
|
|
18
|
+
|
|
19
|
+
* mean and sigma value obtained from the measurement of containment diameters of a number of
|
|
20
|
+
mirror panels in cm (``--psf_measurement_containment_mean`` and
|
|
21
|
+
``--psf_measurement_containment_sigma``)
|
|
22
|
+
* file (table) with measured PSF for each mirror panel spot size (``--psf_measurement``)
|
|
23
|
+
|
|
24
|
+
The containment fraction used for the PSF diameter calculation is set through
|
|
25
|
+
the argument ``--containment_fraction`` (typically 0.8 = 80%).
|
|
26
|
+
|
|
27
|
+
Mirror panels are simulated individually, using one of the following options to set the
|
|
28
|
+
mirror panel focal length:
|
|
29
|
+
|
|
30
|
+
* file (table) with measured focal lengths per mirror panel
|
|
31
|
+
(provided through ``--mirror_list``)
|
|
32
|
+
* randomly generated focal lengths using an expected spread (value given through
|
|
33
|
+
``--random_flen``) around the mean focal length (provided through the
|
|
34
|
+
:ref:`Model Parameters DB`). This option is switched with ``--use_random_flen``.
|
|
35
|
+
|
|
36
|
+
The tuning algorithm requires a starting value for the random reflection angle. This is either
|
|
37
|
+
taken from the :ref:`Model Parameters DB` (default) or can be set using the argument ``--rnda``.
|
|
38
|
+
|
|
39
|
+
Ray-tracing simulations are performed for single mirror configurations for each
|
|
40
|
+
mirror given in the mirror_list. The mean simulated containment diameter for all the mirrors
|
|
41
|
+
is compared with the mean measured containment diameter. The algorithm defines a new value for
|
|
42
|
+
the random reflection angle based on the sign of the difference between measured and simulated
|
|
43
|
+
containment diameters and a new set of simulations is performed. This process is repeated
|
|
44
|
+
until the sign of the difference changes, meaning that the two final values of the random
|
|
45
|
+
reflection angle brackets the optimal. These two values are used to find the optimal one by
|
|
46
|
+
a linear interpolation. Finally, simulations are performed by using the interpolated value,
|
|
47
|
+
which is defined as the desired optimal.
|
|
48
|
+
|
|
49
|
+
The option ``--no_tuning`` can be used if one only wants to simulate one value for the random
|
|
50
|
+
reflection angle and compare the results with the measured ones.
|
|
51
|
+
|
|
52
|
+
Results of the tuning are plotted. See examples of the PSF containment diameter
|
|
53
|
+
D80 vs random reflection angle plot, on the left, and the D80 distributions
|
|
54
|
+
(per mirror panel), on the right.
|
|
55
|
+
|
|
56
|
+
.. _derive_rnda_plot:
|
|
37
57
|
.. image:: images/derive_mirror_rnda_North-MST-FlashCam-D.png
|
|
38
58
|
:width: 49 %
|
|
39
59
|
.. image:: images/derive_mirror_rnda_North-MST-FlashCam-D_D80-distributions.png
|
|
40
60
|
:width: 49 %
|
|
41
61
|
|
|
42
|
-
This application uses the following
|
|
62
|
+
This application uses the following :ref:`SimulationSoftware` tools:
|
|
63
|
+
|
|
43
64
|
- sim_telarray/bin/sim_telarray
|
|
44
65
|
- sim_telarray/bin/rx (optional)
|
|
45
66
|
|
|
@@ -48,54 +69,53 @@
|
|
|
48
69
|
telescope (str, required)
|
|
49
70
|
Telescope name (e.g. North-LST-1, South-SST-D, ...)
|
|
50
71
|
model_version (str, optional)
|
|
51
|
-
Model version
|
|
72
|
+
Model version
|
|
52
73
|
psf_measurement (str, optional)
|
|
53
|
-
|
|
74
|
+
Table with results from PSF measurements for each mirror panel spot size
|
|
54
75
|
psf_measurement_containment_mean (float, required)
|
|
55
76
|
Mean of measured containment diameter [cm]
|
|
56
77
|
psf_measurement_containment_sigma (float, optional)
|
|
57
78
|
Std dev of measured containment diameter [cm]
|
|
58
79
|
containment_fraction (float, required)
|
|
59
|
-
Containment fraction for diameter calculation
|
|
80
|
+
Containment fraction for diameter calculation
|
|
60
81
|
rnda (float, optional)
|
|
61
|
-
Starting value of mirror_reflection_random_angle. If not given, the value from the
|
|
62
|
-
default model
|
|
82
|
+
Starting value of mirror_reflection_random_angle [deg]. If not given, the value from the
|
|
83
|
+
default model is read from the simulation model database.
|
|
63
84
|
mirror_list (file, optional)
|
|
64
|
-
|
|
65
|
-
lengths need to be taken into account. It contains the following information about the \
|
|
66
|
-
mirrors: ID, panel radius, optical PSF (d80), PSF (d80) and surface reflectivity.
|
|
85
|
+
Table with mirror ID and panel radius.
|
|
67
86
|
use_random_flen (activation mode, optional)
|
|
68
|
-
Use random focal lengths, instead of the measured ones. The argument random_flen can be
|
|
87
|
+
Use random focal lengths, instead of the measured ones. The argument random_flen can be
|
|
69
88
|
used to replace the default random_focal_length from the model.
|
|
70
89
|
random_flen (float, optional)
|
|
71
|
-
Value of the random focal lengths to replace the default random_focal_length. Only used if
|
|
90
|
+
Value of the random focal lengths to replace the default random_focal_length. Only used if
|
|
72
91
|
use_random_flen is activated.
|
|
73
92
|
no_tuning (activation mode, optional)
|
|
74
93
|
Turn off the tuning - A single case will be simulated and plotted.
|
|
75
94
|
test (activation mode, optional)
|
|
76
95
|
If activated, application will be faster by simulating only few mirrors.
|
|
77
96
|
verbosity (str, optional)
|
|
78
|
-
Log level to print
|
|
97
|
+
Log level to print.
|
|
79
98
|
|
|
80
99
|
Example
|
|
81
100
|
-------
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
Get mirror list and PSF data from DB:
|
|
85
|
-
|
|
86
|
-
.. code-block:: console
|
|
87
|
-
|
|
88
|
-
simtools-get-file-from-db --file_name MLTdata-preproduction.ecsv
|
|
89
|
-
|
|
90
|
-
Run the application. Runtime about 4 min.
|
|
101
|
+
Derive mirror random reflection angle for a mid-sized telescope (MST),
|
|
102
|
+
simulation production Prod5.
|
|
91
103
|
|
|
92
104
|
.. code-block:: console
|
|
93
105
|
|
|
94
|
-
simtools-derive-mirror-rnda
|
|
95
|
-
--
|
|
96
|
-
--
|
|
106
|
+
simtools-derive-mirror-rnda \\
|
|
107
|
+
--site North \\
|
|
108
|
+
--telescope MST-FlashCam-D \\
|
|
109
|
+
--containment_fraction 0.8 \\
|
|
110
|
+
--mirror_list MLTdata-preproduction.ecsv \\
|
|
111
|
+
--psf_measurement MLTdata-preproduction.ecsv \\
|
|
112
|
+
--rnda 0.0063 \\
|
|
113
|
+
--test
|
|
97
114
|
|
|
98
|
-
|
|
115
|
+
Runtime about 4 min.
|
|
116
|
+
|
|
117
|
+
The output is saved in `simtools-output/derive_mirror_rnda`.
|
|
118
|
+
Use the parameter ``--output_path`` to change the output directory.
|
|
99
119
|
|
|
100
120
|
Expected final print-out message:
|
|
101
121
|
|
|
@@ -111,11 +131,6 @@
|
|
|
111
131
|
Previous value = 0.006300
|
|
112
132
|
New value = 0.004975
|
|
113
133
|
|
|
114
|
-
|
|
115
|
-
.. todo::
|
|
116
|
-
|
|
117
|
-
* Change default model to default (after this feature is implemented in db_handler)
|
|
118
|
-
* Fix the set_style. For some reason, sphinx cannot built docs with it on.
|
|
119
134
|
"""
|
|
120
135
|
|
|
121
136
|
import logging
|
|
@@ -245,7 +260,7 @@ def _print_and_write_results(
|
|
|
245
260
|
args_dict, rnda_start, rnda_opt, mean_d80, sig_d80, results_rnda, results_mean, results_sig
|
|
246
261
|
):
|
|
247
262
|
"""
|
|
248
|
-
Print results to screen write metadata and data files
|
|
263
|
+
Print results to screen and write metadata and data files
|
|
249
264
|
in the requested format
|
|
250
265
|
|
|
251
266
|
"""
|
|
@@ -287,12 +302,10 @@ def _print_and_write_results(
|
|
|
287
302
|
f"containment_radius_sigma_D{containment_fraction_percent}",
|
|
288
303
|
),
|
|
289
304
|
)
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
file_writer.write(
|
|
295
|
-
metadata=MetadataCollector(args_dict=args_dict).top_level_meta, product_data=result_table
|
|
305
|
+
writer.ModelDataWriter.dump(
|
|
306
|
+
args_dict=args_dict,
|
|
307
|
+
metadata=MetadataCollector(args_dict=args_dict).top_level_meta,
|
|
308
|
+
product_data=result_table,
|
|
296
309
|
)
|
|
297
310
|
|
|
298
311
|
|
|
@@ -303,7 +316,9 @@ def _get_psf_containment(logger, args_dict):
|
|
|
303
316
|
|
|
304
317
|
"""
|
|
305
318
|
|
|
306
|
-
|
|
319
|
+
# If this is a test, read just the first few lines since we only simulate those mirrors
|
|
320
|
+
data_end = args_dict["number_of_mirrors_to_test"] + 1 if args_dict["test"] else None
|
|
321
|
+
_psf_list = Table.read(args_dict["psf_measurement"], format="ascii.ecsv", data_end=data_end)
|
|
307
322
|
try:
|
|
308
323
|
args_dict["psf_measurement_containment_mean"] = np.nanmean(
|
|
309
324
|
np.array(_psf_list["psf_opt"].to("cm").value)
|
|
@@ -333,6 +348,9 @@ def main():
|
|
|
333
348
|
|
|
334
349
|
tel = _define_telescope_model(label, args_dict, db_config)
|
|
335
350
|
|
|
351
|
+
if args_dict["test"]:
|
|
352
|
+
args_dict["number_of_mirrors_to_test"] = 4
|
|
353
|
+
|
|
336
354
|
if args_dict["psf_measurement"]:
|
|
337
355
|
_get_psf_containment(logger, args_dict)
|
|
338
356
|
if not args_dict["psf_measurement_containment_mean"]:
|
|
@@ -345,7 +363,9 @@ def main():
|
|
|
345
363
|
ray = RayTracing.from_kwargs(
|
|
346
364
|
telescope_model=tel,
|
|
347
365
|
single_mirror_mode=True,
|
|
348
|
-
mirror_numbers=list(range(1,
|
|
366
|
+
mirror_numbers=list(range(1, args_dict["number_of_mirrors_to_test"] + 1))
|
|
367
|
+
if args_dict["test"]
|
|
368
|
+
else "all",
|
|
349
369
|
simtel_source_path=args_dict.get("simtel_path", None),
|
|
350
370
|
use_random_focal_length=args_dict["use_random_flen"],
|
|
351
371
|
)
|
|
@@ -365,7 +385,7 @@ def main():
|
|
|
365
385
|
if isinstance(rnda_start, str):
|
|
366
386
|
rnda_start = float(rnda_start.split()[0])
|
|
367
387
|
|
|
368
|
-
logger.info(f"Start value for mirror_reflection_random_angle: {rnda_start}")
|
|
388
|
+
logger.info(f"Start value for mirror_reflection_random_angle: {rnda_start} deg")
|
|
369
389
|
|
|
370
390
|
results_rnda = []
|
|
371
391
|
results_mean = []
|
|
@@ -386,6 +406,10 @@ def main():
|
|
|
386
406
|
collect_results(rnda, mean_d80, sig_d80)
|
|
387
407
|
while not stop:
|
|
388
408
|
rnda = rnda - (0.1 * rnda_start * sign_delta)
|
|
409
|
+
if rnda < 0:
|
|
410
|
+
rnda = 0
|
|
411
|
+
collect_results(rnda, mean_d80, sig_d80)
|
|
412
|
+
break
|
|
389
413
|
mean_d80, sig_d80 = run(rnda)
|
|
390
414
|
new_sign_delta = np.sign(mean_d80 - args_dict["psf_measurement_containment_mean"])
|
|
391
415
|
stop = new_sign_delta != sign_delta
|