Regridding tools using xarray and flox.
Project description
xarray-regrid: Regridding utilities for xarray.
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)
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.
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
Built Distribution
File details
Details for the file xarray_regrid-0.2.1.tar.gz
.
File metadata
- Download URL: xarray_regrid-0.2.1.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd03be80b42be55182af580c98b10c574511ec9e01e0cbe9d49d079372c0f862 |
|
MD5 | 722bf36664a272a6034b38e78fd0b5a6 |
|
BLAKE2b-256 | b7f49b7a9e11e54d2bbe5a7770a66e1557f5120f6d7f8f5816594844570a8316 |
File details
Details for the file xarray_regrid-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: xarray_regrid-0.2.1-py3-none-any.whl
- Upload date:
- Size: 15.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c95d71e264ad4d80a4055f1996988b65b90e133236d1c8550e1e074396af434 |
|
MD5 | cd410d13b821209b8d20d953d601c61a |
|
BLAKE2b-256 | 7c69f99e11633fa9859cfe0f3fc95e6c3fb9d01b265fb06523dc3f0e7c69a969 |