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/jhardenberg/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.5.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.5-py3-none-any.whl (33.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: smmregrid-0.1.5.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.5.tar.gz
Algorithm Hash digest
SHA256 c8738d0117a5bfc06dd57008c17cd4dc3ae3f89b99b73311d5440002340cdf92
MD5 862cc9bd093edae541f995e332eda6df
BLAKE2b-256 6b3c5db755b0997e479a7a167d35cc363d7045c37bd1cf5447616fa0922f967b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: smmregrid-0.1.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 7d2532de3dcbd5532ec3a6190f5e4f472973ea15d8c227fd2a3ebb3adb51e812
MD5 e859a75f58e1dc4c02255205ce23a6c7
BLAKE2b-256 996489d7b2d99912a6bc809dd3f5cd3793858d84d01b8bdd50d9bc3aed2cd1fb

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