Xarray version 2026.4.0 breaks GraphCast Demo Notebook: "time" coord parsed as `int32` instead `timedelta64`
The new xarray version parses NetCDF dataset "time" coord as "int32" instead "timedelta". The issue occurs when parsing the NetCDF example weather data files loaded from google cloud bucket.
Problem
Inside the graphcast_demo.ipynb, section "Load the example data", a NetCDF file is loaded and opened with xarray:
with gcs_bucket.blob(f"{dir_prefix}dataset/{dataset_file.value}").open("rb") as f:
example_batch = xarray.load_dataset(f).compute()The new xarray version parses the time coordinate of the dataset as int32. But the graphcast code excpects "An xarray.Dataset with a 'time' dimension whose coordinates are timedeltas.[…]" (graphcast.data_utils.extract_input_target_times).
This leads to the error in graphcast/graphcast/data_utils.py:282
TypeError: Concatenation operation is not implemented for NumPy arrays, use np.concatenate() instead. Please do not rely on this error; it may not be given on all Python implementations.
Reason
Xarray version 2026.4.0 finalizes the deprecation timedelta decoding via units:
Xarray will now no longer by default decode variables with only a timedelta-like "units" attribute into np.timedelta64 values. […] https://github.com/pydata/xarray/pull/11173
This means that the "time" coordinate of NetCDF files like graphcast/dataset/source-era5_date-2022-01-01_res-0.25_levels-37_steps-01.nc will not be parsed as timedelta64 even though it has the attribute units: hours.
Proposed Solution
Enforce previous behaviour by explicitly setting decode_timedelta=True:
with gcs_bucket.blob(f"{dir_prefix}dataset/{dataset_file.value}").open("rb") as f:
example_batch = xarray.load_dataset(f, decode_timedelta=True).compute()Source: google-deepmind/weathernext