Skip to main content

Regridding based on sparse matrix multiplication

Project description

Maintenance PyTest Coverage Status PyPI Conda Documentation DOI

smmregrid

A compact python regridder using sparse matrix multiplication

The regridder uses CDO as a backend for weights computation, and then uses efficiently sparse matrix multiplication with dask to provide xarray lazy output. It supports all grids supported by CDO.

Please note that this tool is not thought as "another interpolation tool", but rather a method to apply pre-computed weights within the python environment. The speedup against CDO is estimated to be about ~1.5 to ~5 times, slightly lower if then files are written to the disk. 2D and 3D data are supported on all the grids supported by CDO, and special treatment can be assigned to vertical coordinates with changing mask (e.g. ocean 3D datasets). It works smoothly on both xarray.Dataset and xarray.DataArray. Attributes are kept and target grids can be both file on disk or CDO-compliant grids (e.g. r180x90, n128, etc).

The tool works for python versions >=3.8. It is safer to run it through conda/mamba. Install with:

mamba create -n smmregrid "python>=3.8" cdo eccodes numba
mamba activate smmregrid
pip install smmregrid

Alternatively, you can clone the repo and use the environment file available

git clone https://github.com/jvonhard/smmregrid.git
cd smmregrid
mamba env create -f environment.yml
mamba activate smmregrid
pip install -e .

As a disclaimer, this repository represents a modification of the regridding routines developed in climtas by Scott Wales, which already implements efficiently this idea and has no other significant dependencies.

Cautionary notes:

  • It does not work correctly if the Xarray.Dataset includes fields with time-varying missing points
  • It works only with interpolation methods/grids supported by CDO
  • It does not support ESMF weigths.

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

smmregrid-0.1.4.tar.gz (31.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smmregrid-0.1.4-py3-none-any.whl (33.8 kB view details)

Uploaded Python 3

File details

Details for the file smmregrid-0.1.4.tar.gz.

File metadata

  • Download URL: smmregrid-0.1.4.tar.gz
  • Upload date:
  • Size: 31.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for smmregrid-0.1.4.tar.gz
Algorithm Hash digest
SHA256 38e7dc1e060df2cdc5bb65e8d50b744381a57279837ccbeb4919f94e6956f237
MD5 5c018c49a51360cb1595877d9f7e7a0b
BLAKE2b-256 4f8e93066af0aba5219a4eea46951d3e2b2fbe43e7678acfdcecd4e2d1ca6144

See more details on using hashes here.

File details

Details for the file smmregrid-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: smmregrid-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 33.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for smmregrid-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c928e2acf10d2c2f0950270c1a00a968d90343bc908843780d256095db1011a8
MD5 d59a4a8b3b53b53b53ddef78b13cb4eb
BLAKE2b-256 1702b8347eb00a05afccf12138fc0492b70eb6a1561b7add0b178b2c9a23e0e3

See more details on using hashes here.

Supported by

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