Skip to content

Commit

Permalink
Merge pull request #164 from braden6521/sofast_fixed_multi
Browse files Browse the repository at this point in the history
Sofast Fixed multi facet capability
  • Loading branch information
e10harvey authored Oct 9, 2024
2 parents b7816bf + 18e7b4e commit 3fda296
Show file tree
Hide file tree
Showing 28 changed files with 866 additions and 597 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def generate_dataset(
image = np.zeros(mask.shape) * np.nan
for idx in range(sofast.num_facets):
mask = sofast.data_image_processing_facet[idx].mask_processed
slopes_xy = sofast.data_characterization_facet[idx].slopes_facet_xy
slopes_xy = sofast.data_calculation_facet[idx].slopes_facet_xy
slopes = np.sqrt(np.sum(slopes_xy**2, 0))
image[mask] = slopes
plt.figure()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

from os.path import join, dirname, exists
from typing import Literal
from typing import Literal, Final

import matplotlib.pyplot as plt
import numpy as np
Expand Down Expand Up @@ -73,8 +73,9 @@ def generate_dataset(
print(f'All data saved to: {file_dataset_out:s}')

# Show slope map
mask = sofast.data_image_processing_facet[0].mask_processed
slopes_xy = sofast.data_characterization_facet[0].slopes_facet_xy
idx_facet: Final = 0
mask = sofast.data_image_processing_facet[idx_facet].mask_processed
slopes_xy = sofast.data_calculation_facet[idx_facet].slopes_facet_xy
slopes = np.sqrt(np.sum(slopes_xy**2, 0))
image = np.zeros(mask.shape) * np.nan
image[mask] = slopes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def generate_dataset(

# Show slope map
mask = sofast.data_image_processing_facet[0].mask_processed
slopes_xy = sofast.data_characterization_facet[0].slopes_facet_xy
slopes_xy = sofast.data_calculation_facet[0].slopes_facet_xy
slopes = np.sqrt(np.sum(slopes_xy**2, 0))
image = np.zeros(mask.shape) * np.nan
image[mask] = slopes
Expand Down
20 changes: 9 additions & 11 deletions example/sofast_fringe/example_process_facet_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from opencsp.app.sofast.lib.MeasurementSofastFringe import MeasurementSofastFringe
from opencsp.app.sofast.lib.ProcessSofastFringe import ProcessSofastFringe
from opencsp.app.sofast.lib.SpatialOrientation import SpatialOrientation
from opencsp.app.sofast.lib.SofastConfiguration import SofastConfiguration
from opencsp.common.lib.camera.Camera import Camera
from opencsp.common.lib.csp.FacetEnsemble import FacetEnsemble
from opencsp.common.lib.deflectometry.Surface2DParabolic import Surface2DParabolic
Expand Down Expand Up @@ -132,21 +133,16 @@ def example_process_facet_ensemble():
data['robust_least_squares'] = bool(data['robust_least_squares'])
surfaces.append(Surface2DParabolic(**data))

# Update search parameters
# sofast.params.mask_hist_thresh = 0.83
# sofast.params.geometry.perimeter_refine_perpendicular_search_dist = 15.0
# sofast.params.geometry.facet_corns_refine_frac_keep = 1.0
# sofast.params.geometry.facet_corns_refine_perpendicular_search_dist = 3.0
# sofast.params.geometry.facet_corns_refine_step_length = 5.0

# Process
sofast.process_optic_multifacet(facet_data, ensemble_data, surfaces)

# 3. Log best-fit parabolic focal lengths
# =======================================
for idx in range(sofast.num_facets):
surf_coefs = sofast.data_characterization_facet[idx].surf_coefs_facet
focal_lengths_xy = [1 / 4 / surf_coefs[2], 1 / 4 / surf_coefs[5]]
sofast_config = SofastConfiguration()
sofast_config.load_sofast_object(sofast)
sofast_stats = sofast_config.get_measurement_stats()
for stat in sofast_stats:
focal_lengths_xy = stat['focal_lengths_parabolic_xy']
lt.info(f'Facet {idx:d} xy focal lengths (meters): {focal_lengths_xy[0]:.3f}, {focal_lengths_xy[1]:.3f}')

# 4. Plot slope magnitude
Expand All @@ -165,8 +161,10 @@ def example_process_facet_ensemble():
axis_control_m = rca.meters()

# Plot slope map
res = 0.002 # meter, make the plot with 2mm spatial resolution
clim = 7 # mrad, draw the plot with +/-7mrad scale bars, this mirror has erorrs that extend to about +/-7mrad
fig_record = fm.setup_figure(figure_control, axis_control_m, title='')
ensemble.plot_orthorectified_slope(res=0.002, clim=7, axis=fig_record.axis)
ensemble.plot_orthorectified_slope(res=res, clim=clim, axis=fig_record.axis)
fig_record.save(dir_save, 'slope_magnitude', 'png')

# 5. Plot 3d representation of facet ensemble
Expand Down
2 changes: 1 addition & 1 deletion example/sofast_fringe/example_process_single_facet.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def example_process_single_facet():

# 3. Log best-fit parabolic focal lengths
# =======================================
surf_coefs = sofast.data_characterization_facet[0].surf_coefs_facet
surf_coefs = sofast.data_calculation_facet[0].surf_coefs_facet
focal_lengths_xy = [1 / 4 / surf_coefs[2], 1 / 4 / surf_coefs[5]]
lt.info(f'Facet xy focal lengths (meters): ' f'{focal_lengths_xy[0]:.3f}, {focal_lengths_xy[1]:.3f}')

Expand Down
2 changes: 1 addition & 1 deletion example/sofast_fringe/example_process_undefined_shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def example_process_undefined_shape_facet():

# 3. Log best-fit parabolic focal lengths
# =======================================
surf_coefs = sofast.data_characterization_facet[0].surf_coefs_facet
surf_coefs = sofast.data_calculation_facet[0].surf_coefs_facet
focal_lengths_xy = [1 / 4 / surf_coefs[2], 1 / 4 / surf_coefs[5]]
lt.info(f'Facet xy focal lengths (meters): ' f'{focal_lengths_xy[0]:.3f}, {focal_lengths_xy[1]:.3f}')

Expand Down
Loading

0 comments on commit 3fda296

Please sign in to comment.