earthkit-data icon indicating copy to clipboard operation
earthkit-data copied to clipboard

Allow multiple date formats when using sel on GRIB data

Open sandorkertesz opened this issue 1 year ago • 0 comments

If ds is a GRIB filedlist, using sel() for the date key only works when it is specified as an int:

ds.sel(date=20230510)

However, ideally e.g. these should also work:

ds.sel(date="20230510")
ds.sel(date="2023-05-10")
ds.sel(date=np.datetime64("2023-05-10"))
ds.sel(date=datetime.datetime(2023,5,10))
...

Similarly, we should be able to specify datetime.timedelta or np.timedelta64 for "step":

ds.sel(step=datetime.timedelta(hours=6))
ds.sel(step=datetime.timedelta(hours=6, minutes=15))
ds.sel(step=np.timedelta64(6, 'h'))
...

sandorkertesz avatar Nov 08 '23 14:11 sandorkertesz