lair.inventories.Inventory.regrid#

Inventory.regrid(out_grid, method='conservative', inplace=False)[source]#

Regrid the data to a new grid. Uses xesmf for regridding.

Note

At present, xesmf only supports regridding lat-lon grids. self.data must be on a lat-lon grid. Possibly could use xesmf.frontend.BaseRegridder to regrid to a generic grid.

Warning

xarray.Dataset.cf.add_bounds is known to have issues, including near the 180th meridian. Care should be taken when using this method, especially with global datasets.

Parameters:
  • out_grid (xr.DataArray) – The new grid to resample to. Must be a lat-lon grid.

  • method (str, optional) –

    The regridding method, by default ‘conservative’.

    Note

    Other xesmf regrid methods can be passed, but it is highly encouraged to use a conservative method for fluxes.

  • inplace (bool, optional) – Whether to modify the data in place, by default False.

Returns:

Inventory – The regridded inventory. If inplace=True returns self, otherwise returns a new Inventory copy.

Return type:

Self

See also

Inventory.resample

To a new resolution over the same area.

lair.geo.regrid

The same for any field, bilinear by default.

Notes

The inventory example checks that a conservative regrid keeps the total.