Skip to content
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

Multiple coreg fit_pts fixes. #407

Merged
merged 12 commits into from
Aug 22, 2023

Conversation

erikmannerfelt
Copy link
Contributor

@erikmannerfelt erikmannerfelt commented Aug 16, 2023

My first PR in quite some time!

Two things have been done in this PR; re-implementing my PR (liuh886#7) to the fork that was #346, and solving some small issues that I've found along the way.

The most important change: smashing the half-pixel shift inconsistency

The first part is arguably the most important because the fit_pts functions of NuthKaab and GradientDescending have been at risk of being half a pixel off since #346 was merged! The tests introduced in the PR did not actually check for the fit_pts result on points, but only on rasters converted to points in a predefined manner. My PR (liuh886#7) that fixed this was unfortunately lost along the way in #346... Anyway, here it is again, which fixes and tests the fit_pts half-pixel problem. The reason for the issue was that sampling was not done consistently in the centers of the pixels. The solution is quite hacky I feel, because I'm shifting coordinates and then sampling corners, but it works, as proven by the tests. Paging @liuh886 and @mmazzolini just to let you know that this problem exists in the current release of xdem. EDIT: It might be that the functionality worked before, but it wasn't tested properly, and could be half a pixel off with the wrong GDAL AREA_OR_POINT settings. This PR makes it so this won't happen (at least according to the tests).

Improvements

Other fixes

@erikmannerfelt erikmannerfelt added bug Something isn't working enhancement Feature improvement or request labels Aug 16, 2023
@erikmannerfelt erikmannerfelt linked an issue Aug 16, 2023 that may be closed by this pull request
@liuh886
Copy link
Contributor

liuh886 commented Aug 19, 2023

brilliant! Thanks, Eric, I am on the way back to Oslo, and I am going to have a test on the half-pixel shift bug next week!

@erikmannerfelt
Copy link
Contributor Author

@adehecq, I had to disable your test (tests/test_coreg.py::test_dem_coregistration) because it segfaults both on my machine and in CI! Do you have any idea of why?

Since it shouldn't be due to this PR, I'll leave this test as skipped and then add an issue for it.

@erikmannerfelt erikmannerfelt marked this pull request as ready for review August 21, 2023 11:56
@erikmannerfelt erikmannerfelt self-assigned this Aug 21, 2023
@erikmannerfelt
Copy link
Contributor Author

Oh and @rhugonnet, I acknowledge that the ICP improvement efforts could be seen as misplaced to do now if we're to revamp everything either way. But this way, even the current functionality of xdem has more features. And more importantly for me, I can do my work like I intended now that ICP and CoregPipeline works with ICESat-2!

xdem/coreg/affine.py Outdated Show resolved Hide resolved
rhugonnet
rhugonnet previously approved these changes Aug 21, 2023
Copy link
Contributor

@rhugonnet rhugonnet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, thanks for all the fixes and the tests!

I agree, we can leave the big refactoring to a separate PR, in particular:

  • Use a single fit() method,
  • Define "raster-raster", "point-raster" and "point-point" logic,
  • Consistent point preprocessing/postprocessing.

Very weird to suddenly have a segmentation fault on dem_coregistration, but nowhere else (especially when it is just a wrapper of other functions)... 🤔

@erikmannerfelt erikmannerfelt merged commit 2dd9a21 into GlacioHack:main Aug 22, 2023
13 checks passed
@erikmannerfelt erikmannerfelt deleted the fit_pts_fixes branch August 22, 2023 12:19
@erikmannerfelt
Copy link
Contributor Author

Thanks for the inputs, @rhugonnet !

@adehecq
Copy link
Member

adehecq commented Sep 7, 2023

@adehecq, I had to disable your test (tests/test_coreg.py::test_dem_coregistration) because it segfaults both on my machine and in CI! Do you have any idea of why?

Weird... Did you add an issue for this? I can have a look at it later, once we work on the big coreg changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement Feature improvement or request
Projects
None yet
4 participants