gammasimtools 0.9.0__py3-none-any.whl → 0.10.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.9.0.dist-info → gammasimtools-0.10.0.dist-info}/METADATA +2 -2
- {gammasimtools-0.9.0.dist-info → gammasimtools-0.10.0.dist-info}/RECORD +94 -85
- {gammasimtools-0.9.0.dist-info → gammasimtools-0.10.0.dist-info}/entry_points.txt +2 -1
- simtools/_version.py +2 -2
- simtools/applications/calculate_trigger_rate.py +15 -38
- simtools/applications/convert_all_model_parameters_from_simtel.py +9 -28
- simtools/applications/convert_geo_coordinates_of_array_elements.py +47 -45
- simtools/applications/convert_model_parameter_from_simtel.py +2 -2
- simtools/applications/db_add_file_to_db.py +1 -2
- simtools/applications/db_add_simulation_model_from_repository_to_db.py +110 -0
- simtools/applications/db_add_value_from_json_to_db.py +1 -2
- simtools/applications/db_development_tools/write_array_elements_positions_to_repository.py +6 -6
- simtools/applications/db_get_file_from_db.py +11 -12
- simtools/applications/db_get_parameter_from_db.py +44 -32
- simtools/applications/derive_photon_electron_spectrum.py +99 -0
- simtools/applications/generate_array_config.py +17 -17
- simtools/applications/generate_regular_arrays.py +15 -15
- simtools/applications/generate_simtel_array_histograms.py +11 -48
- simtools/applications/production_generate_simulation_config.py +25 -7
- simtools/applications/production_scale_events.py +2 -2
- simtools/applications/simulate_prod.py +1 -1
- simtools/applications/simulate_prod_htcondor_generator.py +26 -26
- simtools/applications/submit_data_from_external.py +12 -4
- simtools/applications/submit_model_parameter_from_external.py +8 -6
- simtools/applications/validate_camera_efficiency.py +2 -2
- simtools/applications/validate_file_using_schema.py +23 -19
- simtools/camera/single_photon_electron_spectrum.py +168 -0
- simtools/configuration/commandline_parser.py +8 -1
- simtools/constants.py +10 -3
- simtools/corsika/corsika_config.py +8 -7
- simtools/corsika/corsika_histograms.py +1 -1
- simtools/data_model/data_reader.py +0 -3
- simtools/data_model/metadata_collector.py +3 -4
- simtools/data_model/metadata_model.py +8 -124
- simtools/data_model/model_data_writer.py +17 -63
- simtools/data_model/schema.py +213 -0
- simtools/data_model/validate_data.py +9 -44
- simtools/db/db_handler.py +323 -495
- simtools/db/db_model_upload.py +139 -0
- simtools/io_operations/hdf5_handler.py +54 -24
- simtools/layout/array_layout.py +33 -28
- simtools/model/array_model.py +13 -7
- simtools/model/model_parameter.py +22 -54
- simtools/model/site_model.py +2 -2
- simtools/production_configuration/calculate_statistical_errors_grid_point.py +119 -144
- simtools/production_configuration/event_scaler.py +7 -17
- simtools/production_configuration/generate_simulation_config.py +5 -32
- simtools/production_configuration/interpolation_handler.py +8 -11
- simtools/runners/corsika_simtel_runner.py +3 -1
- simtools/schemas/input/MST_mirror_2f_measurements.schema.yml +39 -0
- simtools/schemas/input/single_pe_spectrum.schema.yml +38 -0
- simtools/schemas/integration_tests_config.metaschema.yml +10 -0
- simtools/schemas/model_parameter.metaschema.yml +7 -2
- simtools/schemas/model_parameter_and_data_schema.metaschema.yml +2 -0
- simtools/schemas/model_parameters/array_element_position_utm.schema.yml +1 -1
- simtools/schemas/model_parameters/array_window.schema.yml +37 -0
- simtools/schemas/model_parameters/asum_clipping.schema.yml +0 -4
- simtools/schemas/model_parameters/channels_per_chip.schema.yml +1 -1
- simtools/schemas/model_parameters/corsika_iact_io_buffer.schema.yml +2 -2
- simtools/schemas/model_parameters/dsum_clipping.schema.yml +0 -2
- simtools/schemas/model_parameters/dsum_ignore_below.schema.yml +0 -2
- simtools/schemas/model_parameters/dsum_offset.schema.yml +0 -2
- simtools/schemas/model_parameters/dsum_pedsub.schema.yml +0 -2
- simtools/schemas/model_parameters/dsum_pre_clipping.schema.yml +0 -2
- simtools/schemas/model_parameters/dsum_prescale.schema.yml +0 -2
- simtools/schemas/model_parameters/dsum_presum_max.schema.yml +0 -2
- simtools/schemas/model_parameters/dsum_presum_shift.schema.yml +0 -2
- simtools/schemas/model_parameters/dsum_shaping.schema.yml +0 -2
- simtools/schemas/model_parameters/dsum_shaping_renormalize.schema.yml +0 -2
- simtools/schemas/model_parameters/dsum_threshold.schema.yml +0 -2
- simtools/schemas/model_parameters/dsum_zero_clip.schema.yml +0 -2
- simtools/schemas/model_parameters/fadc_compensate_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_lg_compensate_pedestal.schema.yml +1 -1
- simtools/schemas/model_parameters/fadc_noise.schema.yml +3 -3
- simtools/schemas/model_parameters/fake_mirror_list.schema.yml +33 -0
- simtools/schemas/model_parameters/laser_photons.schema.yml +2 -2
- simtools/schemas/model_parameters/secondary_mirror_degraded_reflection.schema.yml +1 -1
- simtools/schemas/production_configuration_metrics.schema.yml +68 -0
- simtools/schemas/production_tables.schema.yml +41 -0
- simtools/simtel/simtel_config_writer.py +5 -6
- simtools/simtel/simtel_io_histogram.py +32 -67
- simtools/simtel/simtel_io_histograms.py +15 -30
- simtools/simtel/simulator_array.py +2 -1
- simtools/simtel/simulator_camera_efficiency.py +5 -0
- simtools/simtel/simulator_light_emission.py +3 -1
- simtools/simtel/simulator_ray_tracing.py +2 -1
- simtools/testing/helpers.py +6 -13
- simtools/testing/validate_output.py +131 -47
- simtools/utils/general.py +102 -12
- simtools/utils/names.py +24 -20
- simtools/applications/db_add_model_parameters_from_repository_to_db.py +0 -176
- simtools/db/db_array_elements.py +0 -130
- {gammasimtools-0.9.0.dist-info → gammasimtools-0.10.0.dist-info}/LICENSE +0 -0
- {gammasimtools-0.9.0.dist-info → gammasimtools-0.10.0.dist-info}/WHEEL +0 -0
- {gammasimtools-0.9.0.dist-info → gammasimtools-0.10.0.dist-info}/top_level.txt +0 -0
- /simtools/{camera_efficiency.py → camera/camera_efficiency.py} +0 -0
|
@@ -1,56 +1,56 @@
|
|
|
1
1
|
#!/usr/bin/python3
|
|
2
2
|
"""Convert and print a list of array element positions in different coordinate systems.
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
4
|
+
Description
|
|
5
|
+
-----------
|
|
6
|
+
|
|
7
|
+
Convert array element positions in different CTAO coordinate systems.
|
|
8
|
+
Available coordinate systems are:
|
|
9
|
+
|
|
10
|
+
1. UTM system
|
|
11
|
+
2. ground system (similar to sim_telarray system with x-axis pointing toward geographic north
|
|
12
|
+
and y-axis pointing towards the west); altitude relative to the CORSIKA observation level.
|
|
13
|
+
Altitude is the height of the elevation rotation axis (plus some possible mirror offset).
|
|
14
|
+
3. Mercator system
|
|
15
|
+
|
|
16
|
+
Command line arguments
|
|
17
|
+
----------------------
|
|
18
|
+
input (str)
|
|
19
|
+
File name with list of array element positions.
|
|
20
|
+
Input can be given as astropy table file (ecsv) or a single array element in
|
|
21
|
+
a json file.
|
|
22
|
+
print (str)
|
|
23
|
+
Print in requested coordinate system; possible are ground, utm, mercator
|
|
24
|
+
export (str)
|
|
25
|
+
Export array element list to file in requested coordinate system;
|
|
26
|
+
possible are ground, utm, mercator
|
|
27
|
+
select_assets (str)
|
|
28
|
+
Select a subset of array elements / telescopes (e.g., MSTN, LSTN)
|
|
29
|
+
|
|
30
|
+
Example
|
|
31
|
+
-------
|
|
32
|
+
Convert a list of array elements using a list of telescope positions in UTM coordinates.
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
.. code-block:: console
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
simtools-convert-geo-coordinates-of-array-elements
|
|
37
|
+
--input tests/resources/telescope_positions-North-utm.ecsv
|
|
38
|
+
--print ground
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
The converted list of telescope positions in ground coordinates is printed to the screen.
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
The following example converts a list of telescope positions in UTM coordinates
|
|
43
|
+
and writes the output to a file in ground (sim_telarray) coordinates. Also selects
|
|
44
|
+
only a subset of the array elements (telescopes; ignore calibration devices):
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
.. code-block:: console
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
simtools-convert-geo-coordinates-of-array-elements
|
|
49
|
+
--input tests/resources/telescope_positions-North-utm.ecsv
|
|
50
|
+
--export ground
|
|
51
|
+
--select_assets LSTN
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
Expected output is a ecsv file in the directory printed to the screen.
|
|
54
54
|
|
|
55
55
|
"""
|
|
56
56
|
|
|
@@ -133,7 +133,7 @@ def _parse(label=None, description=None):
|
|
|
133
133
|
output=True,
|
|
134
134
|
require_command_line=True,
|
|
135
135
|
db_config=True,
|
|
136
|
-
simulation_model=["model_version", "site"],
|
|
136
|
+
simulation_model=["model_version", "parameter_version", "site"],
|
|
137
137
|
)
|
|
138
138
|
|
|
139
139
|
|
|
@@ -170,7 +170,9 @@ def main():
|
|
|
170
170
|
|
|
171
171
|
if args_dict["export"] is not None:
|
|
172
172
|
product_data = (
|
|
173
|
-
layout.export_one_telescope_as_json(
|
|
173
|
+
layout.export_one_telescope_as_json(
|
|
174
|
+
crs_name=args_dict["export"], parameter_version=args_dict.get("parameter_version")
|
|
175
|
+
)
|
|
174
176
|
if args_dict.get("input", "").endswith(".json")
|
|
175
177
|
else layout.export_telescope_list_table(crs_name=args_dict["export"])
|
|
176
178
|
)
|
|
@@ -78,7 +78,7 @@ def _parse(label=None, description=None):
|
|
|
78
78
|
type=str,
|
|
79
79
|
required=True,
|
|
80
80
|
)
|
|
81
|
-
return config.initialize(simulation_model=["telescope", "
|
|
81
|
+
return config.initialize(simulation_model=["telescope", "parameter_version"], output=True)
|
|
82
82
|
|
|
83
83
|
|
|
84
84
|
def main(): # noqa: D103
|
|
@@ -107,7 +107,7 @@ def main(): # noqa: D103
|
|
|
107
107
|
parameter_name=simtel_config_reader.parameter_name,
|
|
108
108
|
value=simtel_config_reader.parameter_dict.get(args_dict["simtel_telescope_name"]),
|
|
109
109
|
instrument=args_dict["telescope"],
|
|
110
|
-
|
|
110
|
+
parameter_version=args_dict["parameter_version"],
|
|
111
111
|
output_file=args_dict["output_file"],
|
|
112
112
|
output_path=args_dict.get("output_path"),
|
|
113
113
|
use_plain_output_path=args_dict.get("use_plain_output_path"),
|
|
@@ -18,8 +18,7 @@
|
|
|
18
18
|
A directory with files to upload to the DB. \
|
|
19
19
|
All files in the directory with a predefined list of extensions will be uploaded.
|
|
20
20
|
db (str)
|
|
21
|
-
The DB to insert the files to.
|
|
22
|
-
The choices are either the default CTA simulation DB or a sandbox for testing.
|
|
21
|
+
The DB to insert the files to.
|
|
23
22
|
|
|
24
23
|
Example
|
|
25
24
|
-------
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#!/usr/bin/python3
|
|
2
|
+
r"""
|
|
3
|
+
Add parameters and production tables from a simulation model repository to a new database.
|
|
4
|
+
|
|
5
|
+
Generates a new database with all required collections.
|
|
6
|
+
Follows the structure of the CTAO gitlab simulation model repository.
|
|
7
|
+
|
|
8
|
+
This is an application for experts and should not be used by the general user.
|
|
9
|
+
|
|
10
|
+
Command line arguments
|
|
11
|
+
|
|
12
|
+
input_path (str, required)
|
|
13
|
+
Path of local copy of model parameter repository.
|
|
14
|
+
db_name (str, required)
|
|
15
|
+
Name of new DB to be created.
|
|
16
|
+
type (str, optional)
|
|
17
|
+
Type of data to be uploaded to the DB. Options are: model_parameters, production_tables.
|
|
18
|
+
|
|
19
|
+
Examples
|
|
20
|
+
--------
|
|
21
|
+
Upload model data repository to the DB:
|
|
22
|
+
|
|
23
|
+
.. code-block:: console
|
|
24
|
+
|
|
25
|
+
simtools-db-simulation-model-from-repository-to-db \
|
|
26
|
+
--input_path /path/to/repository \
|
|
27
|
+
--db_name new_db_name \
|
|
28
|
+
--type model_parameters
|
|
29
|
+
|
|
30
|
+
Upload production tables to the DB:
|
|
31
|
+
|
|
32
|
+
.. code-block:: console
|
|
33
|
+
|
|
34
|
+
simtools-db-simulation-model-from-repository-to-db \
|
|
35
|
+
--input_path /path/to/repository \
|
|
36
|
+
--db_name new_db_name \
|
|
37
|
+
--type production_tables
|
|
38
|
+
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
import logging
|
|
42
|
+
from pathlib import Path
|
|
43
|
+
|
|
44
|
+
import simtools.utils.general as gen
|
|
45
|
+
from simtools.configuration import configurator
|
|
46
|
+
from simtools.db import db_handler, db_model_upload
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _parse(label=None, description=None):
|
|
50
|
+
"""
|
|
51
|
+
Parse command line configuration.
|
|
52
|
+
|
|
53
|
+
Parameters
|
|
54
|
+
----------
|
|
55
|
+
label : str
|
|
56
|
+
Label describing application.
|
|
57
|
+
description : str
|
|
58
|
+
Description of application.
|
|
59
|
+
|
|
60
|
+
Returns
|
|
61
|
+
-------
|
|
62
|
+
CommandLineParser
|
|
63
|
+
Command line parser object.
|
|
64
|
+
"""
|
|
65
|
+
config = configurator.Configurator(label=label, description=description)
|
|
66
|
+
config.parser.add_argument(
|
|
67
|
+
"--input_path",
|
|
68
|
+
help="Path to simulation model repository.",
|
|
69
|
+
type=Path,
|
|
70
|
+
required=True,
|
|
71
|
+
)
|
|
72
|
+
config.parser.add_argument(
|
|
73
|
+
"--db_name",
|
|
74
|
+
help="Name of the new simulation model database to be created.",
|
|
75
|
+
type=str.strip,
|
|
76
|
+
required=True,
|
|
77
|
+
)
|
|
78
|
+
config.parser.add_argument(
|
|
79
|
+
"--type",
|
|
80
|
+
help="Type of data to be uploaded to the database.",
|
|
81
|
+
type=str,
|
|
82
|
+
required=False,
|
|
83
|
+
default="model_parameters",
|
|
84
|
+
choices=["model_parameters", "production_tables"],
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
args_dict, db_config = config.initialize(output=True, require_command_line=True, db_config=True)
|
|
88
|
+
db_config["db_simulation_model"] = args_dict["db_name"] # overwrite explicitly DB configuration
|
|
89
|
+
return args_dict, db_config
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def main():
|
|
93
|
+
"""Application main."""
|
|
94
|
+
label = Path(__file__).stem
|
|
95
|
+
args_dict, db_config = _parse(
|
|
96
|
+
label, description="Add or update a model parameter database to the DB"
|
|
97
|
+
)
|
|
98
|
+
logger = logging.getLogger()
|
|
99
|
+
logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
|
|
100
|
+
|
|
101
|
+
db = db_handler.DatabaseHandler(mongo_db_config=db_config)
|
|
102
|
+
|
|
103
|
+
if args_dict.get("type") == "model_parameters":
|
|
104
|
+
db_model_upload.add_model_parameters_to_db(args_dict, db)
|
|
105
|
+
elif args_dict.get("type") == "production_tables":
|
|
106
|
+
db_model_upload.add_production_tables_to_db(args_dict, db)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
if __name__ == "__main__":
|
|
110
|
+
main()
|
|
@@ -10,8 +10,7 @@ r"""
|
|
|
10
10
|
db_collection (str, required)
|
|
11
11
|
The DB collection to which to add the file.
|
|
12
12
|
db (str)
|
|
13
|
-
The DB to insert the files to.
|
|
14
|
-
The choices are either the default CTA simulation DB or a sandbox for testing.
|
|
13
|
+
The DB to insert the files to.
|
|
15
14
|
|
|
16
15
|
Example
|
|
17
16
|
-------
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
File containing a table of array element positions.
|
|
12
12
|
repository_path : str
|
|
13
13
|
Path of local copy of model parameter repository.
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
parameter_version : str
|
|
15
|
+
Parameter version.
|
|
16
16
|
site : str
|
|
17
17
|
Observatory site.
|
|
18
18
|
coordinate_system : str
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
simtools-write-array-element-positions-to-repository \
|
|
28
28
|
--input /path/to/positions.txt \
|
|
29
29
|
--repository_path /path/to/repository \
|
|
30
|
-
--
|
|
30
|
+
--parameter_version 0.1.0 \
|
|
31
31
|
--coordinate_system ground \
|
|
32
32
|
--site North
|
|
33
33
|
|
|
@@ -82,7 +82,7 @@ def _parse(label=None, description=None):
|
|
|
82
82
|
choices=["ground", "utm"],
|
|
83
83
|
)
|
|
84
84
|
|
|
85
|
-
return config.initialize(db_config=True, simulation_model="site")
|
|
85
|
+
return config.initialize(db_config=True, simulation_model=["site", "parameter_version"])
|
|
86
86
|
|
|
87
87
|
|
|
88
88
|
def write_utm_array_elements_to_repository(args_dict, logger):
|
|
@@ -115,7 +115,7 @@ def write_utm_array_elements_to_repository(args_dict, logger):
|
|
|
115
115
|
parameter_name="array_element_position_utm",
|
|
116
116
|
instrument=instrument,
|
|
117
117
|
value=f"{row['utm_east']} {row['utm_north']} {row['altitude']}",
|
|
118
|
-
|
|
118
|
+
parameter_version=args_dict["parameter_version"],
|
|
119
119
|
output_path=output_path,
|
|
120
120
|
output_file="array_element_position_utm.json",
|
|
121
121
|
)
|
|
@@ -137,7 +137,7 @@ def write_ground_array_elements_to_repository(args_dict, db_config, logger):
|
|
|
137
137
|
"""
|
|
138
138
|
array_model = ArrayModel(
|
|
139
139
|
mongo_db_config=db_config,
|
|
140
|
-
model_version=
|
|
140
|
+
model_version=None,
|
|
141
141
|
site=args_dict["site"],
|
|
142
142
|
array_elements=args_dict["input"],
|
|
143
143
|
)
|
|
@@ -49,8 +49,9 @@ def _parse():
|
|
|
49
49
|
|
|
50
50
|
config.parser.add_argument(
|
|
51
51
|
"--file_name",
|
|
52
|
-
help="The name of the file to be downloaded.",
|
|
52
|
+
help="The name of the file(s) to be downloaded (single file or space-separated list).",
|
|
53
53
|
type=str,
|
|
54
|
+
nargs="+",
|
|
54
55
|
required=True,
|
|
55
56
|
)
|
|
56
57
|
return config.initialize(db_config=True, output=True)
|
|
@@ -66,15 +67,14 @@ def main(): # noqa: D103
|
|
|
66
67
|
db = db_handler.DatabaseHandler(mongo_db_config=db_config)
|
|
67
68
|
available_dbs = [
|
|
68
69
|
db_config["db_simulation_model"],
|
|
69
|
-
db.DB_CTA_SIMULATION_MODEL_DESCRIPTIONS,
|
|
70
|
-
db.DB_DERIVED_VALUES,
|
|
71
|
-
"sandbox",
|
|
72
70
|
]
|
|
73
|
-
file_id =
|
|
71
|
+
file_id = {}
|
|
74
72
|
for db_name in available_dbs:
|
|
75
73
|
try:
|
|
76
|
-
file_id = db.
|
|
77
|
-
db_name,
|
|
74
|
+
file_id = db.export_model_files(
|
|
75
|
+
db_name=db_name,
|
|
76
|
+
dest=_io_handler.get_output_directory(),
|
|
77
|
+
file_names=args_dict["file_name"],
|
|
78
78
|
)
|
|
79
79
|
logger.info(
|
|
80
80
|
f"Got file {args_dict['file_name']} from DB {db_name} "
|
|
@@ -84,11 +84,10 @@ def main(): # noqa: D103
|
|
|
84
84
|
except FileNotFoundError:
|
|
85
85
|
continue
|
|
86
86
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
f"The file {
|
|
90
|
-
|
|
91
|
-
raise FileNotFoundError
|
|
87
|
+
for key, value in file_id.items():
|
|
88
|
+
if value is None:
|
|
89
|
+
logger.error(f"The file {key} was not found in any of the available DBs.")
|
|
90
|
+
raise FileNotFoundError
|
|
92
91
|
|
|
93
92
|
|
|
94
93
|
if __name__ == "__main__":
|
|
@@ -26,7 +26,7 @@ r"""
|
|
|
26
26
|
|
|
27
27
|
Example
|
|
28
28
|
-------
|
|
29
|
-
Get the mirror_list parameter from the DB.
|
|
29
|
+
Get the mirror_list parameter used for a given model_version from the DB.
|
|
30
30
|
|
|
31
31
|
.. code-block:: console
|
|
32
32
|
|
|
@@ -34,18 +34,13 @@ r"""
|
|
|
34
34
|
--site North --telescope LSTN-01 \\
|
|
35
35
|
--model_version 5.0.0
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
Get the mirror_list parameter using the parameter_version from the DB.
|
|
38
38
|
|
|
39
39
|
.. code-block:: console
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
'Value': 'mirror_CTA-N-LST1_v2019-03-31.dat',
|
|
45
|
-
'Version': '5.0.0',
|
|
46
|
-
'_id': ObjectId('608834f257df2db2531b8e78'),
|
|
47
|
-
'entry_date': datetime.datetime(2021, 4, 27, 15, 59, 46, tzinfo=<bson.tz_util.FixedOffset \
|
|
48
|
-
object at 0x7f601dd51d80>)}
|
|
41
|
+
simtools-db-get-parameter-from-db --parameter mirror_list \\
|
|
42
|
+
--site North --telescope LSTN-01 \\
|
|
43
|
+
--parameter_version 1.0.0
|
|
49
44
|
|
|
50
45
|
"""
|
|
51
46
|
|
|
@@ -73,7 +68,6 @@ def _parse():
|
|
|
73
68
|
config.parser.add_argument(
|
|
74
69
|
"--db_collection",
|
|
75
70
|
help="DB collection to which to add the file",
|
|
76
|
-
default="telescopes",
|
|
77
71
|
required=False,
|
|
78
72
|
)
|
|
79
73
|
config.parser.add_argument(
|
|
@@ -83,7 +77,9 @@ def _parse():
|
|
|
83
77
|
required=False,
|
|
84
78
|
)
|
|
85
79
|
|
|
86
|
-
return config.initialize(
|
|
80
|
+
return config.initialize(
|
|
81
|
+
db_config=True, simulation_model=["telescope", "parameter_version", "model_version"]
|
|
82
|
+
)
|
|
87
83
|
|
|
88
84
|
|
|
89
85
|
def main(): # noqa: D103
|
|
@@ -94,37 +90,53 @@ def main(): # noqa: D103
|
|
|
94
90
|
|
|
95
91
|
db = db_handler.DatabaseHandler(mongo_db_config=db_config)
|
|
96
92
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
args_dict["
|
|
101
|
-
args_dict["
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
pars = db.get_model_parameters(
|
|
108
|
-
args_dict["site"],
|
|
109
|
-
args_dict["telescope"],
|
|
110
|
-
args_dict["model_version"],
|
|
111
|
-
collection="telescopes",
|
|
93
|
+
# get parameter using 'parameter_version'
|
|
94
|
+
if args_dict["parameter_version"] is not None:
|
|
95
|
+
pars = db.get_model_parameter(
|
|
96
|
+
parameter=args_dict["parameter"],
|
|
97
|
+
parameter_version=args_dict["parameter_version"],
|
|
98
|
+
site=args_dict["site"],
|
|
99
|
+
array_element_name=args_dict["telescope"],
|
|
100
|
+
collection=(
|
|
101
|
+
args_dict["db_collection"] if args_dict.get("db_collection") else "telescopes"
|
|
102
|
+
),
|
|
112
103
|
)
|
|
104
|
+
# get parameter using 'model_version'
|
|
105
|
+
elif args_dict["model_version"] is not None:
|
|
106
|
+
if args_dict["telescope"]:
|
|
107
|
+
pars = db.get_model_parameters(
|
|
108
|
+
site=args_dict["site"],
|
|
109
|
+
array_element_name=args_dict["telescope"],
|
|
110
|
+
model_version=args_dict["model_version"],
|
|
111
|
+
collection=(
|
|
112
|
+
"configuration_sim_telarray"
|
|
113
|
+
if args_dict.get("db_collection") == "configuration_sim_telarray"
|
|
114
|
+
else "telescopes"
|
|
115
|
+
),
|
|
116
|
+
)
|
|
117
|
+
else:
|
|
118
|
+
pars = db.get_model_parameters(
|
|
119
|
+
site=args_dict.get("site"),
|
|
120
|
+
model_version=args_dict["model_version"],
|
|
121
|
+
collection=(
|
|
122
|
+
args_dict["db_collection"] if args_dict.get("db_collection") else "sites"
|
|
123
|
+
),
|
|
124
|
+
array_element_name=None,
|
|
125
|
+
)
|
|
113
126
|
else:
|
|
114
|
-
|
|
127
|
+
raise ValueError("Either 'parameter_version' or 'model_version' must be provided.")
|
|
115
128
|
if args_dict["parameter"] not in pars:
|
|
116
129
|
raise KeyError(f"The requested parameter, {args_dict['parameter']}, does not exist.")
|
|
117
130
|
if args_dict["output_file"] is not None:
|
|
118
|
-
|
|
131
|
+
_output_file = (
|
|
132
|
+
Path(io_handler.IOHandler().get_output_directory()) / args_dict["output_file"]
|
|
133
|
+
)
|
|
119
134
|
pars[args_dict["parameter"]].pop("_id")
|
|
120
135
|
pars[args_dict["parameter"]].pop("entry_date")
|
|
121
|
-
_output_file = Path(_io_handler.get_output_directory()) / args_dict["output_file"]
|
|
122
136
|
with open(_output_file, "w", encoding="utf-8") as json_file:
|
|
123
137
|
json.dump(pars[args_dict["parameter"]], json_file, indent=4)
|
|
124
138
|
else:
|
|
125
|
-
print()
|
|
126
139
|
pprint(pars[args_dict["parameter"]])
|
|
127
|
-
print()
|
|
128
140
|
|
|
129
141
|
|
|
130
142
|
if __name__ == "__main__":
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
#!/usr/bin/python3
|
|
2
|
+
|
|
3
|
+
r"""
|
|
4
|
+
Derive single photon electron spectrum from a given amplitude spectrum.
|
|
5
|
+
|
|
6
|
+
Normalizes singe-p.e. amplitude distribution to mean amplitude of 1.0,
|
|
7
|
+
as required by sim_telarray. Allows to fold in afterpulse distribution
|
|
8
|
+
to prompt a spectrum. Uses the sim_telarray tool 'norm_spe' to normalize
|
|
9
|
+
the spectra.
|
|
10
|
+
|
|
11
|
+
Input files can be in ecsv format (preferred) or in the sim_telarray legacy format.
|
|
12
|
+
|
|
13
|
+
Two output files with identical data are written to the output directory:
|
|
14
|
+
|
|
15
|
+
- 'output_file'.ecsv: Single photon electron spectrum in ecsv format (data and metadata).
|
|
16
|
+
- 'output_file'.dat: Single photon electron spectrum in sim_telarray format.
|
|
17
|
+
|
|
18
|
+
Example
|
|
19
|
+
-------
|
|
20
|
+
|
|
21
|
+
.. code-block:: console
|
|
22
|
+
|
|
23
|
+
simtools-derive-photon-electron-spectrum \\
|
|
24
|
+
--input_spectrum spectrum_photon_electron.ecsv \\
|
|
25
|
+
--afterpulse_spectrum spectrum_afterpulse.ecsv \\
|
|
26
|
+
--step_size 0.02 \\
|
|
27
|
+
--max_amplitude 42.0 \\
|
|
28
|
+
--use_norm_spe \\
|
|
29
|
+
--output_path ./tests/output \\
|
|
30
|
+
--output_file spectrum_photon_electron_afterpulse.ecsv
|
|
31
|
+
|
|
32
|
+
For an example of how to plot the single photon electron spectrum, see the
|
|
33
|
+
integration test 'tests/integration_tests/config/plot_tabular_data_for_single_pe_data.yml'.
|
|
34
|
+
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
import logging
|
|
38
|
+
from pathlib import Path
|
|
39
|
+
|
|
40
|
+
import simtools.utils.general as gen
|
|
41
|
+
from simtools.camera.single_photon_electron_spectrum import SinglePhotonElectronSpectrum
|
|
42
|
+
from simtools.configuration import configurator
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _parse(label):
|
|
46
|
+
"""Parse command line configuration."""
|
|
47
|
+
config = configurator.Configurator(
|
|
48
|
+
label=label,
|
|
49
|
+
description="Derive single photon electron spectrum from a given amplitude spectrum.",
|
|
50
|
+
)
|
|
51
|
+
config.parser.add_argument(
|
|
52
|
+
"--input_spectrum",
|
|
53
|
+
help="File with amplitude spectrum.",
|
|
54
|
+
type=Path,
|
|
55
|
+
required=True,
|
|
56
|
+
)
|
|
57
|
+
config.parser.add_argument(
|
|
58
|
+
"--afterpulse_spectrum",
|
|
59
|
+
help="File with afterpulse spectrum.",
|
|
60
|
+
type=Path,
|
|
61
|
+
required=False,
|
|
62
|
+
)
|
|
63
|
+
config.parser.add_argument(
|
|
64
|
+
"--step_size",
|
|
65
|
+
help="Step size in amplitude spectrum",
|
|
66
|
+
type=float,
|
|
67
|
+
default=0.02,
|
|
68
|
+
required=False,
|
|
69
|
+
)
|
|
70
|
+
config.parser.add_argument(
|
|
71
|
+
"--max_amplitude",
|
|
72
|
+
help="Maximum amplitude in amplitude spectrum",
|
|
73
|
+
type=float,
|
|
74
|
+
default=42.0,
|
|
75
|
+
required=False,
|
|
76
|
+
)
|
|
77
|
+
config.parser.add_argument(
|
|
78
|
+
"--use_norm_spe",
|
|
79
|
+
help="Use sim_telarray tool 'norm_spe' to normalize the spectrum.",
|
|
80
|
+
action="store_true",
|
|
81
|
+
required=False,
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
return config.initialize(db_config=False, output=True)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def main(): # noqa: D103
|
|
88
|
+
args_dict, _ = _parse(Path(__file__).stem)
|
|
89
|
+
|
|
90
|
+
logger = logging.getLogger()
|
|
91
|
+
logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
|
|
92
|
+
|
|
93
|
+
single_pe = SinglePhotonElectronSpectrum(args_dict)
|
|
94
|
+
single_pe.derive_single_pe_spectrum()
|
|
95
|
+
single_pe.write_single_pe_spectrum()
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
if __name__ == "__main__":
|
|
99
|
+
main()
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
#!/usr/bin/python3
|
|
2
2
|
"""
|
|
3
|
-
|
|
3
|
+
Generate sim_telarray configuration files for a given array.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
The applications generates the sim_telarray configuration files for a given array, site,
|
|
6
|
+
and model_version using the model parameters stored in the database.
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
Command line arguments
|
|
9
|
+
----------------------
|
|
10
|
+
site : str
|
|
11
|
+
Site name (e.g., North, South).
|
|
12
|
+
array_layout_name : str
|
|
13
|
+
Name of the layout array (e.g., test_layout, alpha, 4mst, etc.).
|
|
14
|
+
array_element_list : list
|
|
15
|
+
List of array elements (e.g., telescopes) to plot (e.g., ``LSTN-01 LSTN-02 MSTN``).
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
Example
|
|
18
|
+
-------
|
|
19
|
+
North - 5.0.0:
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
.. code-block:: console
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
simtools-generate-array-config --site North --array_layout_name alpha --model_version 5.0.0
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
The output is saved in simtools-output/test/model.
|
|
26
26
|
"""
|
|
27
27
|
|
|
28
28
|
import logging
|