Differences on datetime values appears after writing reindexed variable on netCDF file
See original GitHub issueIn my Dataset i’ve got a time serie coordinate who begins like this
<xarray.DataArray 'time' (time: 10)>
array(['2014-02-15T00:00:00.000000000+0100',
'2014-02-15T18:10:00.000000000+0100',
'2014-02-16T18:10:00.000000000+0100',
'2014-02-17T18:10:00.000000000+0100',
'2014-02-18T18:10:00.000000000+0100',
'2014-02-19T18:10:00.000000000+0100',
'2014-02-20T18:10:00.000000000+0100',
'2014-02-21T18:10:00.000000000+0100',
'2014-02-22T00:00:00.000000000+0100',
'2014-02-23T00:00:00.000000000+0100'], dtype='datetime64[ns]')
Coordinates:
* time (time) datetime64[ns] 2014-02-14T23:00:00 2014-02-15T17:10:00 ...
And all is ok when I write and re-open the netdcdf file
Then i try to add to this dataset a reindexed variable like this
da["MeanRainfallHeigh"] = rain.reindex(time =da.time).fillna(0)
Everything is still good for the writing, but when I reopen the netcdf file, the time values are modified for the minutes part.
<xarray.DataArray 'time' (time: 10)>
array(['2014-02-15T00:00:00.000000000+0100',
'2014-02-15T18:00:00.000000000+0100',
'2014-02-16T18:00:00.000000000+0100',
'2014-02-17T18:00:00.000000000+0100',
'2014-02-18T18:00:00.000000000+0100',
'2014-02-19T18:00:00.000000000+0100',
'2014-02-20T18:00:00.000000000+0100',
'2014-02-21T18:00:00.000000000+0100',
'2014-02-22T00:00:00.000000000+0100',
'2014-02-23T00:00:00.000000000+0100'], dtype='datetime64[ns]')
Coordinates:
* time (time) datetime64[ns] 2014-02-14T23:00:00 2014-02-15T17:00:00 ...
Thanks!
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Reading and writing files - Xarray
It is possible to append or overwrite netCDF variables using the mode='a' argument. When using this option, all variables in the dataset will...
Read more >Writing NetCDF Files: Best Practices
There are two strategies for storing a date/time into a netCDF variable. One is to encode it as a numeric value and a...
Read more >Method for Time Slicing in Netcdf similar to xarray
The easiest approach I could find is from netCDF4 import date2index from datetime import datetime timeindex = date2index(datetime(1990,12,1) ...
Read more >2 Components of a NetCDF Dataset
NetCDF dimension declarations appear after the dimensions keyword, netCDF variables and attributes are defined after the variables keyword, and variable data ...
Read more >Database Engine events and errors - SQL Server
139, 15, No, Cannot assign a default value to a local variable. ... 566, 21, Yes, An error occurred while writing an audit...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
FYI,
merged.time.encoding = {}
before callingto_netcdf
seems to avoid the RuntimeWarning.There you go !