diff --git a/opencsp/app/camera_calibration/CameraCalibration.py b/opencsp/app/camera_calibration/CameraCalibration.py index dbf8fc68a..7ccef597e 100644 --- a/opencsp/app/camera_calibration/CameraCalibration.py +++ b/opencsp/app/camera_calibration/CameraCalibration.py @@ -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') @@ -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() diff --git a/opencsp/app/select_image_points/SelectImagePoints.py b/opencsp/app/select_image_points/SelectImagePoints.py index 986c0f76d..f360a9385 100644 --- a/opencsp/app/select_image_points/SelectImagePoints.py +++ b/opencsp/app/select_image_points/SelectImagePoints.py @@ -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() diff --git a/opencsp/app/sofast/SofastGUI.py b/opencsp/app/sofast/SofastGUI.py index b61d96ee8..41f1cdd53 100644 --- a/opencsp/app/sofast/SofastGUI.py +++ b/opencsp/app/sofast/SofastGUI.py @@ -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') @@ -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) diff --git a/opencsp/app/sofast/lib/AbstractMeasurementSofast.py b/opencsp/app/sofast/lib/AbstractMeasurementSofast.py index 89b8c82ea..483c39083 100644 --- a/opencsp/app/sofast/lib/AbstractMeasurementSofast.py +++ b/opencsp/app/sofast/lib/AbstractMeasurementSofast.py @@ -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 diff --git a/opencsp/app/sofast/lib/DistanceOpticScreen.py b/opencsp/app/sofast/lib/DistanceOpticScreen.py index 3d3f2b157..ea23b194d 100644 --- a/opencsp/app/sofast/lib/DistanceOpticScreen.py +++ b/opencsp/app/sofast/lib/DistanceOpticScreen.py @@ -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] @@ -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] diff --git a/opencsp/app/sofast/lib/MeasurementSofastFixed.py b/opencsp/app/sofast/lib/MeasurementSofastFixed.py index b6a611590..0263e507c 100644 --- a/opencsp/app/sofast/lib/MeasurementSofastFixed.py +++ b/opencsp/app/sofast/lib/MeasurementSofastFixed.py @@ -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 @@ -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 @@ -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': diff --git a/opencsp/app/sofast/lib/MeasurementSofastFringe.py b/opencsp/app/sofast/lib/MeasurementSofastFringe.py index f1f89edd6..1ffe10a0a 100644 --- a/opencsp/app/sofast/lib/MeasurementSofastFringe.py +++ b/opencsp/app/sofast/lib/MeasurementSofastFringe.py @@ -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 diff --git a/opencsp/common/lib/deflectometry/ImageProjection.py b/opencsp/common/lib/deflectometry/ImageProjection.py index 648bd0cec..b3c07b258 100644 --- a/opencsp/common/lib/deflectometry/ImageProjection.py +++ b/opencsp/common/lib/deflectometry/ImageProjection.py @@ -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) diff --git a/opencsp/common/lib/deflectometry/ImageProjectionSetupGUI.py b/opencsp/common/lib/deflectometry/ImageProjectionSetupGUI.py index 8a603f59e..adb7c84de 100644 --- a/opencsp/common/lib/deflectometry/ImageProjectionSetupGUI.py +++ b/opencsp/common/lib/deflectometry/ImageProjectionSetupGUI.py @@ -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') @@ -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 diff --git a/opencsp/common/lib/tool/hdf5_tools.py b/opencsp/common/lib/tool/hdf5_tools.py index 6a5fb1303..228664f98 100644 --- a/opencsp/common/lib/tool/hdf5_tools.py +++ b/opencsp/common/lib/tool/hdf5_tools.py @@ -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 ''. diff --git a/opencsp/common/lib/tool/tk_tools.py b/opencsp/common/lib/tool/tk_tools.py index b3b5d0ca4..2bee986ba 100644 --- a/opencsp/common/lib/tool/tk_tools.py +++ b/opencsp/common/lib/tool/tk_tools.py @@ -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}") @@ -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).