How to parse a non-standard time unit format as years since 850-01-01 0:0:0 in xarray library for windows? #7610
-
Recently, I have been working with some netCDF data that has a time dimension in the format of years since 850-01-01 0:0:0. However, I encountered some issues when using xarray to read in and analyze the data. ValueError: In general, units must be one of 'microseconds', 'milliseconds', 'seconds', 'minutes', 'hours', or 'days' (or select abbreviated versions of these). For the '360_day' calendar, 'months' can also be used, or for the 'noleap' calendar 'common_years' can also be used. Got 'years' instead, which are not recognized. I understand that xarray has been designed to handle various types of time formats, but I have not been able to find a solution for this particular format. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Through underlying libraries (cftime in this case) xarray can typically understand date formats like the one listed when decoding times, but the main issue is the use of
There are ways to work around this manually, however. What kind of calendar does your data use and what is the convention used for the meaning of the |
Beta Was this translation helpful? Give feedback.
Through underlying libraries (cftime in this case) xarray can typically understand date formats like the one listed when decoding times, but the main issue is the use of
"years"
as the time unit."years"
can have an ambiguous meaning, so the common practice is to not make any assumptions. This paragraph in the Time Coordinate section of the CF Conventions provides some context: