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
Every climate transformation I do requires changing the time (datetime64[ns]) dimension into a YYYYDDD 365-day calendar time (int64) dimension. This seems like a good candidate for admission into the toolbox.
Proposed API
The function should accept as inputs:
a dataset indexed by some time dimension and any other dimensions, with an arbitrary number of data variables, which may or may not be indexed by the time dimension.
the name of the time dimension, which should be a datetime-like object, and which may have leap-years and may be less than or greater than a full year
an inplace argument (default False)
The function should return:
a dataset indexed by some integer 365-day YYYYDDD time dimension with the same dimension name. * If inplace=True, the data should be modified in-place, and the function should return None
Suggested Code
defdatetime_to_365_day(ds, dim='time', inplace=False):
ifinplace:
result=dselse:
result=ds.copy()
result=result.loc[{
'time': ~((result['time.month'] ==2) & (result['time.day'] ==29))}]
# this needs to be changed!# currently, this only works for datasets with 1 year or less of data. If there is more# than one year of daily data, this method will fail.# note that the tricky part here is we want March 1 to become YYYY060 regardless# of whether it is a leap year.# result.coords[dim] = result[str(dim)+'.year']*1000 + np.arange(1, len(result[dim])+1)raiseNotImplementedErrorifnotinplace:
returnresult
The text was updated successfully, but these errors were encountered:
Every climate transformation I do requires changing the
time (datetime64[ns])
dimension into a YYYYDDD 365-day calendartime (int64)
dimension. This seems like a good candidate for admission into the toolbox.Proposed API
The function should accept as inputs:
inplace
argument (default False)The function should return:
inplace=True
, the data should be modified in-place, and the function should return NoneSuggested Code
The text was updated successfully, but these errors were encountered: