When I save an xarray dataset, it is changing the datatypes of the variables when saving (or possibly when loading back in). I am not able to produce a minimal working example, because I have no idea what's causing this change (the many others I have saved have worked fine).
My original dataset looks like:
mytest4
Out[177]:
<xarray.Dataset>
Dimensions: (lat: 93, lon: 87, name: 31, time: 82)
Coordinates:
* time (time) datetime64[ns] 2019-01-01 2020-01-01 ... 2100-01-01
* lat (lat) float32 -10.824516 -10.788528 ... -7.532379 -7.4960403
* lon (lon) float32 -79.47869 -79.44204 -79.40539 ... -76.36327 -76.32662
* name (name) <U14 'ACCESS1-0' 'ACCESS1-3' ... 'bcc-csm1-1' 'inmcm4'
Data variables:
pr (name, time, lat, lon) float64 nan nan nan nan ... nan nan nan nan
I then save it using
mytest4.to_netcdf(ETCCDI_folder+'test4.nc')
Open it again
mytest5=xr.open_dataset(ETCCDI_folder+'test4.nc')
And now it looks like this:
mytest5
Out[180]:
<xarray.Dataset>
Dimensions: (lat: 93, lon: 87, name: 31, time: 82)
Coordinates:
* time (time) datetime64[ns] 2019-01-01 2020-01-01 ... 2100-01-01
* lat (lat) float32 -10.824516 -10.788528 ... -7.532379 -7.4960403
* lon (lon) float32 -79.47869 -79.44204 -79.40539 ... -76.36327 -76.32662
* name (name) object 'ACCESS1-0' 'ACCESS1-3' ... 'bcc-csm1-1' 'inmcm4'
Data variables:
pr (name, time, lat, lon) timedelta64[ns] ...
where the 'name' coordinate and more importantly the 'pr' variable have changed datatype. If I use ncview to view 'test4' directly in ETCCDI_folder, it looks as I'd expect, but once loaded back into python it becomes nonsense. Can anyone help?
xr.open_dataset()
, in particular decode_times
and decode_timedelta
encoding
dict option in xr.to_netcdf()
-- see http://xarray.pydata.org/en/stable/generated/xarray.Dataset.to_netcdf.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.