gammasimtools 0.23.0__py3-none-any.whl → 0.25.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.23.0.dist-info → gammasimtools-0.25.0.dist-info}/METADATA +1 -1
- {gammasimtools-0.23.0.dist-info → gammasimtools-0.25.0.dist-info}/RECORD +89 -85
- {gammasimtools-0.23.0.dist-info → gammasimtools-0.25.0.dist-info}/entry_points.txt +1 -0
- simtools/_version.py +2 -2
- simtools/application_control.py +54 -4
- simtools/applications/convert_geo_coordinates_of_array_elements.py +1 -1
- simtools/applications/db_add_file_to_db.py +2 -2
- simtools/applications/db_add_simulation_model_from_repository_to_db.py +1 -1
- simtools/applications/db_add_value_from_json_to_db.py +2 -2
- simtools/applications/db_development_tools/write_array_elements_positions_to_repository.py +1 -1
- simtools/applications/db_generate_compound_indexes.py +1 -1
- simtools/applications/db_get_array_layouts_from_db.py +2 -2
- 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 +4 -2
- simtools/applications/db_upload_model_repository.py +1 -1
- simtools/applications/derive_ctao_array_layouts.py +1 -1
- simtools/applications/derive_psf_parameters.py +5 -0
- simtools/applications/derive_pulse_shape_parameters.py +195 -0
- simtools/applications/generate_array_config.py +1 -1
- simtools/applications/maintain_simulation_model_add_production.py +11 -21
- simtools/applications/plot_array_layout.py +63 -1
- simtools/applications/production_generate_grid.py +1 -1
- simtools/applications/simulate_flasher.py +3 -2
- simtools/applications/simulate_pedestals.py +1 -1
- simtools/applications/simulate_prod.py +8 -23
- simtools/applications/simulate_prod_htcondor_generator.py +7 -0
- simtools/applications/submit_array_layouts.py +7 -5
- simtools/applications/validate_camera_fov.py +1 -1
- simtools/applications/validate_cumulative_psf.py +2 -2
- simtools/applications/validate_file_using_schema.py +49 -123
- simtools/applications/validate_optics.py +1 -1
- simtools/configuration/commandline_parser.py +15 -15
- simtools/configuration/configurator.py +1 -1
- simtools/corsika/corsika_config.py +199 -91
- simtools/data_model/model_data_writer.py +15 -3
- simtools/data_model/schema.py +145 -36
- simtools/data_model/validate_data.py +82 -48
- simtools/db/db_handler.py +61 -294
- simtools/db/db_model_upload.py +3 -2
- simtools/db/mongo_db.py +626 -0
- simtools/dependencies.py +38 -17
- simtools/io/eventio_handler.py +128 -0
- simtools/job_execution/htcondor_script_generator.py +0 -2
- simtools/layout/array_layout.py +7 -7
- simtools/layout/array_layout_utils.py +4 -4
- simtools/model/array_model.py +72 -72
- simtools/model/calibration_model.py +12 -9
- simtools/model/model_parameter.py +196 -160
- simtools/model/model_repository.py +176 -39
- simtools/model/model_utils.py +3 -3
- simtools/model/site_model.py +59 -27
- simtools/model/telescope_model.py +21 -13
- simtools/ray_tracing/mirror_panel_psf.py +4 -4
- simtools/ray_tracing/psf_analysis.py +11 -8
- simtools/ray_tracing/psf_parameter_optimisation.py +823 -680
- simtools/reporting/docs_auto_report_generator.py +1 -1
- simtools/reporting/docs_read_parameters.py +72 -11
- simtools/runners/corsika_runner.py +12 -3
- simtools/runners/corsika_simtel_runner.py +6 -0
- simtools/runners/runner_services.py +17 -7
- simtools/runners/simtel_runner.py +12 -54
- simtools/schemas/model_parameters/flasher_pulse_exp_decay.schema.yml +2 -0
- simtools/schemas/model_parameters/flasher_pulse_shape.schema.yml +50 -0
- simtools/schemas/model_parameters/flasher_pulse_width.schema.yml +2 -0
- simtools/schemas/simulation_models_info.schema.yml +4 -1
- simtools/simtel/pulse_shapes.py +268 -0
- simtools/simtel/simtel_config_writer.py +179 -21
- simtools/simtel/simtel_io_event_writer.py +2 -2
- simtools/simtel/simulator_array.py +58 -12
- simtools/simtel/simulator_light_emission.py +45 -8
- simtools/simulator.py +361 -346
- simtools/testing/assertions.py +110 -10
- simtools/testing/configuration.py +1 -1
- simtools/testing/log_inspector.py +4 -1
- simtools/testing/sim_telarray_metadata.py +1 -1
- simtools/testing/validate_output.py +46 -15
- simtools/utils/names.py +2 -4
- simtools/utils/value_conversion.py +10 -5
- simtools/version.py +61 -0
- simtools/visualization/legend_handlers.py +14 -4
- simtools/visualization/plot_array_layout.py +229 -33
- simtools/visualization/plot_mirrors.py +837 -0
- simtools/visualization/plot_pixels.py +1 -1
- simtools/visualization/plot_psf.py +1 -1
- simtools/visualization/plot_tables.py +1 -1
- simtools/simtel/simtel_io_file_info.py +0 -62
- {gammasimtools-0.23.0.dist-info → gammasimtools-0.25.0.dist-info}/WHEEL +0 -0
- {gammasimtools-0.23.0.dist-info → gammasimtools-0.25.0.dist-info}/licenses/LICENSE +0 -0
- {gammasimtools-0.23.0.dist-info → gammasimtools-0.25.0.dist-info}/top_level.txt +0 -0
|
@@ -3,26 +3,25 @@ r"""
|
|
|
3
3
|
Validate a file or files in a directory using a schema.
|
|
4
4
|
|
|
5
5
|
Input files can be metadata, schema, or data files in yaml, json, or ecsv format.
|
|
6
|
+
For model parameters, the schema files are taken from the simtools model parameter
|
|
7
|
+
schema directory by default.
|
|
6
8
|
|
|
7
9
|
Command line arguments
|
|
8
10
|
----------------------
|
|
9
11
|
file_name (str)
|
|
10
12
|
input file to be validated
|
|
11
|
-
|
|
13
|
+
file_directory (str)
|
|
12
14
|
directory with json files of model parameters to be validated
|
|
13
15
|
schema (str)
|
|
14
16
|
schema file (jsonschema format) used for validation
|
|
15
17
|
data_type (str)
|
|
16
|
-
type of input data (allowed types: metadata, schema, data)
|
|
17
|
-
|
|
18
|
-
Raises
|
|
19
|
-
------
|
|
20
|
-
FileNotFoundError
|
|
21
|
-
if file to be validated is not found
|
|
18
|
+
type of input data (allowed types: metadata, schema, data, model_parameter)
|
|
22
19
|
|
|
23
20
|
Example
|
|
24
21
|
-------
|
|
25
22
|
|
|
23
|
+
Validate metadata of a file:
|
|
24
|
+
|
|
26
25
|
.. code-block:: console
|
|
27
26
|
|
|
28
27
|
simtools-validate-file-using-schema \\
|
|
@@ -30,16 +29,29 @@ r"""
|
|
|
30
29
|
--schema simtools/schemas/metadata.metaschema.yml \\
|
|
31
30
|
--data_type metadata
|
|
32
31
|
|
|
33
|
-
|
|
32
|
+
Validate schema of a file:
|
|
33
|
+
|
|
34
|
+
.. code-block:: console
|
|
35
|
+
|
|
36
|
+
simtools-validate-file-using-schema \\
|
|
37
|
+
--file_name tests/resources/model_parameters/schema-0.3.0/num_gains-1.0.0.json \\
|
|
38
|
+
--schema src/simtools/schemas/model_parameter.metaschema.yml \\
|
|
39
|
+
--data_type schema
|
|
34
40
|
|
|
35
|
-
|
|
36
|
-
|
|
41
|
+
Validate all model parameter files in a directory:
|
|
42
|
+
|
|
43
|
+
.. code-block:: console
|
|
44
|
+
|
|
45
|
+
simtools-validate-file-using-schema \\
|
|
46
|
+
--file_directory tests/resources/model_parameters \\
|
|
47
|
+
--data_type model_parameter
|
|
48
|
+
|
|
49
|
+
"""
|
|
37
50
|
|
|
38
51
|
from simtools.application_control import get_application_label, startup_application
|
|
39
52
|
from simtools.configuration import configurator
|
|
40
53
|
from simtools.constants import MODEL_PARAMETER_SCHEMA_PATH
|
|
41
54
|
from simtools.data_model import metadata_collector, schema, validate_data
|
|
42
|
-
from simtools.io import ascii_handler
|
|
43
55
|
|
|
44
56
|
|
|
45
57
|
def _parse():
|
|
@@ -62,7 +74,7 @@ def _parse():
|
|
|
62
74
|
f"{MODEL_PARAMETER_SCHEMA_PATH}."
|
|
63
75
|
),
|
|
64
76
|
)
|
|
65
|
-
config.parser.add_argument("--schema", help="
|
|
77
|
+
config.parser.add_argument("--schema", help="Schema file", required=False)
|
|
66
78
|
config.parser.add_argument(
|
|
67
79
|
"--data_type",
|
|
68
80
|
help="Type of input data",
|
|
@@ -70,7 +82,7 @@ def _parse():
|
|
|
70
82
|
default="data",
|
|
71
83
|
)
|
|
72
84
|
config.parser.add_argument(
|
|
73
|
-
"--
|
|
85
|
+
"--check_exact_data_type",
|
|
74
86
|
help="Require exact data type for validation",
|
|
75
87
|
action="store_true",
|
|
76
88
|
)
|
|
@@ -82,121 +94,35 @@ def _parse():
|
|
|
82
94
|
return config.initialize(paths=False)
|
|
83
95
|
|
|
84
96
|
|
|
85
|
-
def _get_schema_file_name(args_dict, data_dict=None):
|
|
86
|
-
"""
|
|
87
|
-
Get schema file name from metadata, data dict, or from command line argument.
|
|
88
|
-
|
|
89
|
-
Parameters
|
|
90
|
-
----------
|
|
91
|
-
args_dict (dict)
|
|
92
|
-
command line arguments
|
|
93
|
-
data_dict (dict)
|
|
94
|
-
dictionary with metaschema information
|
|
95
|
-
|
|
96
|
-
Returns
|
|
97
|
-
-------
|
|
98
|
-
schema_file: str
|
|
99
|
-
schema file name
|
|
100
|
-
|
|
101
|
-
"""
|
|
102
|
-
schema_file = args_dict.get("schema")
|
|
103
|
-
if schema_file is None and data_dict is not None:
|
|
104
|
-
schema_file = data_dict.get("meta_schema_url")
|
|
105
|
-
if schema_file is None:
|
|
106
|
-
metadata = metadata_collector.MetadataCollector(
|
|
107
|
-
None, metadata_file_name=args_dict["file_name"]
|
|
108
|
-
)
|
|
109
|
-
schema_file = metadata.get_data_model_schema_file_name()
|
|
110
|
-
return schema_file
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
def _get_file_list(file_directory=None, file_name="*.json"):
|
|
114
|
-
"""Return list of files in a directory."""
|
|
115
|
-
file_list = []
|
|
116
|
-
if file_directory is not None:
|
|
117
|
-
file_list = list(Path(file_directory).rglob(file_name))
|
|
118
|
-
if not file_list:
|
|
119
|
-
raise FileNotFoundError(f"No files found in {file_directory}")
|
|
120
|
-
elif file_name is not None:
|
|
121
|
-
file_list = [file_name]
|
|
122
|
-
|
|
123
|
-
return file_list
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
def validate_dict_using_schema(args_dict, logger):
|
|
127
|
-
"""
|
|
128
|
-
Validate a schema file (or several files) given in yaml or json format.
|
|
129
|
-
|
|
130
|
-
This function validate all documents in a multi-document YAML file.
|
|
131
|
-
Schema is either given as command line argument, read from the meta_schema_url or from
|
|
132
|
-
the metadata section of the data dictionary.
|
|
133
|
-
|
|
134
|
-
"""
|
|
135
|
-
for file_name in _get_file_list(args_dict.get("file_directory"), args_dict.get("file_name")):
|
|
136
|
-
try:
|
|
137
|
-
data = ascii_handler.collect_data_from_file(file_name=file_name)
|
|
138
|
-
except FileNotFoundError as exc:
|
|
139
|
-
raise FileNotFoundError(f"Error reading schema file from {file_name}") from exc
|
|
140
|
-
data = data if isinstance(data, list) else [data]
|
|
141
|
-
try:
|
|
142
|
-
for data_dict in data:
|
|
143
|
-
schema.validate_dict_using_schema(
|
|
144
|
-
data_dict,
|
|
145
|
-
_get_schema_file_name(args_dict, data_dict),
|
|
146
|
-
ignore_software_version=args_dict.get("ignore_software_version", False),
|
|
147
|
-
)
|
|
148
|
-
except Exception as exc:
|
|
149
|
-
raise ValueError(f"Validation of file {file_name} failed") from exc
|
|
150
|
-
logger.info(f"Successful validation of file {file_name}")
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
def validate_data_files(args_dict, logger):
|
|
154
|
-
"""Validate data files."""
|
|
155
|
-
if args_dict.get("file_directory") is not None:
|
|
156
|
-
tmp_args_dict = {}
|
|
157
|
-
for file_name in _get_file_list(args_dict.get("file_directory")):
|
|
158
|
-
tmp_args_dict["file_name"] = file_name
|
|
159
|
-
parameter_name = re.sub(r"-\d+\.\d+\.\d+", "", file_name.stem)
|
|
160
|
-
schema_file = schema.get_model_parameter_schema_file(f"{parameter_name}")
|
|
161
|
-
tmp_args_dict["schema"] = schema_file
|
|
162
|
-
tmp_args_dict["data_type"] = "model_parameter"
|
|
163
|
-
tmp_args_dict["require_exact_data_type"] = args_dict["require_exact_data_type"]
|
|
164
|
-
validate_data_file(tmp_args_dict, logger)
|
|
165
|
-
else:
|
|
166
|
-
validate_data_file(args_dict, logger)
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
def validate_data_file(args_dict, logger):
|
|
170
|
-
"""Validate a data file (e.g., in ecsv, json, yaml format)."""
|
|
171
|
-
data_validator = validate_data.DataValidator(
|
|
172
|
-
schema_file=_get_schema_file_name(args_dict),
|
|
173
|
-
data_file=args_dict["file_name"],
|
|
174
|
-
check_exact_data_type=args_dict["require_exact_data_type"],
|
|
175
|
-
)
|
|
176
|
-
data_validator.validate_and_transform(
|
|
177
|
-
is_model_parameter=(args_dict["data_type"].lower() == "model_parameter")
|
|
178
|
-
)
|
|
179
|
-
|
|
180
|
-
logger.info(f"Successful validation of data file {args_dict['file_name']}")
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
def validate_metadata(args_dict, logger):
|
|
184
|
-
"""Validate metadata."""
|
|
185
|
-
# metadata_collector runs the metadata validation by default, no need to do anything else
|
|
186
|
-
metadata_collector.MetadataCollector(None, metadata_file_name=args_dict["file_name"])
|
|
187
|
-
logger.info(f"Successful validation of metadata {args_dict['file_name']}")
|
|
188
|
-
|
|
189
|
-
|
|
190
97
|
def main():
|
|
191
98
|
"""Validate a file or files in a directory using a schema."""
|
|
192
99
|
app_context = startup_application(_parse)
|
|
193
100
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
101
|
+
file_name = app_context.args.get("file_name")
|
|
102
|
+
file_directory = app_context.args.get("file_directory")
|
|
103
|
+
schema_file = app_context.args.get("schema")
|
|
104
|
+
data_type = app_context.args.get("data_type").lower()
|
|
105
|
+
|
|
106
|
+
if data_type == "metadata":
|
|
107
|
+
# metadata_collector runs the metadata validation by default, no need to do anything else
|
|
108
|
+
metadata_collector.MetadataCollector(None, metadata_file_name=file_name)
|
|
109
|
+
app_context.logger.info(f"Successful validation of metadata {file_name}")
|
|
110
|
+
|
|
111
|
+
elif data_type == "schema":
|
|
112
|
+
schema.validate_schema_from_files(
|
|
113
|
+
file_directory=file_directory,
|
|
114
|
+
file_name=file_name,
|
|
115
|
+
schema_file=schema_file,
|
|
116
|
+
ignore_software_version=app_context.args.get("ignore_software_version", False),
|
|
117
|
+
)
|
|
198
118
|
else:
|
|
199
|
-
validate_data_files(
|
|
119
|
+
validate_data.DataValidator.validate_data_files(
|
|
120
|
+
file_name=file_name,
|
|
121
|
+
file_directory=file_directory,
|
|
122
|
+
is_model_parameter=(data_type == "model_parameter"),
|
|
123
|
+
check_exact_data_type=app_context.args.get("check_exact_data_type", False),
|
|
124
|
+
schema_file=schema_file,
|
|
125
|
+
)
|
|
200
126
|
|
|
201
127
|
|
|
202
128
|
if __name__ == "__main__":
|
|
@@ -137,7 +137,7 @@ def main():
|
|
|
137
137
|
# 'camera_body_diameter': 289.7,
|
|
138
138
|
# 'telescope_transmission': 1
|
|
139
139
|
# }
|
|
140
|
-
# tel_model.
|
|
140
|
+
# tel_model.overwrite_parameters(pars_to_change)
|
|
141
141
|
|
|
142
142
|
app_context.logger.info(
|
|
143
143
|
f"\nValidating telescope optics with ray tracing simulations for {tel_model.name}\n"
|
|
@@ -250,6 +250,13 @@ class CommandLineParser(argparse.ArgumentParser):
|
|
|
250
250
|
type=str,
|
|
251
251
|
default=None,
|
|
252
252
|
)
|
|
253
|
+
_job_group.add_argument(
|
|
254
|
+
"--overwrite_model_parameters",
|
|
255
|
+
help="File name to overwrite model parameters from DB with provided values",
|
|
256
|
+
type=str,
|
|
257
|
+
required=False,
|
|
258
|
+
)
|
|
259
|
+
|
|
253
260
|
if any(
|
|
254
261
|
option in model_options for option in ["site", "telescope", "layout", "layout_file"]
|
|
255
262
|
):
|
|
@@ -261,15 +268,6 @@ class CommandLineParser(argparse.ArgumentParser):
|
|
|
261
268
|
help="telescope model name (e.g., LSTN-01, SSTS-design, ...)",
|
|
262
269
|
type=self.telescope,
|
|
263
270
|
)
|
|
264
|
-
_job_group.add_argument(
|
|
265
|
-
"--telescope_model_file",
|
|
266
|
-
help=(
|
|
267
|
-
"Path to a YAML file containing modifications to the telescope model. "
|
|
268
|
-
"This feature is intended for developers and lacks validation."
|
|
269
|
-
),
|
|
270
|
-
type=Path,
|
|
271
|
-
required=False,
|
|
272
|
-
)
|
|
273
271
|
if "layout" in model_options or "layout_file" in model_options:
|
|
274
272
|
_job_group = self._add_model_option_layout(
|
|
275
273
|
job_group=_job_group,
|
|
@@ -379,12 +377,6 @@ class CommandLineParser(argparse.ArgumentParser):
|
|
|
379
377
|
"required": True,
|
|
380
378
|
"default": 1,
|
|
381
379
|
},
|
|
382
|
-
"number_of_runs": {
|
|
383
|
-
"help": "Number of runs to be simulated.",
|
|
384
|
-
"type": int,
|
|
385
|
-
"required": True,
|
|
386
|
-
"default": 1,
|
|
387
|
-
},
|
|
388
380
|
"event_number_first_shower": {
|
|
389
381
|
"help": "Event number of first shower",
|
|
390
382
|
"type": int,
|
|
@@ -397,6 +389,14 @@ class CommandLineParser(argparse.ArgumentParser):
|
|
|
397
389
|
"required": False,
|
|
398
390
|
"default": True,
|
|
399
391
|
},
|
|
392
|
+
"curved_atmosphere_min_zenith_angle": {
|
|
393
|
+
"help": (
|
|
394
|
+
"Minimum zenith angle (deg) for using curved-atmosphere CORSIKA binaries. "
|
|
395
|
+
),
|
|
396
|
+
"type": CommandLineParser.zenith_angle,
|
|
397
|
+
"required": False,
|
|
398
|
+
"default": 65 * u.deg,
|
|
399
|
+
},
|
|
400
400
|
}
|
|
401
401
|
|
|
402
402
|
@staticmethod
|
|
@@ -10,7 +10,7 @@ import astropy.units as u
|
|
|
10
10
|
from dotenv import load_dotenv
|
|
11
11
|
|
|
12
12
|
import simtools.configuration.commandline_parser as argparser
|
|
13
|
-
from simtools.db.
|
|
13
|
+
from simtools.db.mongo_db import jsonschema_db_dict
|
|
14
14
|
from simtools.io import ascii_handler, io_handler
|
|
15
15
|
from simtools.utils import general as gen
|
|
16
16
|
|