Open adriaat opened 4 weeks ago
Thanks for opening your first issue here at xarray! Be sure to follow the issue template! If you have an idea for a solution, we would really welcome a Pull Request with proposed changes. See the Contributing Guide for more. It may take us a while to respond here, but we really value your contribution. Contributors like you help make xarray better. Thank you!
I can't reproduce this in my environment, I get the expected masked values (thanks for the code snippet, though).
Can you please add the output of xr.show_versions()
to the original post? I suspect this issue to be caused by a outdated, or possibly broken, environment.
I hit an issue that can go silent for many users.
I am masking my data using
dask.array.ma.masked_invalid
(my dataset is much larger than my memory). When saving the results and loading them again, the data is changed. In particular,0.
is assigned to those elements that where masked instead ofnp.nan
orfill_value
, which is1e+20
.Below an example that illustrates the issue:
I expected
mydata
to be either[np.nan, np.nan, np.nan, 2.0]
,numpy.MaskedArray
, or[1e+20, 1e+20, 1e+20, 2.0]
, since:instead of
[0.0, 0.0, 0.0, 2.0]
. No warning is raised, and I do not get why the fill values are replaced by0.
A way to address this for my data (but might not be true for all cases) is to use
xarray.where
before writing to file asor mask the data in some other way, e.g. using xarray.where in the beginning instead of xarray.apply_ufunc.