read_as_masked_array
does not return a mask for datasets with nan nodata values
#270
Labels
bug
Something isn't working
Describe the bug
read_as_masked_array
contains the lines:np.nan is not None
evaluates to True and enters the branch. However,np.nan == np.nan
evaluates to False, so none of the nans are recognized as nodata values. Apparently, if there is nothing to mask, numpy sets the mask to False (of type np.bool_).In this case,
data
is already the correct masked array, the branch can be bypassed, anddata
can be returned as-is.To Reproduce
Steps to reproduce the behavior:
array = read_as_masked_array(path_to_OPERA_RTC)
Expected behavior
If the nodata value is nan, the line
data = np.ma.masked_invalid(raster_band.ReadAsArray())
should have already produced the desired masked array, which can be returned.Additional context
I hit this issue working to get OPERA data running on the HydroSAR HYDRO30
make_water_map
function: https://github.com/HydroSAR/HydroSAR/blob/develop/src/hydrosar/water_map.py#L185The text was updated successfully, but these errors were encountered: