Skip to main content

Regridding tools using xarray and flox.

Project description

xarray-regrid: Regridding utilities for xarray.

Logo

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

  • Linear
  • Nearest-neighbor
  • Conservative
  • Cubic
  • "Most common value" (zonal statistics)

All regridding methods, except for the "most common value" can operate lazily on Dask arrays.

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.

PyPI DOI Docs

Why xarray-regrid?

Regridding is a common operation in earth science and other fields. While xarray does have some interpolation methods available, these are not always straightforward to use. Additionally, methods such as conservative regridding, or taking the most common value, are not available in xarray.

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xarray_regrid-0.3.0.tar.gz (67.4 MB view details)

Uploaded Source

Built Distribution

xarray_regrid-0.3.0-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file xarray_regrid-0.3.0.tar.gz.

File metadata

  • Download URL: xarray_regrid-0.3.0.tar.gz
  • Upload date:
  • Size: 67.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for xarray_regrid-0.3.0.tar.gz
Algorithm Hash digest
SHA256 3b2690df329a651c0ed682d8bbf9fe55866aaa553c42e42f21c66fca467a5931
MD5 da56061aa7896ff11e496e0aa1a7f03d
BLAKE2b-256 98a14067dd05760ff58c205741f5f4b450d647142ab22e18b6fa5882849d4284

See more details on using hashes here.

File details

Details for the file xarray_regrid-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for xarray_regrid-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4e933253d4e1290aef24b708753242a364b421a6f1c4d9ac54348a8d8dee9f33
MD5 1d41f47a81ab6521bbbfd213c2cafbea
BLAKE2b-256 fe33cba1c9269666c69b9331cf2b9ec8c2d73776755209d2f352e013ea3ae94f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page