monet.util.resample

Functions

resample_stratify(da, levels, vertical[, axis])

Vertically interpolate data to specified levels.

resample_xesmf(source_da, target_da[, cleanup])

Resample data from one grid to another using xESMF.

monet.util.resample.resample_stratify(da, levels, vertical, axis=1)

Vertically interpolate data to specified levels.

Uses stratify package to interpolate a DataArray to new vertical levels.

Parameters:
  • da (xarray.DataArray) – The data to interpolate. Must have a vertical dimension.

  • levels (array-like) – The target vertical levels to interpolate to.

  • vertical (array-like) – The current vertical coordinate values.

  • axis (int, default 1) – The axis representing the vertical dimension.

Returns:

Data interpolated to the new vertical levels, preserving attributes and other coordinates.

Return type:

xarray.DataArray

monet.util.resample.resample_xesmf(source_da, target_da, cleanup=False, **kwargs)

Resample data from one grid to another using xESMF.

Uses xESMF to perform regridding between different coordinate systems and grids.

Parameters:
  • source_da (xarray.DataArray or xarray.Dataset) – The source data to regrid.

  • target_da (xarray.DataArray or xarray.Dataset) – The target grid to regrid onto.

  • cleanup (bool, default False) – Whether to remove the temporary weight file after regridding.

  • **kwargs – Additional keyword arguments passed to xesmf.Regridder constructor. Common options include ‘method’ and ‘locstream_out’.

Returns:

The regridded data with the same type as source_da.

Return type:

xarray.DataArray or xarray.Dataset