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

Deal consistently with Raster.data.mask=False #505

Closed
rhugonnet opened this issue Mar 8, 2024 · 1 comment · Fixed by #501
Closed

Deal consistently with Raster.data.mask=False #505

rhugonnet opened this issue Mar 8, 2024 · 1 comment · Fixed by #501
Labels
enhancement Feature improvement or request

Comments

@rhugonnet
Copy link
Member

rhugonnet commented Mar 8, 2024

The mask of a masked array can be just False and not an array of False when there is no nodata. This can lead to some problems in functions.
The function geoutils.raster.array.get_mask circumvents that issue by using np.isfinite(array) on the array if the mask is not an array, but that requires the array (which we wouldn't have necessarily loaded, see #502) and mostly more CPU usage.

We should have a consistent way to deal with this, maybe something similar to what is done in raster_equal here:

# If the mask is just "False", it is equivalent to being equal to an array of False

Or a "good practice" from the NumPy documentation?

@rhugonnet
Copy link
Member Author

Good practice seems to be calling np.ma.getmaskarray(): https://numpy.org/doc/stable/reference/maskedarray.generic.html#accessing-the-mask

@rhugonnet rhugonnet added the enhancement Feature improvement or request label Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature improvement or request
Projects
None yet
1 participant