gammasimtools 0.16.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.16.0.dist-info → gammasimtools-0.18.0.dist-info}/METADATA +5 -2
- {gammasimtools-0.16.0.dist-info → gammasimtools-0.18.0.dist-info}/RECORD +82 -74
- {gammasimtools-0.16.0.dist-info → gammasimtools-0.18.0.dist-info}/WHEEL +1 -1
- {gammasimtools-0.16.0.dist-info → gammasimtools-0.18.0.dist-info}/entry_points.txt +4 -1
- simtools/_version.py +2 -2
- simtools/applications/db_add_simulation_model_from_repository_to_db.py +10 -1
- simtools/applications/derive_ctao_array_layouts.py +5 -5
- simtools/applications/derive_mirror_rnda.py +1 -1
- simtools/applications/generate_simtel_event_data.py +128 -46
- simtools/applications/merge_tables.py +102 -0
- simtools/applications/plot_array_layout.py +145 -258
- 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 +78 -225
- simtools/applications/production_derive_statistics.py +77 -43
- simtools/applications/simulate_light_emission.py +1 -0
- simtools/applications/simulate_prod.py +30 -18
- simtools/applications/simulate_prod_htcondor_generator.py +0 -1
- simtools/applications/submit_array_layouts.py +93 -0
- simtools/applications/verify_simulation_model_production_tables.py +52 -0
- simtools/camera/camera_efficiency.py +3 -3
- simtools/configuration/commandline_parser.py +30 -35
- simtools/configuration/configurator.py +0 -4
- simtools/constants.py +2 -0
- simtools/corsika/corsika_config.py +17 -12
- simtools/corsika/primary_particle.py +46 -13
- simtools/data_model/metadata_collector.py +7 -3
- simtools/data_model/schema.py +15 -1
- simtools/db/db_handler.py +16 -11
- simtools/db/db_model_upload.py +2 -2
- simtools/io_operations/io_handler.py +2 -2
- simtools/io_operations/io_table_handler.py +345 -0
- simtools/job_execution/htcondor_script_generator.py +2 -2
- simtools/job_execution/job_manager.py +7 -121
- simtools/layout/array_layout_utils.py +389 -0
- simtools/model/array_model.py +10 -1
- simtools/model/model_repository.py +134 -0
- simtools/production_configuration/{calculate_statistical_errors_grid_point.py → calculate_statistical_uncertainties_grid_point.py} +101 -112
- simtools/production_configuration/derive_corsika_limits.py +239 -111
- simtools/production_configuration/derive_corsika_limits_grid.py +232 -0
- simtools/production_configuration/derive_production_statistics.py +57 -26
- simtools/production_configuration/derive_production_statistics_handler.py +70 -37
- simtools/production_configuration/interpolation_handler.py +296 -94
- simtools/ray_tracing/ray_tracing.py +7 -6
- simtools/reporting/docs_read_parameters.py +104 -62
- simtools/resources/array-element-ids.json +126 -0
- simtools/runners/corsika_simtel_runner.py +4 -1
- simtools/runners/runner_services.py +5 -4
- 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/dsum_threshold.schema.yml +41 -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/schemas/production_configuration_metrics.schema.yml +2 -2
- simtools/simtel/simtel_config_writer.py +34 -14
- simtools/simtel/simtel_io_event_reader.py +301 -194
- simtools/simtel/simtel_io_event_writer.py +237 -221
- simtools/simtel/simtel_io_file_info.py +9 -4
- simtools/simtel/simtel_io_metadata.py +119 -8
- simtools/simtel/simulator_array.py +2 -2
- simtools/simtel/simulator_light_emission.py +79 -34
- simtools/simtel/simulator_ray_tracing.py +2 -2
- simtools/simulator.py +101 -68
- simtools/testing/validate_output.py +4 -1
- simtools/utils/general.py +1 -3
- simtools/utils/names.py +76 -7
- simtools/visualization/plot_array_layout.py +242 -0
- simtools/visualization/plot_pixels.py +680 -0
- simtools/visualization/plot_tables.py +81 -2
- simtools/visualization/visualize.py +3 -219
- simtools/applications/production_generate_simulation_config.py +0 -152
- simtools/layout/ctao_array_layouts.py +0 -172
- simtools/production_configuration/generate_simulation_config.py +0 -158
- {gammasimtools-0.16.0.dist-info → gammasimtools-0.18.0.dist-info}/licenses/LICENSE +0 -0
- {gammasimtools-0.16.0.dist-info → gammasimtools-0.18.0.dist-info}/top_level.txt +0 -0
- /simtools/{schemas → resources}/array_elements.yml +0 -0
|
@@ -1,17 +1,98 @@
|
|
|
1
1
|
#!/usr/bin/python3
|
|
2
2
|
|
|
3
|
-
"""
|
|
4
|
-
|
|
3
|
+
r"""
|
|
4
|
+
Generate a reduced dataset of event data from output of telescope simulations.
|
|
5
|
+
|
|
6
|
+
Processes sim_telarray output files (typically of type '.simtel.zst') and creates
|
|
7
|
+
reduced datasets containing shower information, array-level parameters, and data about
|
|
8
|
+
triggered telescopes.
|
|
9
|
+
|
|
10
|
+
The output consists of an HDF5 or FITS file containing the following tables:
|
|
11
|
+
|
|
12
|
+
**FILE_INFO**
|
|
13
|
+
|
|
14
|
+
+-------------------+---------+-----------------------------------------------+
|
|
15
|
+
| Field | Type | Description |
|
|
16
|
+
+===================+=========+===============================================+
|
|
17
|
+
| file_name | string | Name of the file |
|
|
18
|
+
+-------------------+---------+-----------------------------------------------+
|
|
19
|
+
| file_id | int64 | Internal unique identifier for the file |
|
|
20
|
+
+-------------------+---------+-----------------------------------------------+
|
|
21
|
+
| particle_id | int64 | PDG particle ID (e.g., 14 for proton) |
|
|
22
|
+
+-------------------+---------+-----------------------------------------------+
|
|
23
|
+
| energy_min | float32 | Minimum simulated energy (TeV) |
|
|
24
|
+
+-------------------+---------+-----------------------------------------------+
|
|
25
|
+
| energy_max | float32 | Maximum simulated energy (TeV) |
|
|
26
|
+
+-------------------+---------+-----------------------------------------------+
|
|
27
|
+
| viewcone_min | float32 | Min viewcone angle (rad) |
|
|
28
|
+
+-------------------+---------+-----------------------------------------------+
|
|
29
|
+
| viewcone_max | float32 | Max viewcone angle (rad) |
|
|
30
|
+
+-------------------+---------+-----------------------------------------------+
|
|
31
|
+
| core_scatter_min | float32 | Min core scatter radius (m) |
|
|
32
|
+
+-------------------+---------+-----------------------------------------------+
|
|
33
|
+
| core_scatter_max | float32 | Max core scatter radius (m) |
|
|
34
|
+
+-------------------+---------+-----------------------------------------------+
|
|
35
|
+
| zenith | float32 | Zenith angle (rad) |
|
|
36
|
+
+-------------------+---------+-----------------------------------------------+
|
|
37
|
+
| azimuth | float32 | Azimuth angle (rad) |
|
|
38
|
+
+-------------------+---------+-----------------------------------------------+
|
|
39
|
+
| nsb_level | float64 | Night sky background level (photons/deg^2/ns) |
|
|
40
|
+
+-------------------+---------+-----------------------------------------------+
|
|
41
|
+
|
|
42
|
+
**SHOWERS**
|
|
43
|
+
|
|
44
|
+
+------------------+---------+-----------------------------------------------+
|
|
45
|
+
| Field | Type | Description |
|
|
46
|
+
+==================+=========+===============================================+
|
|
47
|
+
| shower_id | int64 | Shower identifier |
|
|
48
|
+
+------------------+---------+-----------------------------------------------+
|
|
49
|
+
| event_id | int64 | Event identifier (depends on reuse of showers)|
|
|
50
|
+
+------------------+---------+-----------------------------------------------+
|
|
51
|
+
| file_id | int64 | Internal unique identifier for the file |
|
|
52
|
+
+------------------+---------+-----------------------------------------------+
|
|
53
|
+
| simulated_energy | float64 | Simulated primary energy (TeV) |
|
|
54
|
+
+------------------+---------+-----------------------------------------------+
|
|
55
|
+
| x_core | float64 | Shower core X position on ground (m) |
|
|
56
|
+
+------------------+---------+-----------------------------------------------+
|
|
57
|
+
| y_core | float64 | Shower core Y position on ground (m) |
|
|
58
|
+
+------------------+---------+-----------------------------------------------+
|
|
59
|
+
| shower_azimuth | float64 | Direction of shower azimuth (rad) |
|
|
60
|
+
+------------------+---------+-----------------------------------------------+
|
|
61
|
+
| shower_altitude | float64 | Direction of shower altitude (rad) |
|
|
62
|
+
+------------------+---------+-----------------------------------------------+
|
|
63
|
+
| area_weight | float64 | Weighting factor for sampling area |
|
|
64
|
+
+------------------+---------+-----------------------------------------------+
|
|
65
|
+
|
|
66
|
+
**TRIGGERS**
|
|
67
|
+
|
|
68
|
+
+-----------------+---------+-----------------------------------------------+
|
|
69
|
+
| Field | Type | Description |
|
|
70
|
+
+=================+=========+===============================================+
|
|
71
|
+
| shower_id | int64 | Shower identifier |
|
|
72
|
+
+-----------------+---------+-----------------------------------------------+
|
|
73
|
+
| event_id | int64 | Event identifier (depends on reuse of showers)|
|
|
74
|
+
+-----------------+---------+-----------------------------------------------+
|
|
75
|
+
| file_id | int64 | Internal unique identifier for the file |
|
|
76
|
+
+-----------------+---------+-----------------------------------------------+
|
|
77
|
+
| array_altitude | float64 | Altitude of array pointing direction (rad) |
|
|
78
|
+
+-----------------+---------+-----------------------------------------------+
|
|
79
|
+
| array_azimuth | float64 | Azimuth of array pointing direction (rad) |
|
|
80
|
+
+-----------------+---------+-----------------------------------------------+
|
|
81
|
+
| telescope_list | string | Comma-separated list of triggered telescopes |
|
|
82
|
+
+-----------------+---------+-----------------------------------------------+
|
|
83
|
+
|
|
84
|
+
Several files generated with this application can be combined into a single
|
|
85
|
+
dataset using the 'simtools-merge-tables' command.
|
|
5
86
|
|
|
6
87
|
Command line arguments
|
|
7
88
|
----------------------
|
|
8
89
|
prefix (str, required)
|
|
9
90
|
Path prefix for the input files.
|
|
10
91
|
output_file (str, required)
|
|
11
|
-
|
|
92
|
+
Output file path.
|
|
12
93
|
max_files (int, optional, default=100)
|
|
13
|
-
Maximum number of files to process.
|
|
14
|
-
print_dataset_information (
|
|
94
|
+
Maximum number of input files to process.
|
|
95
|
+
print_dataset_information (int, optional, default=0)
|
|
15
96
|
Print information about the datasets in the generated reduced event dataset.
|
|
16
97
|
|
|
17
98
|
Example
|
|
@@ -20,13 +101,27 @@ Generate a reduced dataset from input files and save the result.
|
|
|
20
101
|
|
|
21
102
|
.. code-block:: console
|
|
22
103
|
|
|
23
|
-
simtools-production-extract-mc-event-data
|
|
24
|
-
simtools-generate-simtel-event-data
|
|
25
|
-
--
|
|
26
|
-
--
|
|
27
|
-
--
|
|
28
|
-
--
|
|
29
|
-
|
|
104
|
+
simtools-production-extract-mc-event-data \\
|
|
105
|
+
simtools-generate-simtel-event-data \\
|
|
106
|
+
--input 'path/to/input_files/gamma_*dark*.simtel.zst' \\
|
|
107
|
+
--output_file output_file.hdf5 \\
|
|
108
|
+
--max_files 50 \\
|
|
109
|
+
--print_dataset_information 10
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
To read a reduced event data file, use the following command reading on of the test files:
|
|
113
|
+
|
|
114
|
+
.. code-block:: console
|
|
115
|
+
|
|
116
|
+
import h5py
|
|
117
|
+
|
|
118
|
+
test_file = "tests/resources/proton_za20deg_azm000deg_North_alpha_6.0.0_reduced_event_data.hdf5"
|
|
119
|
+
|
|
120
|
+
with h5py.File(test_file, "r") as f:
|
|
121
|
+
triggers = f["/TRIGGERS"]
|
|
122
|
+
for row in triggers:
|
|
123
|
+
print({name: row[name] for name in row.dtype.names})
|
|
124
|
+
|
|
30
125
|
"""
|
|
31
126
|
|
|
32
127
|
import logging
|
|
@@ -34,8 +129,8 @@ from pathlib import Path
|
|
|
34
129
|
|
|
35
130
|
import simtools.utils.general as gen
|
|
36
131
|
from simtools.configuration import configurator
|
|
37
|
-
from simtools.
|
|
38
|
-
from simtools.
|
|
132
|
+
from simtools.data_model.metadata_collector import MetadataCollector
|
|
133
|
+
from simtools.io_operations import io_handler, io_table_handler
|
|
39
134
|
from simtools.simtel.simtel_io_event_writer import SimtelIOEventDataWriter
|
|
40
135
|
|
|
41
136
|
|
|
@@ -51,35 +146,24 @@ def _parse(label, description):
|
|
|
51
146
|
config = configurator.Configurator(label=label, description=description)
|
|
52
147
|
|
|
53
148
|
config.parser.add_argument(
|
|
54
|
-
"--
|
|
55
|
-
)
|
|
56
|
-
config.parser.add_argument(
|
|
57
|
-
"--wildcard",
|
|
149
|
+
"--input",
|
|
58
150
|
type=str,
|
|
59
151
|
required=True,
|
|
60
|
-
help="
|
|
152
|
+
help="Input file path (wildcards allowed; e.g., '/data_path/gamma_*dark*.simtel.zst')",
|
|
61
153
|
)
|
|
62
|
-
config.parser.add_argument("--output_file", type=str, required=True, help="Output filename.")
|
|
63
154
|
config.parser.add_argument(
|
|
64
|
-
"--max_files", type=int, default=100, help="Maximum number of files to process."
|
|
155
|
+
"--max_files", type=int, default=100, help="Maximum number of input files to process."
|
|
65
156
|
)
|
|
66
|
-
|
|
67
157
|
config.parser.add_argument(
|
|
68
158
|
"--print_dataset_information",
|
|
69
159
|
type=int,
|
|
70
|
-
help="Print given number of
|
|
160
|
+
help="Print data set information for the given number of events.",
|
|
71
161
|
default=0,
|
|
72
162
|
)
|
|
73
|
-
|
|
74
|
-
return config.initialize(db_config=False)
|
|
163
|
+
return config.initialize(db_config=False, output=True)
|
|
75
164
|
|
|
76
165
|
|
|
77
|
-
def main():
|
|
78
|
-
"""
|
|
79
|
-
Process event data files and store data in reduced dataset.
|
|
80
|
-
|
|
81
|
-
The reduced dataset contains shower information, array information and triggered telescopes.
|
|
82
|
-
"""
|
|
166
|
+
def main(): # noqa: D103
|
|
83
167
|
label = Path(__file__).stem
|
|
84
168
|
|
|
85
169
|
args_dict, _ = _parse(
|
|
@@ -90,27 +174,25 @@ def main():
|
|
|
90
174
|
),
|
|
91
175
|
)
|
|
92
176
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
177
|
+
logger = logging.getLogger()
|
|
178
|
+
logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
|
|
179
|
+
logger.info(f"Loading input files from: {args_dict['input']}")
|
|
96
180
|
|
|
97
|
-
|
|
98
|
-
files = list(
|
|
181
|
+
input_pattern = Path(args_dict["input"])
|
|
182
|
+
files = list(input_pattern.parent.glob(input_pattern.name))
|
|
99
183
|
if not files:
|
|
100
|
-
|
|
184
|
+
logger.warning("No matching input files found.")
|
|
101
185
|
return
|
|
102
186
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
generator.process_files()
|
|
109
|
-
_logger.info(f"reduced dataset saved to: {output_filepath}")
|
|
187
|
+
output_filepath = io_handler.IOHandler().get_output_file(args_dict["output_file"])
|
|
188
|
+
generator = SimtelIOEventDataWriter(files, args_dict["max_files"])
|
|
189
|
+
tables = generator.process_files()
|
|
190
|
+
io_table_handler.write_tables(tables, output_filepath, overwrite_existing=True)
|
|
191
|
+
MetadataCollector.dump(args_dict=args_dict, output_file=output_filepath.with_suffix(".yml"))
|
|
110
192
|
|
|
111
193
|
if args_dict["print_dataset_information"] > 0:
|
|
112
|
-
|
|
113
|
-
|
|
194
|
+
for table in tables:
|
|
195
|
+
table.pprint(max_lines=args_dict["print_dataset_information"], max_width=-1)
|
|
114
196
|
|
|
115
197
|
|
|
116
198
|
if __name__ == "__main__":
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
r"""
|
|
2
|
+
Merge tables from multiple input files into single tables.
|
|
3
|
+
|
|
4
|
+
Allows to merge tables (e.g., astropy tables) from multiple input files into a single file.
|
|
5
|
+
The input files can be of HDF5 or FITS format.
|
|
6
|
+
specified output file.
|
|
7
|
+
|
|
8
|
+
Merging large tables in FITS are not recommended, as it may lead to
|
|
9
|
+
performance issues.
|
|
10
|
+
|
|
11
|
+
Command line arguments
|
|
12
|
+
----------------------
|
|
13
|
+
input str
|
|
14
|
+
Input file(s) (e.g., 'file1 file2').
|
|
15
|
+
input_list str
|
|
16
|
+
File with list of input files with tables.
|
|
17
|
+
table_names list of str
|
|
18
|
+
Names of tables to merge from each input file.
|
|
19
|
+
output_file str
|
|
20
|
+
Output file name.
|
|
21
|
+
output_path str
|
|
22
|
+
Path to the output file for the merged tables.
|
|
23
|
+
|
|
24
|
+
Example
|
|
25
|
+
-------
|
|
26
|
+
|
|
27
|
+
Merge tables from two files generated with 'simtools-generate-simtel-event-data' into a single file.
|
|
28
|
+
|
|
29
|
+
.. code-block:: console
|
|
30
|
+
|
|
31
|
+
simtools-merge-tables \\
|
|
32
|
+
--input_files file1 file2' \\
|
|
33
|
+
--table_names 'SHOWERS TRIGGERS FILE_INFO' \\
|
|
34
|
+
--output_file merged_tables.hdf5
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
import logging
|
|
40
|
+
from pathlib import Path
|
|
41
|
+
|
|
42
|
+
import simtools.utils.general as gen
|
|
43
|
+
from simtools.configuration import configurator
|
|
44
|
+
from simtools.io_operations import io_handler, io_table_handler
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _parse(label, description):
|
|
48
|
+
"""
|
|
49
|
+
Parse command line arguments.
|
|
50
|
+
|
|
51
|
+
Returns
|
|
52
|
+
-------
|
|
53
|
+
dict
|
|
54
|
+
Parsed command-line arguments.
|
|
55
|
+
"""
|
|
56
|
+
config = configurator.Configurator(label=label, description=description)
|
|
57
|
+
|
|
58
|
+
input_group = config.parser.add_mutually_exclusive_group(required=True)
|
|
59
|
+
input_group.add_argument(
|
|
60
|
+
"--input_files",
|
|
61
|
+
type=str,
|
|
62
|
+
nargs="+",
|
|
63
|
+
help="Input file(s) (e.g., 'file1 file2') or a file with a list of input files.",
|
|
64
|
+
)
|
|
65
|
+
config.parser.add_argument(
|
|
66
|
+
"--table_names",
|
|
67
|
+
type=str,
|
|
68
|
+
nargs="+",
|
|
69
|
+
help="Names of tables to merge from each input file.",
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
return config.initialize(db_config=False, output=True)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def main(): # noqa: D103
|
|
76
|
+
label = Path(__file__).stem
|
|
77
|
+
|
|
78
|
+
args_dict, _ = _parse(
|
|
79
|
+
label=label,
|
|
80
|
+
description=("Merge tables from multiple input files into single tables."),
|
|
81
|
+
)
|
|
82
|
+
logger = logging.getLogger()
|
|
83
|
+
logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
|
|
84
|
+
logger.info(f"Loading input files: {args_dict['input_files']}")
|
|
85
|
+
|
|
86
|
+
# accept fits.gz files (.gz)
|
|
87
|
+
input_files = gen.get_list_of_files_from_command_line(
|
|
88
|
+
args_dict["input_files"], [".hdf5", ".gz"]
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
output_path = io_handler.IOHandler().get_output_directory(label)
|
|
92
|
+
output_filepath = Path(output_path).joinpath(f"{args_dict['output_file']}")
|
|
93
|
+
|
|
94
|
+
io_table_handler.merge_tables(
|
|
95
|
+
input_files,
|
|
96
|
+
input_table_names=args_dict["table_names"],
|
|
97
|
+
output_file=output_filepath,
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
if __name__ == "__main__":
|
|
102
|
+
main()
|