gammasimtools 0.8.2__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.
Files changed (122) hide show
  1. {gammasimtools-0.8.2.dist-info → gammasimtools-0.10.0.dist-info}/METADATA +4 -4
  2. {gammasimtools-0.8.2.dist-info → gammasimtools-0.10.0.dist-info}/RECORD +119 -105
  3. {gammasimtools-0.8.2.dist-info → gammasimtools-0.10.0.dist-info}/WHEEL +1 -1
  4. {gammasimtools-0.8.2.dist-info → gammasimtools-0.10.0.dist-info}/entry_points.txt +4 -1
  5. simtools/_version.py +2 -2
  6. simtools/applications/calculate_trigger_rate.py +15 -38
  7. simtools/applications/convert_all_model_parameters_from_simtel.py +9 -28
  8. simtools/applications/convert_geo_coordinates_of_array_elements.py +54 -53
  9. simtools/applications/convert_model_parameter_from_simtel.py +2 -2
  10. simtools/applications/db_add_file_to_db.py +1 -2
  11. simtools/applications/db_add_simulation_model_from_repository_to_db.py +110 -0
  12. simtools/applications/db_add_value_from_json_to_db.py +2 -11
  13. simtools/applications/db_development_tools/write_array_elements_positions_to_repository.py +6 -6
  14. simtools/applications/db_get_array_layouts_from_db.py +3 -1
  15. simtools/applications/db_get_file_from_db.py +11 -12
  16. simtools/applications/db_get_parameter_from_db.py +44 -32
  17. simtools/applications/derive_mirror_rnda.py +10 -1
  18. simtools/applications/derive_photon_electron_spectrum.py +99 -0
  19. simtools/applications/derive_psf_parameters.py +1 -1
  20. simtools/applications/generate_array_config.py +18 -22
  21. simtools/applications/generate_regular_arrays.py +24 -21
  22. simtools/applications/generate_simtel_array_histograms.py +11 -48
  23. simtools/applications/plot_array_layout.py +3 -1
  24. simtools/applications/plot_tabular_data.py +84 -0
  25. simtools/applications/production_generate_simulation_config.py +25 -7
  26. simtools/applications/production_scale_events.py +3 -4
  27. simtools/applications/simulate_light_emission.py +2 -2
  28. simtools/applications/simulate_prod.py +25 -60
  29. simtools/applications/simulate_prod_htcondor_generator.py +95 -0
  30. simtools/applications/submit_data_from_external.py +12 -4
  31. simtools/applications/submit_model_parameter_from_external.py +8 -6
  32. simtools/applications/validate_camera_efficiency.py +3 -3
  33. simtools/applications/validate_camera_fov.py +3 -7
  34. simtools/applications/validate_cumulative_psf.py +3 -7
  35. simtools/applications/validate_file_using_schema.py +38 -24
  36. simtools/applications/validate_optics.py +3 -4
  37. simtools/{camera_efficiency.py → camera/camera_efficiency.py} +1 -4
  38. simtools/camera/single_photon_electron_spectrum.py +168 -0
  39. simtools/configuration/commandline_parser.py +14 -13
  40. simtools/configuration/configurator.py +6 -19
  41. simtools/constants.py +10 -3
  42. simtools/corsika/corsika_config.py +8 -7
  43. simtools/corsika/corsika_histograms.py +1 -1
  44. simtools/data_model/data_reader.py +0 -3
  45. simtools/data_model/metadata_collector.py +21 -4
  46. simtools/data_model/metadata_model.py +8 -111
  47. simtools/data_model/model_data_writer.py +18 -64
  48. simtools/data_model/schema.py +213 -0
  49. simtools/data_model/validate_data.py +73 -51
  50. simtools/db/db_handler.py +395 -790
  51. simtools/db/db_model_upload.py +139 -0
  52. simtools/io_operations/hdf5_handler.py +54 -24
  53. simtools/io_operations/legacy_data_handler.py +61 -0
  54. simtools/job_execution/htcondor_script_generator.py +133 -0
  55. simtools/job_execution/job_manager.py +77 -50
  56. simtools/layout/array_layout.py +33 -28
  57. simtools/model/array_model.py +13 -7
  58. simtools/model/camera.py +4 -2
  59. simtools/model/model_parameter.py +61 -63
  60. simtools/model/site_model.py +3 -3
  61. simtools/production_configuration/calculate_statistical_errors_grid_point.py +119 -144
  62. simtools/production_configuration/event_scaler.py +7 -17
  63. simtools/production_configuration/generate_simulation_config.py +5 -32
  64. simtools/production_configuration/interpolation_handler.py +8 -11
  65. simtools/ray_tracing/mirror_panel_psf.py +47 -27
  66. simtools/runners/corsika_runner.py +14 -3
  67. simtools/runners/corsika_simtel_runner.py +3 -1
  68. simtools/runners/runner_services.py +3 -3
  69. simtools/runners/simtel_runner.py +27 -8
  70. simtools/schemas/input/MST_mirror_2f_measurements.schema.yml +39 -0
  71. simtools/schemas/input/single_pe_spectrum.schema.yml +38 -0
  72. simtools/schemas/integration_tests_config.metaschema.yml +23 -3
  73. simtools/schemas/model_parameter.metaschema.yml +95 -2
  74. simtools/schemas/model_parameter_and_data_schema.metaschema.yml +2 -0
  75. simtools/schemas/model_parameters/array_element_position_utm.schema.yml +1 -1
  76. simtools/schemas/model_parameters/array_window.schema.yml +37 -0
  77. simtools/schemas/model_parameters/asum_clipping.schema.yml +0 -4
  78. simtools/schemas/model_parameters/channels_per_chip.schema.yml +1 -1
  79. simtools/schemas/model_parameters/corsika_iact_io_buffer.schema.yml +2 -2
  80. simtools/schemas/model_parameters/dsum_clipping.schema.yml +0 -2
  81. simtools/schemas/model_parameters/dsum_ignore_below.schema.yml +0 -2
  82. simtools/schemas/model_parameters/dsum_offset.schema.yml +0 -2
  83. simtools/schemas/model_parameters/dsum_pedsub.schema.yml +0 -2
  84. simtools/schemas/model_parameters/dsum_pre_clipping.schema.yml +0 -2
  85. simtools/schemas/model_parameters/dsum_prescale.schema.yml +0 -2
  86. simtools/schemas/model_parameters/dsum_presum_max.schema.yml +0 -2
  87. simtools/schemas/model_parameters/dsum_presum_shift.schema.yml +0 -2
  88. simtools/schemas/model_parameters/dsum_shaping.schema.yml +0 -2
  89. simtools/schemas/model_parameters/dsum_shaping_renormalize.schema.yml +0 -2
  90. simtools/schemas/model_parameters/dsum_threshold.schema.yml +0 -2
  91. simtools/schemas/model_parameters/dsum_zero_clip.schema.yml +0 -2
  92. simtools/schemas/model_parameters/effective_focal_length.schema.yml +31 -1
  93. simtools/schemas/model_parameters/fadc_compensate_pedestal.schema.yml +1 -1
  94. simtools/schemas/model_parameters/fadc_lg_compensate_pedestal.schema.yml +1 -1
  95. simtools/schemas/model_parameters/fadc_noise.schema.yml +3 -3
  96. simtools/schemas/model_parameters/fake_mirror_list.schema.yml +33 -0
  97. simtools/schemas/model_parameters/laser_photons.schema.yml +2 -2
  98. simtools/schemas/model_parameters/secondary_mirror_degraded_reflection.schema.yml +1 -1
  99. simtools/schemas/production_configuration_metrics.schema.yml +68 -0
  100. simtools/schemas/production_tables.schema.yml +41 -0
  101. simtools/simtel/simtel_config_writer.py +5 -6
  102. simtools/simtel/simtel_io_histogram.py +32 -67
  103. simtools/simtel/simtel_io_histograms.py +15 -30
  104. simtools/simtel/simtel_table_reader.py +410 -0
  105. simtools/simtel/simulator_array.py +2 -1
  106. simtools/simtel/simulator_camera_efficiency.py +11 -4
  107. simtools/simtel/simulator_light_emission.py +5 -3
  108. simtools/simtel/simulator_ray_tracing.py +2 -2
  109. simtools/simulator.py +80 -33
  110. simtools/testing/configuration.py +12 -8
  111. simtools/testing/helpers.py +9 -16
  112. simtools/testing/validate_output.py +152 -68
  113. simtools/utils/general.py +149 -12
  114. simtools/utils/names.py +25 -21
  115. simtools/utils/value_conversion.py +9 -1
  116. simtools/visualization/plot_tables.py +106 -0
  117. simtools/visualization/visualize.py +43 -5
  118. simtools/applications/db_add_model_parameters_from_repository_to_db.py +0 -184
  119. simtools/db/db_array_elements.py +0 -130
  120. simtools/db/db_from_repo_handler.py +0 -106
  121. {gammasimtools-0.8.2.dist-info → gammasimtools-0.10.0.dist-info}/LICENSE +0 -0
  122. {gammasimtools-0.8.2.dist-info → gammasimtools-0.10.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/python3
2
+
3
+ r"""
4
+ Derive single photon electron spectrum from a given amplitude spectrum.
5
+
6
+ Normalizes singe-p.e. amplitude distribution to mean amplitude of 1.0,
7
+ as required by sim_telarray. Allows to fold in afterpulse distribution
8
+ to prompt a spectrum. Uses the sim_telarray tool 'norm_spe' to normalize
9
+ the spectra.
10
+
11
+ Input files can be in ecsv format (preferred) or in the sim_telarray legacy format.
12
+
13
+ Two output files with identical data are written to the output directory:
14
+
15
+ - 'output_file'.ecsv: Single photon electron spectrum in ecsv format (data and metadata).
16
+ - 'output_file'.dat: Single photon electron spectrum in sim_telarray format.
17
+
18
+ Example
19
+ -------
20
+
21
+ .. code-block:: console
22
+
23
+ simtools-derive-photon-electron-spectrum \\
24
+ --input_spectrum spectrum_photon_electron.ecsv \\
25
+ --afterpulse_spectrum spectrum_afterpulse.ecsv \\
26
+ --step_size 0.02 \\
27
+ --max_amplitude 42.0 \\
28
+ --use_norm_spe \\
29
+ --output_path ./tests/output \\
30
+ --output_file spectrum_photon_electron_afterpulse.ecsv
31
+
32
+ For an example of how to plot the single photon electron spectrum, see the
33
+ integration test 'tests/integration_tests/config/plot_tabular_data_for_single_pe_data.yml'.
34
+
35
+ """
36
+
37
+ import logging
38
+ from pathlib import Path
39
+
40
+ import simtools.utils.general as gen
41
+ from simtools.camera.single_photon_electron_spectrum import SinglePhotonElectronSpectrum
42
+ from simtools.configuration import configurator
43
+
44
+
45
+ def _parse(label):
46
+ """Parse command line configuration."""
47
+ config = configurator.Configurator(
48
+ label=label,
49
+ description="Derive single photon electron spectrum from a given amplitude spectrum.",
50
+ )
51
+ config.parser.add_argument(
52
+ "--input_spectrum",
53
+ help="File with amplitude spectrum.",
54
+ type=Path,
55
+ required=True,
56
+ )
57
+ config.parser.add_argument(
58
+ "--afterpulse_spectrum",
59
+ help="File with afterpulse spectrum.",
60
+ type=Path,
61
+ required=False,
62
+ )
63
+ config.parser.add_argument(
64
+ "--step_size",
65
+ help="Step size in amplitude spectrum",
66
+ type=float,
67
+ default=0.02,
68
+ required=False,
69
+ )
70
+ config.parser.add_argument(
71
+ "--max_amplitude",
72
+ help="Maximum amplitude in amplitude spectrum",
73
+ type=float,
74
+ default=42.0,
75
+ required=False,
76
+ )
77
+ config.parser.add_argument(
78
+ "--use_norm_spe",
79
+ help="Use sim_telarray tool 'norm_spe' to normalize the spectrum.",
80
+ action="store_true",
81
+ required=False,
82
+ )
83
+
84
+ return config.initialize(db_config=False, output=True)
85
+
86
+
87
+ def main(): # noqa: D103
88
+ args_dict, _ = _parse(Path(__file__).stem)
89
+
90
+ logger = logging.getLogger()
91
+ logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))
92
+
93
+ single_pe = SinglePhotonElectronSpectrum(args_dict)
94
+ single_pe.derive_single_pe_spectrum()
95
+ single_pe.write_single_pe_spectrum()
96
+
97
+
98
+ if __name__ == "__main__":
99
+ main()
@@ -150,7 +150,7 @@ def _parse():
150
150
  help=("Keep the first entry of mirror_reflection_random_angle fixed."),
151
151
  action="store_true",
152
152
  )
153
- return config.initialize(db_config=True, simulation_model="telescope")
153
+ return config.initialize(db_config=True, simulation_model=["telescope", "model_version"])
154
154
 
155
155
 
156
156
  def add_parameters(
@@ -1,32 +1,28 @@
1
1
  #!/usr/bin/python3
2
2
  """
3
- Generate sim_telarray configuration files for a given array.
3
+ Generate sim_telarray configuration files for a given array.
4
4
 
5
- The applications generates the sim_telarray configuration files for a given array, site,
6
- and model_version using the model parameters stored in the database.
5
+ The applications generates the sim_telarray configuration files for a given array, site,
6
+ and model_version using the model parameters stored in the database.
7
7
 
8
- To change model parameters, clone the model parameters repository and apply the changes.
9
- Forward the path to the repository to the application using the ``--db_simulation_model_url``
10
- argument.
8
+ Command line arguments
9
+ ----------------------
10
+ site : str
11
+ Site name (e.g., North, South).
12
+ array_layout_name : str
13
+ Name of the layout array (e.g., test_layout, alpha, 4mst, etc.).
14
+ array_element_list : list
15
+ List of array elements (e.g., telescopes) to plot (e.g., ``LSTN-01 LSTN-02 MSTN``).
11
16
 
12
- Command line arguments
13
- ----------------------
14
- site : str
15
- Site name (e.g., North, South).
16
- array_layout_name : str
17
- Name of the layout array (e.g., test_layout, alpha, 4mst, etc.).
18
- array_element_list : list
19
- List of array elements (e.g., telescopes) to plot (e.g., ``LSTN-01 LSTN-02 MSTN``).
17
+ Example
18
+ -------
19
+ North - 5.0.0:
20
20
 
21
- Example
22
- -------
23
- North - 5.0.0:
24
-
25
- .. code-block:: console
21
+ .. code-block:: console
26
22
 
27
- simtools-generate-array-config --site North --array_layout_name alpha --model_version 5.0.0
23
+ simtools-generate-array-config --site North --array_layout_name alpha --model_version 5.0.0
28
24
 
29
- The output is saved in simtools-output/test/model.
25
+ The output is saved in simtools-output/test/model.
30
26
  """
31
27
 
32
28
  import logging
@@ -54,7 +50,7 @@ def _parse(label, description):
54
50
  Command line parser object.
55
51
  """
56
52
  config = configurator.Configurator(label=label, description=description)
57
- return config.initialize(db_config=True, simulation_model=["site", "layout"])
53
+ return config.initialize(db_config=True, simulation_model=["site", "layout", "model_version"])
58
54
 
59
55
 
60
56
  def main():
@@ -1,31 +1,30 @@
1
1
  #!/usr/bin/python3
2
2
 
3
3
  """
4
- Make a regular array of telescopes and save it as astropy table.
4
+ Make a regular array of telescopes and save it as astropy table.
5
5
 
6
- The arrays consist of one telescope at the center of the array and or of 4 telescopes
7
- in a square grid. These arrays are used for trigger rate simulations.
6
+ The arrays consist of one telescope at the center of the array and or of 4 telescopes
7
+ in a square grid. These arrays are used for trigger rate simulations.
8
8
 
9
- The array layout files created will be available at the data/layout directory.
9
+ The array layout files created will be available at the data/layout directory.
10
10
 
11
- Command line arguments
12
- ----------------------
13
- site (str, required)
14
- observatory site (e.g., North or South).
15
- model_version (str, optional)
16
- Model version to use (e.g., 6.0.0). If not provided, the latest version is used.
11
+ Command line arguments
12
+ ----------------------
13
+ site (str, required)
14
+ observatory site (e.g., North or South).
15
+ model_version (str, optional)
16
+ Model version to use (e.g., 6.0.0). If not provided, the latest version is used.
17
17
 
18
- Example
19
- -------
20
- Runtime < 10 s.
18
+ Example
19
+ -------
20
+ Runtime < 10 s.
21
21
 
22
- .. code-block:: console
22
+ .. code-block:: console
23
23
 
24
- simtools-generate-regular-arrays --site=North
24
+ simtools-generate-regular-arrays --site=North
25
25
  """
26
26
 
27
27
  import logging
28
- import os
29
28
  from pathlib import Path
30
29
 
31
30
  import astropy.units as u
@@ -52,7 +51,9 @@ def _parse():
52
51
  f" SST: {telescope_distance['SST']}\n"
53
52
  ),
54
53
  )
55
- return config.initialize(db_config=False, simulation_model="site", output=True)
54
+ return config.initialize(
55
+ db_config=False, simulation_model=["site", "model_version"], output=True
56
+ )
56
57
 
57
58
 
58
59
  def main():
@@ -101,10 +102,12 @@ def main():
101
102
  table.sort("telescope_name")
102
103
  table.pprint()
103
104
 
104
- output_file = args_dict.get("output_file", None)
105
- if output_file is not None:
106
- base_name, file_extension = os.path.splitext(output_file)
107
- output_file = f"{base_name}-{args_dict['site']}-{array_name}{file_extension}"
105
+ output_file = args_dict.get("output_file")
106
+ if output_file:
107
+ output_path = Path(output_file)
108
+ output_file = output_path.with_name(
109
+ f"{output_path.stem}-{args_dict['site']}-{array_name}{output_path.suffix}"
110
+ )
108
111
  writer.ModelDataWriter.dump(
109
112
  args_dict=args_dict,
110
113
  output_file=output_file,
@@ -13,8 +13,6 @@ r"""
13
13
  Name of the histogram files to be plotted.
14
14
  It can be given as the histogram file names (more than one option allowed) or as a text
15
15
  file with the names of the histogram files in it.
16
- figure_name (str, required)
17
- File name for the pdf output (without extension).
18
16
  pdf (bool, optional)
19
17
  If set, histograms are saved into pdf files.
20
18
  One pdf file contains all the histograms found in the file.
@@ -29,6 +27,8 @@ r"""
29
27
  If the output output_file_name.hdf5 file already exists and hdf5 is set, the tables
30
28
  associated to hdf5 will be overwritten. The remaining tables, if any, will stay
31
29
  untouched.
30
+ test: bool
31
+ Test option. Generate only two histograms for testing purposes.
32
32
 
33
33
  Raises
34
34
  ------
@@ -108,38 +108,6 @@ def _parse(label, description):
108
108
  return config_parser
109
109
 
110
110
 
111
- def build_histogram_files(config_parser, logger):
112
- """
113
- Build a list of histogram files from command line arguments.
114
-
115
- Parameters
116
- ----------
117
- config_parser: dict
118
- Parsed command line arguments.
119
- logger: logging.Logger
120
- Logger object for logging messages.
121
-
122
- Returns
123
- -------
124
- list
125
- List of histogram file paths.
126
- """
127
- histogram_files = []
128
- for one_file in config_parser["hist_file_names"]:
129
- try:
130
- if Path(one_file).suffix in [".zst", ".simtel", ".hdata"]:
131
- histogram_files.append(one_file)
132
- else:
133
- with open(one_file, encoding="utf-8") as file:
134
- for line in file:
135
- histogram_files.append(line.strip())
136
- except FileNotFoundError as exc:
137
- msg = f"{one_file} is not a file."
138
- logger.error(msg)
139
- raise FileNotFoundError from exc
140
- return histogram_files
141
-
142
-
143
111
  def check_and_log_overwrite(config_parser, logger):
144
112
  """
145
113
  Check if the output hdf5 file already exists and log a warning if it does.
@@ -197,36 +165,31 @@ def create_pdf(simtel_histograms, output_file_name, config_parser, logger):
197
165
  logger.info(f"Wrote histograms to the pdf file {output_file_name}.pdf")
198
166
 
199
167
 
200
- def export_to_hdf5(simtel_histograms, output_file_name, overwrite, config_parser, logger):
201
- """Export histograms to an HDF5 file."""
202
- if config_parser["hdf5"]:
203
- logger.info(f"Wrote histograms to the hdf5 file {output_file_name}.hdf5")
204
- simtel_histograms.export_histograms(f"{output_file_name}.hdf5", overwrite=overwrite)
205
-
206
-
207
168
  def main(): # noqa: D103
208
169
  label = Path(__file__).stem
209
- description = "Display the simtel_array histograms."
170
+ description = "Display simtel_array histograms and/or write them into hdf5 format."
210
171
  io_handler_instance = io_handler.IOHandler()
211
172
  config_parser = _parse(label, description)
212
173
  output_path = io_handler_instance.get_output_directory(label, sub_dir="application-plots")
213
174
  logger = logging.getLogger()
214
175
  logger.setLevel(gen.get_log_level_from_user(config_parser["log_level"]))
215
- logger.info("Starting the application.")
216
176
 
217
- histogram_files = build_histogram_files(config_parser, logger)
177
+ histogram_files = gen.get_list_of_files_from_command_line(
178
+ config_parser["hist_file_names"], [".zst", ".simtel", ".hdata"]
179
+ )
218
180
 
219
181
  # If no output name is passed, the tool gets the name of the first histogram of the list
220
182
  if config_parser["output_file_name"] is None:
221
183
  config_parser["output_file_name"] = Path(histogram_files[0]).absolute().name
222
184
  output_file_name = Path(output_path).joinpath(f"{config_parser['output_file_name']}")
223
185
 
224
- # If the hdf5 output file already exists, it is overwritten
225
- overwrite = check_and_log_overwrite(config_parser, logger)
226
-
227
186
  simtel_histograms = SimtelIOHistograms(histogram_files)
228
187
  create_pdf(simtel_histograms, output_file_name, config_parser, logger)
229
- export_to_hdf5(simtel_histograms, output_file_name, overwrite, config_parser, logger)
188
+ if config_parser["hdf5"]:
189
+ simtel_histograms.export_histograms(
190
+ f"{output_file_name}.hdf5",
191
+ overwrite=check_and_log_overwrite(config_parser, logger),
192
+ )
230
193
 
231
194
 
232
195
  if __name__ == "__main__":
@@ -146,7 +146,9 @@ def _parse(label, description, usage):
146
146
  required=False,
147
147
  default=None,
148
148
  )
149
- return config.initialize(db_config=True, simulation_model=["site", "layout", "layout_file"])
149
+ return config.initialize(
150
+ db_config=True, simulation_model=["site", "model_version", "layout", "layout_file"]
151
+ )
150
152
 
151
153
 
152
154
  def _get_site_from_telescope_list_name(telescope_list_file):
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/python3
2
+ """
3
+ Plot tabular data read from file or from model parameter database.
4
+
5
+ Uses a configuration file to define the data to be plotted and all
6
+ plotting details.
7
+
8
+ Command line arguments
9
+ ----------------------
10
+ config_file (str, required)
11
+ Configuration file name for plotting.
12
+
13
+ """
14
+
15
+ import logging
16
+ from pathlib import Path
17
+
18
+ import simtools.utils.general as gen
19
+ from simtools.configuration import configurator
20
+ from simtools.io_operations import io_handler
21
+ from simtools.visualization import plot_tables
22
+
23
+
24
+ def _parse(label, description, usage):
25
+ """
26
+ Parse command line configuration.
27
+
28
+ Parameters
29
+ ----------
30
+ label : str
31
+ Label describing the application.
32
+ description : str
33
+ Description of the application.
34
+ usage : str
35
+ Example on how to use the application.
36
+
37
+ Returns
38
+ -------
39
+ CommandLineParser
40
+ Command line parser object.
41
+ """
42
+ config = configurator.Configurator(label=label, description=description, usage=usage)
43
+
44
+ config.parser.add_argument(
45
+ "--plot_config",
46
+ help="Plotting configuration file name.",
47
+ type=str,
48
+ required=True,
49
+ default=None,
50
+ )
51
+ config.parser.add_argument(
52
+ "--output_file",
53
+ help="Output file name (without suffix)",
54
+ type=str,
55
+ required=True,
56
+ )
57
+ return config.initialize(db_config=True)
58
+
59
+
60
+ def main():
61
+ """Plot tabular data."""
62
+ args_dict, db_config_ = _parse(
63
+ label=Path(__file__).stem,
64
+ description="Plots tabular data.",
65
+ usage="""simtools-plot-tabular-data --plot_config config_file_name "
66
+ --output_file output_file_name""",
67
+ )
68
+ logger = logging.getLogger()
69
+ logger.setLevel(gen.get_log_level_from_user(args_dict.get("log_level", "INFO")))
70
+ io_handler_instance = io_handler.IOHandler()
71
+
72
+ plot_config = gen.convert_keys_in_dict_to_lowercase(
73
+ gen.collect_data_from_file(args_dict["plot_config"])
74
+ )
75
+
76
+ plot_tables.plot(
77
+ config=plot_config["cta_simpipe"]["plot"],
78
+ output_file=io_handler_instance.get_output_file(args_dict["output_file"]),
79
+ db_config=db_config_,
80
+ )
81
+
82
+
83
+ if __name__ == "__main__":
84
+ main()
@@ -1,11 +1,24 @@
1
1
  #!/usr/bin/python3
2
2
 
3
3
  r"""
4
- Configure a simulation based on command-line arguments.
4
+ Derive simulation configuration parameters for a simulation production.
5
5
 
6
- This application configures and
7
- generates simulation parameters for a specific grid point in a statistical uncertainty
8
- evaluation setup.
6
+ Derived simulation configuration parameters include:
7
+
8
+ * energy range
9
+ * shower core scatter radius
10
+ * view cone radius
11
+ * total number of events to be simulated
12
+
13
+ Configuration parameters depend on characteristics of the observations, especially elevation,
14
+ azimuth, and night sky background.
15
+
16
+ The configuration parameters are derived according to the required precision. The metrics are:
17
+
18
+ * statistical uncertainty on the determination of the effective area as function of primary energy
19
+ * fraction of lost events to the selected core scatter and view cone radius (to be implemented)
20
+ * statistical uncertainty of the energy migration matrix as function of primary energy
21
+ (to be implemented)
9
22
 
10
23
  Command line arguments
11
24
  ----------------------
@@ -38,9 +51,9 @@ To run the simulation configuration, execute the script as follows:
38
51
  --nsb 0.3 --ctao_data_level "A" --science_case "high_precision" \
39
52
  --file_path tests/resources/production_dl2_fits/dl2_mc_events_file.fits \
40
53
  --file_type "point-like" \
41
- --metrics_file tests/resources/production_simulation_config_metrics.yaml --site North
54
+ --metrics_file tests/resources/production_simulation_config_metrics.yml --site North
42
55
 
43
- The output will show the configured simulation parameters.
56
+ The output will show the derived simulation parameters.
44
57
  """
45
58
 
46
59
  import json
@@ -51,6 +64,7 @@ import astropy.units as u
51
64
 
52
65
  import simtools.utils.general as gen
53
66
  from simtools.configuration import configurator
67
+ from simtools.data_model import schema
54
68
  from simtools.io_operations import io_handler
55
69
  from simtools.production_configuration.generate_simulation_config import (
56
70
  SimulationConfig,
@@ -60,7 +74,8 @@ from simtools.production_configuration.generate_simulation_config import (
60
74
  def _parse(label):
61
75
  """Parse command-line arguments."""
62
76
  config = configurator.Configurator(
63
- label=label, description="Configure and run a simulation based on input parameters."
77
+ label=label,
78
+ description="Derive simulation configuration parameters for a simulation production.",
64
79
  )
65
80
  config.parser.add_argument(
66
81
  "--azimuth", type=float, required=True, help="Azimuth angle in degrees."
@@ -128,6 +143,9 @@ def main():
128
143
  metrics = (
129
144
  gen.collect_data_from_file(args_dict["metrics_file"]) if "metrics_file" in args_dict else {}
130
145
  )
146
+ schema.validate_dict_using_schema(
147
+ data=metrics, schema_file="production_configuration_metrics.schema.yml"
148
+ )
131
149
 
132
150
  simulation_config = SimulationConfig(
133
151
  grid_point=grid_point_config,
@@ -36,7 +36,6 @@ The output will display the scaled events for the specified grid point.
36
36
 
37
37
  import json
38
38
  import logging
39
- import os
40
39
  from pathlib import Path
41
40
 
42
41
  import astropy.units as u
@@ -94,8 +93,8 @@ def _parse(label, description):
94
93
  config.parser.add_argument(
95
94
  "--metrics_file",
96
95
  type=str,
97
- default="production_simulation_config_metrics.yaml",
98
- help="Metrics definition file. (default: production_simulation_config_metrics.yaml)",
96
+ default="production_simulation_config_metrics.yml",
97
+ help="Metrics definition file. (default: production_simulation_config_metrics.yml)",
99
98
  )
100
99
  config.parser.add_argument(
101
100
  "--science_case", type=str, required=True, help="Science case for the simulation."
@@ -129,7 +128,7 @@ def main():
129
128
  # Build file path based on base_path, zenith, and offset
130
129
  file_name = f"prod6_LaPalma-{int(zenith.value)}deg_"
131
130
  file_name += "gamma_cone.N.Am-4LSTs09MSTs_ID0_reduced.fits"
132
- file_path = os.path.join(args_dict["base_path"], file_name)
131
+ file_path = Path(args_dict["base_path"]).joinpath(file_name)
133
132
 
134
133
  evaluator = StatisticalErrorEvaluator(
135
134
  file_path,
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/python3
2
2
 
3
- """
3
+ r"""
4
4
  Simulate calibration devices using the light emission package.
5
5
 
6
6
  Run the application in the command line.
@@ -235,7 +235,7 @@ def _parse(label):
235
235
  )
236
236
  return config.initialize(
237
237
  db_config=True,
238
- simulation_model="telescope",
238
+ simulation_model=["telescope", "model_version"],
239
239
  require_command_line=True,
240
240
  )
241
241