Skip to content

Commit 062ea89

Browse files
committed
review suggestions
1 parent dc8605e commit 062ea89

9 files changed

Lines changed: 133 additions & 132 deletions

examples/hyperparameter_optimization/generate_plots.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ def plot_kinematics_reconstruction_fluxes(
2525
reconstruction_results: dict[str, dict[str, Any]], save_dir: pathlib.Path
2626
) -> None:
2727
"""
28-
Plot the distribution of reconstruction errors.
28+
Plot kinematic reconstruction flux comparison.
2929
30-
This function plots histograms and kernel density estimations of the pointing errors in reconstruction when comparing
31-
HeliOS and UTIS as methods for focal spot centroid extraction.
30+
The measured fluxes, fluxes with default kinematics and reconstructed kinematics are plotted side by side.
3231
3332
Parameters
3433
----------
@@ -316,10 +315,7 @@ def plot_motor_pos_fluxes(
316315
reconstruction_results: dict[str, Any], save_dir: pathlib.Path
317316
) -> None:
318317
"""
319-
Plot the distribution of reconstruction errors.
320-
321-
This function plots histograms and kernel density estimations of the pointing errors in reconstruction when comparing
322-
HeliOS and UTIS as methods for focal spot centroid extraction.
318+
Plot the flux comparison of the optimized and unoptimized fluxes.
323319
324320
Parameters
325321
----------

examples/hyperparameter_optimization/generate_results_motor_position.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
"""
2+
Generate results with the optimized parameters.
3+
4+
Parameters
5+
----------
6+
config : str
7+
Path to the configuration file.
8+
device : str
9+
Device to use for the computation.
10+
data_dir : str
11+
Path to the data directory.
12+
heliostat_for_reconstruction : dict[str, list[int]]
13+
The heliostat and its calibration numbers.
14+
results_dir : str
15+
Path to where the results will be saved.
16+
scenarios_dir : str
17+
Path to the directory containing the scenarios.
18+
"""
19+
120
import argparse
221
import json
322
import pathlib
@@ -277,24 +296,6 @@ def generate_reconstruction_results(
277296

278297

279298
if __name__ == "__main__":
280-
"""
281-
Generate results with the optimized parameters.
282-
283-
Parameters
284-
----------
285-
config : str
286-
Path to the configuration file.
287-
device : str
288-
Device to use for the computation.
289-
data_dir : str
290-
Path to the data directory.
291-
heliostat_for_reconstruction : dict[str, list[int]]
292-
The heliostat and its calibration numbers.
293-
results_dir : str
294-
Path to where the results will be saved.
295-
scenarios_dir : str
296-
Path to the directory containing the scenarios.
297-
"""
298299
# Set default location for configuration file.
299300
script_dir = pathlib.Path(__file__).resolve().parent
300301
default_config_path = script_dir / "config.yaml"

examples/hyperparameter_optimization/generate_scenarios.py

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
"""
2+
Generate scenarios for the hyperparameter optimizations.
3+
4+
This will generate ideal surface scenarios for the hyperparameter searches.
5+
For the surface evaluation a deflectometry scenario will also be created.
6+
7+
Parameters
8+
----------
9+
config : str
10+
Path to the configuration file.
11+
device : str
12+
Device to use for the computation.
13+
data_dir : str
14+
Path to the data directory.
15+
tower_file_name : str
16+
Name of the file containing the tower measurements.
17+
results_dir : str
18+
Path to the results directory containing the viable heliostats list.
19+
scenarios_dir : str
20+
Path to the directory for saving the generated scenarios.
21+
"""
22+
123
import argparse
224
import json
325
import pathlib
@@ -173,15 +195,15 @@ def generate_ideal_scenario(
173195
)
174196

175197
# Set up light source configuration.
176-
light_source1_config = LightSourceConfig(
198+
light_source_config = LightSourceConfig(
177199
light_source_key="sun_1",
178200
light_source_type=config_dictionary.sun_key,
179201
number_of_rays=10,
180202
distribution_type=config_dictionary.light_source_distribution_is_normal,
181203
mean=0.0,
182204
covariance=4.3681e-06,
183205
)
184-
light_source_list = [light_source1_config]
206+
light_source_list = [light_source_config]
185207
light_source_list_config = LightSourceListConfig(
186208
light_source_list=light_source_list
187209
)
@@ -321,27 +343,6 @@ def generate_fitted_scenario(
321343

322344

323345
if __name__ == "__main__":
324-
"""
325-
Generate scenarios for the hyperparameter optimizations.
326-
327-
This will generate ideal surface scenarios for the hyperparameter searches.
328-
For the surface evaluation a deflectometry scenario will also be created.
329-
330-
Parameters
331-
----------
332-
config : str
333-
Path to the configuration file.
334-
device : str
335-
Device to use for the computation.
336-
data_dir : str
337-
Path to the data directory.
338-
tower_file_name : str
339-
Name of the file containing the tower measurements.
340-
results_dir : str
341-
Path to the results directory containing the viable heliostats list.
342-
scenarios_dir : str
343-
Path to the directory for saving the generated scenarios.
344-
"""
345346
# Set default location for configuration file.
346347
script_dir = pathlib.Path(__file__).resolve().parent
347348
default_config_path = script_dir / "config.yaml"

examples/hyperparameter_optimization/generate_viable_heliostats_list.py

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
"""
2+
Generate list of viable heliostats for the hyperparameter optimizations.
3+
4+
This script identifies a list of viable heliostats, i.e., containing a minimum number of valid measurements, for
5+
the optimization process.
6+
7+
Parameters
8+
----------
9+
config : str
10+
Path to the configuration file.
11+
device : str
12+
Device to use for the computation.
13+
data_dir : str
14+
Path to the data directory.
15+
results_dir : str
16+
Path to where the results will be saved.
17+
minimum_number_of_measurements : int
18+
Minimum number of calibration measurements per heliostat required.
19+
kinematics_reconstruction_image_type : str
20+
Type of calibration image to use for the kinematics reconstruction, i.e., flux or flux-centered.
21+
surface_reconstruction_image_type : str
22+
Type of calibration image to use for the surface reconstruction, i.e., flux or flux-centered.
23+
"""
24+
125
import argparse
226
import json
327
import pathlib
@@ -151,29 +175,6 @@ def find_viable_heliostats(
151175

152176

153177
if __name__ == "__main__":
154-
"""
155-
Generate list of viable heliostats for the hyperparameter optimizations.
156-
157-
This script identifies a list of viable heliostats, i.e., containing a minimum number of valid measurements, for
158-
the optimization process.
159-
160-
Parameters
161-
----------
162-
config : str
163-
Path to the configuration file.
164-
device : str
165-
Device to use for the computation.
166-
data_dir : str
167-
Path to the data directory.
168-
results_dir : str
169-
Path to where the results will be saved.
170-
minimum_number_of_measurements : int
171-
Minimum number of calibration measurements per heliostat required.
172-
kinematics_reconstruction_image_type : str
173-
Type of calibration image to use for the kinematics reconstruction, i.e., flux or flux-centered.
174-
surface_reconstruction_image_type : str
175-
Type of calibration image to use for the surface reconstruction, i.e., flux or flux-centered.
176-
"""
177178
# Set default location for configuration file.
178179
script_dir = pathlib.Path(__file__).resolve().parent
179180
default_config_path = script_dir / "config.yaml"

examples/hyperparameter_optimization/search_kinematic_reconstruction.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
"""
2+
Perform the hyperparameter search for the kinematics reconstruction and save the results.
3+
4+
This script executes the hyperparameter search with ``propulate`` and saves the result for
5+
further inspection.
6+
7+
Parameters
8+
----------
9+
config : str
10+
Path to the configuration file.
11+
device : str
12+
Device to use for the computation.
13+
data_dir : str
14+
Path to the data directory.
15+
heliostat_for_reconstruction : dict[str, list[int]]
16+
The heliostat and its calibration numbers.
17+
results_dir : str
18+
Path to where the results will be saved.
19+
scenarios_dir : str
20+
Path to the directory containing the scenarios.
21+
propulate_logs_dir : str
22+
Path to the directory where propulate will write log messages.
23+
parameter_ranges_kinematics : dict[str, int | float]
24+
The reconstruction parameters.
25+
"""
26+
127
import argparse
228
import json
329
import logging
@@ -24,7 +50,7 @@
2450
from artist.util.environment_setup import get_device
2551

2652
log = logging.getLogger(__name__)
27-
"""A logger for the hyper parameter search."""
53+
"""A logger for the hyperparameter search."""
2854

2955

3056
def kinematics_reconstructor_for_hpo(
@@ -145,31 +171,6 @@ def kinematics_reconstructor_for_hpo(
145171

146172

147173
if __name__ == "__main__":
148-
"""
149-
Perform the hyperparameter search for the kinematics reconstruction and save the results.
150-
151-
This script executes the hyperparameter search with ``propulate`` and saves the result for
152-
further inspection.
153-
154-
Parameters
155-
----------
156-
config : str
157-
Path to the configuration file.
158-
device : str
159-
Device to use for the computation.
160-
data_dir : str
161-
Path to the data directory.
162-
heliostat_for_reconstruction : dict[str, list[int]]
163-
The heliostat and its calibration numbers.
164-
results_dir : str
165-
Path to where the results will be saved.
166-
scenarios_dir : str
167-
Path to the directory containing the scenarios.
168-
propulate_logs_dir : str
169-
Path to the directory where propulate will write log messages.
170-
parameter_ranges_kinematics : dict[str, int | float]
171-
The reconstruction parameters.
172-
"""
173174
comm = MPI.COMM_WORLD
174175

175176
rank = comm.Get_rank()
@@ -291,7 +292,6 @@ def kinematics_reconstructor_for_hpo(
291292
)
292293

293294
log = logging.getLogger(__name__)
294-
rank = comm.Get_rank()
295295
log.info(rank)
296296

297297
seed = 7
@@ -378,10 +378,10 @@ def kinematics_reconstructor_for_hpo(
378378
hpo_result_file = propulate_logs_dir / "island_0_ckpt.pickle"
379379
optimized_parameters_file = results_dir / "hpo_results_kinematics.json"
380380

381-
# Save hpo results in format to be used by plots.
381+
# Save HPO results in format to be used by plots.
382382
if not hpo_result_file.exists():
383383
raise FileNotFoundError(
384-
f"The hpo results located at {hpo_result_file} could not be not found! Please run the hpo script again to generate the results."
384+
f"The HPO results located at {hpo_result_file} could not be not found! Please run the HPO script again to generate the results."
385385
)
386386

387387
with open(hpo_result_file, "rb") as results:

examples/hyperparameter_optimization/search_motor_position_optimization.py

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
"""
2+
Perform the hyperparameter search for the motor position optimization and save the results.
3+
4+
This script executes the hyperparameter search with ``propulate`` and saves the result for
5+
further inspection.
6+
7+
Parameters
8+
----------
9+
config : str
10+
Path to the configuration file.
11+
device : str
12+
Device to use for the computation.
13+
data_dir : str
14+
Path to the data directory.
15+
results_dir : str
16+
Path to where the results will be saved.
17+
scenarios_dir : str
18+
Path to the directory containing the scenarios.
19+
propulate_logs_dir : str
20+
Path to the directory where propulate will write log messages.
21+
parameter_ranges_motor_positions : dict[str, str | int | float]
22+
The reconstruction parameters.
23+
"""
24+
125
import argparse
226
import json
327
import logging
@@ -22,7 +46,7 @@
2246
from artist.util.environment_setup import get_device
2347

2448
log = logging.getLogger(__name__)
25-
"""A logger for the hyper parameter search."""
49+
"""A logger for the hyperparameter search."""
2650

2751

2852
def motor_position_optimizer_for_hpo(
@@ -153,29 +177,6 @@ def motor_position_optimizer_for_hpo(
153177

154178

155179
if __name__ == "__main__":
156-
"""
157-
Perform the hyperparameter search for the motor position optimization and save the results.
158-
159-
This script executes the hyperparameter search with ``propulate`` and saves the result for
160-
further inspection.
161-
162-
Parameters
163-
----------
164-
config : str
165-
Path to the configuration file.
166-
device : str
167-
Device to use for the computation.
168-
data_dir : str
169-
Path to the data directory.
170-
results_dir : str
171-
Path to where the results will be saved.
172-
scenarios_dir : str
173-
Path to the directory containing the scenarios.
174-
propulate_logs_dir : str
175-
Path to the directory where propulate will write log messages.
176-
parameter_ranges_motor_positions : dict[str, str | int | float]
177-
The reconstruction parameters.
178-
"""
179180
comm = MPI.COMM_WORLD
180181

181182
rank = comm.Get_rank()
@@ -364,10 +365,10 @@ def motor_position_optimizer_for_hpo(
364365
hpo_result_file = propulate_logs_dir / "island_0_ckpt.pickle"
365366
optimized_parameters_file = results_dir / "hpo_results_motor_positions.json"
366367

367-
# Save hpo results in format to be used by plots.
368+
# Save HPO results in format to be used by plots.
368369
if not hpo_result_file.exists():
369370
raise FileNotFoundError(
370-
f"The hpo results located at {hpo_result_file} could not be not found! Please run the hpo script again to generate the results."
371+
f"The HPO results located at {hpo_result_file} could not be not found! Please run the HPO script again to generate the results."
371372
)
372373

373374
with open(hpo_result_file, "rb") as results:

examples/hyperparameter_optimization/search_surface_reconstruction.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from artist.util.environment_setup import get_device
2626

2727
log = logging.getLogger(__name__)
28-
"""A logger for the hyper parameter search."""
28+
"""A logger for the hyperparameter search."""
2929

3030

3131
def surface_reconstructor_for_hpo(
@@ -442,10 +442,10 @@ def surface_reconstructor_for_hpo(
442442
hpo_result_file = propulate_logs_dir / "island_0_ckpt.pickle"
443443
optimized_parameters_file = results_dir / "hpo_results_surface.json"
444444

445-
# Save hpo results in format to be used by plots.
445+
# Save HPO results in format to be used by plots.
446446
if not hpo_result_file.exists():
447447
raise FileNotFoundError(
448-
f"The hpo results located at {hpo_result_file} could not be not found! Please run the hpo script again to generate the results."
448+
f"The HPO results located at {hpo_result_file} could not be not found! Please run the HPO script again to generate the results."
449449
)
450450

451451
with open(hpo_result_file, "rb") as results:

0 commit comments

Comments
 (0)