|
7 | 7 | [](https://github.com/SciTools-incubator/iris-esmf-regrid/blob/main/LICENSE) |
8 | 8 | [](https://github.com/SciTools-incubator/iris-esmf-regrid/graphs/contributors) |
9 | 9 |  |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +## Overview |
| 14 | + |
| 15 | +This project aims to provide a bridge between [Iris](https://github.com/SciTools/iris) |
| 16 | +and [ESMF](https://github.com/esmf-org/esmf). This takes the form of regridder classes |
| 17 | +which take Iris cubes as their arguments and use ESMF to perform regridding |
| 18 | +calculations. These classes are designed to perform well on cubes which have multiple |
| 19 | +non-horizontal dimensions and lazy ([Dask](https://github.com/dask/dask)) data. |
| 20 | +Both rectilinear and curvilinear grids as well as UGRID meshes have been supported. |
| 21 | + |
| 22 | +## Regridding Example |
| 23 | + |
| 24 | +There are a range of regridder classes (e.g `MeshToGridESMFRegridder` and |
| 25 | +`GridToMeshESMFRegridder`). For an example of the regridding process, the |
| 26 | +`MeshToGridESMFRegridder` class works as follows: |
| 27 | + |
| 28 | +```python |
| 29 | +import iris |
| 30 | +from iris.experimental.ugrid import PARSE_UGRID_ON_LOAD |
| 31 | +from esmf_regrid.experimental.unstructured_scheme import MeshToGridESMFRegridder |
| 32 | + |
| 33 | +# An example such a file can be found at: |
| 34 | +# https://github.com/SciTools/iris-test-data/blob/master/test_data/NetCDF/unstructured_grid/data_C4.nc |
| 35 | +with PARSE_UGRID_ON_LOAD.context(): |
| 36 | + source_mesh_cube = iris.load_cube("mesh_cube.nc") |
| 37 | + |
| 38 | +# An example of such a file can be found at: |
| 39 | +# https://github.com/SciTools/iris-test-data/blob/master/test_data/NetCDF/global/xyt/SMALL_hires_wind_u_for_ipcc4.nc |
| 40 | +target_grid_cube = iris.load_cube("grid_cube.nc") |
| 41 | + |
| 42 | +# Initialise the regridder with a source mesh and target grid. |
| 43 | +regridder = MeshToGridESMFRegridder(source_mesh_cube, target_grid_cube) |
| 44 | + |
| 45 | +# use the initialised regridder to regrid the data from the source cube |
| 46 | +# onto a cube with the same grid as `target_grid_cube`. |
| 47 | +result = regridder(source_mesh_cube) |
| 48 | +``` |
| 49 | + |
| 50 | +Note that this pattern allows the reuse of an initialised regridder, saving |
| 51 | +significant amounts of time when regridding. To make use of this efficiency across |
| 52 | +sessions, we support the saving of certain regridders. We can do this as follows: |
| 53 | + |
| 54 | +```python |
| 55 | +from esmf_regrid.experimental.io import load_regridder, save_regridder |
| 56 | + |
| 57 | +# Save the regridder. |
| 58 | +save_regridder(regridder, "saved_regridder.nc") |
| 59 | + |
| 60 | +# Load saved regridder. |
| 61 | +loaded_regridder = load_regridder("saved_regridder.nc") |
| 62 | + |
| 63 | +# Use loaded regridder. |
| 64 | +result = loaded_regridder(source_mesh_cube) |
| 65 | +``` |
0 commit comments