You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And as these two objects are quite different (ie not comparable), this leads to quite some exceptions.
For example in HydroMT, we have a preprocess functions to convert cftime to datetimeindex but by doing this, we loose the calendar information (for example from 'noleap' to 'proplectic_gregorian').
Also, in get_rasterdataset, we put an exception to only select the correct times based on time_tuple only if time is of type np.datetime64, which means that data with cftime.datetime type are not cut in time:
I think there is more issues downstream with the type cftime.datetime which is why we put the preprocessor in but would need to investigate.
So I wonder if like xarray we keep the two types possible and if so we should better test and check that every functionality still works for both types of time index.
This discussion was converted from issue #267 on May 25, 2023 13:52.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Working with DatetimeNoLeap calendars, I found this is not so easily handled with HydroMT, especially for xarray objects.
For example, in xarray.open_dataset there is a use_cftime flag which is None by default. This means that times will be decoded to np.datetime64[ns] where possible and else to cftime.datetime:
https://docs.xarray.dev/en/stable/generated/xarray.open_dataset.html
And as these two objects are quite different (ie not comparable), this leads to quite some exceptions.
For example in HydroMT, we have a preprocess functions to convert cftime to datetimeindex but by doing this, we loose the calendar information (for example from 'noleap' to 'proplectic_gregorian').
hydromt/hydromt/data_adapter/data_adapter.py
Lines 25 to 28 in 4784272
Also, in get_rasterdataset, we put an exception to only select the correct times based on time_tuple only if time is of type np.datetime64, which means that data with cftime.datetime type are not cut in time:
hydromt/hydromt/data_adapter/rasterdataset.py
Lines 246 to 251 in 4784272
I think there is more issues downstream with the type cftime.datetime which is why we put the preprocessor in but would need to investigate.
So I wonder if like xarray we keep the two types possible and if so we should better test and check that every functionality still works for both types of time index.
Beta Was this translation helpful? Give feedback.
All reactions