Skip to content

Commit d053dda

Browse files
authored
Merge branch 'develop' into 309-code-bug-incorrect-units-on-enclosed-energy-example
2 parents d7f29f3 + e9aba77 commit d053dda

6 files changed

Lines changed: 777 additions & 165 deletions

File tree

‎contrib/common/lib/cv/spot_analysis/image_processor/EnclosedEnergyImageProcessor.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
AbstractSpotAnalysisImageProcessor,
2020
)
2121
import opencsp.common.lib.tool.log_tools as lt
22+
import matplotlib.pyplot as plt
2223

2324

2425
if TYPE_CHECKING:
@@ -296,7 +297,6 @@ def build_enclosed_energy_plot(self, enclosed_energy_sums: list[int]) -> tuple[n
296297

297298
# close the figure
298299
fig_record.close()
299-
300300
return plot_image, percentages_of_interest_radii
301301

302302
def build_poi_annotations(
@@ -342,9 +342,15 @@ def _execute(self, operable: SpotAnalysisOperable, is_last: bool) -> list[SpotAn
342342
# Generate a visual plot of the enclosed energy
343343
enclosed_energy_plot, percentages_of_interest_radii = self.build_enclosed_energy_plot(enclosed_energy_sums)
344344

345+
plt.imshow(enclosed_energy_plot)
346+
plt.show()
347+
345348
# Attach the enclosed energy annotations
346349
enclosed_energy_annos = self.build_poi_annotations(center, percentages_of_interest_radii)
347350

351+
plt.imshow(example_enclosed_energy_image, cmap="grey")
352+
plt.show()
353+
348354
# Build the new operable
349355
notes = copy.copy(operable.image_processor_notes)
350356
notes.append(tuple([self.name, tuple([percentages_of_interest_radii, [str(v) for v in enclosed_energy_sums]])]))

‎example/enclosed_energy/enclosed_energy.ipynb‎

Lines changed: 246 additions & 46 deletions
Large diffs are not rendered by default.

‎example/target_identification/target_identification.ipynb‎

Lines changed: 502 additions & 114 deletions
Large diffs are not rendered by default.

‎opencsp/common/lib/cv/spot_analysis/image_processor/ViewCrossSectionImageProcessor.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,15 @@ def visualize_operable(
348348
graphs_per_plot_cnt += self._draw_cross_section(operable, np_image, cs_loc, cropped_region)
349349

350350
# draw
351+
first_view = True
351352
for view in self.views:
352353
legend = graphs_per_plot_cnt > 1
353-
view.show(block=False, legend=legend)
354+
355+
# jhs modified, only the first view has actual data to display in the enclosed_energy jupyter notebook
356+
# example, so I am only showing that one here. Also, this is true for the target_identification example
357+
if first_view:
358+
view.show(block=False, legend=legend)
359+
first_view = False
354360

355361
# explicitly set the y-axis range
356362
if self.y_range is not None:

‎opencsp/common/lib/cv/spot_analysis/image_processor/ViewFalseColorImageProcessor.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ def visualize_operable(
148148
else:
149149
ret = [self.apply_mapping_jet(operable, base_image)]
150150

151+
processed_image = ret[0].nparray
152+
153+
self.figure.clear()
154+
self.figure.view.imshow(processed_image)
155+
self.figure.view.show(block=False)
156+
151157
return ret
152158

153159
def close_figures(self):

‎opencsp/common/lib/render/lib/PowerpointImage.py‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ class PowerpointImage(pps.PowerpointShape):
2929
"""
3030

3131
_tmp_save_path = ft.join(orp.opencsp_temporary_dir(), "PowerpointImage/images/tmp")
32+
# _tmp_save_path = ft.join(
33+
# "C:/ctemp", "OpenCSP_example_data/target_identification/HeliostatsSpotSize/3_Process/PowerPointFigures"
34+
# )
3235

3336
def __init__(
3437
self,
@@ -636,7 +639,9 @@ def save(self) -> None | str:
636639
# get a temporary name to save to
637640
found_unused_name = False
638641
for tmp_slide_idx in slide_idx_range:
639-
max_img_idx = 20 # probably shouldn't need more than 20 images in a slide
642+
max_img_idx = (
643+
20 # probably shouldn't need more than 20 images in a slide, TODO, marked, revisit 20 image limit
644+
)
640645
dir_name_ext_pattern = self._get_save_dir_name_ext_pattern(tmp_slide_idx)
641646
max_image_path_name_ext = dir_name_ext_pattern % (max_img_idx - 1)
642647
if ft.file_exists(max_image_path_name_ext):
@@ -656,6 +661,7 @@ def save(self) -> None | str:
656661
lt.info(f"saving image to {image_path_name_ext}")
657662

658663
# save the image
664+
# saved_path, body_ext = self._save(image_path_name_ext) # jhs commented out
659665
saved_path, body_ext = self._save(image_path_name_ext)
660666
if saved_path != self._tmp_save_path:
661667
lt.error_and_raise(
@@ -690,8 +696,8 @@ def clear_tmp_save(self):
690696
# TODO verify that the path is the expected temporary path
691697

692698
# delete the saved files
693-
ft.delete_file(path_name_ext, error_on_not_exists=False)
694-
ft.delete_file(path_name_ext_serialized, error_on_not_exists=False)
699+
# ft.delete_file(path_name_ext, error_on_not_exists=False) # jhs, commented out in order to retain powerpoint figures
700+
# ft.delete_file(path_name_ext_serialized, error_on_not_exists=False)
695701

696702
@classmethod
697703
def clear_tmp_save_all(cls):

0 commit comments

Comments
 (0)