# Can WeatherNext Be Integrated With Other Libraries? Integration Guide for Scientific Python Workflows

> Integrate WeatherNext with xarray JAX pandas and scientific Python. Learn how WeatherNexts native data structures enable seamless integration for your workflows.

- Repository: [Google DeepMind/weathernext](https://github.com/google-deepmind/weathernext)
- Tags: integration-guide
- Published: 2026-08-16

---

**Yes, WeatherNext integrates seamlessly with xarray, JAX, pandas, and the broader scientific Python ecosystem because it uses native data structures and pure functions without hidden state.**

WeatherNext is a modular, pure-Python library from Google DeepMind designed for weather forecasting with Graph Neural Networks and Transformers. Unlike monolithic frameworks, it exposes standard interfaces that let you plug it into existing workflows without vendor lock-in. This guide explains exactly which libraries work with WeatherNext and how to combine them, based on the source code in `google-deepmind/weathernext`.

## WeatherNext xarray Integration for Geospatial Workflows

WeatherNext's data-handling layer is built directly on **xarray**, the standard for labeled multi-dimensional arrays in geoscience.

In [`weathernext/utils/xarray_tree.py`](https://github.com/google-deepmind/weathernext/blob/main/weathernext/utils/xarray_tree.py) and [`weathernext/utils/xarray_dense.py`](https://github.com/google-deepmind/weathernext/blob/main/weathernext/utils/xarray_dense.py), all weather field operations return native `xarray.Dataset` or `xarray.DataArray` objects. This design choice means you can pass WeatherNext outputs to any xarray-compatible library immediately.

### Regridding with xesmf

```python
import xarray as xr
import xesmf as xe
from weathernext.utils import xarray_tree as wn_tree

# Load a WeatherNext dataset (e.g., temperature forecast)

forecast = xr.open_zarr("gs://weather-next-data/forecast.zarr")

# Build a regridder to a 0.5° lat-lon grid

grid = xr.Dataset(
    {"lat": (["lat"], np.arange(-90, 91, 0.5)),
     "lon": (["lon"], np.arange(0, 360, 0.5))}
)
regridder = xe.Regridder(forecast, grid, "bilinear")

# Apply regridding and then hand the result to WeatherNext utilities

regridded = regridder(forecast)
wn_tree.normalize(regridded)          # WeatherNext's preprocessing step

```

Other xarray-compatible libraries that work out of the box include **xrft** for spectral transforms, **xskillscore** for verification metrics, and **Dask** for distributed computing.

## WeatherNext JAX Integration for Deep Learning Pipelines

The model layer in WeatherNext is implemented in **JAX**, giving you full compatibility with the JAX ecosystem. The source files [`weathernext/weathernext1_graph/graphcast.py`](https://github.com/google-deepmind/weathernext/blob/main/weathernext/weathernext1_graph/graphcast.py) (GNN architecture) and [`weathernext/weathernext1_gen/transformer.py`](https://github.com/google-deepmind/weathernext/blob/main/weathernext/weathernext1_gen/transformer.py) (Transformer architecture) expose functional APIs that accept and return JAX arrays.

### Training with Flax and Optax

```python
import jax
import flax.linen as nn
import optax
from weathernext.weathernext1_gen import transformer as wn_transformer
from weathernext.utils import model_utils

class MyWeatherModel(nn.Module):
    @nn.compact
    def __call__(self, x):
        # WeatherNext Transformer block (configurable via Fiddle)

        wn_block = wn_transformer.TransformerBlock(...)
        return wn_block(x)

# Initialise, loss, optimizer

model = MyWeatherModel()
params = model.init(jax.random.PRNGKey(0), sample_input)
tx = optax.adam(1e-3)

# Standard Flax training step

@jax.jit
def train_step(state, batch):
    def loss_fn(p):
        preds = model.apply(p, batch["inputs"])
        return model_utils.mse_loss(preds, batch["targets"])
    grads = jax.grad(loss_fn)(state.params)
    return state.apply_gradients(grads=grads)

```

You can also integrate **chex** for testing, **TensorFlow-Probability** for probabilistic layers, and **Hydra** for configuration management. The utility modules in [`weathernext/utils/model_utils.py`](https://github.com/google-deepmind/weathernext/blob/main/weathernext/utils/model_utils.py), [`weathernext/utils/losses.py`](https://github.com/google-deepmind/weathernext/blob/main/weathernext/utils/losses.py), and [`weathernext/utils/mesh_transformer.py`](https://github.com/google-deepmind/weathernext/blob/main/weathernext/utils/mesh_transformer.py) follow the same functional style, making custom extensions straightforward.

## WeatherNext pandas Integration for Cyclone Analysis

The cyclone tracking subpackage outputs standard **pandas.DataFrame** objects, enabling direct use with the PyData stack.

In [`weathernext/cyclones/tracker_base.py`](https://github.com/google-deepmind/weathernext/blob/main/weathernext/cyclones/tracker_base.py) and [`weathernext/cyclones/ibtracs_processing_utils.py`](https://github.com/google-deepmind/weathernext/blob/main/weathernext/cyclones/ibtracs_processing_utils.py), the tracking pipelines return tabular data with columns for position, intensity, and timestamp—no proprietary wrappers.

### Clustering Tracks with scikit-learn

```python
import pandas as pd
from weathernext.cyclones import cyclone_utils
from sklearn.cluster import DBSCAN

# Generate tracks for a given year

tracks = cyclone_utils.run_tracker(year=2024)

# Convert to feature matrix (e.g., mean latitude/longitude, intensity)

features = tracks[["mean_lat", "mean_lon", "max_intensity"]].values

# Apply DBSCAN to discover spatial-temporal clusters

clusterer = DBSCAN(eps=2.0, min_samples=5).fit(features)
tracks["cluster"] = clusterer.labels_

```

This pattern extends to **statsmodels** for statistical modeling, **seaborn** or **Plotly** for visualization, and **GeoPandas** for spatial analysis.

## Full Python Ecosystem Compatibility

WeatherNext's design philosophy—pure functions, no hidden state, standard Python data structures—means you can embed it alongside virtually any library:

- **Matplotlib / Cartopy** – Plot native xarray outputs directly
- **PyTorch** – Convert JAX arrays via `jax2torch` or run hybrid pipelines
- **Zarr / fsspec** – Load remote datasets with the same storage backends WeatherNext uses
- **NumPy** – All underlying arrays expose `__array__` protocols

The entry point in [`weathernext/__init__.py`](https://github.com/google-deepmind/weathernext/blob/main/weathernext/__init__.py) exposes only what you need, keeping the public surface area minimal and predictable.

## Summary

- **xarray integration** – Native Dataset/DataArray objects work with xesmf, xrft, Dask, and the entire geospatial Python stack
- **JAX integration** – Functional model APIs in [`graphcast.py`](https://github.com/google-deepmind/weathernext/blob/main/graphcast.py) and [`transformer.py`](https://github.com/google-deepmind/weathernext/blob/main/transformer.py) combine with Flax, Optax, and TFP
- **pandas integration** – Cyclone tracking outputs standard DataFrames for scikit-learn, statsmodels, and visualization libraries
- **No lock-in** – Pure Python, no hidden state, standard data structures throughout

## Frequently Asked Questions

### Does WeatherNext require specific versions of JAX or xarray?

WeatherNext follows semantic versioning for its core dependencies. The [`setup.py`](https://github.com/google-deepmind/weathernext/blob/main/setup.py) and [`pyproject.toml`](https://github.com/google-deepmind/weathernext/blob/main/pyproject.toml) in the repository specify compatible ranges, but the codebase avoids experimental JAX features to maintain stability across minor releases. You can typically use the latest stable releases of JAX, xarray, and pandas without conflicts.

### Can I use PyTorch models alongside WeatherNext components?

Yes. Since WeatherNext uses JAX arrays internally, you can convert to PyTorch tensors using `jax2torch` or `dlpack` zero-copy conversion. For hybrid pipelines, run WeatherNext inference to generate xarray outputs, extract NumPy arrays with `.values`, then wrap with `torch.tensor()`. The cyclone tracking utilities already return pandas DataFrames, which PyTorch DataLoaders can consume directly.

### Is WeatherNext compatible with distributed computing frameworks?

Absolutely. Because WeatherNext builds on xarray and JAX, you get Dask integration for free through xarray's backend. For multi-device training, use JAX's `pmap` or `pjit` on the model functions in [`weathernext1_graph/graphcast.py`](https://github.com/google-deepmind/weathernext/blob/main/weathernext1_graph/graphcast.py). The functional design means no global state complicates distributed execution.