When clipping the temp variable in the bran2020 dataset, out-of-bounds values are not maksed correctly. The temp variable is a short with float offset and scale parameters. Masked values (such as over land) are marked using the _FillValue: -32768s in the netCDF file. Masked values in the xarray dataset are nans. Clipped values should be nans also to match.
This PR fixes the below bug by using np.nan for the fill value of already masked data arrays. It needs tests before being merged.
After fixing the bug, the above code makes this plot instead:
Masked vs. clipped data:
>>> # The corner of the dataset which has been masked out incorrectly
>>> print(tassie["temp"][0, 0, 0, 0].values)
array(383.0099, dtype=float32)
>>> # Over land, which was masked when the file was loaded
>>> tassie["temp"][0, 0, 35, 50].values
array(nan, dtype=float32)
When clipping the
temp
variable in thebran2020
dataset, out-of-bounds values are not maksed correctly. Thetemp
variable is ashort
with float offset and scale parameters. Masked values (such as over land) are marked using the_FillValue: -32768s
in the netCDF file. Masked values in the xarray dataset arenan
s. Clipped values should be nans also to match.This PR fixes the below bug by using
np.nan
for the fill value of already masked data arrays. It needs tests before being merged.After fixing the bug, the above code makes this plot instead:
Masked vs. clipped data:
$ ncdump -h bran2020.nc
: