Skip to content

Commit

Permalink
changes to address comments on PR !65
Browse files Browse the repository at this point in the history
  • Loading branch information
bbean23 committed Apr 4, 2024
1 parent 2e74cef commit 11d43f4
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 31 deletions.
4 changes: 2 additions & 2 deletions opencsp/app/camera_calibration/CameraCalibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self):
"""
# Create tkinter object
self.root = tkt._window()
self.root = tkt.window()

# Set title
self.root.title('Camera Calibration')
Expand Down Expand Up @@ -276,7 +276,7 @@ def find_corners(self):

def view_found_corners(self):
# Create new window
root_corns = tkt._window(self.root, TopLevel=True)
root_corns = tkt.window(self.root, TopLevel=True)

# Get number checkerboard points
npts = self.get_npts()
Expand Down
2 changes: 1 addition & 1 deletion opencsp/app/select_image_points/SelectImagePoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,5 @@ def _load_raw_image(file) -> np.ndarray:
)
if file_selected != '':
# Create window
win = SelectImagePoints(tkt._window(), file_selected)
win = SelectImagePoints(tkt.window(), file_selected)
win.run()
4 changes: 2 additions & 2 deletions opencsp/app/sofast/SofastGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(self) -> 'SofastGUI':
self.service = SofastService(self)

# Create tkinter object
self.root = tkt._window()
self.root = tkt.window()

# Set title
self.root.title('SOFAST')
Expand Down Expand Up @@ -515,7 +515,7 @@ def load_image_projection(self) -> None:
# Load data
image_projection_data = ImageProjection.load_from_hdf(file)
# Create new window
projector_root = tkt._window(self.root, TopLevel=True)
projector_root = tkt.window(self.root, TopLevel=True)
# Show window
self.service.image_projection = ImageProjection(projector_root, image_projection_data)

Expand Down
6 changes: 1 addition & 5 deletions opencsp/app/sofast/lib/AbstractMeasurementSofast.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
"""Measurement class for SofastFringe
"""

from abc import ABC, abstractmethod
from abc import ABC
import datetime as dt

import numpy as np

from opencsp.app.sofast.lib.ImageCalibrationAbstract import ImageCalibrationAbstract
import opencsp.app.sofast.lib.DistanceOpticScreen as sod
from opencsp.common.lib.geometry.Vxyz import Vxyz
import opencsp.common.lib.tool.hdf5_tools as h5


Expand Down
30 changes: 23 additions & 7 deletions opencsp/app/sofast/lib/DistanceOpticScreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,27 @@
@dataclass
class DistanceOpticScreen(h5.HDF5_IO_Abstract):
"""Represents a distance measurement between the optic and the center of the screen. This measurement is typically
achieved by displaying the crosshairs from the SofastGUI and measuring from the center of the optic
(measurement_point 0,0,0) to the center of the crosshairs."""
achieved by displaying the crosshairs from the SofastGUI and measuring from the origin of the optic
(measurement_point 0,0,0) to the center of the crosshairs.
v_measure_point_facet: Vxyz = field(default_factory=lambda: Vxyz(0.0, 0.0, 0.0))
The optic's origin is typically the center of the optic for on-axis optics, such as with spherical or flat mirrors
that are symetric around their midpoint."""

v_measure_point_facet: Vxyz = field(default_factory=lambda: Vxyz((0.0, 0.0, 0.0)))
""" Location of measure point, meters. """
dist_optic_screen: float = 0
""" Optic-screen distance, meters. """

def save_to_hdf(self, file: str, prefix: str) -> None:
"""
Saves to HDF file
"""Saves data to given file. Data is stored as: PREFIX + Folder/Field_1
Parameters
----------
file : str
HDF file to save to
prefix : str, optional
Prefix to append to folder path within HDF file (folders must be separated by "/").
Default is empty string ''.
"""
datasets = [prefix + '/v_measure_point_facet', prefix + '/dist_optic_screen']
data = [self.v_measure_point_facet.data.squeeze(), self.dist_optic_screen]
Expand All @@ -27,9 +37,15 @@ def save_to_hdf(self, file: str, prefix: str) -> None:

@classmethod
def load_from_hdf(cls, file: str, prefix: str):
"""
Loads from HDF file
"""Loads data from given file. Assumes data is stored as: PREFIX + Folder/Field_1
Parameters
----------
file : str
HDF file to load from
prefix : str, optional
Prefix to append to folder path within HDF file (folders must be separated by "/").
Default is empty string ''.
"""
groups, file_names_and_shapes = h5.get_groups_and_datasets(file)
file_names = [name for name, shape in file_names_and_shapes]
Expand Down
9 changes: 2 additions & 7 deletions opencsp/app/sofast/lib/MeasurementSofastFixed.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import opencsp.app.sofast.lib.AbstractMeasurementSofast as ams
import opencsp.app.sofast.lib.DistanceOpticScreen as osd
from opencsp.common.lib.geometry.Vxy import Vxy
from opencsp.common.lib.geometry.Vxyz import Vxyz
import opencsp.common.lib.tool.hdf5_tools as hdf5_tools


Expand All @@ -28,10 +27,8 @@ def __init__(
----------
image : np.ndarray
(M, N) ndarray, measurement image
v_measure_point_facet : Vxyz
Location of measurem point on facet, meters
dist_optic_screen : float
Optic to screen distance, meters
dist_optic_screen_measure : DistanceOpticScreen
Measurement point on the optic, and distance from that point to the screen
origin : Vxy
The centroid of the origin dot, pixels
date : datetime, optional
Expand All @@ -42,8 +39,6 @@ def __init__(
super().__init__(dist_optic_screen_measure, date, name)
self.image = image
self.origin = origin
self.date = date
self.name = name

@classmethod
def load_from_hdf(cls, file: str, prefix='') -> 'MeasurementSofastFixed':
Expand Down
1 change: 0 additions & 1 deletion opencsp/app/sofast/lib/MeasurementSofastFringe.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from opencsp.app.sofast.lib.ImageCalibrationAbstract import ImageCalibrationAbstract
import opencsp.app.sofast.lib.AbstractMeasurementSofast as ams
import opencsp.app.sofast.lib.DistanceOpticScreen as osd
from opencsp.common.lib.geometry.Vxyz import Vxyz
import opencsp.common.lib.tool.hdf5_tools as hdf5_tools


Expand Down
2 changes: 1 addition & 1 deletion opencsp/common/lib/deflectometry/ImageProjection.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def in_new_window(cls, display_data: dict):
"""
# Create new tkinter window
root = tkt._window()
root = tkt.window()
# Instantiate class
return cls(root, display_data)

Expand Down
4 changes: 2 additions & 2 deletions opencsp/common/lib/deflectometry/ImageProjectionSetupGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def __init__(self):
self.display_data: dict

# Create tkinter object
self.root = tkt._window()
self.root = tkt.window()

# Set title
self.root.title('ImageProjection Setup')
Expand Down Expand Up @@ -202,7 +202,7 @@ def show_projector(self):
self.update_window_size()

# Create a new Toplevel window
projector_root = tkt._window(self.root, Toplevel=True)
projector_root = tkt.window(self.root, Toplevel=True)
self.projector = ImageProjection(projector_root, self.display_data)

# Activate buttons
Expand Down
2 changes: 1 addition & 1 deletion opencsp/common/lib/tool/hdf5_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def load_from_hdf(cls, file: str, prefix: str = ''):
Parameters
----------
file : str
HDF file to save to
HDF file to load from
prefix : str, optional
Prefix to append to folder path within HDF file (folders must be separated by "/").
Default is empty string ''.
Expand Down
4 changes: 2 additions & 2 deletions opencsp/common/lib/tool/tk_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def showtip(self, event=None):
x += self.widget.winfo_rootx() + self.widget.winfo_width()
y += self.widget.winfo_rooty() + self.widget.winfo_height()
# Creates a toplevel window
self.tw = _window(self.widget, TopLevel=True)
self.tw = window(self.widget, TopLevel=True)
# Leaves only the label and removes the app window
self.tw.wm_overrideredirect(True)
self.tw.wm_geometry(f"+{x:d}+{y:d}")
Expand All @@ -59,7 +59,7 @@ def hidetip(self):
tw.destroy()


def _window(*vargs, TopLevel=False, **kwargs):
def window(*vargs, TopLevel=False, **kwargs):
"""Initializes and returns a new tkinter.Tk (or tkinter.TopLevel) instance.
If creating the window fails, tries again (up to two more times).
Expand Down

0 comments on commit 11d43f4

Please sign in to comment.