gammasimtools 0.9.0__py3-none-any.whl → 0.11.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.11.0.dist-info}/METADATA +4 -2
- {gammasimtools-0.9.0.dist-info → gammasimtools-0.11.0.dist-info}/RECORD +133 -117
- {gammasimtools-0.9.0.dist-info → gammasimtools-0.11.0.dist-info}/WHEEL +1 -1
- {gammasimtools-0.9.0.dist-info → gammasimtools-0.11.0.dist-info}/entry_points.txt +6 -1
- simtools/_version.py +9 -4
- simtools/applications/calculate_trigger_rate.py +15 -38
- simtools/applications/convert_all_model_parameters_from_simtel.py +9 -29
- simtools/applications/convert_geo_coordinates_of_array_elements.py +47 -45
- simtools/applications/convert_model_parameter_from_simtel.py +2 -3
- simtools/applications/db_add_file_to_db.py +1 -3
- 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 +26 -35
- simtools/applications/derive_mirror_rnda.py +1 -2
- simtools/applications/derive_photon_electron_spectrum.py +99 -0
- simtools/applications/derive_psf_parameters.py +1 -0
- simtools/applications/docs_produce_array_element_report.py +71 -0
- simtools/applications/docs_produce_model_parameter_reports.py +63 -0
- simtools/applications/generate_array_config.py +17 -17
- simtools/applications/generate_corsika_histograms.py +2 -2
- simtools/applications/generate_regular_arrays.py +19 -17
- simtools/applications/generate_simtel_array_histograms.py +11 -48
- simtools/applications/production_derive_limits.py +95 -0
- simtools/applications/production_generate_simulation_config.py +37 -33
- simtools/applications/production_scale_events.py +4 -9
- simtools/applications/run_application.py +165 -0
- simtools/applications/simulate_light_emission.py +0 -4
- 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 +18 -11
- simtools/applications/validate_camera_efficiency.py +2 -2
- simtools/applications/validate_file_using_schema.py +26 -22
- simtools/camera/single_photon_electron_spectrum.py +168 -0
- simtools/configuration/commandline_parser.py +37 -1
- simtools/configuration/configurator.py +8 -10
- simtools/constants.py +10 -3
- simtools/corsika/corsika_config.py +19 -17
- simtools/corsika/corsika_histograms.py +5 -7
- simtools/corsika/corsika_histograms_visualize.py +2 -4
- simtools/data_model/data_reader.py +0 -3
- simtools/data_model/metadata_collector.py +20 -12
- simtools/data_model/metadata_model.py +8 -124
- simtools/data_model/model_data_writer.py +81 -75
- simtools/data_model/schema.py +220 -0
- simtools/data_model/validate_data.py +79 -68
- simtools/db/db_handler.py +350 -492
- simtools/db/db_model_upload.py +139 -0
- simtools/dependencies.py +112 -0
- simtools/io_operations/hdf5_handler.py +54 -24
- simtools/layout/array_layout.py +38 -32
- simtools/model/array_model.py +13 -7
- simtools/model/model_parameter.py +55 -54
- simtools/model/site_model.py +2 -2
- simtools/production_configuration/calculate_statistical_errors_grid_point.py +119 -145
- simtools/production_configuration/event_scaler.py +9 -35
- simtools/production_configuration/generate_simulation_config.py +9 -44
- simtools/production_configuration/interpolation_handler.py +9 -15
- simtools/production_configuration/limits_calculation.py +202 -0
- simtools/reporting/docs_read_parameters.py +310 -0
- simtools/runners/corsika_simtel_runner.py +4 -4
- simtools/schemas/{integration_tests_config.metaschema.yml → application_workflow.metaschema.yml} +61 -27
- simtools/schemas/array_elements.yml +8 -0
- simtools/schemas/input/MST_mirror_2f_measurements.schema.yml +39 -0
- simtools/schemas/input/single_pe_spectrum.schema.yml +38 -0
- simtools/schemas/model_parameter.metaschema.yml +103 -2
- simtools/schemas/model_parameter_and_data_schema.metaschema.yml +4 -1
- 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/correct_nsb_spectrum_to_telescope_altitude.schema.yml +1 -1
- simtools/schemas/model_parameters/corsika_cherenkov_photon_bunch_size.schema.yml +2 -0
- simtools/schemas/model_parameters/corsika_cherenkov_photon_wavelength_range.schema.yml +2 -0
- simtools/schemas/model_parameters/corsika_first_interaction_height.schema.yml +2 -0
- simtools/schemas/model_parameters/corsika_iact_io_buffer.schema.yml +4 -2
- simtools/schemas/model_parameters/corsika_iact_max_bunches.schema.yml +2 -0
- simtools/schemas/model_parameters/corsika_iact_split_auto.schema.yml +2 -0
- simtools/schemas/model_parameters/corsika_longitudinal_shower_development.schema.yml +2 -0
- simtools/schemas/model_parameters/corsika_particle_kinetic_energy_cutoff.schema.yml +2 -0
- simtools/schemas/model_parameters/corsika_starting_grammage.schema.yml +2 -0
- 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/iobuf_maximum.schema.yml +1 -1
- simtools/schemas/model_parameters/iobuf_output_maximum.schema.yml +1 -1
- simtools/schemas/model_parameters/laser_photons.schema.yml +2 -2
- simtools/schemas/model_parameters/lightguide_efficiency_vs_incidence_angle.schema.yml +1 -1
- simtools/schemas/model_parameters/lightguide_efficiency_vs_wavelength.schema.yml +1 -1
- simtools/schemas/model_parameters/min_photoelectrons.schema.yml +1 -1
- simtools/schemas/model_parameters/min_photons.schema.yml +1 -1
- simtools/schemas/model_parameters/random_generator.schema.yml +1 -1
- simtools/schemas/model_parameters/sampled_output.schema.yml +1 -1
- simtools/schemas/model_parameters/save_pe_with_amplitude.schema.yml +1 -1
- simtools/schemas/model_parameters/secondary_mirror_degraded_reflection.schema.yml +1 -1
- simtools/schemas/model_parameters/store_photoelectrons.schema.yml +1 -1
- simtools/schemas/model_parameters/tailcut_scale.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_reader.py +1 -2
- simtools/simtel/simtel_config_writer.py +6 -8
- simtools/simtel/simtel_io_histogram.py +32 -68
- simtools/simtel/simtel_io_histograms.py +17 -34
- simtools/simtel/simulator_array.py +2 -1
- simtools/simtel/simulator_camera_efficiency.py +6 -3
- simtools/simtel/simulator_light_emission.py +5 -6
- simtools/simtel/simulator_ray_tracing.py +3 -4
- simtools/testing/configuration.py +2 -1
- simtools/testing/helpers.py +6 -13
- simtools/testing/validate_output.py +141 -47
- simtools/utils/general.py +114 -14
- simtools/utils/names.py +299 -157
- simtools/utils/value_conversion.py +17 -13
- simtools/version.py +2 -2
- simtools/visualization/legend_handlers.py +2 -0
- 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.11.0.dist-info}/LICENSE +0 -0
- {gammasimtools-0.9.0.dist-info → gammasimtools-0.11.0.dist-info}/top_level.txt +0 -0
- /simtools/{camera_efficiency.py → camera/camera_efficiency.py} +0 -0
|
@@ -73,7 +73,7 @@ def _parse(label, description):
|
|
|
73
73
|
|
|
74
74
|
config.parser.add_argument(
|
|
75
75
|
"--simtel_file_names",
|
|
76
|
-
help="Name of the simtel_array output files to be calculate the trigger rate from
|
|
76
|
+
help="Name of the simtel_array output files to be calculate the trigger rate from or the "
|
|
77
77
|
"text file containing the list of simtel_array output files.",
|
|
78
78
|
nargs="+",
|
|
79
79
|
required=True,
|
|
@@ -82,19 +82,19 @@ def _parse(label, description):
|
|
|
82
82
|
|
|
83
83
|
config.parser.add_argument(
|
|
84
84
|
"--save_tables",
|
|
85
|
-
help="
|
|
85
|
+
help="Save trigger rates per energy bin into ECSV files.",
|
|
86
86
|
action="store_true",
|
|
87
87
|
)
|
|
88
88
|
|
|
89
89
|
config.parser.add_argument(
|
|
90
90
|
"--area_from_distribution",
|
|
91
|
-
help="
|
|
91
|
+
help="Calculate trigger rates using the event distribution.",
|
|
92
92
|
action="store_true",
|
|
93
93
|
)
|
|
94
94
|
|
|
95
95
|
config.parser.add_argument(
|
|
96
96
|
"--stack_files",
|
|
97
|
-
help="
|
|
97
|
+
help="Stacks all histograms.",
|
|
98
98
|
action="store_true",
|
|
99
99
|
)
|
|
100
100
|
|
|
@@ -124,22 +124,13 @@ def _get_simulation_parameters(config_parser):
|
|
|
124
124
|
The view cone used in the simulation.
|
|
125
125
|
|
|
126
126
|
"""
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if config_parser["view_cone"] is not None:
|
|
135
|
-
view_cone = [
|
|
136
|
-
config_parser["view_cone"][0].to("deg").value,
|
|
137
|
-
config_parser["view_cone"][1].to("deg").value,
|
|
138
|
-
]
|
|
139
|
-
else:
|
|
140
|
-
view_cone = None
|
|
141
|
-
|
|
142
|
-
return energy_range, view_cone
|
|
127
|
+
|
|
128
|
+
def convert(param, unit):
|
|
129
|
+
return [param[0].to(unit).value, param[1].to(unit).value] if param else None
|
|
130
|
+
|
|
131
|
+
return convert(config_parser.get("energy_range"), "TeV"), convert(
|
|
132
|
+
config_parser.get("view_cone"), "deg"
|
|
133
|
+
)
|
|
143
134
|
|
|
144
135
|
|
|
145
136
|
def main(): # noqa: D103
|
|
@@ -152,23 +143,9 @@ def main(): # noqa: D103
|
|
|
152
143
|
logger = logging.getLogger()
|
|
153
144
|
logger.setLevel(gen.get_log_level_from_user(config_parser["log_level"]))
|
|
154
145
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
try:
|
|
159
|
-
if Path(one_file).suffix in [".zst", ".simtel", ".hdata"]:
|
|
160
|
-
simtel_array_files.append(one_file)
|
|
161
|
-
else:
|
|
162
|
-
# Collecting hist files
|
|
163
|
-
with open(one_file, encoding="utf-8") as file:
|
|
164
|
-
for line in file:
|
|
165
|
-
# Removing '\n' from filename, in case it is left there.
|
|
166
|
-
simtel_array_files.append(line.replace("\n", ""))
|
|
167
|
-
except FileNotFoundError as exc:
|
|
168
|
-
msg = f"{one_file} is not a file."
|
|
169
|
-
logger.error(msg)
|
|
170
|
-
raise FileNotFoundError from exc
|
|
171
|
-
|
|
146
|
+
simtel_array_files = gen.get_list_of_files_from_command_line(
|
|
147
|
+
config_parser["simtel_file_names"], [".zst", ".simtel", ".hdata"]
|
|
148
|
+
)
|
|
172
149
|
energy_range, view_cone = _get_simulation_parameters(config_parser)
|
|
173
150
|
|
|
174
151
|
histograms = SimtelIOHistograms(
|
|
@@ -192,7 +169,7 @@ def main(): # noqa: D103
|
|
|
192
169
|
for i_hist, _ in enumerate(sim_event_rates):
|
|
193
170
|
print(f"\nFile {histograms.histogram_files[i_hist]}\n")
|
|
194
171
|
print(
|
|
195
|
-
f"System trigger rate (Hz): {triggered_event_rates[i_hist].value:.4e} \
|
|
172
|
+
f"System trigger rate (Hz): {triggered_event_rates[i_hist].value:.4e} \u00b1 "
|
|
196
173
|
f"{triggered_event_rate_uncertainties[i_hist].value:.4e} Hz"
|
|
197
174
|
)
|
|
198
175
|
if config_parser["save_tables"]:
|
|
@@ -6,6 +6,8 @@ r"""
|
|
|
6
6
|
ready to be submitted to the model database. Prints out parameters which are not found
|
|
7
7
|
in simtel configuration file and parameters which are not found in simtools schema files.
|
|
8
8
|
|
|
9
|
+
Note that all parameters are assigned the same parameter version.
|
|
10
|
+
|
|
9
11
|
Command line arguments
|
|
10
12
|
----------------------
|
|
11
13
|
simtel_cfg_file (str)
|
|
@@ -30,7 +32,7 @@ r"""
|
|
|
30
32
|
--simtel_cfg_file all_telescope_config_la_palma.cfg\\
|
|
31
33
|
--simtel_telescope_name CT1\\
|
|
32
34
|
--telescope LSTN-01\\
|
|
33
|
-
--
|
|
35
|
+
--parameter_version "1.0.0"
|
|
34
36
|
|
|
35
37
|
The export of the model parameters from sim_telarray for 6.0.0 can be done e.g., as follows:
|
|
36
38
|
|
|
@@ -59,7 +61,7 @@ import numpy as np
|
|
|
59
61
|
import simtools.data_model.model_data_writer as writer
|
|
60
62
|
import simtools.utils.general as gen
|
|
61
63
|
from simtools.configuration import configurator
|
|
62
|
-
from simtools.
|
|
64
|
+
from simtools.data_model import schema
|
|
63
65
|
from simtools.io_operations.io_handler import IOHandler
|
|
64
66
|
from simtools.simtel.simtel_config_reader import SimtelConfigReader
|
|
65
67
|
|
|
@@ -103,27 +105,7 @@ def _parse(label=None, description=None):
|
|
|
103
105
|
type=str,
|
|
104
106
|
required=True,
|
|
105
107
|
)
|
|
106
|
-
return config.initialize(simulation_model=["telescope", "
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
def get_list_of_parameters_and_schema_files(schema_directory):
|
|
110
|
-
"""
|
|
111
|
-
Return list of parameters and schema files located in schema file directory.
|
|
112
|
-
|
|
113
|
-
Returns
|
|
114
|
-
-------
|
|
115
|
-
list
|
|
116
|
-
List of parameters found in schema file directory.
|
|
117
|
-
list
|
|
118
|
-
List of schema files found in schema file directory.
|
|
119
|
-
|
|
120
|
-
"""
|
|
121
|
-
schema_files = sorted(Path(schema_directory).rglob("*.schema.yml"))
|
|
122
|
-
parameters = []
|
|
123
|
-
for schema_file in schema_files:
|
|
124
|
-
schema_dict = gen.collect_data_from_file(file_name=schema_file)
|
|
125
|
-
parameters.append(schema_dict.get("name"))
|
|
126
|
-
return parameters, schema_files
|
|
108
|
+
return config.initialize(simulation_model=["telescope", "parameter_version"])
|
|
127
109
|
|
|
128
110
|
|
|
129
111
|
def get_list_of_simtel_parameters(simtel_config_file, logger):
|
|
@@ -203,7 +185,7 @@ def get_number_of_camera_pixel(args_dict, logger):
|
|
|
203
185
|
"""
|
|
204
186
|
try:
|
|
205
187
|
simtel_config_reader = SimtelConfigReader(
|
|
206
|
-
schema_file=
|
|
188
|
+
schema_file=schema.get_model_parameter_schema_file("camera_pixels"),
|
|
207
189
|
simtel_config_file=args_dict["simtel_cfg_file"],
|
|
208
190
|
simtel_telescope_name=args_dict["simtel_telescope_name"],
|
|
209
191
|
)
|
|
@@ -219,7 +201,6 @@ def read_and_export_parameters(args_dict, logger):
|
|
|
219
201
|
"""
|
|
220
202
|
Read and export parameters from simtel configuration file to json files.
|
|
221
203
|
|
|
222
|
-
Only applicable parameters are exported to json.
|
|
223
204
|
Provide extensive logging information on the parameters found in the simtel
|
|
224
205
|
configuration file.
|
|
225
206
|
|
|
@@ -238,8 +219,8 @@ def read_and_export_parameters(args_dict, logger):
|
|
|
238
219
|
List of simtools parameter not found in simtel configuration file.
|
|
239
220
|
|
|
240
221
|
"""
|
|
241
|
-
_parameters, _schema_files =
|
|
242
|
-
args_dict.get("schema_directory"
|
|
222
|
+
_parameters, _schema_files = schema.get_get_model_parameter_schema_files(
|
|
223
|
+
args_dict.get("schema_directory")
|
|
243
224
|
)
|
|
244
225
|
_simtel_parameters = get_list_of_simtel_parameters(args_dict["simtel_cfg_file"], logger)
|
|
245
226
|
|
|
@@ -251,7 +232,6 @@ def read_and_export_parameters(args_dict, logger):
|
|
|
251
232
|
_parameters_not_in_simtel = []
|
|
252
233
|
|
|
253
234
|
for _parameter, _schema_file in zip(_parameters, _schema_files):
|
|
254
|
-
|
|
255
235
|
logger.info(f"Parameter: {_parameter} Schema file: {_schema_file}")
|
|
256
236
|
simtel_config_reader = read_simtel_config_file(
|
|
257
237
|
args_dict, logger, _schema_file, _camera_pixel
|
|
@@ -266,7 +246,7 @@ def read_and_export_parameters(args_dict, logger):
|
|
|
266
246
|
parameter_name=_parameter,
|
|
267
247
|
value=simtel_config_reader.parameter_dict.get(args_dict["simtel_telescope_name"]),
|
|
268
248
|
instrument=args_dict["telescope"],
|
|
269
|
-
|
|
249
|
+
parameter_version=args_dict["parameter_version"],
|
|
270
250
|
output_file=io_handler.get_output_file(f"{_parameter}.json"),
|
|
271
251
|
)
|
|
272
252
|
|
|
@@ -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,11 +78,10 @@ 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
|
|
85
|
-
|
|
86
85
|
args_dict, _ = _parse(
|
|
87
86
|
label=Path(__file__).stem,
|
|
88
87
|
description="Convert simulation model parameter from sim_telarray to simtools format.",
|
|
@@ -107,7 +106,7 @@ def main(): # noqa: D103
|
|
|
107
106
|
parameter_name=simtel_config_reader.parameter_name,
|
|
108
107
|
value=simtel_config_reader.parameter_dict.get(args_dict["simtel_telescope_name"]),
|
|
109
108
|
instrument=args_dict["telescope"],
|
|
110
|
-
|
|
109
|
+
parameter_version=args_dict["parameter_version"],
|
|
111
110
|
output_file=args_dict["output_file"],
|
|
112
111
|
output_path=args_dict.get("output_path"),
|
|
113
112
|
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
|
-------
|
|
@@ -47,7 +46,6 @@ from simtools.db import db_handler
|
|
|
47
46
|
|
|
48
47
|
|
|
49
48
|
def _parse():
|
|
50
|
-
|
|
51
49
|
config = configurator.Configurator(
|
|
52
50
|
description="Add file to the DB.",
|
|
53
51
|
usage="simtools-add-file-to-db --file_name test_application.dat --db test-data",
|
|
@@ -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__":
|