-
Notifications
You must be signed in to change notification settings - Fork 25
Move filter.py from xDEM to GeoUtils and integrate into raster class
#699
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
base: main
Are you sure you want to change the base?
Conversation
99598cc to
41144c2
Compare
|
Great, thanks! 😄 We have a memo page to work on someone else's PR here 😉: https://github.com/GlacioHack/xdem/wiki/Work-on-someone-else's-PR) I only have a few comments:
For next PRs, we also need to:
|
|
We could also easily add an NMAD filter based on Numba (just mirroring the median filter code with Numba, with the NMAD calculation instead), which would solve this 4-year old issue! GlacioHack/xdem#69 |
|
We could add it to our "project" once created ? |
filter.py from xDEM to GeoUtils and integrate into raster class
1b5bc53 to
18681de
Compare
|
@rhugonnet can you please check one last time, I think we might have some confusion with Numba ? |
|
What confusion, can you explain in more details? |
|
Great, thanks! 🙂 |
|
I thought you wanted numba to be mandatory, I don't know why, maybe because of two weeks hollidays, sorry ^^ |
f88d800 to
ab8ba38
Compare
|
Perfect! I see Numba is being annoying when solving in CI within the already-existing environment. To fix this, the trick is to replace "graphviz" by "graphviz, numba" at this line to pre-install it:
That should do the trick 😉 But it means that we'll never be testing that the package functions normally without Numba in its environment. |
3d53de5 to
6646665
Compare
|
Thanks @adebardo for continuing this long process of moving the filters! 😅 I made all my comments in-line but here are some major comments:
Looking at the previous PR and Romain's comments, it looks like point 1 and 3 may have be discussed already but I'm not sure what was the conclusion. |
|
Great find on This is amazing news, it means we can have performant convolutions/filters with NaNs without requiring Numba, and comforts me into moving Numba into an optional dependency, while having SciPy as default main dependency (both for xDEM and GeoUtils). @adebardo If the performance is indeed much better than |
|
Hello, |
Good catch! For new features, we can do this: from packaging.version import Version
if Version(scipy.__version__) > Version("1.16.0"):
generic_filter = scipy.ndimage.vectorized_filter
else:
generic_filter = scipy.ndimage.generic_filterThat should solve it 😉 (i.e. it will work on any Python version) |
46f921e to
017b227
Compare
84719ad to
965f199
Compare
Resolves #690
I'm picking up @vschaffn's work on filter management from geoutils. I couldn't find any other way than to create a new PR. Valentin's history should be preserved.
I've tried to incorporate the other feedback, with more tests and better handling of NaNs without _nan_safe_filter.
Previous PR
Context
The current filter.py module in xDEM provides a collection of filters that are highly useful for digital elevation models (DEMs). However, these filtering utilities are not intrinsically tied to elevation data—they are generally applicable to any geospatial raster data. Given this, it makes more architectural sense for them to live in GeoUtils.
Changes
Tests
Documentation
Note
When this ticket is approved, a linked PR to remove filters in xDEM will be opened.