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
@@ -0,0 +1,192 @@
1
+ #!/usr/bin/python3
2
+
3
+ """
4
+ Summary
5
+ -------
6
+ This application allows to write sim_telarray histograms into pdf and hdf5 files.
7
+ It accepts multiple lists of histograms files, a single list or a histogram file.
8
+ Each histogram is plotted in a page of the pdf file if the --pdf option is activated.
9
+
10
+
11
+ Command line arguments
12
+ ----------------------
13
+ hist_file_names (str, optional)
14
+ Name of the histogram files to be plotted.
15
+ It can be given as the histogram file names (more than one option allowed) or as a text
16
+ file with the names of the histogram files in it.
17
+ figure_name (str, required)
18
+ File name for the pdf output (without extension).
19
+ pdf (bool, optional)
20
+ If set, histograms are saved into pdf files.
21
+ One pdf file contains all the histograms found in the file.
22
+ The name of the file is controlled via `output_file_name`.
23
+ hdf5: bool
24
+ If true, histograms are saved into hdf5 files.
25
+ At least one of `pdf` and `hdf5` has to be activated.
26
+ output_file_name (str, optional)
27
+ The name of the output hdf5 (and/or pdf) files (without the path).
28
+ If not given, `output_file_name` takes the name from the (first) input file
29
+ (`hist_file_names`).
30
+ If the output `output_file_name.hdf5` file already exists and `hdf5` is set, the tables
31
+ associated to `hdf5` will be overwritten. The remaining tables, if any, will stay
32
+ untouched.
33
+ verbosity (str, optional)
34
+ Log level to print.
35
+
36
+ Raises
37
+ ------
38
+ TypeError:
39
+ if argument passed through `hist_file_names` is not a file.
40
+
41
+ Example
42
+ -------
43
+ .. code-block:: console
44
+
45
+ simtools-generate-simtel-array-histograms --hist_file_names tests/resources/
46
+ run2_gamma_za20deg_azm0deg-North-Prod5_test-production-5.hdata.zst
47
+ --output_file_name test_hist_hdata --hdf5 --pdf
48
+
49
+ """
50
+
51
+ import logging
52
+ from pathlib import Path
53
+
54
+ import matplotlib.pyplot as plt
55
+ from matplotlib.backends.backend_pdf import PdfPages
56
+
57
+ import simtools.utils.general as gen
58
+ from simtools.configuration import configurator
59
+ from simtools.io_operations import io_handler
60
+ from simtools.simtel.simtel_histograms import SimtelHistograms
61
+
62
+
63
+ def _parse(label, description):
64
+ """
65
+ Parse command line configuration
66
+
67
+ Parameters
68
+ ----------
69
+ label: str
70
+ Label describing the application.
71
+ description: str
72
+ Description of the application.
73
+
74
+ Returns
75
+ -------
76
+ CommandLineParser
77
+ Command line parser object
78
+
79
+ """
80
+ config = configurator.Configurator(label=label, description=description)
81
+
82
+ config.parser.add_argument(
83
+ "--hist_file_names",
84
+ help="Name of the histogram files to be plotted or the text file containing the list of "
85
+ "histogram files.",
86
+ nargs="+",
87
+ required=True,
88
+ type=str,
89
+ )
90
+
91
+ config.parser.add_argument(
92
+ "--hdf5", help="Save histograms into a hdf5 file.", action="store_true", required=False
93
+ )
94
+
95
+ config.parser.add_argument(
96
+ "--pdf", help="Save histograms into a pdf file.", action="store_true", required=False
97
+ )
98
+
99
+ config.parser.add_argument(
100
+ "--output_file_name",
101
+ help="Name of the hdf5 (and/or pdf) file where to save the histograms.",
102
+ type=str,
103
+ required=False,
104
+ default=None,
105
+ )
106
+
107
+ config_parser, _ = config.initialize(db_config=False, paths=True)
108
+ if not config_parser["pdf"]:
109
+ if not config_parser["hdf5"]:
110
+ config.parser.error("At least one argument is required: `--pdf` or `--hdf5`.")
111
+
112
+ return config_parser
113
+
114
+
115
+ def main():
116
+ label = Path(__file__).stem
117
+ description = "Display the simtel_array histograms."
118
+ io_handler_instance = io_handler.IOHandler()
119
+ config_parser = _parse(label, description)
120
+ output_path = io_handler_instance.get_output_directory(label, sub_dir="application-plots")
121
+ logger = logging.getLogger()
122
+ logger.setLevel(gen.get_log_level_from_user(config_parser["log_level"]))
123
+ logger.info("Starting the application.")
124
+
125
+ # Building list of histograms from the input files
126
+ histogram_files = []
127
+ for one_file in config_parser["hist_file_names"]:
128
+ try:
129
+ if Path(one_file).suffix in [".zst", ".simtel", ".hdata"]:
130
+ histogram_files.append(one_file)
131
+ else:
132
+ # Collecting hist files
133
+ with open(one_file, encoding="utf-8") as file:
134
+ for line in file:
135
+ # Removing '\n' from filename, in case it is left there.
136
+ histogram_files.append(line.replace("\n", ""))
137
+ except FileNotFoundError as exc:
138
+ msg = f"{one_file} is not a file."
139
+ logger.error(msg)
140
+ raise FileNotFoundError from exc
141
+
142
+ # If no output name is passed, the tool gets the name of the first histogram of the list
143
+ if config_parser["output_file_name"] is None:
144
+ config_parser["output_file_name"] = Path(histogram_files[0]).absolute().name
145
+ output_file_name = Path(output_path).joinpath(f"{config_parser['output_file_name']}")
146
+
147
+ # If the hdf5 output file already exists, it is overwritten
148
+ if (Path(f"{config_parser['output_file_name']}.hdf5").exists()) and (config_parser["hdf5"]):
149
+ msg = (
150
+ f"Output hdf5 file {config_parser['output_file_name']}.hdf5 already exists. "
151
+ f"Overwriting it."
152
+ )
153
+ logger.warning(msg)
154
+ overwrite = True
155
+ else:
156
+ overwrite = False
157
+
158
+ # Building SimtelHistograms
159
+ simtel_histograms = SimtelHistograms(histogram_files)
160
+
161
+ if config_parser["pdf"]:
162
+ logger.debug(f"Creating the pdf file {output_file_name}.pdf")
163
+ pdf_pages = PdfPages(f"{output_file_name}.pdf")
164
+
165
+ if config_parser["test"]:
166
+ number_of_histograms = 2
167
+ else:
168
+ number_of_histograms = simtel_histograms.number_of_histograms
169
+
170
+ for i_hist in range(number_of_histograms):
171
+ title = simtel_histograms.get_histogram_title(i_hist)
172
+
173
+ logger.debug(f"Processing: {title}")
174
+
175
+ fig, ax = plt.subplots(1, 1, figsize=(6, 6))
176
+ simtel_histograms.plot_one_histogram(i_hist, ax)
177
+
178
+ plt.tight_layout()
179
+ pdf_pages.savefig(fig)
180
+ plt.clf()
181
+
182
+ plt.close()
183
+ pdf_pages.close()
184
+ logger.info(f"Wrote histograms to the pdf file {output_file_name}.pdf")
185
+
186
+ if config_parser["hdf5"]:
187
+ logger.info(f"Wrote histograms to the hdf5 file {output_file_name}.hdf5")
188
+ simtel_histograms.export_histograms(f"{output_file_name}.hdf5", overwrite=overwrite)
189
+
190
+
191
+ if __name__ == "__main__":
192
+ main()
@@ -18,7 +18,7 @@
18
18
  Name of the local output directory where to save the files.
19
19
  Default it $CWD.
20
20
  verbosity (str, optional)
21
- Log level to print (default=INFO).
21
+ Log level to print.
22
22
 
23
23
  Example
24
24
  -------
@@ -6,7 +6,7 @@
6
6
  Get a parameter entry from DB for a specific telescope or a site.
7
7
  The application receives a parameter name, a site, a telescope (if applicable) and \
8
8
  optionally a version. It then prints out the parameter entry.
9
- If no version is provided, the value of the current model is printed..
9
+ If no version is provided, the value of the released model is printed..
10
10
 
11
11
  Command line arguments
12
12
  ----------------------
@@ -20,7 +20,7 @@
20
20
  Telescope model name (e.g. LST-1, SST-D, ...)
21
21
 
22
22
  log_level (str, optional)
23
- Log level to print (default=INFO).
23
+ Log level to print.
24
24
 
25
25
  Raises
26
26
  ------
@@ -64,7 +64,7 @@ def main():
64
64
  "Get a parameter entry from DB for a specific telescope or a site. "
65
65
  "The application receives a parameter name a site, a telescope (if applicable), "
66
66
  " and optionally a version. It then prints out the parameter entry. "
67
- "If no version is provided, the value of the current model is printed. "
67
+ "If no version is provided, the value of the released model is printed. "
68
68
  )
69
69
  )
70
70
  config.parser.add_argument("--parameter", help="Parameter name", type=str, required=True)
@@ -12,8 +12,12 @@
12
12
 
13
13
  Command line arguments
14
14
  ----------------------
15
+ site (str, required)
16
+ observatory site (e.g., North or South).
17
+ model_version (str, optional)
18
+ Model version to use (e.g., prod6). If not provided, the latest version is used.
15
19
  verbosity (str, optional)
16
- Log level to print (default=INFO).
20
+ Log level to print.
17
21
 
18
22
  Example
19
23
  -------
@@ -21,28 +25,22 @@
21
25
 
22
26
  .. code-block:: console
23
27
 
24
- simtools-make-regular-arrays
28
+ simtools-make-regular-arrays --site=North
25
29
 
26
- The output is saved in simtools-output/make_regular_arrays.
27
-
28
- Expected final print-out message:
29
-
30
- .. code-block:: console
31
-
32
- INFO::layout_array(l608)::export_telescope_list::Exporting telescope list to /workdir/exter\
33
- nal/simtools/simtools-output/make_regular_arrays/layout/telescope_positions-North-4LS\
34
- T-corsika.ecsv
35
30
  """
36
31
 
37
32
  import logging
33
+ import os
38
34
  from pathlib import Path
39
35
 
40
36
  import astropy.units as u
41
37
 
38
+ import simtools.data_model.model_data_writer as writer
42
39
  import simtools.utils.general as gen
43
- from simtools import db_handler, io_handler
40
+ from simtools import db_handler
44
41
  from simtools.configuration import configurator
45
- from simtools.layout.layout_array import LayoutArray
42
+ from simtools.io_operations import io_handler
43
+ from simtools.layout.array_layout import ArrayLayout
46
44
 
47
45
 
48
46
  def main():
@@ -55,7 +53,7 @@ def main():
55
53
  "The array layout files created should be available at the data/layout directory."
56
54
  ),
57
55
  )
58
- args_dict, db_config = config.initialize(db_config=True)
56
+ args_dict, db_config = config.initialize(db_config=True, site_model=True, output=True)
59
57
 
60
58
  label = "make_regular_arrays"
61
59
 
@@ -64,100 +62,98 @@ def main():
64
62
 
65
63
  _io_handler = io_handler.IOHandler()
66
64
 
67
- corsika_pars = gen.collect_data_from_yaml_or_dict(
65
+ corsika_pars = gen.collect_data_from_file_or_dict(
68
66
  _io_handler.get_input_data_file("parameters", "corsika_parameters.yml"), None
69
67
  )
70
68
 
71
69
  # Reading site parameters from DB
72
70
  db = db_handler.DatabaseHandler(mongo_db_config=db_config)
71
+ site_pars_db = db.get_site_parameters(
72
+ site=args_dict["site"], model_version=args_dict["model_version"]
73
+ )
73
74
 
74
- site_pars_db = {}
75
75
  layout_center_data = {}
76
+ layout_center_data["center_lat"] = float(site_pars_db["ref_lat"]["Value"]) * u.deg
77
+ layout_center_data["center_lon"] = float(site_pars_db["ref_long"]["Value"]) * u.deg
78
+ layout_center_data["center_alt"] = float(site_pars_db["altitude"]["Value"]) * u.m
79
+ layout_center_data["EPSG"] = site_pars_db["EPSG"]["Value"]
76
80
  corsika_telescope_data = {}
77
- for site in ["North", "South"]:
78
- site_pars_db[site] = db.get_site_parameters(site=site, model_version="prod5")
79
-
80
- layout_center_data[site] = {}
81
- layout_center_data[site]["center_lat"] = (
82
- float(site_pars_db[site]["ref_lat"]["Value"]) * u.deg
83
- )
84
- layout_center_data[site]["center_lon"] = (
85
- float(site_pars_db[site]["ref_long"]["Value"]) * u.deg
86
- )
87
- layout_center_data[site]["center_alt"] = (
88
- float(site_pars_db[site]["altitude"]["Value"]) * u.m
89
- )
90
- layout_center_data[site]["EPSG"] = site_pars_db[site]["EPSG"]["Value"]
91
- corsika_telescope_data[site] = {}
92
- corsika_telescope_data[site]["corsika_obs_level"] = layout_center_data[site]["center_alt"]
93
- corsika_telescope_data[site]["corsika_sphere_center"] = corsika_pars[
94
- "corsika_sphere_center"
95
- ]
96
- corsika_telescope_data[site]["corsika_sphere_radius"] = corsika_pars[
97
- "corsika_sphere_radius"
98
- ]
81
+ corsika_telescope_data["corsika_obs_level"] = layout_center_data["center_alt"]
82
+ corsika_telescope_data["corsika_sphere_center"] = corsika_pars["corsika_sphere_center"]
83
+ corsika_telescope_data["corsika_sphere_radius"] = corsika_pars["corsika_sphere_radius"]
99
84
 
100
85
  # Telescope distances for 4 tel square arrays
101
86
  # !HARDCODED
102
87
  telescope_distance = {"LST": 57.5 * u.m, "MST": 70 * u.m, "SST": 80 * u.m}
103
88
 
104
- for site in ["South", "North"]:
105
- for array_name in ["1SST", "4SST", "1MST", "4MST", "1LST", "4LST"]:
106
- logger.info(f"Processing array {array_name}")
107
- layout = LayoutArray(
108
- site=site,
109
- mongo_db_config=db_config,
110
- label=label,
111
- name=f"{site}-{array_name}",
112
- layout_center_data=layout_center_data[site],
113
- corsika_telescope_data=corsika_telescope_data[site],
89
+ for array_name in ["1SST", "4SST", "1MST", "4MST", "1LST", "4LST"]:
90
+ logger.info(f"Processing array {array_name}")
91
+ layout = ArrayLayout(
92
+ site=args_dict["site"],
93
+ mongo_db_config=db_config,
94
+ label=label,
95
+ name=f"{args_dict['site']}-{array_name}",
96
+ layout_center_data=layout_center_data,
97
+ corsika_telescope_data=corsika_telescope_data,
98
+ )
99
+
100
+ tel_size = array_name[1:4]
101
+
102
+ # Single telescope at the center
103
+ if array_name[0] == "1":
104
+ layout.add_telescope(
105
+ telescope_name=tel_size + "-01",
106
+ crs_name="ground",
107
+ xx=0 * u.m,
108
+ yy=0 * u.m,
109
+ tel_corsika_z=0 * u.m,
110
+ )
111
+ # 4 telescopes in a regular square grid
112
+ else:
113
+ layout.add_telescope(
114
+ telescope_name=tel_size + "-01",
115
+ crs_name="ground",
116
+ xx=telescope_distance[tel_size],
117
+ yy=telescope_distance[tel_size],
118
+ tel_corsika_z=0 * u.m,
119
+ )
120
+ layout.add_telescope(
121
+ telescope_name=tel_size + "-02",
122
+ crs_name="ground",
123
+ xx=-telescope_distance[tel_size],
124
+ yy=telescope_distance[tel_size],
125
+ tel_corsika_z=0 * u.m,
126
+ )
127
+ layout.add_telescope(
128
+ telescope_name=tel_size + "-03",
129
+ crs_name="ground",
130
+ xx=telescope_distance[tel_size],
131
+ yy=-telescope_distance[tel_size],
132
+ tel_corsika_z=0 * u.m,
133
+ )
134
+ layout.add_telescope(
135
+ telescope_name=tel_size + "-04",
136
+ crs_name="ground",
137
+ xx=-telescope_distance[tel_size],
138
+ yy=-telescope_distance[tel_size],
139
+ tel_corsika_z=0 * u.m,
114
140
  )
115
141
 
116
- tel_size = array_name[1:4]
117
-
118
- # Single telescope at the center
119
- if array_name[0] == "1":
120
- layout.add_telescope(
121
- telescope_name=tel_size + "-01",
122
- crs_name="corsika",
123
- xx=0 * u.m,
124
- yy=0 * u.m,
125
- tel_corsika_z=0 * u.m,
126
- )
127
- # 4 telescopes in a regular square grid
128
- else:
129
- layout.add_telescope(
130
- telescope_name=tel_size + "-01",
131
- crs_name="corsika",
132
- xx=telescope_distance[tel_size],
133
- yy=telescope_distance[tel_size],
134
- tel_corsika_z=0 * u.m,
135
- )
136
- layout.add_telescope(
137
- telescope_name=tel_size + "-02",
138
- crs_name="corsika",
139
- xx=-telescope_distance[tel_size],
140
- yy=telescope_distance[tel_size],
141
- tel_corsika_z=0 * u.m,
142
- )
143
- layout.add_telescope(
144
- telescope_name=tel_size + "-03",
145
- crs_name="corsika",
146
- xx=telescope_distance[tel_size],
147
- yy=-telescope_distance[tel_size],
148
- tel_corsika_z=0 * u.m,
149
- )
150
- layout.add_telescope(
151
- telescope_name=tel_size + "-04",
152
- crs_name="corsika",
153
- xx=-telescope_distance[tel_size],
154
- yy=-telescope_distance[tel_size],
155
- tel_corsika_z=0 * u.m,
156
- )
157
-
158
- layout.convert_coordinates()
159
- layout.print_telescope_list()
160
- layout.export_telescope_list(crs_name="corsika", corsika_z=None)
142
+ layout.convert_coordinates()
143
+ layout.print_telescope_list()
144
+ output_file = args_dict.get("output_file", None)
145
+ if output_file is not None:
146
+ base_name, file_extension = os.path.splitext(output_file)
147
+ output_file = f"{base_name}-{args_dict['site']}-{array_name}{file_extension}"
148
+ writer.ModelDataWriter.dump(
149
+ args_dict=args_dict,
150
+ output_file=output_file,
151
+ metadata=None,
152
+ product_data=layout.export_telescope_list_table(
153
+ crs_name="ground",
154
+ corsika_z=False,
155
+ ),
156
+ )
161
157
 
162
158
 
163
159
  if __name__ == "__main__":
@@ -19,21 +19,21 @@
19
19
  File name for the pdf output.
20
20
  telescope_list (str, optional)
21
21
  The telescopes file (.ecsv) with the array information.
22
- layout_array_name (str, optional)
22
+ array_layout_name (str, optional)
23
23
  Name of the layout array (e.g., North-TestLayout, South-TestLayout, North-4LST, etc.).
24
24
  rotate_angle (float, optional)
25
25
  Angle to rotate the array before plotting (in degrees).
26
26
  show_tel_label (bool, optional)
27
27
  Shows the telescope labels in the plot.
28
28
  verbosity (str, optional)
29
- Log level to print (default=INFO).
29
+ Log level to print.
30
30
 
31
31
  Example
32
32
  -------
33
33
  .. code-block:: console
34
34
 
35
35
  simtools-plot-layout-array --figure_name northern_array_alpha \
36
- --layout_array_name North-TestLayout
36
+ --array_layout_name North-TestLayout
37
37
 
38
38
  """
39
39
 
@@ -44,9 +44,10 @@ import matplotlib.pyplot as plt
44
44
  from astropy import units as u
45
45
 
46
46
  import simtools.utils.general as gen
47
- from simtools import io_handler
48
47
  from simtools.configuration import configurator
49
- from simtools.layout.layout_array import LayoutArray
48
+ from simtools.data_model import data_reader
49
+ from simtools.io_operations import io_handler
50
+ from simtools.layout.array_layout import ArrayLayout
50
51
  from simtools.visualization.visualize import plot_array
51
52
 
52
53
 
@@ -103,8 +104,8 @@ def _parse(label, description, usage):
103
104
  default=None,
104
105
  )
105
106
  input_group.add_argument(
106
- "--layout_array_name",
107
- help="Name of the layout array.",
107
+ "--array_layout_name",
108
+ help="Name of the array layout.",
108
109
  nargs="+",
109
110
  type=str,
110
111
  required=False,
@@ -117,7 +118,7 @@ def _parse(label, description, usage):
117
118
  def main():
118
119
  label = Path(__file__).stem
119
120
  description = "Plots layout array."
120
- usage = "python applications/plot_layout_array.py --layout_array_name test_layout"
121
+ usage = "python applications/plot_array_layout.py --array_layout_name test_layout"
121
122
  args_dict, _ = _parse(label, description, usage)
122
123
  io_handler_instance = io_handler.IOHandler()
123
124
 
@@ -135,13 +136,13 @@ def main():
135
136
  logger.info("Plotting array from telescope list file(s).")
136
137
  telescope_file = args_dict["telescope_list"]
137
138
 
138
- elif args_dict["layout_array_name"] is not None:
139
+ elif args_dict["array_layout_name"] is not None:
139
140
  logger.info("Plotting array from layout array name(s).")
140
141
  telescope_file = [
141
142
  io_handler_instance.get_input_data_file(
142
143
  "layout", f"telescope_positions-{one_array}.ecsv"
143
144
  )
144
- for one_array in args_dict["layout_array_name"]
145
+ for one_array in args_dict["array_layout_name"]
145
146
  ]
146
147
 
147
148
  for one_file in telescope_file:
@@ -150,19 +151,19 @@ def main():
150
151
  logger.debug(f"Processing: {one_angle}.")
151
152
  if args_dict["figure_name"] is None:
152
153
  plot_file_name = (
153
- f"plot_layout_array_{(Path(one_file).name).split('.')[0]}_"
154
+ f"plot_array_layout_{(Path(one_file).name).split('.')[0]}_"
154
155
  f"{str((round((one_angle.to(u.deg).value))))}deg"
155
156
  )
156
157
  else:
157
158
  plot_file_name = args_dict["figure_name"]
158
159
 
159
- telescope_table = LayoutArray.read_telescope_list_file(one_file)
160
- telescopes_dict = LayoutArray.include_radius_into_telescope_table(telescope_table)
160
+ telescope_table = data_reader.read_table_from_file(one_file)
161
+ telescopes_dict = ArrayLayout.include_radius_into_telescope_table(telescope_table)
161
162
  fig_out = plot_array(
162
163
  telescopes_dict, rotate_angle=one_angle, show_tel_label=args_dict["show_tel_label"]
163
164
  )
164
165
  output_dir = io_handler_instance.get_output_directory(
165
- label, dir_type="application-plots"
166
+ label, sub_dir="application-plots"
166
167
  )
167
168
  plot_file = output_dir.joinpath(plot_file_name)
168
169