Replace level_map and deprecate reference_point and center parameters#92
Open
cfs-data wants to merge 35 commits into
Open
Replace level_map and deprecate reference_point and center parameters#92cfs-data wants to merge 35 commits into
level_map and deprecate reference_point and center parameters#92cfs-data wants to merge 35 commits into
Conversation
level_map with built-in functionlevel_map with built-in function
level_map with built-in functionlevel_map with built-in function and depecrate reference_point parameter
level_map with built-in function and depecrate reference_point parameterlevel_map and depecrate reference_point parameter
level_map and depecrate reference_point parameterlevel_map and deprecrate reference_point parameter
level_map and deprecrate reference_point parameterlevel_map and deprecate reference_point parameter
Collaborator
|
@Raytesnel will PR impact us? |
Collaborator
ja |
level_map and deprecate reference_point parameterlevel_map and deprecate reference_point parameter
Collaborator
|
Is this PR still applicable? |
level_map and deprecate reference_point parameterlevel_map and deprecate reference_point parameter
level_map and deprecate reference_point parameterlevel_map and deprecate reference_point and Mark.center parameter
level_map and deprecate reference_point and Mark.center parameterlevel_map and deprecate reference_point parameter
…e/scratch into replace-map-level
…e/scratch into replace-map-level
level_map and deprecate reference_point parameterlevel_map and deprecate reference_point parameter
level_map and deprecate reference_point parameterlevel_map and deprecate reference_point parameter
SimoneAriens
approved these changes
May 18, 2026
level_map and deprecate reference_point parameterlevel_map and deprecate reference_point and center parameters
Diff CoverageDiff: origin/main..HEAD, staged and unstaged changes
Summary
packages/scratch-core/src/conversion/leveling/core.py |
Minimum allowed line rate is |
vergep
reviewed
May 19, 2026
Collaborator
There was a problem hiding this comment.
In this PR, you do two things:
- You remove the center functionality, which I think is really nice! It is redundant for surface corrections indeed.
- You use surfalize to lavel_map. This is a bit trickier in my opinion. If I understand it correctly, the surfalize detrend_polynomial operation to degree 1 equals SurfaceTerms=Plane, and to degree 2 equals SurfaceTerms = Plane + Sphere. But SurfaceTerms uses a lot of 'subterms', that are not covered by surfalize. Still all the tests pass. That means: I think we don't need all those subterms, but it would be good to check this explicitly. If that is the case, the code can be simplified even further, where we only have two SurfaceTerms: Plane, Plane + Sphere. That would lead to a major deletion of code lines as put forward in this PR, which is really nice! However, if we do need the subterms, we have to include a lot of the original code back in i'm afraid.
| """Get the highest polynomial degree present in the given surface terms.""" | ||
| if terms == SurfaceTerms.NONE: | ||
| raise ValueError(f"No degree defined for {terms}") | ||
| return max(_DEGREE_MAP[term] for term in terms) |
Collaborator
There was a problem hiding this comment.
I think this conversion is tricky. SurfaceTerms.Plane is the only case for which degree is 1. And SurfaceTerms.Sphere is the only case for which degree is 2. When i look at the definition of the designmatrix in detrend_polynomial.
| leveled_map=scan_image.data, | ||
| fitted_surface=np.full_like(scan_image.data, 0.0), | ||
| ) | ||
| if scan_image.valid_mask.sum() < 3: |
| if self.terms == SurfaceTerms.NONE: | ||
| return True | ||
| # We need at least 3 values for the least squares solver | ||
| return scan_image.valid_mask.sum() < 3 |
Collaborator
There was a problem hiding this comment.
1 + get_polynomial_degree(self.terms)?
| assert not np.allclose( | ||
| result_centered.leveled_map, result_ref.leveled_map, equal_nan=True | ||
| @pytest.mark.parametrize("terms", list(SurfaceTerms)) | ||
| def test_map_level_has_effect(scan_image_with_nans: ScanImage, terms: SurfaceTerms): |
Collaborator
There was a problem hiding this comment.
wat test je hier nou? of, in her geval van geen surface term er niks gebeurt is, en anders of er wel iets gebeurt is. Maar gebeurt er dan het goede?
vergep
requested changes
May 19, 2026
SimoneAriens
approved these changes
May 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes:
level_map()is replaced by a built-in function fromsurfalizereference_pointhas no influence on end-to-end tests so this parameter has been removed in this branch.centerproperty ofMarkhad no influence on end-to-end tests, so this property has been removed as well