Handling Time Coordinates #6513
-
Hi everyone, I am new to using xarray, and I have been facing a problem with handling time coordinates. I have had six-hourly model outputs for 60 years. The matrix dimensions are 576x360x17x1460 or 576x360x17x1464 (lon, lat, level, time), depending on whether the year is a leap year. The time units are "days since 0000-01-01 00:00:00". When I use mf_dataset to open all the files, it turns out that in the concatenated data, the time is decoded as 0000-01-01 06:00:00 to 0061-01-01 00:00:00. This creates a problem with monthly averages as I am getting 721 months instead of 720 months (12 months x 60 years of data). I think the last time step, 0061-01-01 00:00:00 (the 61st year) is the source of this problem. Can anyone from the community please help me tackle this situation so, that I get 720 months when I calculate the monthly average rather than 721? I hope my question is clear. I would really appreciate some help on this. Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You could try |
Beta Was this translation helpful? Give feedback.
You could try
ds["time"] = ds.time - pd.Timedelta("3H")
to subtract 3 hours (or some other offset) from the time vector IF that makes sense.