cedadev / nappy

NASA Ames Processing in PYthon (NAPPy) - a Python library for reading, writing and converting NASA Ames files.
BSD 3-Clause "New" or "Revised" License
9 stars 13 forks source link

There is an xarray issue with the "wet" variable in CRUTS #24

Closed agstephens closed 3 years ago

agstephens commented 3 years ago

Here is an issue we need to solve:

# ncdump -h ~/.mini-ceda-archive/main/archive/badc/cru/data/cru_ts/cru_ts_4.04/data/wet/cru_ts4.04.1901.2019.wet.dat.nc | grep wet
netcdf cru_ts4.04.1901.2019.wet.dat {
        float wet(time, lat, lon) ;
                wet:long_name = "wet day frequency" ;
                wet:units = "days" ;
                wet:correlation_decay_distance = 450.f ;
                wet:_FillValue = 9.96921e+36f ;
                wet:missing_value = 9.96921e+36f ;

Xarray tries to be clever:

ds = xr.open_dataset(fpath)
ds.wet --> has been converted to a datetime64 type
- because units are "days".

We don't want that so:

ds = xr.open_dataset(fpath, decode_times=False)
ds.wet --> has been decoded to a float64 type
- BUT: the time dimension is also not decoded

Not sure how to fix this!!!

agstephens commented 3 years ago

Resolved with: xr.open_dataset(...., decode_timedelta=False)