improver.cli.regrid module

Script to regrid a NetCDF file

process(cube, target_grid, land_sea_mask=None, *, regrid_mode='bilinear', extrapolation_mode='nanmask', land_sea_mask_vicinity=25000, regridded_title=None)[source]

Regrids source cube data onto a target grid. Optional land-sea awareness.

Parameters:
  • cube (iris.cube.Cube) – Source cube to be regridded.

  • target_grid (iris.cube.Cube) – Cube defining the spatial grid onto which to regrid the source data. If also using land_sea_mask-aware regridding then this must be land_binary_mask data.

  • land_sea_mask (iris.cube.Cube) – Cube describing the land_binary_mask on the source grid if land-sea aware regridding is required, with land points set to one and sea points set to zero. This can be a larger domain than cube, so long as cube is a strict cut-out (not a reprojection) of the land_sea_mask domain.

  • regrid_mode (str) – Selects which regridding techniques to use. Default uses iris.analysis.Linear(); “nearest” uses iris.analysis.Nearest(); “nearest-with-mask” uses Nearest() with land-sea awareness. “nearest-2”: new/fast version without using Iris “nearest-with-mask-2”: new super-fast version without using Iris “bilinear-with-mask”: bilinear option with land-sea mask considered

  • extrapolation_mode (str) – Mode to use for extrapolating data into regions beyond the limits of the input cube domain. Refer to online documentation for iris.analysis. Modes are - extrapolate - extrapolated points will take their values from the nearest source point nan - extrapolated points will be set to NaN error - a ValueError will be raised notifying an attempt to extrapolate mask - extrapolated points will always be masked, even if the source data is not a MaskedArray nanmask - if the source data is a MaskedArray extrapolated points will be masked; otherwise they will be set to NaN

  • land_sea_mask_vicinity (float) – Radius of vicinity to search for a coastline, in metres.

  • regridded_title (str) – New “title” attribute to be set if the field is being regridded (since “title” may contain grid information). If None, a default value is used.

Returns:

Processed cube.

Return type:

iris.cube.Cube

Raises:
  • ValueError – If source land_sea_mask is supplied but regrid mode is not “nearest-with-mask”.

  • ValueError – If regrid_mode is “nearest-with-mask” but no source land_sea_mask is provided (from plugin).