google-deepmind / google-deepmind/weathernext

Xarray version 2026.4.0 breaks GraphCast Demo Notebook: "time" coord parsed as `int32` instead `timedelta64`

Open Beginner friendly
#212 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
7.7k
Forks
986
PR merge metrics
No merged PRs in 30d

Description

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:
```python
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](https://github.com/pydata/xarray/releases/tag/v2026.04.0):
> 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`:

```python
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()
```

Contributor guide

Open the contributing guide

Research direction

Start in graphcast_demo.ipynb at the “Load the example data” section and inspect the xarray.load_dataset call for the NetCDF file. Run that notebook path with the example weather data; done means the time coordinate is decoded as timedeltas and the later GraphCast data processing no longer raises the reported error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data, machine-learning
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
84/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.