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
simtools/utils/names.py
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
import logging
|
|
4
4
|
import re
|
|
5
5
|
from functools import cache
|
|
6
|
-
from importlib.resources import files
|
|
7
6
|
from pathlib import Path
|
|
8
7
|
|
|
9
8
|
import yaml
|
|
10
9
|
|
|
10
|
+
from simtools.constants import MODEL_PARAMETER_SCHEMA_PATH, SCHEMA_PATH
|
|
11
|
+
|
|
11
12
|
_logger = logging.getLogger(__name__)
|
|
12
13
|
|
|
13
14
|
__all__ = [
|
|
@@ -34,7 +35,7 @@ def array_elements():
|
|
|
34
35
|
dict
|
|
35
36
|
Array elements.
|
|
36
37
|
"""
|
|
37
|
-
with open(
|
|
38
|
+
with open(Path(SCHEMA_PATH) / "array_elements.yml", encoding="utf-8") as file:
|
|
38
39
|
return yaml.safe_load(file)["data"]
|
|
39
40
|
|
|
40
41
|
|
|
@@ -59,7 +60,7 @@ def site_names():
|
|
|
59
60
|
@cache
|
|
60
61
|
def load_model_parameters(class_key_list):
|
|
61
62
|
model_parameters = {}
|
|
62
|
-
schema_files = list(Path(
|
|
63
|
+
schema_files = list(Path(MODEL_PARAMETER_SCHEMA_PATH).rglob("*.yml"))
|
|
63
64
|
for schema_file in schema_files:
|
|
64
65
|
with open(schema_file, encoding="utf-8") as f:
|
|
65
66
|
data = yaml.safe_load(f)
|
|
@@ -293,7 +294,7 @@ def get_site_from_array_element_name(name):
|
|
|
293
294
|
return array_elements()[get_array_element_type_from_name(name)]["site"]
|
|
294
295
|
|
|
295
296
|
|
|
296
|
-
def get_collection_name_from_array_element_name(name):
|
|
297
|
+
def get_collection_name_from_array_element_name(name, array_elements_only=True):
|
|
297
298
|
"""
|
|
298
299
|
Get collection name (e.g., telescopes, calibration_devices, sites) of array element from name.
|
|
299
300
|
|
|
@@ -301,6 +302,8 @@ def get_collection_name_from_array_element_name(name):
|
|
|
301
302
|
----------
|
|
302
303
|
name: str
|
|
303
304
|
Array element name.
|
|
305
|
+
array_elements_only: bool
|
|
306
|
+
If True, only array elements are considered.
|
|
304
307
|
|
|
305
308
|
Returns
|
|
306
309
|
-------
|
|
@@ -311,18 +314,28 @@ def get_collection_name_from_array_element_name(name):
|
|
|
311
314
|
return array_elements()[get_array_element_type_from_name(name)]["collection"]
|
|
312
315
|
except ValueError:
|
|
313
316
|
pass
|
|
317
|
+
if name.startswith("OBS"):
|
|
318
|
+
return "sites"
|
|
314
319
|
try:
|
|
315
320
|
validate_site_name(name)
|
|
316
321
|
return "sites"
|
|
317
322
|
except ValueError as exc:
|
|
318
|
-
|
|
323
|
+
if array_elements_only:
|
|
324
|
+
raise ValueError(f"Invalid array element name {name}") from exc
|
|
325
|
+
if name in (
|
|
326
|
+
"configuration_sim_telarray",
|
|
327
|
+
"configuration_corsika",
|
|
328
|
+
"Files",
|
|
329
|
+
"Dummy-Telescope",
|
|
330
|
+
):
|
|
331
|
+
return name
|
|
332
|
+
|
|
333
|
+
raise ValueError(f"Invalid array element name {name}")
|
|
319
334
|
|
|
320
335
|
|
|
321
336
|
def get_simulation_software_name_from_parameter_name(
|
|
322
337
|
par_name,
|
|
323
338
|
simulation_software="sim_telarray",
|
|
324
|
-
search_telescope_parameters=True,
|
|
325
|
-
search_site_parameters=True,
|
|
326
339
|
):
|
|
327
340
|
"""
|
|
328
341
|
Get the name used in the simulation software from the model parameter name.
|
|
@@ -336,21 +349,13 @@ def get_simulation_software_name_from_parameter_name(
|
|
|
336
349
|
Model parameter name.
|
|
337
350
|
simulation_software: str
|
|
338
351
|
Simulation software name.
|
|
339
|
-
search_telescope_parameters: bool
|
|
340
|
-
If True, telescope model parameters are included.
|
|
341
|
-
search_site_parameters: bool
|
|
342
|
-
If True, site model parameters are included.
|
|
343
352
|
|
|
344
353
|
Returns
|
|
345
354
|
-------
|
|
346
355
|
str
|
|
347
356
|
Simtel parameter name.
|
|
348
357
|
"""
|
|
349
|
-
_parameter_names = {}
|
|
350
|
-
if search_telescope_parameters:
|
|
351
|
-
_parameter_names.update(telescope_parameters())
|
|
352
|
-
if search_site_parameters:
|
|
353
|
-
_parameter_names.update(site_parameters())
|
|
358
|
+
_parameter_names = {**telescope_parameters(), **site_parameters()}
|
|
354
359
|
|
|
355
360
|
try:
|
|
356
361
|
_parameter = _parameter_names[par_name]
|
|
@@ -575,12 +580,11 @@ def sanitize_name(name):
|
|
|
575
580
|
ValueError:
|
|
576
581
|
if the string name can not be sanitized.
|
|
577
582
|
"""
|
|
578
|
-
|
|
583
|
+
if name is None:
|
|
584
|
+
# _logger.info("The string is None and can't be sanitized.")
|
|
585
|
+
return name
|
|
579
586
|
sanitized = name.lower()
|
|
580
|
-
|
|
581
|
-
# Replace spaces with underscores
|
|
582
587
|
sanitized = sanitized.replace(" ", "_")
|
|
583
|
-
|
|
584
588
|
# Remove characters that are not alphanumerics or underscores
|
|
585
589
|
sanitized = re.sub(r"\W|^(?=\d)", "_", sanitized)
|
|
586
590
|
if not sanitized.isidentifier():
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/python3
|
|
2
|
-
r"""
|
|
3
|
-
Add parameters found in a model parameter repository to a new database.
|
|
4
|
-
|
|
5
|
-
Generates a new database with all required collections.
|
|
6
|
-
Follows the structure of the CTAO gitlab model parameters repository.
|
|
7
|
-
file as input.
|
|
8
|
-
|
|
9
|
-
This is an application for experts and should not be used by the general user.
|
|
10
|
-
|
|
11
|
-
Command line arguments
|
|
12
|
-
|
|
13
|
-
input_path (str, required)
|
|
14
|
-
Path of local copy of model parameter repository.
|
|
15
|
-
db_name (str, required)
|
|
16
|
-
Name of new DB to be created.
|
|
17
|
-
type (str, optional)
|
|
18
|
-
Type of data to be uploaded to the DB. Options are: model_parameters
|
|
19
|
-
|
|
20
|
-
Examples
|
|
21
|
-
--------
|
|
22
|
-
Upload model data repository to the DB:
|
|
23
|
-
|
|
24
|
-
.. code-block:: console
|
|
25
|
-
|
|
26
|
-
simtools-db-add_model-parameters-from-repository-to-db \
|
|
27
|
-
--input_path /path/to/repository \
|
|
28
|
-
--db_name new_db_name \
|
|
29
|
-
--type model_parameters
|
|
30
|
-
"""
|
|
31
|
-
|
|
32
|
-
import logging
|
|
33
|
-
from pathlib import Path
|
|
34
|
-
|
|
35
|
-
import simtools.utils.general as gen
|
|
36
|
-
from simtools.configuration import configurator
|
|
37
|
-
from simtools.db import db_handler
|
|
38
|
-
from simtools.utils import names
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
def _parse(label=None, description=None):
|
|
42
|
-
"""
|
|
43
|
-
Parse command line configuration.
|
|
44
|
-
|
|
45
|
-
Parameters
|
|
46
|
-
----------
|
|
47
|
-
label : str
|
|
48
|
-
Label describing application.
|
|
49
|
-
description : str
|
|
50
|
-
Description of application.
|
|
51
|
-
|
|
52
|
-
Returns
|
|
53
|
-
-------
|
|
54
|
-
CommandLineParser
|
|
55
|
-
Command line parser object.
|
|
56
|
-
"""
|
|
57
|
-
config = configurator.Configurator(label=label, description=description)
|
|
58
|
-
config.parser.add_argument(
|
|
59
|
-
"--input_path",
|
|
60
|
-
help="Path to model parameter repository.",
|
|
61
|
-
type=Path,
|
|
62
|
-
required=True,
|
|
63
|
-
)
|
|
64
|
-
config.parser.add_argument(
|
|
65
|
-
"--db_name",
|
|
66
|
-
help="Name of the new model parameter database to be created.",
|
|
67
|
-
type=str.strip,
|
|
68
|
-
required=True,
|
|
69
|
-
)
|
|
70
|
-
config.parser.add_argument(
|
|
71
|
-
"--type",
|
|
72
|
-
help="Type of data to be uploaded to the database.",
|
|
73
|
-
type=str,
|
|
74
|
-
required=False,
|
|
75
|
-
default="model_parameters",
|
|
76
|
-
choices=["model_parameters"],
|
|
77
|
-
)
|
|
78
|
-
|
|
79
|
-
args_dict, db_config = config.initialize(
|
|
80
|
-
output=True, require_command_line=True, db_config=True, simulation_model="version"
|
|
81
|
-
)
|
|
82
|
-
db_config["db_simulation_model"] = args_dict["db_name"] # overwrite explicitly DB configuration
|
|
83
|
-
return args_dict, db_config
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
def add_values_from_json_to_db(file, collection, db, db_name, file_prefix, logger):
|
|
87
|
-
"""
|
|
88
|
-
Upload data from json files to db.
|
|
89
|
-
|
|
90
|
-
Parameters
|
|
91
|
-
----------
|
|
92
|
-
file : list
|
|
93
|
-
Json file to be uploaded to the DB.
|
|
94
|
-
collection : str
|
|
95
|
-
The DB collection to which to add the file.
|
|
96
|
-
db : DatabaseHandler
|
|
97
|
-
Database handler object.
|
|
98
|
-
db_name : str
|
|
99
|
-
Name of the database to be created.
|
|
100
|
-
file_prefix : str
|
|
101
|
-
Path to location of all additional files to be uploaded.
|
|
102
|
-
logger : logging.Logger
|
|
103
|
-
Logger object.
|
|
104
|
-
"""
|
|
105
|
-
par_dict = gen.collect_data_from_file(file_name=file)
|
|
106
|
-
logger.info(
|
|
107
|
-
f"Adding the following parameter to the DB: {par_dict['parameter']} "
|
|
108
|
-
f"(collection {collection} in database {db_name})"
|
|
109
|
-
)
|
|
110
|
-
db.add_new_parameter(
|
|
111
|
-
db_name=db_name,
|
|
112
|
-
par_dict=par_dict,
|
|
113
|
-
collection_name=collection,
|
|
114
|
-
file_prefix=file_prefix,
|
|
115
|
-
)
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
def _add_model_parameters_to_db(args_dict, db, logger):
|
|
119
|
-
"""
|
|
120
|
-
Add model parameters to the DB.
|
|
121
|
-
|
|
122
|
-
Parameters
|
|
123
|
-
----------
|
|
124
|
-
args_dict : dict
|
|
125
|
-
Command line arguments.
|
|
126
|
-
db : DatabaseHandler
|
|
127
|
-
Database handler object.
|
|
128
|
-
logger : logging.Logger
|
|
129
|
-
Logger object.
|
|
130
|
-
|
|
131
|
-
"""
|
|
132
|
-
input_path = Path(args_dict["input_path"])
|
|
133
|
-
array_elements = [d for d in input_path.iterdir() if d.is_dir()]
|
|
134
|
-
for element in array_elements:
|
|
135
|
-
try:
|
|
136
|
-
collection = names.get_collection_name_from_array_element_name(element.name)
|
|
137
|
-
except ValueError:
|
|
138
|
-
if element.name.startswith("OBS"):
|
|
139
|
-
collection = "sites"
|
|
140
|
-
elif element.name in {"configuration_sim_telarray", "configuration_corsika"}:
|
|
141
|
-
collection = element.name
|
|
142
|
-
elif element.name == "Files":
|
|
143
|
-
logger.info("Files are uploaded with the corresponding model parameters")
|
|
144
|
-
continue
|
|
145
|
-
logger.info(f"Reading model parameters for {element.name} into collection {collection}")
|
|
146
|
-
files_to_insert = list(Path(element).rglob("*json"))
|
|
147
|
-
for file in files_to_insert:
|
|
148
|
-
if collection == "files":
|
|
149
|
-
logger.info("Not yet implemented files")
|
|
150
|
-
else:
|
|
151
|
-
add_values_from_json_to_db(
|
|
152
|
-
file=file,
|
|
153
|
-
collection=collection,
|
|
154
|
-
db=db,
|
|
155
|
-
db_name=args_dict["db_name"],
|
|
156
|
-
file_prefix=input_path / "Files",
|
|
157
|
-
logger=logger,
|
|
158
|
-
)
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
def main():
|
|
162
|
-
"""Application main."""
|
|
163
|
-
label = Path(__file__).stem
|
|
164
|
-
args_dict, db_config = _parse(
|
|
165
|
-
label, description="Add or update a model parameter database to the DB"
|
|
166
|
-
)
|
|
167
|
-
logger = logging.getLogger()
|
|
168
|
-
logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
|
|
169
|
-
|
|
170
|
-
db = db_handler.DatabaseHandler(mongo_db_config=db_config)
|
|
171
|
-
|
|
172
|
-
_add_model_parameters_to_db(args_dict, db, logger)
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
if __name__ == "__main__":
|
|
176
|
-
main()
|
simtools/db/db_array_elements.py
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
"""Retrieval of array elements from the database."""
|
|
2
|
-
|
|
3
|
-
from functools import lru_cache
|
|
4
|
-
|
|
5
|
-
from pymongo import ASCENDING
|
|
6
|
-
|
|
7
|
-
from simtools.utils import names
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
@lru_cache
|
|
11
|
-
def get_array_elements(db_collection, model_version):
|
|
12
|
-
"""
|
|
13
|
-
Get all array element names and their design model for a given DB collection.
|
|
14
|
-
|
|
15
|
-
Uses the 'design_model' parameter to determine the design model of the array element.
|
|
16
|
-
Assumes that a design model is defined for every array element.
|
|
17
|
-
|
|
18
|
-
Parameters
|
|
19
|
-
----------
|
|
20
|
-
db_collection:
|
|
21
|
-
pymongo.collection.Collection
|
|
22
|
-
model_version: str
|
|
23
|
-
Model version.
|
|
24
|
-
|
|
25
|
-
Returns
|
|
26
|
-
-------
|
|
27
|
-
dict
|
|
28
|
-
Dict with array element names found and their design model
|
|
29
|
-
|
|
30
|
-
Raises
|
|
31
|
-
------
|
|
32
|
-
ValueError
|
|
33
|
-
If query for collection name not implemented.
|
|
34
|
-
KeyError
|
|
35
|
-
If array element entry in the database is incomplete.
|
|
36
|
-
|
|
37
|
-
"""
|
|
38
|
-
query = {"version": model_version}
|
|
39
|
-
results = db_collection.find(query, {"instrument": 1, "value": 1, "parameter": 1}).sort(
|
|
40
|
-
"instrument", ASCENDING
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
_all_available_array_elements = {}
|
|
44
|
-
for doc in results:
|
|
45
|
-
try:
|
|
46
|
-
if doc["parameter"] == "design_model":
|
|
47
|
-
_all_available_array_elements[doc["instrument"]] = doc["value"]
|
|
48
|
-
except KeyError as exc:
|
|
49
|
-
raise KeyError(f"Incomplete array element entry in the database: {doc}.") from exc
|
|
50
|
-
|
|
51
|
-
if len(_all_available_array_elements) == 0:
|
|
52
|
-
raise ValueError(f"No array elements found in DB collection {db_collection}.")
|
|
53
|
-
|
|
54
|
-
return _all_available_array_elements
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
def get_array_element_list_for_db_query(array_element_name, db, model_version, collection):
|
|
58
|
-
"""
|
|
59
|
-
Get array element name and design model for querying the database.
|
|
60
|
-
|
|
61
|
-
Return a list of array element names to be used for querying the database for a given array
|
|
62
|
-
element. This is in most cases the array element itself and its design model.
|
|
63
|
-
In cases of no design model available, the design model of the array element is returned.
|
|
64
|
-
|
|
65
|
-
Parameters
|
|
66
|
-
----------
|
|
67
|
-
array_element_name: str
|
|
68
|
-
Name of the array element model (e.g. MSTN-01).
|
|
69
|
-
db: DBHandler
|
|
70
|
-
Instance of the database handler
|
|
71
|
-
model_version: str
|
|
72
|
-
Model version.
|
|
73
|
-
collection: str
|
|
74
|
-
DB collection to get the array elements from (e.g., telescopes, calibration_devices)
|
|
75
|
-
|
|
76
|
-
Returns
|
|
77
|
-
-------
|
|
78
|
-
list
|
|
79
|
-
List of array element model names as used in the DB.
|
|
80
|
-
|
|
81
|
-
"""
|
|
82
|
-
try:
|
|
83
|
-
_available_array_elements = get_array_elements(
|
|
84
|
-
db.get_collection(db_name=None, collection_name=collection),
|
|
85
|
-
db.model_version(model_version),
|
|
86
|
-
)
|
|
87
|
-
except ValueError:
|
|
88
|
-
return [names.get_array_element_type_from_name(array_element_name) + "-design"]
|
|
89
|
-
try:
|
|
90
|
-
return [_available_array_elements[array_element_name], array_element_name]
|
|
91
|
-
except KeyError:
|
|
92
|
-
pass
|
|
93
|
-
|
|
94
|
-
if array_element_name in _available_array_elements.values():
|
|
95
|
-
return [array_element_name]
|
|
96
|
-
|
|
97
|
-
raise ValueError(f"Array element {array_element_name} not found in DB.")
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
def get_array_elements_of_type(array_element_type, db, model_version, collection):
|
|
101
|
-
"""
|
|
102
|
-
Get all array elements of a certain type in the specified collection in the DB.
|
|
103
|
-
|
|
104
|
-
Return e.g. for array_element_type='MSTS' all MSTS array elements found in the collection.
|
|
105
|
-
|
|
106
|
-
Parameters
|
|
107
|
-
----------
|
|
108
|
-
array_element_type : str
|
|
109
|
-
Type of the array element (e.g. LSTN, MSTS)
|
|
110
|
-
model_version : str
|
|
111
|
-
Which version to get the array elements of
|
|
112
|
-
collection : str
|
|
113
|
-
Which collection to get the array elements from:
|
|
114
|
-
i.e. telescopes, calibration_devices
|
|
115
|
-
db_name : str
|
|
116
|
-
Database name
|
|
117
|
-
|
|
118
|
-
Returns
|
|
119
|
-
-------
|
|
120
|
-
list
|
|
121
|
-
Sorted list of all array element names found in collection
|
|
122
|
-
|
|
123
|
-
"""
|
|
124
|
-
_available_array_elements = get_array_elements(
|
|
125
|
-
db.get_collection(db_name=None, collection_name=collection),
|
|
126
|
-
db.model_version(model_version),
|
|
127
|
-
)
|
|
128
|
-
return sorted(
|
|
129
|
-
[entry for entry in _available_array_elements if entry.startswith(array_element_type)]
|
|
130
|
-
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|