gammasimtools 0.22.0__py3-none-any.whl → 0.23.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.22.0.dist-info → gammasimtools-0.23.0.dist-info}/METADATA +2 -1
- {gammasimtools-0.22.0.dist-info → gammasimtools-0.23.0.dist-info}/RECORD +114 -112
- simtools/_version.py +2 -2
- simtools/application_control.py +118 -0
- simtools/applications/calculate_incident_angles.py +17 -22
- simtools/applications/convert_all_model_parameters_from_simtel.py +28 -43
- simtools/applications/convert_geo_coordinates_of_array_elements.py +26 -45
- simtools/applications/convert_model_parameter_from_simtel.py +21 -41
- simtools/applications/db_add_file_to_db.py +12 -13
- simtools/applications/db_add_simulation_model_from_repository_to_db.py +20 -33
- simtools/applications/db_add_value_from_json_to_db.py +28 -23
- simtools/applications/db_development_tools/write_array_elements_positions_to_repository.py +19 -34
- simtools/applications/db_generate_compound_indexes.py +11 -13
- simtools/applications/db_get_array_layouts_from_db.py +19 -39
- simtools/applications/db_get_file_from_db.py +15 -17
- simtools/applications/db_get_parameter_from_db.py +33 -35
- simtools/applications/db_inspect_databases.py +10 -11
- simtools/applications/db_upload_model_repository.py +13 -31
- simtools/applications/derive_ctao_array_layouts.py +16 -21
- simtools/applications/derive_mirror_rnda.py +9 -14
- simtools/applications/derive_photon_electron_spectrum.py +7 -10
- simtools/applications/derive_psf_parameters.py +13 -20
- simtools/applications/derive_trigger_rates.py +6 -9
- simtools/applications/docs_produce_array_element_report.py +22 -23
- simtools/applications/docs_produce_calibration_reports.py +26 -24
- simtools/applications/docs_produce_model_parameter_reports.py +15 -22
- simtools/applications/docs_produce_simulation_configuration_report.py +21 -22
- simtools/applications/generate_array_config.py +14 -33
- simtools/applications/generate_corsika_histograms.py +22 -43
- simtools/applications/generate_default_metadata.py +15 -36
- simtools/applications/generate_regular_arrays.py +11 -15
- simtools/applications/generate_simtel_event_data.py +23 -33
- simtools/applications/maintain_simulation_model_add_production.py +12 -19
- simtools/applications/maintain_simulation_model_compare_productions.py +10 -12
- simtools/applications/maintain_simulation_model_verify_production_tables.py +8 -11
- simtools/applications/merge_tables.py +14 -23
- simtools/applications/plot_array_layout.py +77 -54
- simtools/applications/plot_simtel_events.py +11 -13
- simtools/applications/plot_tabular_data.py +17 -38
- simtools/applications/plot_tabular_data_for_model_parameter.py +16 -23
- simtools/applications/print_version.py +14 -42
- simtools/applications/production_derive_corsika_limits.py +5 -9
- simtools/applications/production_derive_statistics.py +12 -25
- simtools/applications/production_generate_grid.py +20 -48
- simtools/applications/production_merge_corsika_limits.py +17 -21
- simtools/applications/run_application.py +12 -32
- simtools/applications/simulate_flasher.py +21 -25
- simtools/applications/simulate_illuminator.py +7 -14
- simtools/applications/simulate_pedestals.py +13 -13
- simtools/applications/simulate_prod.py +21 -33
- simtools/applications/simulate_prod_htcondor_generator.py +11 -25
- simtools/applications/submit_array_layouts.py +15 -18
- simtools/applications/submit_data_from_external.py +18 -34
- simtools/applications/submit_model_parameter_from_external.py +27 -40
- simtools/applications/validate_camera_efficiency.py +23 -21
- simtools/applications/validate_camera_fov.py +21 -26
- simtools/applications/validate_cumulative_psf.py +27 -35
- simtools/applications/validate_file_using_schema.py +15 -33
- simtools/applications/validate_optics.py +26 -32
- simtools/camera/camera_efficiency.py +0 -2
- simtools/configuration/commandline_parser.py +32 -4
- simtools/configuration/configurator.py +0 -5
- simtools/corsika/corsika_config.py +0 -5
- simtools/data_model/data_reader.py +0 -2
- simtools/data_model/metadata_collector.py +0 -2
- simtools/data_model/model_data_writer.py +0 -2
- simtools/data_model/validate_data.py +0 -2
- simtools/db/db_handler.py +0 -2
- simtools/io/hdf5_handler.py +0 -5
- simtools/io/legacy_data_handler.py +0 -5
- simtools/job_execution/job_manager.py +0 -3
- simtools/layout/array_layout.py +0 -2
- simtools/layout/telescope_position.py +0 -2
- simtools/model/array_model.py +2 -4
- simtools/model/calibration_model.py +0 -2
- simtools/model/camera.py +0 -2
- simtools/model/mirrors.py +0 -2
- simtools/model/model_parameter.py +30 -7
- simtools/model/model_utils.py +0 -5
- simtools/model/site_model.py +0 -2
- simtools/model/telescope_model.py +0 -2
- simtools/production_configuration/calculate_statistical_uncertainties_grid_point.py +0 -2
- simtools/production_configuration/derive_production_statistics.py +0 -2
- simtools/production_configuration/interpolation_handler.py +0 -2
- simtools/ray_tracing/psf_analysis.py +0 -2
- simtools/ray_tracing/ray_tracing.py +0 -2
- simtools/reporting/docs_auto_report_generator.py +108 -0
- simtools/reporting/docs_read_parameters.py +1 -7
- simtools/runners/corsika_runner.py +0 -2
- simtools/runners/corsika_simtel_runner.py +0 -2
- simtools/runners/simtel_runner.py +0 -2
- simtools/schemas/model_parameters/transit_time_random.schema.yml +29 -0
- simtools/simtel/simtel_config_reader.py +0 -2
- simtools/simtel/simtel_config_writer.py +31 -13
- simtools/simtel/simtel_io_metadata.py +3 -3
- simtools/simtel/simulator_array.py +9 -21
- simtools/simtel/simulator_camera_efficiency.py +0 -2
- simtools/simtel/simulator_light_emission.py +1 -3
- simtools/simtel/simulator_ray_tracing.py +0 -2
- simtools/simulator.py +0 -5
- simtools/testing/assertions.py +2 -2
- simtools/testing/configuration.py +17 -4
- simtools/utils/general.py +5 -13
- simtools/utils/geometry.py +0 -5
- simtools/utils/names.py +1 -13
- simtools/version.py +61 -0
- simtools/visualization/plot_array_layout.py +129 -23
- simtools/visualization/plot_incident_angles.py +0 -2
- simtools/visualization/plot_simtel_events.py +0 -11
- simtools/visualization/visualize.py +0 -12
- {gammasimtools-0.22.0.dist-info → gammasimtools-0.23.0.dist-info}/WHEEL +0 -0
- {gammasimtools-0.22.0.dist-info → gammasimtools-0.23.0.dist-info}/entry_points.txt +0 -0
- {gammasimtools-0.22.0.dist-info → gammasimtools-0.23.0.dist-info}/licenses/LICENSE +0 -0
- {gammasimtools-0.22.0.dist-info → gammasimtools-0.23.0.dist-info}/top_level.txt +0 -0
|
@@ -33,35 +33,23 @@
|
|
|
33
33
|
|
|
34
34
|
"""
|
|
35
35
|
|
|
36
|
-
import logging
|
|
37
36
|
from pathlib import Path
|
|
38
37
|
|
|
39
38
|
import astropy.table
|
|
40
39
|
|
|
41
|
-
|
|
40
|
+
from simtools.application_control import get_application_label, startup_application
|
|
42
41
|
from simtools.configuration import configurator
|
|
43
42
|
from simtools.data_model.model_data_writer import ModelDataWriter
|
|
44
43
|
from simtools.io import ascii_handler
|
|
45
44
|
from simtools.model.array_model import ArrayModel
|
|
46
45
|
|
|
47
46
|
|
|
48
|
-
def _parse(
|
|
49
|
-
"""
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
label : str
|
|
55
|
-
Label describing application.
|
|
56
|
-
description : str
|
|
57
|
-
Description of application.
|
|
58
|
-
|
|
59
|
-
Returns
|
|
60
|
-
-------
|
|
61
|
-
CommandLineParser
|
|
62
|
-
Command line parser object.
|
|
63
|
-
"""
|
|
64
|
-
config = configurator.Configurator(label=label, description=description)
|
|
47
|
+
def _parse():
|
|
48
|
+
"""Parse command line configuration."""
|
|
49
|
+
config = configurator.Configurator(
|
|
50
|
+
label=get_application_label(__file__),
|
|
51
|
+
description="Add array element positions to model parameter repository",
|
|
52
|
+
)
|
|
65
53
|
config.parser.add_argument(
|
|
66
54
|
"--input",
|
|
67
55
|
help="File containing a table of array element positions.",
|
|
@@ -96,8 +84,8 @@ def write_utm_array_elements_to_repository(args_dict, logger):
|
|
|
96
84
|
----------
|
|
97
85
|
args_dict : dict
|
|
98
86
|
Command line arguments.
|
|
99
|
-
logger :
|
|
100
|
-
|
|
87
|
+
app_context.logger : app_context.logger
|
|
88
|
+
app_context.logger object.
|
|
101
89
|
|
|
102
90
|
"""
|
|
103
91
|
array_elements = astropy.table.Table.read(args_dict["input"])
|
|
@@ -131,8 +119,8 @@ def write_ground_array_elements_to_repository(args_dict, db_config, logger):
|
|
|
131
119
|
Command line arguments.
|
|
132
120
|
db_config : dict
|
|
133
121
|
Database configuration.
|
|
134
|
-
logger :
|
|
135
|
-
|
|
122
|
+
logger : logger
|
|
123
|
+
logger object.
|
|
136
124
|
|
|
137
125
|
"""
|
|
138
126
|
array_model = ArrayModel(
|
|
@@ -155,19 +143,16 @@ def write_ground_array_elements_to_repository(args_dict, db_config, logger):
|
|
|
155
143
|
|
|
156
144
|
def main():
|
|
157
145
|
"""Application main."""
|
|
158
|
-
|
|
159
|
-
args_dict, db_config = _parse(
|
|
160
|
-
label, description="Add array element positions to model parameter repository"
|
|
161
|
-
)
|
|
162
|
-
logger = logging.getLogger()
|
|
163
|
-
logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
|
|
146
|
+
app_context = startup_application(_parse)
|
|
164
147
|
|
|
165
|
-
if
|
|
166
|
-
write_utm_array_elements_to_repository(
|
|
167
|
-
elif
|
|
168
|
-
write_ground_array_elements_to_repository(
|
|
148
|
+
if app_context.args["coordinate_system"] == "utm":
|
|
149
|
+
write_utm_array_elements_to_repository(app_context.args, app_context.logger)
|
|
150
|
+
elif app_context.args["coordinate_system"] == "ground":
|
|
151
|
+
write_ground_array_elements_to_repository(
|
|
152
|
+
app_context.args, app_context.db_config, app_context.logger
|
|
153
|
+
)
|
|
169
154
|
else:
|
|
170
|
-
logger.error("Invalid coordinate system. Allowed are 'utm' and 'ground'.")
|
|
155
|
+
app_context.logger.error("Invalid coordinate system. Allowed are 'utm' and 'ground'.")
|
|
171
156
|
raise ValueError
|
|
172
157
|
|
|
173
158
|
|
|
@@ -13,16 +13,16 @@ db_name (str, optional)
|
|
|
13
13
|
Database name (use "all" for all databases)
|
|
14
14
|
"""
|
|
15
15
|
|
|
16
|
-
import
|
|
17
|
-
|
|
18
|
-
import simtools.utils.general as gen
|
|
16
|
+
from simtools.application_control import get_application_label, startup_application
|
|
19
17
|
from simtools.configuration import configurator
|
|
20
18
|
from simtools.db import db_handler
|
|
21
19
|
|
|
22
20
|
|
|
23
21
|
def _parse():
|
|
22
|
+
"""Parse command line configuration."""
|
|
24
23
|
config = configurator.Configurator(
|
|
25
|
-
description="Generate compound indexes for a specific database"
|
|
24
|
+
description="Generate compound indexes for a specific database",
|
|
25
|
+
label=get_application_label(__file__),
|
|
26
26
|
)
|
|
27
27
|
config.parser.add_argument(
|
|
28
28
|
"--db_name",
|
|
@@ -33,18 +33,16 @@ def _parse():
|
|
|
33
33
|
return config.initialize(db_config=True)
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
def main():
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
logger = logging.getLogger()
|
|
40
|
-
logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
|
|
36
|
+
def main():
|
|
37
|
+
"""Generate compound indexes for the specified database."""
|
|
38
|
+
app_context = startup_application(_parse, setup_io_handler=False)
|
|
41
39
|
|
|
42
|
-
db = db_handler.DatabaseHandler(mongo_db_config=db_config)
|
|
40
|
+
db = db_handler.DatabaseHandler(mongo_db_config=app_context.db_config)
|
|
43
41
|
|
|
44
42
|
db.generate_compound_indexes_for_databases(
|
|
45
|
-
db_name=
|
|
46
|
-
db_simulation_model=
|
|
47
|
-
db_simulation_model_version=
|
|
43
|
+
db_name=app_context.args["db_name"],
|
|
44
|
+
db_simulation_model=app_context.args.get("db_simulation_model"),
|
|
45
|
+
db_simulation_model_version=app_context.args.get("db_simulation_model_version"),
|
|
48
46
|
)
|
|
49
47
|
|
|
50
48
|
|
|
@@ -51,33 +51,19 @@ Retrieve telescope positions from database (utm coordinate system) and write to
|
|
|
51
51
|
--output_file telescope_positions-test_layout.ecsv
|
|
52
52
|
"""
|
|
53
53
|
|
|
54
|
-
import logging
|
|
55
|
-
from pathlib import Path
|
|
56
|
-
|
|
57
54
|
import simtools.data_model.model_data_writer as writer
|
|
58
|
-
|
|
55
|
+
from simtools.application_control import get_application_label, startup_application
|
|
59
56
|
from simtools.configuration import configurator
|
|
60
57
|
from simtools.model.array_model import ArrayModel
|
|
61
58
|
from simtools.model.site_model import SiteModel
|
|
62
59
|
|
|
63
60
|
|
|
64
|
-
def _parse(
|
|
65
|
-
"""
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
label : str
|
|
71
|
-
Label describing the application.
|
|
72
|
-
description : str
|
|
73
|
-
Description of the application.
|
|
74
|
-
|
|
75
|
-
Returns
|
|
76
|
-
-------
|
|
77
|
-
CommandLineParser
|
|
78
|
-
Command line parser object.
|
|
79
|
-
"""
|
|
80
|
-
config = configurator.Configurator(label=label, description=description)
|
|
61
|
+
def _parse():
|
|
62
|
+
"""Parse command line configuration."""
|
|
63
|
+
config = configurator.Configurator(
|
|
64
|
+
label=get_application_label(__file__),
|
|
65
|
+
description="Get list of array elements as defined in the db (array layout).",
|
|
66
|
+
)
|
|
81
67
|
|
|
82
68
|
input_group = config.parser.add_mutually_exclusive_group()
|
|
83
69
|
input_group.add_argument(
|
|
@@ -128,33 +114,27 @@ def _layout_from_db(args_dict, db_config):
|
|
|
128
114
|
|
|
129
115
|
|
|
130
116
|
def main():
|
|
131
|
-
"""Get list of array elements as defined in the db
|
|
132
|
-
|
|
133
|
-
args_dict, db_config = _parse(
|
|
134
|
-
label,
|
|
135
|
-
"Get list of array elements as defined in the db (array layout).",
|
|
136
|
-
)
|
|
137
|
-
logger = logging.getLogger()
|
|
138
|
-
logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
|
|
117
|
+
"""Get list of array layouts or list of elements for a given layout as defined in the db."""
|
|
118
|
+
app_context = startup_application(_parse)
|
|
139
119
|
|
|
140
|
-
if
|
|
141
|
-
if
|
|
120
|
+
if app_context.args.get("list_available_layouts", False):
|
|
121
|
+
if app_context.args.get("site", None) is None:
|
|
142
122
|
raise ValueError("Site must be provided to list available layouts.")
|
|
143
123
|
site_model = SiteModel(
|
|
144
|
-
mongo_db_config=db_config,
|
|
145
|
-
model_version=
|
|
146
|
-
site=
|
|
124
|
+
mongo_db_config=app_context.db_config,
|
|
125
|
+
model_version=app_context.args["model_version"],
|
|
126
|
+
site=app_context.args["site"],
|
|
147
127
|
)
|
|
148
128
|
print(site_model.get_list_of_array_layouts())
|
|
149
129
|
else:
|
|
150
|
-
logger.info("Array layout: %s",
|
|
151
|
-
layout = _layout_from_db(
|
|
130
|
+
app_context.logger.info("Array layout: %s", app_context.args["array_layout_name"])
|
|
131
|
+
layout = _layout_from_db(app_context.args, app_context.db_config)
|
|
152
132
|
layout.pprint()
|
|
153
133
|
|
|
154
|
-
if not
|
|
134
|
+
if not app_context.args.get("output_file_from_default", False):
|
|
155
135
|
writer.ModelDataWriter.dump(
|
|
156
|
-
args_dict=
|
|
157
|
-
output_file=
|
|
136
|
+
args_dict=app_context.args,
|
|
137
|
+
output_file=app_context.args["output_file"],
|
|
158
138
|
metadata=None,
|
|
159
139
|
product_data=layout,
|
|
160
140
|
)
|
|
@@ -33,16 +33,15 @@
|
|
|
33
33
|
|
|
34
34
|
"""
|
|
35
35
|
|
|
36
|
-
import
|
|
37
|
-
|
|
38
|
-
import simtools.utils.general as gen
|
|
36
|
+
from simtools.application_control import get_application_label, startup_application
|
|
39
37
|
from simtools.configuration import configurator
|
|
40
38
|
from simtools.db import db_handler
|
|
41
|
-
from simtools.io import io_handler
|
|
42
39
|
|
|
43
40
|
|
|
44
41
|
def _parse():
|
|
42
|
+
"""Parse command line configuration."""
|
|
45
43
|
config = configurator.Configurator(
|
|
44
|
+
label=get_application_label(__file__),
|
|
46
45
|
description="Get file(s) from the DB.",
|
|
47
46
|
usage="simtools-get-file-from-db --file_name mirror_CTA-S-LST_v2020-04-07.dat",
|
|
48
47
|
)
|
|
@@ -57,24 +56,23 @@ def _parse():
|
|
|
57
56
|
return config.initialize(db_config=True, output=True)
|
|
58
57
|
|
|
59
58
|
|
|
60
|
-
def main():
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
logger = logging.getLogger()
|
|
64
|
-
logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
|
|
65
|
-
_io_handler = io_handler.IOHandler()
|
|
59
|
+
def main():
|
|
60
|
+
"""Get file from database."""
|
|
61
|
+
app_context = startup_application(_parse)
|
|
66
62
|
|
|
67
|
-
db = db_handler.DatabaseHandler(mongo_db_config=db_config)
|
|
63
|
+
db = db_handler.DatabaseHandler(mongo_db_config=app_context.db_config)
|
|
68
64
|
file_id = db.export_model_files(
|
|
69
|
-
dest=
|
|
70
|
-
file_names=
|
|
65
|
+
dest=app_context.io_handler.get_output_directory(),
|
|
66
|
+
file_names=app_context.args["file_name"],
|
|
71
67
|
)
|
|
72
68
|
if file_id is None:
|
|
73
|
-
logger.error(
|
|
69
|
+
app_context.logger.error(
|
|
70
|
+
f"The file {app_context.args['file_name']} was not found in {db.db_name}."
|
|
71
|
+
)
|
|
74
72
|
raise FileNotFoundError
|
|
75
|
-
logger.info(
|
|
76
|
-
f"Got file {
|
|
77
|
-
f"and saved into {
|
|
73
|
+
app_context.logger.info(
|
|
74
|
+
f"Got file {app_context.args['file_name']} from DB {db.db_name} "
|
|
75
|
+
f"and saved into {app_context.io_handler.get_output_directory()}"
|
|
78
76
|
)
|
|
79
77
|
|
|
80
78
|
|
|
@@ -60,23 +60,23 @@ r"""
|
|
|
60
60
|
|
|
61
61
|
"""
|
|
62
62
|
|
|
63
|
-
import logging
|
|
64
|
-
from pathlib import Path
|
|
65
63
|
from pprint import pprint
|
|
66
64
|
|
|
67
|
-
|
|
65
|
+
from simtools.application_control import get_application_label, startup_application
|
|
68
66
|
from simtools.configuration import configurator
|
|
69
67
|
from simtools.db import db_handler
|
|
70
|
-
from simtools.io import ascii_handler
|
|
68
|
+
from simtools.io import ascii_handler
|
|
71
69
|
|
|
72
70
|
|
|
73
71
|
def _parse():
|
|
72
|
+
"""Parse command line configuration."""
|
|
74
73
|
config = configurator.Configurator(
|
|
74
|
+
label=get_application_label(__file__),
|
|
75
75
|
description=(
|
|
76
76
|
"Get a parameter entry from DB for a specific telescope or a site. "
|
|
77
77
|
"The application receives a parameter name, a site, a telescope (if applicable), "
|
|
78
78
|
"and a version. It then prints out the parameter entry. "
|
|
79
|
-
)
|
|
79
|
+
),
|
|
80
80
|
)
|
|
81
81
|
|
|
82
82
|
config.parser.add_argument("--parameter", help="Parameter name", type=str, required=True)
|
|
@@ -104,48 +104,46 @@ def _parse():
|
|
|
104
104
|
)
|
|
105
105
|
|
|
106
106
|
|
|
107
|
-
def main():
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
logger = logging.getLogger()
|
|
111
|
-
logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
|
|
107
|
+
def main():
|
|
108
|
+
"""Get a parameter entry from DB for a specific telescope or a site."""
|
|
109
|
+
app_context = startup_application(_parse)
|
|
112
110
|
|
|
113
|
-
db = db_handler.DatabaseHandler(mongo_db_config=db_config)
|
|
111
|
+
db = db_handler.DatabaseHandler(mongo_db_config=app_context.db_config)
|
|
114
112
|
|
|
115
113
|
pars = db.get_model_parameter(
|
|
116
|
-
parameter=
|
|
117
|
-
site=
|
|
118
|
-
array_element_name=
|
|
119
|
-
parameter_version=
|
|
120
|
-
model_version=
|
|
114
|
+
parameter=app_context.args["parameter"],
|
|
115
|
+
site=app_context.args["site"],
|
|
116
|
+
array_element_name=app_context.args.get("telescope"),
|
|
117
|
+
parameter_version=app_context.args.get("parameter_version"),
|
|
118
|
+
model_version=app_context.args.get("model_version"),
|
|
121
119
|
)
|
|
122
|
-
if
|
|
120
|
+
if app_context.args["export_model_file"] or app_context.args["export_model_file_as_table"]:
|
|
123
121
|
table = db.export_model_file(
|
|
124
|
-
parameter=
|
|
125
|
-
site=
|
|
126
|
-
array_element_name=
|
|
127
|
-
parameter_version=
|
|
128
|
-
model_version=
|
|
129
|
-
export_file_as_table=
|
|
122
|
+
parameter=app_context.args["parameter"],
|
|
123
|
+
site=app_context.args["site"],
|
|
124
|
+
array_element_name=app_context.args["telescope"],
|
|
125
|
+
parameter_version=app_context.args.get("parameter_version"),
|
|
126
|
+
model_version=app_context.args.get("model_version"),
|
|
127
|
+
export_file_as_table=app_context.args["export_model_file_as_table"],
|
|
130
128
|
)
|
|
131
|
-
param_value = pars[
|
|
132
|
-
table_file =
|
|
133
|
-
logger.info(f"Exported model file {param_value} to {table_file}")
|
|
129
|
+
param_value = pars[app_context.args["parameter"]]["value"]
|
|
130
|
+
table_file = app_context.io_handler.get_output_file(param_value)
|
|
131
|
+
app_context.logger.info(f"Exported model file {param_value} to {table_file}")
|
|
134
132
|
if table and table_file.suffix != ".ecsv":
|
|
135
133
|
table.write(table_file.with_suffix(".ecsv"), format="ascii.ecsv", overwrite=True)
|
|
136
|
-
logger.info(
|
|
134
|
+
app_context.logger.info(
|
|
135
|
+
f"Exported model file {param_value} to {table_file.with_suffix('.ecsv')}"
|
|
136
|
+
)
|
|
137
137
|
|
|
138
|
-
if
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
)
|
|
142
|
-
pars[args_dict["parameter"]].pop("_id")
|
|
143
|
-
pars[args_dict["parameter"]].pop("entry_date")
|
|
138
|
+
if app_context.args["output_file"] is not None:
|
|
139
|
+
pars[app_context.args["parameter"]].pop("_id")
|
|
140
|
+
pars[app_context.args["parameter"]].pop("entry_date")
|
|
144
141
|
ascii_handler.write_data_to_file(
|
|
145
|
-
data=pars[
|
|
142
|
+
data=pars[app_context.args["parameter"]],
|
|
143
|
+
output_file=app_context.io_handler.get_output_file(app_context.args["output_file"]),
|
|
146
144
|
)
|
|
147
145
|
else:
|
|
148
|
-
pprint(pars[
|
|
146
|
+
pprint(pars[app_context.args["parameter"]])
|
|
149
147
|
|
|
150
148
|
|
|
151
149
|
if __name__ == "__main__":
|
|
@@ -9,15 +9,16 @@ db_name (str, optional)
|
|
|
9
9
|
Database name (use "all" for all databases)
|
|
10
10
|
"""
|
|
11
11
|
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
import simtools.utils.general as gen
|
|
12
|
+
from simtools.application_control import get_application_label, startup_application
|
|
15
13
|
from simtools.configuration import configurator
|
|
16
14
|
from simtools.db import db_handler
|
|
17
15
|
|
|
18
16
|
|
|
19
17
|
def _parse():
|
|
20
|
-
|
|
18
|
+
"""Parse command line configuration."""
|
|
19
|
+
config = configurator.Configurator(
|
|
20
|
+
label=get_application_label(__file__), description="Inspect databases"
|
|
21
|
+
)
|
|
21
22
|
config.parser.add_argument(
|
|
22
23
|
"--db_name",
|
|
23
24
|
help="Database name",
|
|
@@ -27,18 +28,16 @@ def _parse():
|
|
|
27
28
|
return config.initialize(db_config=True)
|
|
28
29
|
|
|
29
30
|
|
|
30
|
-
def main():
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
logger = logging.getLogger()
|
|
34
|
-
logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
|
|
31
|
+
def main():
|
|
32
|
+
"""Inspect databases."""
|
|
33
|
+
app_context = startup_application(_parse, setup_io_handler=False)
|
|
35
34
|
|
|
36
|
-
db = db_handler.DatabaseHandler(mongo_db_config=db_config)
|
|
35
|
+
db = db_handler.DatabaseHandler(mongo_db_config=app_context.db_config)
|
|
37
36
|
# databases without internal databases we don't have rights to modify
|
|
38
37
|
databases = [
|
|
39
38
|
d for d in db.db_client.list_database_names() if d not in ("config", "admin", "local")
|
|
40
39
|
]
|
|
41
|
-
requested =
|
|
40
|
+
requested = app_context.args["db_name"]
|
|
42
41
|
if requested != "all" and requested not in databases:
|
|
43
42
|
raise ValueError(
|
|
44
43
|
f"Requested database '{requested}' not found. "
|
|
@@ -40,10 +40,7 @@ used to name the database, but no tag checkout is done):
|
|
|
40
40
|
|
|
41
41
|
"""
|
|
42
42
|
|
|
43
|
-
import
|
|
44
|
-
from pathlib import Path
|
|
45
|
-
|
|
46
|
-
import simtools.utils.general as gen
|
|
43
|
+
from simtools.application_control import get_application_label, startup_application
|
|
47
44
|
from simtools.configuration import configurator
|
|
48
45
|
from simtools.db import db_handler, db_model_upload
|
|
49
46
|
|
|
@@ -53,23 +50,12 @@ DEFAULT_REPOSITORY_URL = (
|
|
|
53
50
|
)
|
|
54
51
|
|
|
55
52
|
|
|
56
|
-
def _parse(
|
|
57
|
-
"""
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
label : str
|
|
63
|
-
Label describing application.
|
|
64
|
-
description : str
|
|
65
|
-
Description of application.
|
|
66
|
-
|
|
67
|
-
Returns
|
|
68
|
-
-------
|
|
69
|
-
tuple
|
|
70
|
-
Command line parser object and database configuration.
|
|
71
|
-
"""
|
|
72
|
-
config = configurator.Configurator(label=label, description=description)
|
|
53
|
+
def _parse():
|
|
54
|
+
"""Parse command line configuration."""
|
|
55
|
+
config = configurator.Configurator(
|
|
56
|
+
label=get_application_label(__file__),
|
|
57
|
+
description="Upload model parameters from repository to database",
|
|
58
|
+
)
|
|
73
59
|
config.parser.add_argument(
|
|
74
60
|
"--branch",
|
|
75
61
|
help="Repository branch to clone (optional, defaults to using version tag).",
|
|
@@ -99,22 +85,18 @@ def _parse(label=None, description=None):
|
|
|
99
85
|
|
|
100
86
|
def main():
|
|
101
87
|
"""Application main."""
|
|
102
|
-
|
|
103
|
-
label=Path(__file__).stem, description="Upload model parameters from repository to database"
|
|
104
|
-
)
|
|
105
|
-
logger = logging.getLogger()
|
|
106
|
-
logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
|
|
88
|
+
app_context = startup_application(_parse)
|
|
107
89
|
|
|
108
|
-
db = db_handler.DatabaseHandler(mongo_db_config=db_config)
|
|
90
|
+
db = db_handler.DatabaseHandler(mongo_db_config=app_context.db_config)
|
|
109
91
|
db.print_connection_info()
|
|
110
92
|
|
|
111
93
|
db_model_upload.add_complete_model(
|
|
112
|
-
tmp_dir=
|
|
94
|
+
tmp_dir=app_context.args.get("tmp_dir"),
|
|
113
95
|
db=db,
|
|
114
|
-
db_simulation_model=
|
|
115
|
-
db_simulation_model_version=
|
|
96
|
+
db_simulation_model=app_context.args.get("db_simulation_model"),
|
|
97
|
+
db_simulation_model_version=app_context.args.get("db_simulation_model_version"),
|
|
116
98
|
repository_url=DEFAULT_REPOSITORY_URL,
|
|
117
|
-
repository_branch=
|
|
99
|
+
repository_branch=app_context.args.get("branch"),
|
|
118
100
|
)
|
|
119
101
|
|
|
120
102
|
|
|
@@ -42,10 +42,7 @@ r"""
|
|
|
42
42
|
--updated_parameter_version 3.0.0
|
|
43
43
|
"""
|
|
44
44
|
|
|
45
|
-
import
|
|
46
|
-
from pathlib import Path
|
|
47
|
-
|
|
48
|
-
import simtools.utils.general as gen
|
|
45
|
+
from simtools.application_control import get_application_label, startup_application
|
|
49
46
|
from simtools.configuration import configurator
|
|
50
47
|
from simtools.db import db_handler
|
|
51
48
|
from simtools.layout.array_layout_utils import (
|
|
@@ -55,10 +52,10 @@ from simtools.layout.array_layout_utils import (
|
|
|
55
52
|
)
|
|
56
53
|
|
|
57
54
|
|
|
58
|
-
def _parse(
|
|
55
|
+
def _parse():
|
|
59
56
|
"""Parse command line configuration."""
|
|
60
57
|
config = configurator.Configurator(
|
|
61
|
-
label=
|
|
58
|
+
label=get_application_label(__file__),
|
|
62
59
|
description="Derive CTAO array layouts from CTAO common identifiers repository.",
|
|
63
60
|
)
|
|
64
61
|
config.parser.add_argument(
|
|
@@ -85,34 +82,32 @@ def _parse(label):
|
|
|
85
82
|
)
|
|
86
83
|
|
|
87
84
|
|
|
88
|
-
def main():
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
logger = logging.getLogger()
|
|
92
|
-
logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
|
|
85
|
+
def main():
|
|
86
|
+
"""Derive CTAO array layouts from CTAO common identifiers repository."""
|
|
87
|
+
app_context = startup_application(_parse)
|
|
93
88
|
|
|
94
89
|
ctao_array_layouts = retrieve_ctao_array_layouts(
|
|
95
|
-
site=
|
|
96
|
-
repository_url=
|
|
97
|
-
branch_name=
|
|
90
|
+
site=app_context.args["site"],
|
|
91
|
+
repository_url=app_context.args["repository_url"],
|
|
92
|
+
branch_name=app_context.args["repository_branch"],
|
|
98
93
|
)
|
|
99
94
|
|
|
100
|
-
db = db_handler.DatabaseHandler(mongo_db_config=db_config)
|
|
95
|
+
db = db_handler.DatabaseHandler(mongo_db_config=app_context.db_config)
|
|
101
96
|
db_array_layouts = db.get_model_parameter(
|
|
102
97
|
parameter="array_layouts",
|
|
103
|
-
site=
|
|
98
|
+
site=app_context.args["site"],
|
|
104
99
|
array_element_name=None,
|
|
105
|
-
parameter_version=
|
|
106
|
-
model_version=
|
|
100
|
+
parameter_version=app_context.args.get("parameter_version"),
|
|
101
|
+
model_version=app_context.args.get("model_version"),
|
|
107
102
|
)
|
|
108
103
|
db_array_layouts["array_layouts"].pop("_id", None)
|
|
109
104
|
db_array_layouts["array_layouts"].pop("entry_date", None)
|
|
110
|
-
logger.info(f"Layouts from model parameter database: {db_array_layouts}")
|
|
105
|
+
app_context.logger.info(f"Layouts from model parameter database: {db_array_layouts}")
|
|
111
106
|
|
|
112
107
|
write_array_layouts(
|
|
113
108
|
array_layouts=merge_array_layouts(db_array_layouts["array_layouts"], ctao_array_layouts),
|
|
114
|
-
args_dict=
|
|
115
|
-
db_config=db_config,
|
|
109
|
+
args_dict=app_context.args,
|
|
110
|
+
db_config=app_context.db_config,
|
|
116
111
|
)
|
|
117
112
|
|
|
118
113
|
|
|
@@ -125,18 +125,15 @@ r"""
|
|
|
125
125
|
|
|
126
126
|
"""
|
|
127
127
|
|
|
128
|
-
import
|
|
129
|
-
from pathlib import Path
|
|
130
|
-
|
|
131
|
-
import simtools.utils.general as gen
|
|
128
|
+
from simtools.application_control import get_application_label, startup_application
|
|
132
129
|
from simtools.configuration import configurator
|
|
133
130
|
from simtools.ray_tracing.mirror_panel_psf import MirrorPanelPSF
|
|
134
131
|
|
|
135
132
|
|
|
136
|
-
def _parse(
|
|
133
|
+
def _parse():
|
|
137
134
|
"""Parse command line configuration."""
|
|
138
135
|
config = configurator.Configurator(
|
|
139
|
-
description="Derive mirror random reflection angle.", label=
|
|
136
|
+
description="Derive mirror random reflection angle.", label=get_application_label(__file__)
|
|
140
137
|
)
|
|
141
138
|
psf_group = config.parser.add_mutually_exclusive_group()
|
|
142
139
|
psf_group.add_argument(
|
|
@@ -217,15 +214,13 @@ def _parse(label):
|
|
|
217
214
|
)
|
|
218
215
|
|
|
219
216
|
|
|
220
|
-
def main():
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
args_dict, db_config = _parse(label)
|
|
217
|
+
def main():
|
|
218
|
+
"""Derive mirror random reflection angle of a single mirror panel."""
|
|
219
|
+
app_context = startup_application(_parse)
|
|
224
220
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
panel_psf = MirrorPanelPSF(label, args_dict, db_config)
|
|
221
|
+
panel_psf = MirrorPanelPSF(
|
|
222
|
+
app_context.args.get("label"), app_context.args, app_context.db_config
|
|
223
|
+
)
|
|
229
224
|
panel_psf.derive_random_reflection_angle(save_figures=True)
|
|
230
225
|
panel_psf.print_results()
|
|
231
226
|
panel_psf.write_optimization_data()
|
|
@@ -34,18 +34,17 @@ r"""
|
|
|
34
34
|
|
|
35
35
|
"""
|
|
36
36
|
|
|
37
|
-
import logging
|
|
38
37
|
from pathlib import Path
|
|
39
38
|
|
|
40
|
-
|
|
39
|
+
from simtools.application_control import get_application_label, startup_application
|
|
41
40
|
from simtools.camera.single_photon_electron_spectrum import SinglePhotonElectronSpectrum
|
|
42
41
|
from simtools.configuration import configurator
|
|
43
42
|
|
|
44
43
|
|
|
45
|
-
def _parse(
|
|
44
|
+
def _parse():
|
|
46
45
|
"""Parse command line configuration."""
|
|
47
46
|
config = configurator.Configurator(
|
|
48
|
-
label=
|
|
47
|
+
label=get_application_label(__file__),
|
|
49
48
|
description="Derive single photon electron spectrum from a given amplitude spectrum.",
|
|
50
49
|
)
|
|
51
50
|
config.parser.add_argument(
|
|
@@ -112,13 +111,11 @@ def _parse(label):
|
|
|
112
111
|
return config.initialize(db_config=False, output=True, simulation_model=["telescope"])
|
|
113
112
|
|
|
114
113
|
|
|
115
|
-
def main():
|
|
116
|
-
|
|
114
|
+
def main():
|
|
115
|
+
"""Derive single photon electron spectrum from a given amplitude spectrum."""
|
|
116
|
+
app_context = startup_application(_parse)
|
|
117
117
|
|
|
118
|
-
|
|
119
|
-
logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
|
|
120
|
-
|
|
121
|
-
single_pe = SinglePhotonElectronSpectrum(args_dict)
|
|
118
|
+
single_pe = SinglePhotonElectronSpectrum(app_context.args)
|
|
122
119
|
single_pe.derive_single_pe_spectrum()
|
|
123
120
|
single_pe.write_single_pe_spectrum()
|
|
124
121
|
|