gammasimtools 0.17.0__py3-none-any.whl → 0.18.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.17.0.dist-info → gammasimtools-0.18.0.dist-info}/METADATA +2 -1
- {gammasimtools-0.17.0.dist-info → gammasimtools-0.18.0.dist-info}/RECORD +44 -42
- {gammasimtools-0.17.0.dist-info → gammasimtools-0.18.0.dist-info}/entry_points.txt +1 -0
- simtools/_version.py +2 -2
- simtools/applications/db_add_simulation_model_from_repository_to_db.py +10 -1
- simtools/applications/derive_mirror_rnda.py +1 -1
- simtools/applications/generate_simtel_event_data.py +95 -3
- simtools/applications/merge_tables.py +14 -16
- simtools/applications/plot_tabular_data.py +12 -1
- simtools/applications/plot_tabular_data_for_model_parameter.py +103 -0
- simtools/applications/production_derive_corsika_limits.py +61 -23
- simtools/configuration/commandline_parser.py +2 -1
- simtools/constants.py +2 -0
- simtools/data_model/schema.py +15 -1
- simtools/db/db_handler.py +5 -0
- simtools/io_operations/io_table_handler.py +1 -1
- simtools/layout/array_layout_utils.py +5 -1
- simtools/model/array_model.py +5 -1
- simtools/production_configuration/derive_corsika_limits_grid.py +46 -3
- simtools/resources/array-element-ids.json +126 -0
- simtools/schemas/model_parameter_and_data_schema.metaschema.yml +5 -1
- simtools/schemas/model_parameters/atmospheric_profile.schema.yml +41 -0
- simtools/schemas/model_parameters/atmospheric_transmission.schema.yml +43 -0
- simtools/schemas/model_parameters/camera_filter.schema.yml +10 -0
- simtools/schemas/model_parameters/camera_filter_incidence_angle.schema.yml +10 -0
- simtools/schemas/model_parameters/discriminator_pulse_shape.schema.yml +31 -0
- simtools/schemas/model_parameters/fadc_pulse_shape.schema.yml +12 -0
- simtools/schemas/model_parameters/lightguide_efficiency_vs_incidence_angle.schema.yml +10 -0
- simtools/schemas/model_parameters/mirror_reflectivity.schema.yml +10 -0
- simtools/schemas/model_parameters/nsb_reference_spectrum.schema.yml +12 -0
- simtools/schemas/model_parameters/pm_photoelectron_spectrum.schema.yml +19 -0
- simtools/schemas/model_parameters/quantum_efficiency.schema.yml +10 -0
- simtools/schemas/plot_configuration.metaschema.yml +46 -57
- simtools/simtel/simtel_io_event_reader.py +1 -1
- simtools/simtel/simtel_io_event_writer.py +37 -1
- simtools/simtel/simtel_io_metadata.py +99 -3
- simtools/utils/general.py +0 -2
- simtools/utils/names.py +71 -2
- simtools/visualization/plot_pixels.py +0 -1
- simtools/visualization/plot_tables.py +81 -2
- {gammasimtools-0.17.0.dist-info → gammasimtools-0.18.0.dist-info}/WHEEL +0 -0
- {gammasimtools-0.17.0.dist-info → gammasimtools-0.18.0.dist-info}/licenses/LICENSE +0 -0
- {gammasimtools-0.17.0.dist-info → gammasimtools-0.18.0.dist-info}/top_level.txt +0 -0
- /simtools/{schemas → resources}/array_elements.yml +0 -0
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/python3
|
|
2
2
|
"""Plot tabular data."""
|
|
3
3
|
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
4
6
|
import numpy as np
|
|
5
7
|
from astropy.table import Table
|
|
6
8
|
|
|
7
9
|
import simtools.utils.general as gen
|
|
10
|
+
from simtools.constants import SCHEMA_PATH
|
|
8
11
|
from simtools.db import db_handler
|
|
9
12
|
from simtools.io_operations import legacy_data_handler
|
|
10
13
|
from simtools.visualization import visualize
|
|
@@ -20,6 +23,8 @@ def plot(config, output_file, db_config=None):
|
|
|
20
23
|
Configuration dictionary for plotting.
|
|
21
24
|
output_file: str
|
|
22
25
|
Output file.
|
|
26
|
+
db_config: dict, optional
|
|
27
|
+
Database configuration dictionary for accessing the model parameter database.
|
|
23
28
|
"""
|
|
24
29
|
data = read_table_data(config, db_config)
|
|
25
30
|
|
|
@@ -29,6 +34,8 @@ def plot(config, output_file, db_config=None):
|
|
|
29
34
|
)
|
|
30
35
|
visualize.save_figure(fig, output_file)
|
|
31
36
|
|
|
37
|
+
return output_file
|
|
38
|
+
|
|
32
39
|
|
|
33
40
|
def read_table_data(config, db_config):
|
|
34
41
|
"""
|
|
@@ -69,7 +76,8 @@ def read_table_data(config, db_config):
|
|
|
69
76
|
_config["select_values"]["column_name"],
|
|
70
77
|
_config["select_values"]["value"],
|
|
71
78
|
)
|
|
72
|
-
|
|
79
|
+
label = _config.get("label", f"{_config.get('column_x')} vs {_config.get('column_y')}")
|
|
80
|
+
data[label] = gen.get_structure_array_from_table(
|
|
73
81
|
table,
|
|
74
82
|
[
|
|
75
83
|
_config["column_x"],
|
|
@@ -93,7 +101,7 @@ def _read_table_from_model_database(table_config, db_config):
|
|
|
93
101
|
Returns
|
|
94
102
|
-------
|
|
95
103
|
Table
|
|
96
|
-
Astropy table
|
|
104
|
+
Astropy table
|
|
97
105
|
"""
|
|
98
106
|
db = db_handler.DatabaseHandler(mongo_db_config=db_config)
|
|
99
107
|
return db.export_model_file(
|
|
@@ -109,3 +117,74 @@ def _read_table_from_model_database(table_config, db_config):
|
|
|
109
117
|
def _select_values_from_table(table, column_name, value):
|
|
110
118
|
"""Return a table with only the rows where column_name == value."""
|
|
111
119
|
return table[np.isclose(table[column_name], value)]
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def generate_plot_configurations(
|
|
123
|
+
parameter, parameter_version, site, telescope, output_path, plot_type
|
|
124
|
+
):
|
|
125
|
+
"""
|
|
126
|
+
Generate plot configurations for a model parameter from schema files.
|
|
127
|
+
|
|
128
|
+
Parameters
|
|
129
|
+
----------
|
|
130
|
+
parameter: str
|
|
131
|
+
Model parameter name.
|
|
132
|
+
|
|
133
|
+
Returns
|
|
134
|
+
-------
|
|
135
|
+
tuple
|
|
136
|
+
Tuple containing a list of plot configurations and a list of output file names.
|
|
137
|
+
Return None, if no plot configurations are found.
|
|
138
|
+
"""
|
|
139
|
+
schema = gen.change_dict_keys_case(
|
|
140
|
+
gen.collect_data_from_file(
|
|
141
|
+
file_name=SCHEMA_PATH / "model_parameters" / f"{parameter}.schema.yml"
|
|
142
|
+
)
|
|
143
|
+
)
|
|
144
|
+
configs = schema.get("plot_configuration")
|
|
145
|
+
if not configs:
|
|
146
|
+
return None
|
|
147
|
+
if plot_type != "all":
|
|
148
|
+
configs = [config for config in configs if config.get("type") == plot_type]
|
|
149
|
+
if not configs:
|
|
150
|
+
raise ValueError(
|
|
151
|
+
f"No plot configuration found for type '{plot_type}' in parameter '{parameter}'."
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
output_files = []
|
|
155
|
+
for _config in configs:
|
|
156
|
+
for _table in _config.get("tables", []):
|
|
157
|
+
_table["parameter_version"] = parameter_version
|
|
158
|
+
_table["site"] = site
|
|
159
|
+
output_files.append(
|
|
160
|
+
_generate_output_file_name(
|
|
161
|
+
parameter=parameter,
|
|
162
|
+
parameter_version=parameter_version,
|
|
163
|
+
site=site,
|
|
164
|
+
telescope=telescope,
|
|
165
|
+
plot_type=_config.get("type"),
|
|
166
|
+
output_path=output_path,
|
|
167
|
+
)
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
return configs, output_files
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def _generate_output_file_name(
|
|
174
|
+
parameter,
|
|
175
|
+
parameter_version,
|
|
176
|
+
site,
|
|
177
|
+
telescope,
|
|
178
|
+
plot_type,
|
|
179
|
+
output_path=None,
|
|
180
|
+
file_extension=".pdf",
|
|
181
|
+
):
|
|
182
|
+
"""Generate output file name based on table file and appendix."""
|
|
183
|
+
parts = [parameter, parameter_version, site]
|
|
184
|
+
if telescope:
|
|
185
|
+
parts.append(telescope)
|
|
186
|
+
if plot_type != parameter:
|
|
187
|
+
parts.append(plot_type)
|
|
188
|
+
filename = "_".join(parts) + file_extension
|
|
189
|
+
|
|
190
|
+
return Path(output_path) / filename if output_path else Path(filename)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|