Replies: 9 comments
-
import cftime
import xarray as xr
inits = xr.cftime_range('1994', '1996', freq='YS')
inits = xr.CFTimeIndex(inits)
print(inits)
>>> CFTimeIndex([1994-01-01 00:00:00, 1995-01-01 00:00:00, 1996-01-01 00:00:00], dtype='object')
# Align with verification for next year.
inits.shift(1, 'YS') # Current way we handle it
>>> CFTimeIndex([1995-01-01 00:00:00, 1996-01-01 00:00:00, 1997-01-01 00:00:00], dtype='object')
# Initialization on a specific day with year forecasts.
inits = [cftime.DatetimeProlepticGregorian(1995, 3, 1),
cftime.DatetimeProlepticGregorian(1996, 3, 1)]
inits = xr.CFTimeIndex(inits)
print(inits)
>>> CFTimeIndex([1995-03-01 00:00:00, 1996-03-01 00:00:00], dtype='object')
inits.shift(365, 'D') # Perhaps their verification is aligned one year out.
>>> CFTimeIndex([1996-02-29 00:00:00, 1997-03-01 00:00:00], dtype='object') Similarly we use
|
Beta Was this translation helpful? Give feedback.
-
Currently, if an E.g. import numpy as np
import pandas as pd
from climpred.utils import convert_time_index
init = np.arange(1990, 1995)
da = xr.DataArray(np.random.rand(len(init)), dims='time', coords=[init])
print(convert_time_index(da, 'time', '').time.to_index())
>>> CFTimeIndex([1990-01-01 00:00:00, 1991-01-01 00:00:00, 1992-01-01 00:00:00,
1993-01-01 00:00:00, 1994-01-01 00:00:00],
dtype='object', name='time') So here we just take floats/ints and essentially append on -01-01. But what if the values coming in are decimal time (e.g. 1990.3) or netcdf style integers that correspond to "days since ...". Should we have a try statement that tries to |
Beta Was this translation helpful? Give feedback.
-
Alright that's all I've got for now! Just wanted to open the discussion with people who have thought about these things so we can find a standard and start chipping away at them with PRs. |
Beta Was this translation helpful? Give feedback.
-
Regarding 3.: is there any data center that provides fractional float inits? We could simply not allow this... easiest way. |
Beta Was this translation helpful? Give feedback.
-
I'm thinking these issues are big enough that it would be helpful to collect information from the various hindcast datasets currently out there and then see what is common and what is different between them and what is clearly defined and what is ambiguous wrt to handling of time and time-related metadata. I think this will help us see how to answer these questions robustly. At the very least, it will help me get a big picture view of the issues across the various communities and envision a robust set of solutions. Where is the best place to collect all this information? Once we agree on a location, I can start populating information for NMME, SubX, International S2S database, and the NCEP/UFS hindcasts (with the idea that we keep weather timescales in mind for the future as well). I think we have the potential to help define a more common and consistent set of metadata and definitions across the entire Earth System Prediction community with respect to time. We are planning for the future for SubX and NMME databases so there is also an opportunity here to influence how they will be setup in the future. |
Beta Was this translation helpful? Give feedback.
-
I think having an overview of the different product names, eg. |
Beta Was this translation helpful? Give feedback.
-
#332 requires Leap or NoLeap. it cannot handle the other calendars yet. for now it checks dayofyear in resampling uninitialized. |
Beta Was this translation helpful? Give feedback.
-
This goal is worked at in https://github.com/bradyrx/climpred/pull/332 but not resolved. |
Beta Was this translation helpful? Give feedback.
-
a comment when implementing need to align with discussion about init times: I propose:
|
Beta Was this translation helpful? Give feedback.
-
CC @kpegion, @aaronspring, @ahuang11, @jmunroe, @Thomas-Moore-Creative, @dougiesquire, @jukent. Looking for insight on time stuff here if/when folks have time to think about this!
With the soon-to-be-merged https://github.com/bradyrx/climpred/pull/294, it's time to figure out some assumptions and standards for dealing with pesky datetime in aligning initialized predictions. I want to work out a system here so we can slowly introduce PRs to handle some of these ideas.
I think we should also add a dedicated docs page on all this datetime stuff. We could draw from some of the thoughts from @jukent in https://ncar.github.io/xdev/posts/time/.
FYI I have some code snippets at https://github.com/bradyrx/esmtools/blob/master/esmtools/temporal.py that could be useful for the below cases.
Here are some thoughts/issues I think are important to discuss (I am going to break them up into separate comments):
.shift()
withcftime
ofnlags
'MS' (month-start).So currently we use the
MS
practice which means we don't have to worry about leap years or leap-year calendars. We just align with a verification product on the first of the next month for a monthly forecast. Of course there are issues..shift(1, 'M')
instead of.shift(1, 'MS')
? Do we just ask that users convert their verification product to MS?Beta Was this translation helpful? Give feedback.
All reactions