-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sofast Fixed multi facet capability #164
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @braden6521! My main concerns are the absence of bounds checks on facet indices and cleaning some of the constant values up with self documenting variables / enums.
@@ -74,7 +74,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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: make 0 a Final (https://docs.python.org/3/library/typing.html#typing.Final) local variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never heard of Final before. That's cool, thanks for the suggestion.
@@ -74,7 +74,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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: same as above for 2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a duplicate of above?
# ensemble.plot_orthorectified_slope(res=0.002, clim=7, axis=fig_record.axis) | ||
# fig_record.save(dir_save, 'slope_magnitude', 'png') | ||
fig_record = fm.setup_figure(figure_control, axis_control_m, title='') | ||
ensemble.plot_orthorectified_slope(res=0.002, clim=7, axis=fig_record.axis) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unless self-explanatory for a SME please add some docs or self documenting variables for the "0.002" and "7" magic values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good comment. Documented.
@@ -145,7 +145,7 @@ def example_process_facet_ensemble(): | |||
# 3. Log best-fit parabolic focal lengths | |||
# ======================================= | |||
for idx in range(sofast.num_facets): | |||
surf_coefs = sofast.data_characterization_facet[idx].surf_coefs_facet | |||
surf_coefs = sofast.data_calculation_facet[idx].surf_coefs_facet | |||
focal_lengths_xy = [1 / 4 / surf_coefs[2], 1 / 4 / surf_coefs[5]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: more magic numbers 1,4,2,5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -47,6 +48,8 @@ def __init__(self, points: Vxy, x_min: int, x_max: int, y_min: int, y_max: int) | |||
self._neighbor_dists = np.zeros((self._num_pts, 4)) * np.nan # left, right, up, down | |||
|
|||
self.search_thresh = 5.0 # pixels | |||
self.max_num_iters: int = 100 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider making this a "Final" (https://docs.python.org/3/library/typing.html#typing.Final)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the comment. These values will likely be updated by the user, so I didn't make them Final. However, they were in desperate need of documentation. I added documentation inline and in the module docstring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, if these are defaults will the default values be obvious to the user? If not, please add the default to the doc string such as: "(default: 100)".
@@ -206,69 +205,3 @@ def draw(self, view: View3d, facet_style: RenderControlFacet = None, transform: | |||
|
|||
if facet_style.draw_mirror_curvature: | |||
self.mirror.draw(view, facet_style.mirror_styles, transform * self.mirror._self_to_parent_transform) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for removing these unverified methods
# Get all mirror region vertices | ||
points_xy = Pxy.merge([loop.vertices for loop in facet.mirror.region.loops]) # mirror frame | ||
points_z = facet.mirror.surface_displacement_at(points_xy) # mirror frame | ||
# If the corners aren't in range of the mirror's interpolation function, set to 0 | ||
if np.any(np.isnan(points_z)): | ||
lt.warn(f'Could not find corner z values for facet number {facet_idx:d}; filling with zeros.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lt.warn(f'Could not find corner z values for facet number {facet_idx:d}; filling with zeros.') | |
lt.warn(f'Could not find corner z values for facet number {facet_idx:03d}; filling with zeros.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change made.
while searcher._self_to_parent_transform is not None: | ||
if searcher is target: | ||
return transform | ||
while searcher.parent is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider filing a follow-on issue if these linear searches are expected to be a bottleneck
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. As we use this capability more, I will keep this in mind.
@@ -0,0 +1,18 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider filing a follow-on issue to randomly generate this test data at runtime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still do not fully understand how to use random numbers in tests. Any suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's discuss this. Even if it is a more robust test, it may not be straight forward or practical to generate random values.
@@ -0,0 +1,10 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above. These specific JSON files define the physical shape of the facet being measured. But if there is more opportunity to use randomness in these tests, I could implement it.
b71822b
to
36e9691
Compare
# ensemble.plot_orthorectified_slope(res=0.002, clim=7, axis=fig_record.axis) | ||
# fig_record.save(dir_save, 'slope_magnitude', 'png') | ||
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 extent to about +/-7mrad |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clim = 7 # mrad, draw the plot with +/-7mrad scale bars, this mirror has erorrs that extent to about +/-7mrad | |
clim = 7 # mrad, draw the plot with +/-7mrad scale bars, this mirror has erorrs that extend to about +/-7mrad | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch 🤦♂️
@@ -47,6 +48,8 @@ def __init__(self, points: Vxy, x_min: int, x_max: int, y_min: int, y_max: int) | |||
self._neighbor_dists = np.zeros((self._num_pts, 4)) * np.nan # left, right, up, down | |||
|
|||
self.search_thresh = 5.0 # pixels | |||
self.max_num_iters: int = 100 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, if these are defaults will the default values be obvious to the user? If not, please add the default to the doc string such as: "(default: 100)".
|
||
# Facet definition | ||
if self.data_facet_def is not None: | ||
for idx_facet, facet_data in enumerate(self.data_facet_def): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you anticipate any bugs related to values larger than 999, I would strongly suggest adding a bounds check where appropriate to ensure that that largest facet index does not exceed 999, and, if it does, throw an exception stating that this is not permitted. I confirmed that the width specifier does not truncate values larger than 999 in the f-strings, so that should be fine.
@@ -0,0 +1,18 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's discuss this. Even if it is a more robust test, it may not be straight forward or practical to generate random values.
… perimeter xyz points
…r single and multi facets.
…cess sofast class.
83cfa3a
to
18e7b4e
Compare
NOTE:
Depends on #163.