Stream: general

Topic: datettime type mismatch in CMIP6 models when concatenating


view this post on Zulip Mira Berdahl (May 03 2024 at 00:24):

When concatenating various CMIP6 models, I'm running into a datettime mismatch issue:

_ds = list(ds_regrid_dict.values())
_coord = list(ds_regrid_dict.keys())
ds_out_regrid = xr.concat(objs=_ds, dim=_coord, coords="all").rename({'concat_dim':'model'})
ds_out_regrid

TypeError: cannot compare cftime.DatetimeProlepticGregorian(1985, 1, 16, 12, 0, 0, 0, has_year_zero=True) and cftime.DatetimeNoLeap(1985, 1, 16, 12, 0, 0, 0, has_year_zero=True)

I'm adapting this example from online:
https://nordicesmhub.github.io/forces-2021/learning/example-notebooks/xesmf_regridding.html

Anyone know a smart way to get around this?

view this post on Zulip Katelyn FitzGerald (May 03 2024 at 00:37):

You might look into xarray's interp_calendar or convert_calendar to help align the calendars / time coords.

view this post on Zulip Mira Berdahl (May 03 2024 at 21:12):

Katelyn FitzGerald said:

You might look into xarray's interp_calendar or convert_calendar to help align the calendars / time coords.

Thanks, I'll look into those.


Last updated: May 16 2025 at 17:14 UTC