gammasimtools 0.8.2__py3-none-any.whl → 0.9.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.8.2.dist-info → gammasimtools-0.9.0.dist-info}/METADATA +3 -3
- {gammasimtools-0.8.2.dist-info → gammasimtools-0.9.0.dist-info}/RECORD +64 -59
- {gammasimtools-0.8.2.dist-info → gammasimtools-0.9.0.dist-info}/WHEEL +1 -1
- {gammasimtools-0.8.2.dist-info → gammasimtools-0.9.0.dist-info}/entry_points.txt +2 -0
- simtools/_version.py +2 -2
- simtools/applications/convert_all_model_parameters_from_simtel.py +1 -1
- simtools/applications/convert_geo_coordinates_of_array_elements.py +8 -9
- simtools/applications/convert_model_parameter_from_simtel.py +1 -1
- simtools/applications/db_add_model_parameters_from_repository_to_db.py +2 -10
- simtools/applications/db_add_value_from_json_to_db.py +1 -9
- simtools/applications/db_get_array_layouts_from_db.py +3 -1
- simtools/applications/db_get_parameter_from_db.py +1 -1
- simtools/applications/derive_mirror_rnda.py +10 -1
- simtools/applications/derive_psf_parameters.py +1 -1
- simtools/applications/generate_array_config.py +1 -5
- simtools/applications/generate_regular_arrays.py +9 -6
- simtools/applications/plot_array_layout.py +3 -1
- simtools/applications/plot_tabular_data.py +84 -0
- simtools/applications/production_scale_events.py +1 -2
- simtools/applications/simulate_light_emission.py +2 -2
- simtools/applications/simulate_prod.py +24 -59
- simtools/applications/simulate_prod_htcondor_generator.py +95 -0
- simtools/applications/submit_data_from_external.py +1 -1
- simtools/applications/validate_camera_efficiency.py +1 -1
- simtools/applications/validate_camera_fov.py +3 -7
- simtools/applications/validate_cumulative_psf.py +3 -7
- simtools/applications/validate_file_using_schema.py +31 -21
- simtools/applications/validate_optics.py +3 -4
- simtools/camera_efficiency.py +1 -4
- simtools/configuration/commandline_parser.py +7 -13
- simtools/configuration/configurator.py +6 -19
- simtools/data_model/metadata_collector.py +18 -0
- simtools/data_model/metadata_model.py +18 -5
- simtools/data_model/model_data_writer.py +1 -1
- simtools/data_model/validate_data.py +67 -10
- simtools/db/db_handler.py +92 -315
- simtools/io_operations/legacy_data_handler.py +61 -0
- simtools/job_execution/htcondor_script_generator.py +133 -0
- simtools/job_execution/job_manager.py +77 -50
- simtools/model/camera.py +4 -2
- simtools/model/model_parameter.py +40 -10
- simtools/model/site_model.py +1 -1
- simtools/ray_tracing/mirror_panel_psf.py +47 -27
- simtools/runners/corsika_runner.py +14 -3
- simtools/runners/runner_services.py +3 -3
- simtools/runners/simtel_runner.py +27 -8
- simtools/schemas/integration_tests_config.metaschema.yml +15 -5
- simtools/schemas/model_parameter.metaschema.yml +90 -2
- simtools/schemas/model_parameters/effective_focal_length.schema.yml +31 -1
- simtools/simtel/simtel_table_reader.py +410 -0
- simtools/simtel/simulator_camera_efficiency.py +6 -4
- simtools/simtel/simulator_light_emission.py +2 -2
- simtools/simtel/simulator_ray_tracing.py +1 -2
- simtools/simulator.py +80 -33
- simtools/testing/configuration.py +12 -8
- simtools/testing/helpers.py +5 -5
- simtools/testing/validate_output.py +26 -26
- simtools/utils/general.py +50 -3
- simtools/utils/names.py +2 -2
- simtools/utils/value_conversion.py +9 -1
- simtools/visualization/plot_tables.py +106 -0
- simtools/visualization/visualize.py +43 -5
- simtools/db/db_from_repo_handler.py +0 -106
- {gammasimtools-0.8.2.dist-info → gammasimtools-0.9.0.dist-info}/LICENSE +0 -0
- {gammasimtools-0.8.2.dist-info → gammasimtools-0.9.0.dist-info}/top_level.txt +0 -0
|
@@ -5,6 +5,7 @@ import copy
|
|
|
5
5
|
import logging
|
|
6
6
|
import re
|
|
7
7
|
from collections import OrderedDict
|
|
8
|
+
from pathlib import Path
|
|
8
9
|
|
|
9
10
|
import astropy.units as u
|
|
10
11
|
import matplotlib.patches as mpatches
|
|
@@ -27,6 +28,7 @@ __all__ = [
|
|
|
27
28
|
"plot_array",
|
|
28
29
|
"plot_hist_2d",
|
|
29
30
|
"plot_table",
|
|
31
|
+
"save_figure",
|
|
30
32
|
"set_style",
|
|
31
33
|
]
|
|
32
34
|
|
|
@@ -366,6 +368,12 @@ def handle_kwargs(kwargs):
|
|
|
366
368
|
"empty_markers": False,
|
|
367
369
|
"plot_ratio": False,
|
|
368
370
|
"plot_difference": False,
|
|
371
|
+
"xscale": "linear",
|
|
372
|
+
"yscale": "linear",
|
|
373
|
+
"xlim": (None, None),
|
|
374
|
+
"ylim": (None, None),
|
|
375
|
+
"xtitle": None,
|
|
376
|
+
"ytitle": None,
|
|
369
377
|
}
|
|
370
378
|
for key, default in kwargs_defaults.items():
|
|
371
379
|
kwargs[key] = kwargs.pop(key, default)
|
|
@@ -414,11 +422,17 @@ def plot_main_data(data_dict, kwargs, plot_args):
|
|
|
414
422
|
"""Plot the main data."""
|
|
415
423
|
for label, data_now in data_dict.items():
|
|
416
424
|
assert len(data_now.dtype.names) == 2, "Input array must have two columns with titles."
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
425
|
+
x_column_name, y_column_name = data_now.dtype.names[0], data_now.dtype.names[1]
|
|
426
|
+
x_title = kwargs["xtitle"] if kwargs.get("xtitle") else x_column_name
|
|
427
|
+
y_title = kwargs["ytitle"] if kwargs.get("ytitle") else y_column_name
|
|
428
|
+
x_title_unit = _add_unit(x_title, data_now[x_column_name])
|
|
429
|
+
y_title_unit = _add_unit(y_title, data_now[y_column_name])
|
|
430
|
+
plt.plot(data_now[x_column_name], data_now[y_column_name], label=label, **plot_args)
|
|
431
|
+
|
|
432
|
+
plt.xscale(kwargs["xscale"])
|
|
433
|
+
plt.yscale(kwargs["yscale"])
|
|
434
|
+
plt.xlim(kwargs["xlim"])
|
|
435
|
+
plt.ylim(kwargs["ylim"])
|
|
422
436
|
plt.ylabel(y_title_unit)
|
|
423
437
|
if not (kwargs["plot_ratio"] or kwargs["plot_difference"]):
|
|
424
438
|
plt.xlabel(x_title_unit)
|
|
@@ -878,3 +892,27 @@ def plot_simtel_ctapipe(filename, cleaning_args, distance, return_cleaned=False)
|
|
|
878
892
|
ax.set_axis_off()
|
|
879
893
|
fig.tight_layout()
|
|
880
894
|
return fig
|
|
895
|
+
|
|
896
|
+
|
|
897
|
+
def save_figure(fig, output_file, figure_format=None, log_title=""):
|
|
898
|
+
"""
|
|
899
|
+
Save figure to output file(s).
|
|
900
|
+
|
|
901
|
+
Parameters
|
|
902
|
+
----------
|
|
903
|
+
fig: plt.figure
|
|
904
|
+
Figure to save.
|
|
905
|
+
output_file: Path, str
|
|
906
|
+
Path to save the figure (without suffix).
|
|
907
|
+
figure_format: list
|
|
908
|
+
List of formats to save the figure.
|
|
909
|
+
title: str
|
|
910
|
+
Title of the figure to be added to the log message.
|
|
911
|
+
"""
|
|
912
|
+
figure_format = figure_format or ["pdf", "png"]
|
|
913
|
+
for fmt in figure_format:
|
|
914
|
+
_file = Path(output_file).with_suffix(f".{fmt}")
|
|
915
|
+
fig.savefig(_file, format=fmt, bbox_inches="tight")
|
|
916
|
+
logging.info(f"Saved plot {log_title} to {_file}")
|
|
917
|
+
|
|
918
|
+
fig.clf()
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Module to mimic DB interaction for simulation model DB development.
|
|
3
|
-
|
|
4
|
-
Read simulation model values from files in simulation model repository.
|
|
5
|
-
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
|
-
import logging
|
|
9
|
-
|
|
10
|
-
import simtools.utils.general as gen
|
|
11
|
-
from simtools.utils import names
|
|
12
|
-
|
|
13
|
-
logger = logging.getLogger(__name__)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def update_model_parameters_from_repo(
|
|
17
|
-
parameters,
|
|
18
|
-
site,
|
|
19
|
-
array_element_name,
|
|
20
|
-
parameter_collection,
|
|
21
|
-
model_version,
|
|
22
|
-
db_simulation_model_url,
|
|
23
|
-
):
|
|
24
|
-
"""
|
|
25
|
-
Update model parameters with values from a repository.
|
|
26
|
-
|
|
27
|
-
Existing entries will be updated, new entries will be added.
|
|
28
|
-
|
|
29
|
-
Parameters
|
|
30
|
-
----------
|
|
31
|
-
parameters: dict
|
|
32
|
-
Existing dictionary with parameters to be updated.
|
|
33
|
-
site: str
|
|
34
|
-
Observatory site (e.g., South or North)
|
|
35
|
-
array_element_name: str
|
|
36
|
-
Array element name (e.g., MSTN-01, MSTN-design)
|
|
37
|
-
parameter_collection: str
|
|
38
|
-
Collection of parameters to be queried (e.g., telescope or site)
|
|
39
|
-
model_version: str
|
|
40
|
-
Model version to use.
|
|
41
|
-
db_simulation_model_url: str
|
|
42
|
-
URL to the simulation model repository.
|
|
43
|
-
|
|
44
|
-
Returns
|
|
45
|
-
-------
|
|
46
|
-
dict
|
|
47
|
-
Updated dictionary with parameters.
|
|
48
|
-
|
|
49
|
-
"""
|
|
50
|
-
logger.info(
|
|
51
|
-
"Updating model parameters from repository for site: %s, array element: %s",
|
|
52
|
-
site,
|
|
53
|
-
array_element_name,
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
if db_simulation_model_url is None:
|
|
57
|
-
logger.debug(f"No repository specified, skipping {parameter_collection} parameter updates")
|
|
58
|
-
return parameters
|
|
59
|
-
|
|
60
|
-
if parameter_collection in ["telescopes", "calibration"]:
|
|
61
|
-
_file_path = gen.join_url_or_path(
|
|
62
|
-
db_simulation_model_url,
|
|
63
|
-
"model_versions",
|
|
64
|
-
model_version,
|
|
65
|
-
array_element_name,
|
|
66
|
-
)
|
|
67
|
-
# use design array element model in case there is no model defined for this array element ID
|
|
68
|
-
_design_model = names.get_array_element_type_from_name(array_element_name) + "-design"
|
|
69
|
-
if _design_model == array_element_name:
|
|
70
|
-
_design_model = None
|
|
71
|
-
elif parameter_collection == "site":
|
|
72
|
-
_file_path = gen.join_url_or_path(
|
|
73
|
-
db_simulation_model_url,
|
|
74
|
-
"model_versions",
|
|
75
|
-
model_version,
|
|
76
|
-
"OBS-" + site,
|
|
77
|
-
)
|
|
78
|
-
_design_model = None
|
|
79
|
-
else:
|
|
80
|
-
raise ValueError(f"Unknown parameter collection {parameter_collection}")
|
|
81
|
-
|
|
82
|
-
for key in parameters:
|
|
83
|
-
_tmp_par = {}
|
|
84
|
-
_parameter_file = gen.join_url_or_path(_file_path, f"{key}.json")
|
|
85
|
-
try:
|
|
86
|
-
_tmp_par = gen.collect_data_from_file(file_name=_parameter_file)
|
|
87
|
-
except (FileNotFoundError, gen.InvalidConfigDataError):
|
|
88
|
-
# use design array element model in case there is no model defined for this
|
|
89
|
-
# array element ID. Accept errors, as not all parameters are defined in the repository
|
|
90
|
-
try:
|
|
91
|
-
_file_path = gen.join_url_or_path(
|
|
92
|
-
db_simulation_model_url,
|
|
93
|
-
"model_versions",
|
|
94
|
-
model_version,
|
|
95
|
-
_design_model,
|
|
96
|
-
)
|
|
97
|
-
_tmp_par = gen.collect_data_from_file(
|
|
98
|
-
file_name=gen.join_url_or_path(_file_path, f"{key}.json")
|
|
99
|
-
)
|
|
100
|
-
except (FileNotFoundError, TypeError, gen.InvalidConfigDataError):
|
|
101
|
-
pass
|
|
102
|
-
if _tmp_par.get("version") == model_version:
|
|
103
|
-
parameters[key] = _tmp_par
|
|
104
|
-
|
|
105
|
-
# return all entries which are not None
|
|
106
|
-
return {key: value for key, value in parameters.items() if value is not None}
|
|
File without changes
|
|
File without changes
|