oocgcm.core.grids.generic_2d_grid.spatial_average_xy

generic_2d_grid.spatial_average_xy(array, where=None, grid_location=None)

Return the horizontal average of array in regions where where is True.

Parameters:

array : xarray.DataArray

a dataarray with an additonal attribute specifying the grid_location. The dimension of array should include ‘x’ and ‘y’. The shape of array should match the shape of the grid.

where: boolean xarray.DataArray

dataarray with value = True where the integration should be applied The dimension of where should be a subset of the dimension of array. For each dimension, the size should be equal to the corresponding size of array dataarray. if where is None, the function return the integral in all the domain defined by the grid object.

grid_location : str

string describing the grid location : eg ‘u’,’v’,’t’,’f’...
  • if grid_location is not None
    check compatibility with array.attrs.grid_location
  • if grid_location is None
    use array.attrs.grid_location by default
Returns:

average: xarray.DataArray

a dataarray with reduced dimension defining the average of array in the region of interest.

See also

integrate_dxdy
spatial integral over a region