-
Notifications
You must be signed in to change notification settings - Fork 41
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
xdem.coreg.ICP.fit_pts
fails for unknown reason with a regular dataset
#423
Comments
Also, @rhugonnet and @adehecq, if you have any recommendations of how to make a minimal (non-)working example, I'm all ears. It's a float32 DEM with ICESat-2 points that should work just like in the test. But it doesn't! |
Wait what the heck is the difference between |
I have a deadline today, will look in more details tomorrow. Quick answer on your last question:
More details in the examples: https://geoutils.readthedocs.io/en/stable/analysis_examples/index.html#point-extraction |
Thanks for the info! That makes more sense now. But perhaps they could just be one function with an "interpolate" kwarg to |
As promised in #422 , here's the other issue hehe.
This is a strange one. I already have a fix, but I don't understand why it helps!
Problem description
When running
ICP.fit_pts()
I ran into the issue that led to #422; my points were all filtered away for some reason. After some debugging, I found where this happens, but I still don't know why.First, rasters containing information on the normals are sampled using regular
Raster.interp_points
calls:xdem/xdem/coreg/affine.py
Lines 525 to 529 in 3956073
Then, when the rasters have been sampled, a convoluted nan removal line removes the unsuccessful samples:
xdem/xdem/coreg/affine.py
Lines 536 to 537 in 3956073
This led to my ref_dem being empty, as the above
interp_points
for some reason only returned nans! I figured out a fix for this problem, but I still don't understand the symptom...The solution
Instead of the sampling in the code (shown above), I changed it to:
Basically, I make a more efficient nearest neighbour sampling by first determining the row and column indices, then directly indexing the underlying raster. This should be much more efficient, as that part is only done once instead of three times, and for some reason it fixes my problem with the sampling.
What's the actual problem?
Without a minimal (non-)working example, it's hard for me to figure out exactly what's wrong... Honestly, I think it boils down to one of two potential issues:
Raster.interp_points
in geoutilsHonestly, and argument for making a PR to "fix" this can simply be motivated by performance. If
Raster.interp_points
is not used in the method, noRaster
s have to be instantiated and I can just use the rasterio coords to ij functions. That'd reduce the amount of copying that might happen and it will probably make the code look cleaner. I might open a PR to improve the code and then add an associated geoutils issue for tackling the underlying problem.Still, it would be great to get to the bottom of why this actually fails... @rhugonnet or @adehecq, have you experienced something similar before with this function?
The text was updated successfully, but these errors were encountered: