-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
I am currently using this package to analyze SST data from 950 to 1800. Hence, I need to use cftime objects. Without fixing possible errors with the calendar I came across a problem with the function add_doy().
I'd simply propose a new branch called cftime first that removes
not_leap_year = ~t.dt.is_leap_year
doy = doy_original + (not_leap_year & march_or_later)and adds
not_leap_year = xr.apply_ufunc(cftime.is_leap_year,
t.dt.year,
input_core_dims=[[]],
output_core_dims=[[]],
kwargs={'calendar': "standard",
"has_year_zero":None},
dask="allowed",
vectorize=True)
doy = doy_original + (~not_leap_year & march_or_later)One could also just catch the type of the DatetimeIndex and choose between those two methods. The problem with cftime objects is that they do not have the function is_leap_year. cftime.is_leap_year only takes integers, therefore I needed to use apply_ufunc.
Metadata
Metadata
Assignees
Labels
No labels