Skip to content

Commit 40deb93

Browse files
committed
fixes
1 parent 3f72333 commit 40deb93

5 files changed

Lines changed: 113 additions & 96 deletions

tutorials/00_generate_scenario_from_paint_tutorial.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
device = get_device()
2424

2525
# Specify the path to your scenario file.
26-
scenario_path = pathlib.Path("test")
26+
scenario_path = pathlib.Path("please/insert/the/path/to/the/scenario/here/name")
2727

2828
# Specify the path to your tower-measurements.json file.
2929
tower_file = pathlib.Path(
30-
"/workVERLEIHNIX/mb/ARTIST/tutorials/data/paint/tower-measurements.json"
30+
"please/insert/the/path/to/the/paint/data/here/tower-measurements.json"
3131
)
3232

3333
# Specify the following data for each heliostat that you want to include in the scenario:

tutorials/02_heliostat_raytracing_distributed_tutorial.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
device = get_device()
2323

2424
# Specify the path to your scenario.h5 file.
25-
scenario_path = pathlib.Path("/workVERLEIHNIX/mb/ARTIST/tutorials/data/scenarios/test_scenario_paint_multiple_heliostat_groups_deflectometry.h5")
25+
scenario_path = pathlib.Path("please/insert/the/path/to/the/scenario/here/scenario.h5")
2626

2727
# Set the number of heliostat groups, this is needed for process group assignment.
2828
number_of_heliostat_groups = Scenario.get_number_of_heliostat_groups_from_hdf5(
@@ -161,7 +161,9 @@
161161
for name, m in zip(heliostat_group.names, active_heliostats_mask)
162162
for _ in range(m)
163163
]
164-
target_names = {v: k for k, v in scenario.solar_tower.target_name_to_index.items()}
164+
target_names = {
165+
v: k for k, v in scenario.solar_tower.target_name_to_index.items()
166+
}
165167
plt.imshow(bitmaps_per_heliostat[i].cpu().detach(), cmap="gray")
166168
plt.axis("off")
167169
plt.title(
@@ -193,7 +195,9 @@
193195

194196
# Plot the combined bitmaps of heliostats on the same target reduced within each group.
195197
for target_area_index in range(combined_bitmaps_per_target.shape[0]):
196-
target_names = {v: k for k, v in scenario.solar_tower.target_name_to_index.items()}
198+
target_names = {
199+
v: k for k, v in scenario.solar_tower.target_name_to_index.items()
200+
}
197201
plt.imshow(
198202
combined_bitmaps_per_target[target_area_index].cpu().detach(),
199203
cmap="gray",
@@ -213,7 +217,9 @@
213217

214218
# Plot the final combined bitmaps of heliostats on the same target fully reduced.
215219
for target_area_index in range(combined_bitmaps_per_target.shape[0]):
216-
target_names = {v: k for k, v in scenario.solar_tower.target_name_to_index.items()}
220+
target_names = {
221+
v: k for k, v in scenario.solar_tower.target_name_to_index.items()
222+
}
217223
plt.imshow(
218224
combined_bitmaps_per_target[target_area_index].cpu().detach(),
219225
cmap="gray",

tutorials/03_nurbs_surface_reconstruction_tutorial.py

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -359,51 +359,51 @@ def create_flux_plots(
359359
device = get_device()
360360

361361
# Specify the path to your scenario.h5 file and specify the configuration.
362-
scenario_path = pathlib.Path("/workVERLEIHNIX/mb/ARTIST/tutorials/data/scenarios/test_scenario_paint_multiple_heliostat_groups_ideal.h5")
363-
base_path_data = "/workVERLEIHNIX/share/PAINT_data"
364-
heliostat_names_reconstruction = ["AA39", "AC43"]
365-
heliostat_names_plots = ["AA39", "AC43"]
362+
scenario_path = pathlib.Path("please/insert/the/path/to/the/scenario/here/scenario.h5")
363+
base_path_data = "base/path/data"
364+
heliostat_names_reconstruction = ["heliostat_1"]
365+
heliostat_names_plots = ["heliostat_1", "..."]
366366

367367
# Also specify the heliostats to be calibrated and the paths to your calibration-properties.json files.
368368
# Please use the following style: list[tuple[str, list[pathlib.Path], list[pathlib.Path]]]
369-
# heliostat_data_mapping = [
370-
# (
371-
# "heliostat_name_1",
372-
# [
373-
# pathlib.Path(
374-
# "please/insert/the/path/to/the/paint/data/here/calibration-properties.json"
375-
# ),
376-
# # ....
377-
# ],
378-
# [
379-
# pathlib.Path("please/insert/the/path/to/the/paint/data/here/flux.png"),
380-
# # ....
381-
# ],
382-
# ),
383-
# (
384-
# "heliostat_name_2",
385-
# [
386-
# pathlib.Path(
387-
# "please/insert/the/path/to/the/paint/data/here/calibration-properties.json"
388-
# ),
389-
# # ....
390-
# ],
391-
# [
392-
# pathlib.Path("please/insert/the/path/to/the/paint/data/here/flux.png"),
393-
# # ....
394-
# ],
395-
# ),
396-
# # ...
397-
# ]
369+
heliostat_data_mapping = [
370+
(
371+
"heliostat_name_1",
372+
[
373+
pathlib.Path(
374+
"please/insert/the/path/to/the/paint/data/here/calibration-properties.json"
375+
),
376+
# ....
377+
],
378+
[
379+
pathlib.Path("please/insert/the/path/to/the/paint/data/here/flux.png"),
380+
# ....
381+
],
382+
),
383+
(
384+
"heliostat_name_2",
385+
[
386+
pathlib.Path(
387+
"please/insert/the/path/to/the/paint/data/here/calibration-properties.json"
388+
),
389+
# ....
390+
],
391+
[
392+
pathlib.Path("please/insert/the/path/to/the/paint/data/here/flux.png"),
393+
# ....
394+
],
395+
),
396+
# ...
397+
]
398398

399399
# Or if you have a directory with downloaded data use this code to create a mapping.
400-
heliostat_data_mapping = paint_scenario_parser.build_heliostat_data_mapping(
401-
base_path=base_path_data,
402-
heliostat_names=heliostat_names_reconstruction,
403-
number_of_measurements=7,
404-
image_variant="flux-centered",
405-
randomize=True,
406-
)
400+
# heliostat_data_mapping = paint_scenario_parser.build_heliostat_data_mapping(
401+
# base_path=base_path_data,
402+
# heliostat_names=heliostat_names_reconstruction,
403+
# number_of_measurements=2,
404+
# image_variant="flux-centered",
405+
# randomize=True,
406+
# )
407407

408408
# Configure the optimization.
409409
optimizer_dict = {
@@ -447,7 +447,7 @@ def create_flux_plots(
447447
str,
448448
CalibrationDataParser | list[tuple[str, list[pathlib.Path], list[pathlib.Path]]],
449449
] = {
450-
config_dictionary.data_parser: PaintCalibrationDataParser(sample_limit=7),
450+
config_dictionary.data_parser: PaintCalibrationDataParser(sample_limit=2),
451451
config_dictionary.heliostat_data_mapping: heliostat_data_mapping,
452452
}
453453

@@ -476,8 +476,8 @@ def create_flux_plots(
476476
# Another possibility would be the pixel loss:
477477
# loss_definition = PixelLoss(scenario=scenario)
478478

479-
scenario.set_number_of_rays(number_of_rays=150)
480-
resolution = torch.tensor([300, 360], device=device)
479+
scenario.set_number_of_rays(number_of_rays=170)
480+
resolution = torch.tensor([256, 256], device=device)
481481

482482
# Visualize the surfaces and flux distributions from the initial heliostats.
483483
number_of_plots_per_heliostat = 2

tutorials/04_kinematic_reconstruction_tutorial.py

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from artist.core.heliostat_ray_tracer import HeliostatRayTracer
1212
from artist.core.kinematics_reconstructor import KinematicsReconstructor
1313
from artist.core.loss_functions import FocalSpotLoss
14-
from artist.data_parser import paint_scenario_parser
1514
from artist.data_parser.calibration_data_parser import CalibrationDataParser
1615
from artist.data_parser.paint_calibration_parser import PaintCalibrationDataParser
1716
from artist.field.heliostat_group import HeliostatGroup
@@ -182,47 +181,47 @@ def create_plots(
182181
device = get_device()
183182

184183
# Specify the path to your scenario.h5 file.
185-
scenario_path = pathlib.Path("/workVERLEIHNIX/mb/ARTIST/tutorials/data/scenarios/test_scenario_paint_multiple_heliostat_groups_deflectometry.h5")
184+
scenario_path = pathlib.Path("please/insert/the/path/to/the/scenario/here/scenario.h5")
186185

187186
# Also specify the heliostats to be calibrated and the paths to your calibration-properties.json files.
188187
# Please use the following style: list[tuple[str, list[pathlib.Path], list[pathlib.Path]]]
189-
# heliostat_data_mapping = [
190-
# (
191-
# "heliostat_name_1",
192-
# [
193-
# pathlib.Path(
194-
# "please/insert/the/path/to/the/paint/data/here/calibration-properties.json"
195-
# ),
196-
# # ....
197-
# ],
198-
# [
199-
# pathlib.Path("please/insert/the/path/to/the/paint/data/here/flux.png"),
200-
# # ....
201-
# ],
202-
# ),
203-
# (
204-
# "heliostat_name_2",
205-
# [
206-
# pathlib.Path(
207-
# "please/insert/the/path/to/the/paint/data/here/calibration-properties.json"
208-
# ),
209-
# # ....
210-
# ],
211-
# [
212-
# pathlib.Path("please/insert/the/path/to/the/paint/data/here/flux.png"),
213-
# # ....
214-
# ],
215-
# ),
216-
# ]
188+
heliostat_data_mapping = [
189+
(
190+
"heliostat_name_1",
191+
[
192+
pathlib.Path(
193+
"please/insert/the/path/to/the/paint/data/here/calibration-properties.json"
194+
),
195+
# ....
196+
],
197+
[
198+
pathlib.Path("please/insert/the/path/to/the/paint/data/here/flux.png"),
199+
# ....
200+
],
201+
),
202+
(
203+
"heliostat_name_2",
204+
[
205+
pathlib.Path(
206+
"please/insert/the/path/to/the/paint/data/here/calibration-properties.json"
207+
),
208+
# ....
209+
],
210+
[
211+
pathlib.Path("please/insert/the/path/to/the/paint/data/here/flux.png"),
212+
# ....
213+
],
214+
),
215+
]
217216

218217
# Or if you have a directory with downloaded data use this code to create a mapping.
219-
heliostat_data_mapping = paint_scenario_parser.build_heliostat_data_mapping(
220-
base_path="/workVERLEIHNIX/share/PAINT_data",
221-
heliostat_names=["AA39", "AA31"],
222-
number_of_measurements=2,
223-
image_variant="flux",
224-
randomize=True,
225-
)
218+
# heliostat_data_mapping = paint_scenario_parser.build_heliostat_data_mapping(
219+
# base_path="base/path/data",
220+
# heliostat_names=["heliostat_1", "..."],
221+
# number_of_measurements=5,
222+
# image_variant="flux",
223+
# randomize=True,
224+
# )
226225

227226
# Configure the optimization.
228227
optimizer_dict = {
@@ -295,15 +294,15 @@ def create_plots(
295294
scenario_file=scenario_file, device=device
296295
)
297296

298-
resolution = torch.tensor([300, 360], device=device)
297+
resolution = torch.tensor([256, 256], device=device)
299298

300299
bitmaps_before, _ = create_fluxes(
301300
data_parser=data_parser_plots,
302301
heliostat_data_mapping=[
303302
(heliostat[0], [heliostat[1][-1]], [heliostat[2][-1]])
304303
for heliostat in heliostat_data_mapping
305304
],
306-
resolution=resolution
305+
resolution=resolution,
307306
)
308307

309308
loss_definition = FocalSpotLoss(scenario=scenario)
@@ -316,7 +315,7 @@ def create_plots(
316315
dni=500,
317316
optimization_configuration=optimization_configuration,
318317
reconstruction_method=config_dictionary.kinematics_reconstruction_raytracing,
319-
bitmap_resolution=resolution
318+
bitmap_resolution=resolution,
320319
)
321320

322321
# Reconstruct the kinematics.
@@ -333,7 +332,7 @@ def create_plots(
333332
(heliostat[0], [heliostat[1][-1]], [heliostat[2][-1]])
334333
for heliostat in heliostat_data_mapping
335334
],
336-
resolution=resolution
335+
resolution=resolution,
337336
)
338337
create_plots(
339338
fluxes_before=bitmaps_before,

tutorials/05_motor_positions_optimizer_tutorial.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@ def create_flux_plot(label: str, resolution: torch.Tensor) -> None:
3333
resolution : torch.Tensor
3434
Bitmap resolution.
3535
"""
36-
total_flux = torch.zeros((resolution[index_mapping.unbatched_bitmap_u], resolution[index_mapping.unbatched_bitmap_e]), device=device)
36+
total_flux = torch.zeros(
37+
(
38+
resolution[index_mapping.unbatched_bitmap_u],
39+
resolution[index_mapping.unbatched_bitmap_e],
40+
),
41+
device=device,
42+
)
3743

3844
for heliostat_group_index, heliostat_group in enumerate(
3945
scenario.heliostat_field.heliostat_groups
@@ -124,7 +130,7 @@ def create_flux_plot(label: str, resolution: torch.Tensor) -> None:
124130
device = get_device()
125131

126132
# Specify the path to your scenario.h5 file.
127-
scenario_path = pathlib.Path("/workVERLEIHNIX/mb/ARTIST/examples/field_optimizations/scenarios/ideal_baseline_scenario.h5")
133+
scenario_path = pathlib.Path("please/insert/the/path/to/the/scenario/here/scenario.h5")
128134

129135
# Set optimizer parameters.
130136
optimizer_dict = {
@@ -179,8 +185,8 @@ def create_flux_plot(label: str, resolution: torch.Tensor) -> None:
179185
scenario_file=scenario_file,
180186
device=device,
181187
)
182-
183-
bitmap_resolution = torch.tensor([300, 360], device=device)
188+
189+
bitmap_resolution = torch.tensor([256, 256], device=device)
184190
# Set DNI W/m^2.
185191
dni = 800
186192
# Set number of rays per surface point.
@@ -211,10 +217,16 @@ def create_flux_plot(label: str, resolution: torch.Tensor) -> None:
211217
# loss_definition = FocalSpotLoss(scenario=scenario)
212218
# For an optimization using a distribution as target use this loss function definition:
213219
e_trapezoid = utils.trapezoid_distribution(
214-
total_width=bitmap_resolution[index_mapping.unbatched_bitmap_e], slope_width=30, plateau_width=110, device=device
220+
total_width=bitmap_resolution[index_mapping.unbatched_bitmap_e],
221+
slope_width=30,
222+
plateau_width=110,
223+
device=device,
215224
)
216225
u_trapezoid = utils.trapezoid_distribution(
217-
total_width=bitmap_resolution[index_mapping.unbatched_bitmap_u], slope_width=30, plateau_width=110, device=device
226+
total_width=bitmap_resolution[index_mapping.unbatched_bitmap_u],
227+
slope_width=30,
228+
plateau_width=110,
229+
device=device,
218230
)
219231
ground_truth = u_trapezoid.unsqueeze(
220232
index_mapping.unbatched_bitmap_u

0 commit comments

Comments
 (0)