time decoding error with "days since"
See original GitHub issueI am trying to use xray with some CESM POP model netCDF output, which supposedly follows CF-1.0 conventions. It is failing because the models time units are “'days since 0000-01-01 00:00:00”. When calling open_dataset, I get the following error:
ValueError: unable to decode time units u'days since 0000-01-01 00:00:00' with the default calendar. Try opening your dataset with decode_times=False. Full traceback:
Traceback (most recent call last):
File "/home/rpa/xray/xray/conventions.py", line 372, in __init__
# Otherwise, tracebacks end up swallowed by Dataset.__repr__ when users
File "/home/rpa/xray/xray/conventions.py", line 145, in decode_cf_datetime
dates = _decode_datetime_with_netcdf4(flat_num_dates, units, calendar)
File "/home/rpa/xray/xray/conventions.py", line 97, in _decode_datetime_with_netcdf4
dates = np.asarray(nc4.num2date(num_dates, units, calendar))
File "netCDF4/_netCDF4.pyx", line 4522, in netCDF4._netCDF4.num2date (netCDF4/_netCDF4.c:50388)
File "netCDF4/_netCDF4.pyx", line 4337, in netCDF4._netCDF4._dateparse (netCDF4/_netCDF4.c:48234)
ValueError: year is out of range
Full metadata for the time variable:
double time(time) ;
time:long_name = "time" ;
time:units = "days since 0000-01-01 00:00:00" ;
time:bounds = "time_bound" ;
time:calendar = "noleap" ;
I guess this is a problem with the underlying netCDF4 num2date package?
Issue Analytics
- State:
- Created 8 years ago
- Comments:20 (13 by maintainers)
Top Results From Across the Web
time decoding error in reading CESM outputs (netCDF files)
Hi, I am trying to use xarray to open CESM outputs in netCDF format. Here is the error: ValueError: unable to decode time...
Read more >xarray error when decoding netcdf data with time units of ...
Try opening your dataset with decode_times=False. Is there a trick to open netcdf data files with units "years since" in xarray?
Read more >How to correct a #VALUE! error in the DAYS function
Solution: Check your system's date and time settings to make sure that they match the format of the dates referred to in the...
Read more >Time and Date Decoding - Hacking with Swift
There is no built-in Swift way to decode the ISO 8601 duration format, which is what duration is in. For that you would...
Read more >Fixing-Your-XML-Error.pdf - IRS
If you take some time to deconstruct the message in your rejection email, ... If you cannot resolve your XML Error after understanding...
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
@rabernat -
Yes - this is all coming from the
netCDF4.netcdftime
module.The work around with xray is to use
ds = xray.open_dataset(filename, decode_times=False)
then to fix up the time variable “manually”. You can usexray.decode_cf()
or simply assign a new pandas time index to your time variable.As an aside, I also work with CESM output and this is a common problem with its netCDF output.
I’m also getting the same error:
ValueError: unable to decode time units 'months since 1955-01-01 00:00:00' with 'the default calendar'. Try opening your dataset with decode_times=False or installing cftime if it is not installed.