meteodatalab.operators.crop

Horizontal cropping operator.

Functions

crop(field, bounds)

Crop the field to the given bounds.

Classes

Bounds(xmin, xmax, ymin, ymax)

class meteodatalab.operators.crop.Bounds(xmin, xmax, ymin, ymax)[source]
xmax: int

Alias for field number 1

xmin: int

Alias for field number 0

ymax: int

Alias for field number 3

ymin: int

Alias for field number 2

meteodatalab.operators.crop.crop(field: DataArray, bounds: Bounds) DataArray[source]

Crop the field to the given bounds.

Only fields defined on regular grids in rotlatlon coordinates, without rotation nor flipped axes are supported.

Parameters:
  • field (xarray.DataArray) – The field to crop.

  • bounds (Bounds) – Bounds of the cropped area given as indices of the array in following order: xmin, xmax, ymin, ymax. All bounds are inclusive.

Raises:

ValueError – If there are any consistency issues with the provided bounds or any of the conditions on the input grid not met.

Returns:

The data is set to cropped domain and the metadata is updated accordingly.

Return type:

xarray.DataArray