Skip to content

Commit

Permalink
Updated test-spatial-processing and test-slopeSolver to use SpatialOr…
Browse files Browse the repository at this point in the history
…ientation object
  • Loading branch information
braden6521 committed Mar 21, 2024
1 parent 1cbe79a commit b9cd3a1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
22 changes: 10 additions & 12 deletions opencsp/app/sofast/test/test_spatial_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
import numpy as np
from scipy.spatial.transform import Rotation

from opencsp.app.sofast.lib.DisplayShape import DisplayShape as Display
from opencsp.app.sofast.lib.MeasurementSofastFringe import (
MeasurementSofastFringe as Measurement,
)
from opencsp.app.sofast.lib.MeasurementSofastFringe import MeasurementSofastFringe
import opencsp.app.sofast.lib.spatial_processing as sp
from opencsp.app.sofast.lib.SpatialOrientation import SpatialOrientation
from opencsp.common.lib.camera.Camera import Camera
from opencsp.common.lib.geometry.Vxy import Vxy
from opencsp.common.lib.geometry.Vxyz import Vxyz
Expand All @@ -31,7 +29,7 @@ def setUpClass(cls):
cls.data_file_facet = os.path.join(base_dir, 'calculations_facet/data.h5')
cls.data_file_measurement = os.path.join(base_dir, 'measurement_facet.h5')

cls.display = Display.load_from_hdf(cls.data_file_facet)
cls.orientation = SpatialOrientation.load_from_hdf(cls.data_file_facet)
cls.camera = Camera.load_from_hdf(cls.data_file_facet)

def test_t_from_distance(self):
Expand All @@ -42,14 +40,14 @@ def test_t_from_distance(self):

# Load test data
data = load_hdf5_datasets(datasets, self.data_file_facet)
measurement = Measurement.load_from_hdf(self.data_file_measurement)
measurement = MeasurementSofastFringe.load_from_hdf(self.data_file_measurement)

# Perform calculation
v_cam_optic_cam_exp = sp.t_from_distance(
Vxy(data['v_mask_centroid_image']),
measurement.optic_screen_dist,
self.camera,
self.display.v_cam_screen_cam,
self.orientation.v_cam_screen_cam,
).data.squeeze()

# Test
Expand All @@ -67,7 +65,7 @@ def test_r_from_position(self):
# Perform calculation
r_optic_cam_exp = (
sp.r_from_position(
Vxyz(data['v_cam_optic_cam_exp']), self.display.v_cam_screen_cam
Vxyz(data['v_cam_optic_cam_exp']), self.orientation.v_cam_screen_cam
)
.inv()
.as_rotvec()
Expand Down Expand Up @@ -115,11 +113,11 @@ def test_distance_error(self):

# Load test data
data = load_hdf5_datasets(datasets, self.data_file_facet)
measurement = Measurement.load_from_hdf(self.data_file_measurement)
measurement = MeasurementSofastFringe.load_from_hdf(self.data_file_measurement)

# Perform calculation
error_optic_screen_dist_2 = sp.distance_error(
self.display.v_cam_screen_cam,
self.orientation.v_cam_screen_cam,
Vxyz(data['v_cam_optic_cam_refine_2']),
measurement.optic_screen_dist,
)
Expand Down Expand Up @@ -162,15 +160,15 @@ def test_refine_v_distance(self):

# Load test data
data = load_hdf5_datasets(datasets, self.data_file_facet)
measurement = Measurement.load_from_hdf(self.data_file_measurement)
measurement = MeasurementSofastFringe.load_from_hdf(self.data_file_measurement)

# Perform calculation
r_cam_optic = Rotation.from_rotvec(data['r_optic_cam_refine_1'])
v_meas_pt_optic_cam = measurement.measure_point.rotate(r_cam_optic)
v_cam_optic_cam_refine_2 = sp.refine_v_distance(
Vxyz(data['v_cam_optic_cam_refine_1']),
measurement.optic_screen_dist,
self.display.v_cam_screen_cam,
self.orientation.v_cam_screen_cam,
v_meas_pt_optic_cam,
).data.squeeze()

Expand Down
10 changes: 3 additions & 7 deletions opencsp/common/lib/deflectometry/test/test_SlopeSolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
import numpy as np
from scipy.spatial.transform import Rotation

from opencsp.app.sofast.lib.DisplayShape import DisplayShape as Display
from opencsp.app.sofast.lib.MeasurementSofastFringe import (
MeasurementSofastFringe as Measurement,
)
from opencsp.app.sofast.lib.MeasurementSofastFringe import MeasurementSofastFringe
from opencsp.app.sofast.lib.SpatialOrientation import SpatialOrientation
from opencsp.common.lib.deflectometry.SlopeSolver import SlopeSolver
from opencsp.common.lib.deflectometry.Surface2DParabolic import Surface2DParabolic
Expand Down Expand Up @@ -46,13 +43,12 @@ def setUpClass(cls):
]
# Load data
data = load_hdf5_datasets(datasets, cls.data_file_facet)
display = Display.load_from_hdf(cls.data_file_facet)
measurement = Measurement.load_from_hdf(data_file_measurement)
measurement = MeasurementSofastFringe.load_from_hdf(data_file_measurement)
ori = SpatialOrientation.load_from_hdf(cls.data_file_facet)

# Create spatial orientation object
r_cam_optic = Rotation.from_rotvec(data['r_optic_cam_refine_1']).inv()
v_cam_optic_cam = Vxyz(data['v_cam_optic_cam_refine_2'])
ori = SpatialOrientation(display.r_cam_screen, display.v_cam_screen_cam)
ori.orient_optic_cam(r_cam_optic, v_cam_optic_cam)

# Perform calculations
Expand Down

0 comments on commit b9cd3a1

Please sign in to comment.