Skip to main content

Iris regridding scheme using ESMF

Project description

iris-esmf-regrid

Build Status pre-commit.ci status codecov Code style: black License Contributors Mark stale issues and pull requests


Click here for the API documentation

Overview

This project aims to provide a bridge between Iris and ESMF. This takes the form of regridder classes which take Iris cubes as their arguments and use ESMF to perform regridding calculations. These classes are designed to perform well on cubes which have multiple non-horizontal dimensions and lazy (Dask) data. Both rectilinear and curvilinear grids as well as UGRID meshes have been supported.

Regridding Example

There are a range of regridder classes (e.g MeshToGridESMFRegridder and GridToMeshESMFRegridder). For an example of the regridding process, the MeshToGridESMFRegridder class works as follows:

import iris
from iris.experimental.ugrid import PARSE_UGRID_ON_LOAD
from esmf_regrid.experimental.unstructured_scheme import MeshToGridESMFRegridder

# An example such a file can be found at:
# https://github.com/SciTools/iris-test-data/blob/master/test_data/NetCDF/unstructured_grid/data_C4.nc
with PARSE_UGRID_ON_LOAD.context():
    source_mesh_cube = iris.load_cube("mesh_cube.nc")

# An example of such a file can be found at:
# https://github.com/SciTools/iris-test-data/blob/master/test_data/NetCDF/global/xyt/SMALL_hires_wind_u_for_ipcc4.nc
target_grid_cube = iris.load_cube("grid_cube.nc")

# Initialise the regridder with a source mesh and target grid.
regridder = MeshToGridESMFRegridder(source_mesh_cube, target_grid_cube)

# use the initialised regridder to regrid the data from the source cube
# onto a cube with the same grid as `target_grid_cube`.
result = regridder(source_mesh_cube)

Note that this pattern allows the reuse of an initialised regridder, saving significant amounts of time when regridding. To make use of this efficiency across sessions, we support the saving of certain regridders. We can do this as follows:

from esmf_regrid.experimental.io import load_regridder, save_regridder

# Save the regridder.
save_regridder(regridder, "saved_regridder.nc")

# Load saved regridder.
loaded_regridder = load_regridder("saved_regridder.nc")

# Use loaded regridder.
result = loaded_regridder(source_mesh_cube)

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

esmf_regrid-0.6.0.tar.gz (50.5 kB view hashes)

Uploaded Source

Built Distribution

esmf_regrid-0.6.0-py3-none-any.whl (68.5 kB view hashes)

Uploaded Python 3

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