EXCITED-CO2 / xarray-regrid

Regridding utility for xarray
Apache License 2.0
55 stars 5 forks source link

xarray-regrid: Regridding utilities for xarray.

Logo

With xarray-regrid it is possible to regrid between two rectilinear grids. The following methods are supported:

Note that "Most common value" is designed to regrid categorical data to a coarse resolution. For regridding categorical data to a finer resolution, please use "nearest-neighbor" regridder.

DOI

Installation

pip install xarray-regrid

Usage

The xarray-regrid routines are accessed using the "regrid" accessor on an xarray Dataset:

import xarray_regrid

ds = xr.open_dataset("input_data.nc")
ds_grid = xr.open_dataset("target_grid.nc")

ds.regrid.linear(ds_grid)

For examples, see the benchmark notebooks and the demo notebooks.

Benchmarks

The benchmark notebooks contain comparisons to more standard methods (CDO, xESMF).

To be able to run the notebooks, a conda environment is required (due to ESMF and CDO). You can install this environment using the environment.yml file in this repository. Micromamba is a lightweight version of the much faster "mamba" conda alternative.

micromamba create -n environment_name -f environment.yml

Acknowledgements

This package was developed under Netherlands eScience Center grant NLESC.OEC.2022.017.