gammasimtools 0.5.1__py3-none-any.whl → 0.6.1__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 (78) hide show
  1. {gammasimtools-0.5.1.dist-info → gammasimtools-0.6.1.dist-info}/METADATA +80 -28
  2. gammasimtools-0.6.1.dist-info/RECORD +91 -0
  3. {gammasimtools-0.5.1.dist-info → gammasimtools-0.6.1.dist-info}/WHEEL +1 -1
  4. {gammasimtools-0.5.1.dist-info → gammasimtools-0.6.1.dist-info}/entry_points.txt +4 -2
  5. simtools/_version.py +14 -2
  6. simtools/applications/add_file_to_db.py +2 -1
  7. simtools/applications/compare_cumulative_psf.py +10 -15
  8. simtools/applications/db_development_tools/add_new_parameter_to_db.py +12 -6
  9. simtools/applications/derive_mirror_rnda.py +95 -71
  10. simtools/applications/generate_corsika_histograms.py +216 -131
  11. simtools/applications/generate_default_metadata.py +110 -0
  12. simtools/applications/generate_simtel_array_histograms.py +192 -0
  13. simtools/applications/get_file_from_db.py +1 -1
  14. simtools/applications/get_parameter.py +3 -3
  15. simtools/applications/make_regular_arrays.py +89 -93
  16. simtools/applications/{plot_layout_array.py → plot_array_layout.py} +15 -14
  17. simtools/applications/print_array_elements.py +81 -34
  18. simtools/applications/produce_array_config.py +2 -2
  19. simtools/applications/production.py +39 -5
  20. simtools/applications/sim_showers_for_trigger_rates.py +26 -30
  21. simtools/applications/simulate_prod.py +49 -107
  22. simtools/applications/submit_data_from_external.py +8 -10
  23. simtools/applications/tune_psf.py +16 -18
  24. simtools/applications/validate_camera_efficiency.py +63 -9
  25. simtools/applications/validate_camera_fov.py +9 -13
  26. simtools/applications/validate_file_using_schema.py +127 -0
  27. simtools/applications/validate_optics.py +13 -15
  28. simtools/camera_efficiency.py +73 -80
  29. simtools/configuration/commandline_parser.py +52 -22
  30. simtools/configuration/configurator.py +98 -33
  31. simtools/constants.py +9 -0
  32. simtools/corsika/corsika_config.py +28 -22
  33. simtools/corsika/corsika_default_config.py +282 -0
  34. simtools/corsika/corsika_histograms.py +328 -282
  35. simtools/corsika/corsika_histograms_visualize.py +162 -163
  36. simtools/corsika/corsika_runner.py +8 -4
  37. simtools/corsika_simtel/corsika_simtel_runner.py +18 -23
  38. simtools/data_model/data_reader.py +129 -0
  39. simtools/data_model/metadata_collector.py +346 -118
  40. simtools/data_model/metadata_model.py +123 -218
  41. simtools/data_model/model_data_writer.py +79 -22
  42. simtools/data_model/validate_data.py +96 -46
  43. simtools/db_handler.py +67 -42
  44. simtools/io_operations/__init__.py +0 -0
  45. simtools/io_operations/hdf5_handler.py +112 -0
  46. simtools/{io_handler.py → io_operations/io_handler.py} +51 -22
  47. simtools/job_execution/job_manager.py +1 -1
  48. simtools/layout/{layout_array.py → array_layout.py} +168 -199
  49. simtools/layout/geo_coordinates.py +196 -0
  50. simtools/layout/telescope_position.py +12 -12
  51. simtools/model/array_model.py +16 -14
  52. simtools/model/camera.py +5 -8
  53. simtools/model/mirrors.py +136 -73
  54. simtools/model/model_utils.py +1 -69
  55. simtools/model/telescope_model.py +32 -25
  56. simtools/psf_analysis.py +26 -19
  57. simtools/ray_tracing.py +54 -26
  58. simtools/schemas/data.metaschema.yml +400 -0
  59. simtools/schemas/metadata.metaschema.yml +566 -0
  60. simtools/simtel/simtel_config_writer.py +14 -5
  61. simtools/simtel/simtel_histograms.py +266 -83
  62. simtools/simtel/simtel_runner.py +8 -7
  63. simtools/simtel/simtel_runner_array.py +7 -8
  64. simtools/simtel/simtel_runner_camera_efficiency.py +48 -2
  65. simtools/simtel/simtel_runner_ray_tracing.py +61 -25
  66. simtools/simulator.py +43 -50
  67. simtools/utils/general.py +232 -286
  68. simtools/utils/geometry.py +163 -0
  69. simtools/utils/names.py +294 -142
  70. simtools/visualization/legend_handlers.py +115 -9
  71. simtools/visualization/visualize.py +13 -13
  72. gammasimtools-0.5.1.dist-info/RECORD +0 -83
  73. simtools/applications/plot_simtel_histograms.py +0 -120
  74. simtools/applications/validate_schema_files.py +0 -135
  75. simtools/corsika/corsika_output_visualize.py +0 -345
  76. simtools/data_model/validate_schema.py +0 -285
  77. {gammasimtools-0.5.1.dist-info → gammasimtools-0.6.1.dist-info}/LICENSE +0 -0
  78. {gammasimtools-0.5.1.dist-info → gammasimtools-0.6.1.dist-info}/top_level.txt +0 -0
@@ -1,10 +1,15 @@
1
1
  import datetime
2
2
  import logging
3
+ import re
3
4
  from pathlib import Path
4
5
 
5
6
  __all__ = ["IOHandlerSingleton", "IOHandler"]
6
7
 
7
8
 
9
+ class IncompleteIOHandlerInit(Exception):
10
+ """Exception raised when IOHandler is not initialized"""
11
+
12
+
8
13
  class IOHandlerSingleton(type):
9
14
  """
10
15
  Singleton base class
@@ -45,11 +50,11 @@ class IOHandler(metaclass=IOHandlerSingleton):
45
50
  Parameters
46
51
  ----------
47
52
  output_path: str or Path
48
- Parent path of the output files created by this class.
53
+ Path pointing to the output directory.
49
54
  data_path: str or Path
50
- Parent path of the data files.
55
+ Path pointing to the data files (e.g., CORSIKA or sim_telarray output).
51
56
  model_path: str or Path
52
- Parent path of the output files created by this class.
57
+ Path pointing to the model file directory.
53
58
  use_plain_output_path: bool
54
59
  Use plain output path without adding tool name and date
55
60
 
@@ -59,18 +64,22 @@ class IOHandler(metaclass=IOHandlerSingleton):
59
64
  self.data_path = data_path
60
65
  self.model_path = model_path
61
66
 
62
- def get_output_directory(self, label=None, dir_type=None, test=False):
67
+ def get_output_directory(self, label=None, sub_dir=None, dir_type="simtools"):
63
68
  """
64
- Get the output directory for the directory type dir_type
69
+ Return path to output directory
65
70
 
66
71
  Parameters
67
72
  ----------
68
73
  label: str
69
74
  Instance label.
70
- dir_type: str
75
+ sub_dir: str
71
76
  Name of the subdirectory (ray-tracing, model etc)
72
- test: bool
73
- If true, return test output location
77
+ dir_type: str
78
+ The type of directory (e.g., 'simtools', 'test', 'simtools-result').
79
+ If 'simtools-result' is used, the output directory will be returned
80
+ without appending a subdirectory string when using the
81
+ use_plain_output_path option. For the cause of not using use_plain_output_path,
82
+ output paths appended by 'simtools-output'.
74
83
 
75
84
  Returns
76
85
  -------
@@ -80,21 +89,30 @@ class IOHandler(metaclass=IOHandlerSingleton):
80
89
  ------
81
90
  FileNotFoundError
82
91
  if error creating directory
92
+ TypeError
93
+ raised for errors while creating directory name
83
94
  """
84
95
 
85
96
  if self.use_plain_output_path:
86
97
  path = Path(self.output_path)
87
98
  else:
88
- if test:
89
- output_directory_prefix = Path(self.output_path).joinpath("test-output")
99
+ if str(self.output_path).endswith("-output"):
100
+ output_directory_prefix = Path(self.output_path)
90
101
  else:
91
- output_directory_prefix = Path(self.output_path).joinpath("simtools-output")
92
-
93
- today = datetime.date.today()
94
- label_dir = label if label is not None else "d-" + str(today)
102
+ try:
103
+ output_directory_prefix = Path(self.output_path).joinpath(
104
+ re.sub(r"\-result$", "", dir_type) + "-output"
105
+ )
106
+ except TypeError:
107
+ self._logger.error(f"Error creating output directory name from {dir_type}")
108
+ raise
109
+ label_dir = label if label is not None else "d-" + str(datetime.date.today())
95
110
  path = output_directory_prefix.joinpath(label_dir)
96
- if dir_type is not None:
97
- path = path.joinpath(dir_type)
111
+ if sub_dir is not None:
112
+ if not self.use_plain_output_path:
113
+ path = path.joinpath(sub_dir)
114
+ elif dir_type != "simtools-result":
115
+ path = path.joinpath(sub_dir)
98
116
 
99
117
  try:
100
118
  path.mkdir(parents=True, exist_ok=True)
@@ -104,7 +122,7 @@ class IOHandler(metaclass=IOHandlerSingleton):
104
122
 
105
123
  return path.absolute()
106
124
 
107
- def get_output_file(self, file_name, label=None, dir_type=None, test=False):
125
+ def get_output_file(self, file_name, label=None, sub_dir=None, dir_type="simtools"):
108
126
  """
109
127
  Get path of an output file.
110
128
 
@@ -114,17 +132,20 @@ class IOHandler(metaclass=IOHandlerSingleton):
114
132
  File name.
115
133
  label: str
116
134
  Instance label.
117
- dir_type: str
135
+ sub_dir: str
118
136
  Name of the subdirectory (ray-tracing, model etc)
119
- test: bool
120
- If true, return test output location
137
+ dir_type: str
138
+ Directory type (e.g., 'simtools', 'test', 'simtools-result')
139
+ If 'simtools-result' is used, the output directory will be returned
140
+ without appending a subdirectory string when using the
141
+ use_plain_output_path option.
121
142
 
122
143
  Returns
123
144
  -------
124
145
  Path
125
146
  """
126
147
  return (
127
- self.get_output_directory(label=label, dir_type=dir_type, test=test)
148
+ self.get_output_directory(label=label, sub_dir=sub_dir, dir_type=dir_type)
128
149
  .joinpath(file_name)
129
150
  .absolute()
130
151
  )
@@ -145,10 +166,18 @@ class IOHandler(metaclass=IOHandlerSingleton):
145
166
  Returns
146
167
  -------
147
168
  Path
169
+
170
+ Raises
171
+ ------
172
+ IncompleteIOHandlerInit
173
+ if data_path is not set
174
+
148
175
  """
149
176
 
150
177
  if test:
151
178
  file_prefix = Path("tests/resources/")
152
- else:
179
+ elif self.data_path is not None:
153
180
  file_prefix = Path(self.data_path).joinpath(parent_dir)
181
+ else:
182
+ raise IncompleteIOHandlerInit
154
183
  return file_prefix.joinpath(file_name).absolute()
@@ -81,7 +81,7 @@ class JobManager:
81
81
  Parameters
82
82
  ----------
83
83
  run_script: str
84
- Shell script descring the job to be submitted.
84
+ Shell script describing the job to be submitted.
85
85
  run_out_file: str or Path
86
86
  Redirect output/error/job stream to this file (out,err,job suffix).
87
87
  log_file: str or Path