improver.cli.nbhood_land_and_sea module

Script to run neighbourhooding processing over areas of land and sea separately before combining them to return unified fields. Topographic zones may also be employed, with the sea area being treated as a distinct zone.

process(cube, mask, weights=None, *, neighbourhood_shape='square', radii, lead_times=None, area_sum=False)[source]

Module to process land and sea separately before combining them.

Neighbourhood the input dataset over two distinct regions of land and sea. If performed as a single level neighbourhood, a land-sea mask should be provided. If instead topographic_zone neighbourhooding is being employed, the mask should be one of topographic zones. In the latter case a weights array is also needed to collapse the topographic_zone coordinate. These weights are created with the improver generate-topography-bands-weights CLI and should be made using a land-sea mask, which will then be employed within this code to draw the distinction between the two surface types.

Parameters:
  • cube (iris.cube.Cube) – A cube to be processed.

  • mask (iris.cube.Cube) – A cube containing either a mask of topographic zones over land or a land-sea mask. If this is a land-sea mask, land points should be set to one and sea points set to zero.

  • weights (iris.cube.Cube) – A cube containing the weights which are used for collapsing the dimension gained through masking. These weights must have been created using a land-sea mask. (Optional).

  • neighbourhood_shape (str) – Name of the neighbourhood method to use. Options: “circular”, “square”. Default: “square”.

  • radii (list of float) – The radius or a list of radii in metres of the neighbourhood to apply. If it is a list, it must be the same length as lead_times, which defines at which lead time to use which nbhood radius. The radius will be interpolated for intermediate lead times.

  • lead_times (list of int) – The lead times in hours that correspond to the radii to be used. If lead_times are set, radii must be a list the same length as lead_times. Lead times must be given as integer values.

  • area_sum (bool) – Return sum rather than fraction over the neighbourhood area.

Returns:

tuple containing:
result (iris.cube.Cube):

A cube of the processed data.

Return type:

(tuple)

Raises:
  • ValueError – If the topographic zone mask has the attribute topographic_zones_include_seapoints.

  • IOError – if a weights cube isn’t given and a topographic_zone mask is given.

  • ValueError – If the weights cube has the attribute topographic_zones_include_seapoints.

  • RuntimeError – If lead times are not None and has a different length to radii.

  • TypeError – A weights cube has been provided but no topographic zone.