Skip to content

Latest commit

 

History

History
68 lines (51 loc) · 3.54 KB

README.md

File metadata and controls

68 lines (51 loc) · 3.54 KB

iris-esmf-regrid

Build Status Documentation 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)