gammasimtools 0.9.0__py3-none-any.whl → 0.10.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.10.0.dist-info}/METADATA +2 -2
- {gammasimtools-0.9.0.dist-info → gammasimtools-0.10.0.dist-info}/RECORD +94 -85
- {gammasimtools-0.9.0.dist-info → gammasimtools-0.10.0.dist-info}/entry_points.txt +2 -1
- simtools/_version.py +2 -2
- simtools/applications/calculate_trigger_rate.py +15 -38
- simtools/applications/convert_all_model_parameters_from_simtel.py +9 -28
- simtools/applications/convert_geo_coordinates_of_array_elements.py +47 -45
- simtools/applications/convert_model_parameter_from_simtel.py +2 -2
- simtools/applications/db_add_file_to_db.py +1 -2
- 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 +44 -32
- simtools/applications/derive_photon_electron_spectrum.py +99 -0
- simtools/applications/generate_array_config.py +17 -17
- simtools/applications/generate_regular_arrays.py +15 -15
- simtools/applications/generate_simtel_array_histograms.py +11 -48
- simtools/applications/production_generate_simulation_config.py +25 -7
- simtools/applications/production_scale_events.py +2 -2
- 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 +8 -6
- simtools/applications/validate_camera_efficiency.py +2 -2
- simtools/applications/validate_file_using_schema.py +23 -19
- simtools/camera/single_photon_electron_spectrum.py +168 -0
- simtools/configuration/commandline_parser.py +8 -1
- simtools/constants.py +10 -3
- simtools/corsika/corsika_config.py +8 -7
- simtools/corsika/corsika_histograms.py +1 -1
- simtools/data_model/data_reader.py +0 -3
- simtools/data_model/metadata_collector.py +3 -4
- simtools/data_model/metadata_model.py +8 -124
- simtools/data_model/model_data_writer.py +17 -63
- simtools/data_model/schema.py +213 -0
- simtools/data_model/validate_data.py +9 -44
- simtools/db/db_handler.py +323 -495
- simtools/db/db_model_upload.py +139 -0
- simtools/io_operations/hdf5_handler.py +54 -24
- simtools/layout/array_layout.py +33 -28
- simtools/model/array_model.py +13 -7
- simtools/model/model_parameter.py +22 -54
- simtools/model/site_model.py +2 -2
- simtools/production_configuration/calculate_statistical_errors_grid_point.py +119 -144
- simtools/production_configuration/event_scaler.py +7 -17
- simtools/production_configuration/generate_simulation_config.py +5 -32
- simtools/production_configuration/interpolation_handler.py +8 -11
- simtools/runners/corsika_simtel_runner.py +3 -1
- simtools/schemas/input/MST_mirror_2f_measurements.schema.yml +39 -0
- simtools/schemas/input/single_pe_spectrum.schema.yml +38 -0
- simtools/schemas/integration_tests_config.metaschema.yml +10 -0
- simtools/schemas/model_parameter.metaschema.yml +7 -2
- simtools/schemas/model_parameter_and_data_schema.metaschema.yml +2 -0
- 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/corsika_iact_io_buffer.schema.yml +2 -2
- 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/laser_photons.schema.yml +2 -2
- simtools/schemas/model_parameters/secondary_mirror_degraded_reflection.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_writer.py +5 -6
- simtools/simtel/simtel_io_histogram.py +32 -67
- simtools/simtel/simtel_io_histograms.py +15 -30
- simtools/simtel/simulator_array.py +2 -1
- simtools/simtel/simulator_camera_efficiency.py +5 -0
- simtools/simtel/simulator_light_emission.py +3 -1
- simtools/simtel/simulator_ray_tracing.py +2 -1
- simtools/testing/helpers.py +6 -13
- simtools/testing/validate_output.py +131 -47
- simtools/utils/general.py +102 -12
- simtools/utils/names.py +24 -20
- 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.10.0.dist-info}/LICENSE +0 -0
- {gammasimtools-0.9.0.dist-info → gammasimtools-0.10.0.dist-info}/WHEEL +0 -0
- {gammasimtools-0.9.0.dist-info → gammasimtools-0.10.0.dist-info}/top_level.txt +0 -0
- /simtools/{camera_efficiency.py → camera/camera_efficiency.py} +0 -0
|
@@ -82,6 +82,16 @@ definitions:
|
|
|
82
82
|
description: |
|
|
83
83
|
"Reference file used for comparison."
|
|
84
84
|
type: string
|
|
85
|
+
TEST_SIMTEL_CFG_FILES:
|
|
86
|
+
description: |
|
|
87
|
+
"Reference file used for comparison of sim_telarray configuration files."
|
|
88
|
+
type: object
|
|
89
|
+
additionalProperties: false
|
|
90
|
+
patternProperties:
|
|
91
|
+
"^[0-9]+\\.[0-9]+\\.[0-9]+$": # Semantic versioning pattern (e.g., "5.0.0", "6.0.0")
|
|
92
|
+
type: string
|
|
93
|
+
description: Path to the configuration file for the given version.
|
|
94
|
+
minProperties: 1
|
|
85
95
|
TOLERANCE:
|
|
86
96
|
description: "Allowed tolerance for floating point comparison."
|
|
87
97
|
type: number
|
|
@@ -25,14 +25,19 @@ definitions:
|
|
|
25
25
|
type: boolean
|
|
26
26
|
description: "This parameter is a file."
|
|
27
27
|
instrument:
|
|
28
|
-
type:
|
|
28
|
+
type:
|
|
29
|
+
- string
|
|
30
|
+
- "null"
|
|
29
31
|
description: "Associated instrument."
|
|
30
32
|
site:
|
|
31
|
-
type:
|
|
33
|
+
type:
|
|
34
|
+
- string
|
|
35
|
+
- "null"
|
|
32
36
|
description: "Associated CTAO site."
|
|
33
37
|
enum:
|
|
34
38
|
- North
|
|
35
39
|
- South
|
|
40
|
+
- null
|
|
36
41
|
type:
|
|
37
42
|
type: string
|
|
38
43
|
description: "Data type"
|
|
@@ -25,6 +25,7 @@ definitions:
|
|
|
25
25
|
description: "name of meta schema (e.g. simpipe-schema)"
|
|
26
26
|
meta_schema_url:
|
|
27
27
|
type: string
|
|
28
|
+
format: uri
|
|
28
29
|
description: "url to meta schema definition"
|
|
29
30
|
meta_schema_version:
|
|
30
31
|
type: string
|
|
@@ -322,6 +323,7 @@ definitions:
|
|
|
322
323
|
- ValidateArrayElementCoordinates
|
|
323
324
|
- ValidateAtmosphericModel
|
|
324
325
|
- ValidateCameraChargeResponse
|
|
326
|
+
- ValidateCameraEfficiency
|
|
325
327
|
- ValidateCameraGainsAndEfficiency
|
|
326
328
|
- ValidateCameraGeometry
|
|
327
329
|
- ValidateCameraLinearity
|
|
@@ -7,7 +7,7 @@ meta_schema_url: https://raw.githubusercontent.com/gammasim/simtools/main/src/si
|
|
|
7
7
|
meta_schema_version: 0.1.0
|
|
8
8
|
name: array_element_position_utm
|
|
9
9
|
description: |-
|
|
10
|
-
Position and
|
|
10
|
+
Position and altitude of an array element (e.g., a telescope) in UTM coordinates.
|
|
11
11
|
short_description: UTM coordinate position of an array element.
|
|
12
12
|
data:
|
|
13
13
|
- type: double
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
%YAML 1.2
|
|
2
|
+
---
|
|
3
|
+
title: Schema for array_window model parameter
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
meta_schema: simpipe-schema
|
|
6
|
+
meta_schema_url: https://raw.githubusercontent.com/gammasim/simtools/main/src/simtools/schemas/model_parameter_and_data_schema.metaschema.yml
|
|
7
|
+
meta_schema_version: 0.1.0
|
|
8
|
+
name: array_window
|
|
9
|
+
description: |-
|
|
10
|
+
Length of a coincidence window of the default stereo trigger,
|
|
11
|
+
after correction of fixed (cable length, focal length, etc.)
|
|
12
|
+
and variable (view direction) delays.
|
|
13
|
+
short_description: |-
|
|
14
|
+
Length of a coincidence window of the default stereo trigger.
|
|
15
|
+
data:
|
|
16
|
+
- type: double
|
|
17
|
+
unit: ns
|
|
18
|
+
default: 1000.
|
|
19
|
+
instrument:
|
|
20
|
+
class: Camera
|
|
21
|
+
type:
|
|
22
|
+
- LSTN
|
|
23
|
+
- LSTS
|
|
24
|
+
- MSTN
|
|
25
|
+
- MSTS
|
|
26
|
+
- SSTS
|
|
27
|
+
- SCTS
|
|
28
|
+
activity:
|
|
29
|
+
setting:
|
|
30
|
+
- SetParameterFromExternal
|
|
31
|
+
validation:
|
|
32
|
+
- ValidateParameterByExpert
|
|
33
|
+
- ValidateTriggerPerformance
|
|
34
|
+
source:
|
|
35
|
+
- Initial instrument setup
|
|
36
|
+
simulation_software:
|
|
37
|
+
- name: sim_telarray
|
|
@@ -8,7 +8,7 @@ meta_schema_version: 0.1.0
|
|
|
8
8
|
name: channels_per_chip
|
|
9
9
|
description: |-
|
|
10
10
|
Number of channels per readout chip.
|
|
11
|
-
Potentially useful for
|
|
11
|
+
Potentially useful for cross-talk calculations.
|
|
12
12
|
short_description: Number of channels per readout chip.
|
|
13
13
|
data:
|
|
14
14
|
- type: uint
|
|
@@ -8,7 +8,7 @@ meta_schema_version: 0.1.0
|
|
|
8
8
|
name: fadc_compensate_pedestal
|
|
9
9
|
description: |-
|
|
10
10
|
Emulate FADC pedestal compensation (as e.g., done in camera firmware using FPGAs)
|
|
11
|
-
to
|
|
11
|
+
to homogenize significant pixel-to-pixel variations of raw pedestals values
|
|
12
12
|
(for high-gain channel for dual-gain readout).
|
|
13
13
|
The resulting values are still unsigned integers and no rescaling takes place
|
|
14
14
|
(pure integer pedestal offset). No compensation takes place for the default value
|
|
@@ -8,7 +8,7 @@ meta_schema_version: 0.1.0
|
|
|
8
8
|
name: fadc_lg_compensate_pedestal
|
|
9
9
|
description: |-
|
|
10
10
|
Emulate FADC pedestal compensation (as e.g., done in camera firmware using FPGAs)
|
|
11
|
-
to
|
|
11
|
+
to homogenize significant pixel-to-pixel variations of raw pedestals values
|
|
12
12
|
(for low-gain channel for dual-gain readout).
|
|
13
13
|
The resulting values are still unsigned integers and no rescaling takes place
|
|
14
14
|
(pure integer pedestal offset). No compensation takes place for the default value
|
|
@@ -7,13 +7,13 @@ meta_schema_url: https://raw.githubusercontent.com/gammasim/simtools/main/src/si
|
|
|
7
7
|
meta_schema_version: 0.1.0
|
|
8
8
|
name: fadc_noise
|
|
9
9
|
description: |-
|
|
10
|
-
Gaussian r.m.s. spread of white noise per time bin in
|
|
10
|
+
Gaussian r.m.s. spread of white noise per time bin in digitization
|
|
11
11
|
(for high-gain channel, if different gains are used).
|
|
12
|
-
short_description: Gaussian r.m.s. spread of white noise per time bin in
|
|
12
|
+
short_description: Gaussian r.m.s. spread of white noise per time bin in digitization.
|
|
13
13
|
data:
|
|
14
14
|
- type: double
|
|
15
15
|
description: |-
|
|
16
|
-
Gaussian r.m.s. spread of white noise per time bin in
|
|
16
|
+
Gaussian r.m.s. spread of white noise per time bin in digitization
|
|
17
17
|
(for high-gain channel in case of dual-readout chain)
|
|
18
18
|
unit: count
|
|
19
19
|
default: 4.0
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
%YAML 1.2
|
|
2
|
+
---
|
|
3
|
+
title: Schema for fake_mirror_list model parameter
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
meta_schema: simpipe-schema
|
|
6
|
+
meta_schema_url: https://raw.githubusercontent.com/gammasim/simtools/main/src/simtools/schemas/model_parameter_and_data_schema.metaschema.yml
|
|
7
|
+
meta_schema_version: 0.1.0
|
|
8
|
+
developer_note: To be replaced by a data table
|
|
9
|
+
name: fake_mirror_list
|
|
10
|
+
short_description: Fake mirror list to be used for camera efficiency calculations ('testeff' program).
|
|
11
|
+
description: |-
|
|
12
|
+
Fake mirror list to be used for camera efficiency calculations ('testeff' program).
|
|
13
|
+
Allows to obtain realistic distributions of the photon incidence angles on the camera plan.
|
|
14
|
+
Not to be used for actual simulations.
|
|
15
|
+
data:
|
|
16
|
+
- type: file
|
|
17
|
+
unit: dimensionless
|
|
18
|
+
default: None
|
|
19
|
+
instrument:
|
|
20
|
+
class: Structure
|
|
21
|
+
type:
|
|
22
|
+
- SSTS
|
|
23
|
+
- SCTS
|
|
24
|
+
activity:
|
|
25
|
+
setting:
|
|
26
|
+
- SetParameterFromExternal
|
|
27
|
+
validation:
|
|
28
|
+
- ValidateParameterByExpert
|
|
29
|
+
- ValidateCameraEfficiency
|
|
30
|
+
source:
|
|
31
|
+
- Initial instrument setup
|
|
32
|
+
simulation_software:
|
|
33
|
+
- name: sim_telarray
|
|
@@ -7,9 +7,9 @@ meta_schema_url: https://raw.githubusercontent.com/gammasim/simtools/main/src/si
|
|
|
7
7
|
meta_schema_version: 0.1.0
|
|
8
8
|
name: laser_photons
|
|
9
9
|
description: |-
|
|
10
|
-
Number of laser photons at each
|
|
10
|
+
Number of laser photons at each photo detector.
|
|
11
11
|
short_description: |-
|
|
12
|
-
Number of laser photons at each
|
|
12
|
+
Number of laser photons at each photo detector.
|
|
13
13
|
data:
|
|
14
14
|
- type: double
|
|
15
15
|
unit: dimensionless
|
|
@@ -10,7 +10,7 @@ description: |-
|
|
|
10
10
|
Mirror degradation factor for the secondary mirror (wavelength independent).
|
|
11
11
|
Strictly interpreted as being for reflection on the secondary mirror of a
|
|
12
12
|
dual-mirror telescope, and still gets applied in simulations where only
|
|
13
|
-
the reflection on the primary mirror is
|
|
13
|
+
the reflection on the primary mirror is bypassed (for example a
|
|
14
14
|
flat-fielding light source illuminating the camera via reflection on the
|
|
15
15
|
secondary).
|
|
16
16
|
short_description: |-
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
---
|
|
2
|
+
$schema: http://json-schema.org/draft-06/schema#
|
|
3
|
+
$ref: '#/definitions/ErrorMetrics'
|
|
4
|
+
title: Statistical Error Metrics Schema
|
|
5
|
+
description: |
|
|
6
|
+
YAML representation of simulation production configuration
|
|
7
|
+
metrics.
|
|
8
|
+
version: 0.1.0
|
|
9
|
+
name: production_configuration_metrics.metaschema
|
|
10
|
+
type: object
|
|
11
|
+
additionalProperties: false
|
|
12
|
+
|
|
13
|
+
definitions:
|
|
14
|
+
ErrorMetrics:
|
|
15
|
+
type: object
|
|
16
|
+
description: Definition of error metrics and validity ranges.
|
|
17
|
+
additionalProperties: false
|
|
18
|
+
properties:
|
|
19
|
+
uncertainty_effective_area:
|
|
20
|
+
$ref: '#/definitions/ErrorMetric'
|
|
21
|
+
energy_estimate:
|
|
22
|
+
$ref: '#/definitions/ErrorMetric'
|
|
23
|
+
|
|
24
|
+
ErrorMetric:
|
|
25
|
+
type: object
|
|
26
|
+
description: Error metric definition.
|
|
27
|
+
additionalProperties: false
|
|
28
|
+
properties:
|
|
29
|
+
description:
|
|
30
|
+
type: string
|
|
31
|
+
description: Description of the error metric.
|
|
32
|
+
target_error:
|
|
33
|
+
$ref: '#/definitions/TargetError'
|
|
34
|
+
energy_range:
|
|
35
|
+
$ref: '#/definitions/EnergyRange'
|
|
36
|
+
required:
|
|
37
|
+
- target_error
|
|
38
|
+
- energy_range
|
|
39
|
+
|
|
40
|
+
TargetError:
|
|
41
|
+
type: object
|
|
42
|
+
description: Target error specification.
|
|
43
|
+
additionalProperties: false
|
|
44
|
+
properties:
|
|
45
|
+
value:
|
|
46
|
+
type: number
|
|
47
|
+
description: Target error value.
|
|
48
|
+
required:
|
|
49
|
+
- value
|
|
50
|
+
|
|
51
|
+
EnergyRange:
|
|
52
|
+
type: object
|
|
53
|
+
description: Energy range specification.
|
|
54
|
+
additionalProperties: false
|
|
55
|
+
properties:
|
|
56
|
+
value:
|
|
57
|
+
type: array
|
|
58
|
+
description: Energy range values.
|
|
59
|
+
items:
|
|
60
|
+
type: number
|
|
61
|
+
minItems: 2
|
|
62
|
+
maxItems: 2
|
|
63
|
+
unit:
|
|
64
|
+
type: string
|
|
65
|
+
description: Energy unit.
|
|
66
|
+
required:
|
|
67
|
+
- value
|
|
68
|
+
- unit
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
$schema: http://json-schema.org/draft-06/schema#
|
|
3
|
+
$ref: '#/definitions/ProductionModelTable'
|
|
4
|
+
title: SimPipe DB Production Model Metaschema
|
|
5
|
+
description: |
|
|
6
|
+
YAML representation of DB production model metaschema
|
|
7
|
+
(based on simulation model DB).
|
|
8
|
+
version: 0.1.0
|
|
9
|
+
name: production_table.metaschema
|
|
10
|
+
type: object
|
|
11
|
+
additionalProperties: false
|
|
12
|
+
|
|
13
|
+
definitions:
|
|
14
|
+
ProductionModelTable:
|
|
15
|
+
properties:
|
|
16
|
+
model_version:
|
|
17
|
+
type: string
|
|
18
|
+
description: Model version.
|
|
19
|
+
pattern: '^\d+\.\d+\.\d+$'
|
|
20
|
+
parameters:
|
|
21
|
+
type: object
|
|
22
|
+
description: Model parameters.
|
|
23
|
+
additionalProperties:
|
|
24
|
+
type: object
|
|
25
|
+
description: Model parameter.
|
|
26
|
+
additionalProperties:
|
|
27
|
+
type: string
|
|
28
|
+
description: Parameter version (semantical versioning).
|
|
29
|
+
pattern: '^\d+\.\d+\.\d+$'
|
|
30
|
+
propertyNames:
|
|
31
|
+
description: Allowed parameter name patterns.
|
|
32
|
+
pattern: '^([A-Za-z](ST|LL)[N,S,x]-\d{2,3}|[A-Za-z](ST|LL)[N,S,x]-design|OBS-(North|South)|Dummy-Telescope)$'
|
|
33
|
+
design_model:
|
|
34
|
+
type: object
|
|
35
|
+
description: Design models.
|
|
36
|
+
additionalProperties:
|
|
37
|
+
type: string
|
|
38
|
+
description: Design model of a telescope
|
|
39
|
+
required:
|
|
40
|
+
- model_version
|
|
41
|
+
- parameters
|
|
@@ -78,8 +78,10 @@ class SimtelConfigWriter:
|
|
|
78
78
|
file.write("#endif\n\n")
|
|
79
79
|
|
|
80
80
|
for _simtel_name, value in parameters.items():
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
# array trigger is a site parameter, not a telescope parameter
|
|
82
|
+
# fake_mirror_list is not a sim_telarray parameter (used for testeff only)
|
|
83
|
+
if _simtel_name.startswith("array_trigger") or _simtel_name == "fake_mirror_list":
|
|
84
|
+
continue
|
|
83
85
|
if _simtel_name:
|
|
84
86
|
file.write(f"{_simtel_name} = {self._get_value_string_for_simtel(value)}\n")
|
|
85
87
|
_config_meta = self._get_simtel_metadata("telescope")
|
|
@@ -294,10 +296,7 @@ class SimtelConfigWriter:
|
|
|
294
296
|
_site_parameters = site_model.get_simtel_parameters()
|
|
295
297
|
for par, value in _site_parameters.items():
|
|
296
298
|
_simtel_name = names.get_simulation_software_name_from_parameter_name(
|
|
297
|
-
par,
|
|
298
|
-
simulation_software="sim_telarray",
|
|
299
|
-
search_telescope_parameters=False,
|
|
300
|
-
search_site_parameters=True,
|
|
299
|
+
par, simulation_software="sim_telarray"
|
|
301
300
|
)
|
|
302
301
|
_simtel_name, value = self._convert_model_parameters_to_simtel_format(
|
|
303
302
|
_simtel_name, value, model_path, telescope_model
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Reads the content of either a single histogram (.hdata) or a single simtel_array output (.simtel).
|
|
3
|
-
|
|
4
|
-
Files can be zst compressed.
|
|
5
|
-
"""
|
|
1
|
+
"""Reads the content of either a single histogram or simtel_array output file."""
|
|
6
2
|
|
|
7
3
|
import copy
|
|
8
4
|
import logging
|
|
@@ -81,9 +77,9 @@ class SimtelIOHistogram:
|
|
|
81
77
|
self._config = None
|
|
82
78
|
self._total_area = None
|
|
83
79
|
self._solid_angle = None
|
|
80
|
+
self._histogram = None
|
|
84
81
|
self._total_num_simulated_events = None
|
|
85
82
|
self._total_num_triggered_events = None
|
|
86
|
-
self._histogram = None
|
|
87
83
|
self._initialize_histogram()
|
|
88
84
|
self.trigger_rate = None
|
|
89
85
|
self.trigger_rate_uncertainty = None
|
|
@@ -134,56 +130,39 @@ class SimtelIOHistogram:
|
|
|
134
130
|
"""
|
|
135
131
|
Return information about the input parameters for the simulation.
|
|
136
132
|
|
|
133
|
+
If the file is a .hdata or .hdata.zst, config will be None.
|
|
134
|
+
|
|
137
135
|
Returns
|
|
138
136
|
-------
|
|
139
137
|
dict:
|
|
140
138
|
dictionary with information about the simulation (pyeventio MCRunHeader object).
|
|
141
139
|
"""
|
|
142
140
|
if self._config is None:
|
|
143
|
-
# If the file is a .hdata or .hdata.zst, config will continue to be None.
|
|
144
141
|
with EventIOFile(self.histogram_file) as f:
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
self._config = obj.parse()
|
|
149
|
-
|
|
142
|
+
self._config = next(
|
|
143
|
+
(obj.parse() for obj in f if isinstance(obj, MCRunHeader)), None
|
|
144
|
+
)
|
|
150
145
|
return self._config
|
|
151
146
|
|
|
152
147
|
@property
|
|
153
|
-
def
|
|
154
|
-
"""
|
|
155
|
-
Return the total number of simulated events the histograms.
|
|
156
|
-
|
|
157
|
-
Returns
|
|
158
|
-
-------
|
|
159
|
-
int:
|
|
160
|
-
total number of simulated events.
|
|
161
|
-
"""
|
|
162
|
-
if self._total_num_simulated_events is None:
|
|
163
|
-
events_histogram, _ = self.fill_event_histogram_dicts()
|
|
164
|
-
self._total_num_simulated_events = np.sum(events_histogram["data"])
|
|
165
|
-
logging.debug(f"Number of total simulated showers: {self._total_num_simulated_events}")
|
|
166
|
-
return self._total_num_simulated_events
|
|
167
|
-
|
|
168
|
-
@property
|
|
169
|
-
def total_num_triggered_events(self):
|
|
148
|
+
def total_number_of_events(self):
|
|
170
149
|
"""
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
Please note that this value is not supposed to match the trigger rate x estimated
|
|
174
|
-
observation time, as the simulation is optimized for computational time and the energy
|
|
175
|
-
distribution assumed is not necessarily the reference cosmic-ray spectra.
|
|
150
|
+
Return the total number of simulated and triggered events in the histograms.
|
|
176
151
|
|
|
177
152
|
Returns
|
|
178
153
|
-------
|
|
179
|
-
int:
|
|
180
|
-
total number of simulated events.
|
|
154
|
+
int, int:
|
|
155
|
+
total number of simulated and triggered events.
|
|
181
156
|
"""
|
|
182
|
-
if self._total_num_triggered_events is None:
|
|
183
|
-
|
|
157
|
+
if self._total_num_simulated_events is None or self._total_num_triggered_events is None:
|
|
158
|
+
simulated_histogram, trigger_histogram = self.fill_event_histogram_dicts()
|
|
159
|
+
self._total_num_simulated_events = np.sum(simulated_histogram["data"])
|
|
184
160
|
self._total_num_triggered_events = np.sum(trigger_histogram["data"])
|
|
185
|
-
logging.debug(
|
|
186
|
-
|
|
161
|
+
logging.debug(
|
|
162
|
+
"Number of total simulated / triggered events: "
|
|
163
|
+
f"{self._total_num_simulated_events} / {self._total_num_triggered_events}"
|
|
164
|
+
)
|
|
165
|
+
return self._total_num_simulated_events, self._total_num_triggered_events
|
|
187
166
|
|
|
188
167
|
def fill_event_histogram_dicts(self):
|
|
189
168
|
"""
|
|
@@ -191,34 +170,18 @@ class SimtelIOHistogram:
|
|
|
191
170
|
|
|
192
171
|
Returns
|
|
193
172
|
-------
|
|
194
|
-
dict:
|
|
195
|
-
Information about the histograms with simulated events.
|
|
196
|
-
dict:
|
|
197
|
-
Information about the histograms with triggered events.
|
|
173
|
+
tuple(dict, dict):
|
|
174
|
+
Information about the histograms with simulated and triggered events.
|
|
198
175
|
|
|
199
176
|
Raises
|
|
200
177
|
------
|
|
201
178
|
HistogramIdNotFoundError:
|
|
202
179
|
if histogram ids not found. Problem with the file.
|
|
203
180
|
"""
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
triggered_events_histogram = None
|
|
209
|
-
for hist in self.histogram:
|
|
210
|
-
if hist["id"] == 1:
|
|
211
|
-
events_histogram = hist
|
|
212
|
-
found_simulated_events_hist = True
|
|
213
|
-
elif hist["id"] == 2:
|
|
214
|
-
triggered_events_histogram = hist
|
|
215
|
-
found_triggered_events_hist = True
|
|
216
|
-
if found_simulated_events_hist * found_triggered_events_hist:
|
|
217
|
-
if "triggered_events_histogram" in locals():
|
|
218
|
-
return events_histogram, triggered_events_histogram
|
|
219
|
-
msg = "Histograms ids not found. Please check your files."
|
|
220
|
-
|
|
221
|
-
self._logger.error(msg)
|
|
181
|
+
histograms = {hist["id"]: hist for hist in self.histogram if hist["id"] in {1, 2}}
|
|
182
|
+
if 1 in histograms and 2 in histograms:
|
|
183
|
+
return histograms[1], histograms[2]
|
|
184
|
+
self._logger.error("Histograms ids not found. Please check your files.")
|
|
222
185
|
raise HistogramIdNotFoundError
|
|
223
186
|
|
|
224
187
|
def _set_view_cone(self, view_cone):
|
|
@@ -521,11 +484,11 @@ class SimtelIOHistogram:
|
|
|
521
484
|
"""
|
|
522
485
|
Get the particle distribution function.
|
|
523
486
|
|
|
524
|
-
This depends
|
|
487
|
+
This depends on whether one wants the reference CR distribution or the distribution
|
|
525
488
|
used in the simulation. This is controlled by label.
|
|
526
489
|
By using label="reference", one gets the distribution function according to a pre-defined CR
|
|
527
490
|
distribution, while by using label="simulation", the spectral index of the distribution
|
|
528
|
-
function from the simulation is used.
|
|
491
|
+
function from the simulation is used. The label="simulation" works only when the
|
|
529
492
|
input file is a .simtel file and not a .hdata file.
|
|
530
493
|
|
|
531
494
|
Parameters
|
|
@@ -603,7 +566,8 @@ class SimtelIOHistogram:
|
|
|
603
566
|
self.energy_range[1],
|
|
604
567
|
)
|
|
605
568
|
if stacked_num_simulated_events is None:
|
|
606
|
-
|
|
569
|
+
_simulated_events, _ = self.total_number_of_events
|
|
570
|
+
return (_simulated_events / first_estimate) * u.s
|
|
607
571
|
return (stacked_num_simulated_events / first_estimate) * u.s
|
|
608
572
|
|
|
609
573
|
def estimate_trigger_rate_uncertainty(
|
|
@@ -648,13 +612,14 @@ class SimtelIOHistogram:
|
|
|
648
612
|
dict:
|
|
649
613
|
Dictionary with the information, e.g., view angle, energy range, etc.
|
|
650
614
|
"""
|
|
615
|
+
_simulated, _triggered = self.total_number_of_events
|
|
651
616
|
info_dict = {
|
|
652
617
|
"view_cone": self.view_cone,
|
|
653
618
|
"solid_angle": self.solid_angle,
|
|
654
619
|
"total_area": self.total_area,
|
|
655
620
|
"energy_range": self.energy_range,
|
|
656
|
-
"total_num_simulated_events":
|
|
657
|
-
"total_num_triggered_events":
|
|
621
|
+
"total_num_simulated_events": _simulated,
|
|
622
|
+
"total_num_triggered_events": _triggered,
|
|
658
623
|
}
|
|
659
624
|
if mode != "silent":
|
|
660
625
|
print(info_dict)
|