uxarray.Grid.neighborhood

uxarray.Grid.neighborhood#

Grid.neighborhood(r=1.0, on='face centers')#

Finds the grid elements within r degrees of every element of on, returning a reusable Neighborhood.

The radius query behind this dominates the cost of a neighborhood reduction, so building this once and reducing several times over it is substantially cheaper than calling UxDataArray.neighborhood() repeatedly, which rebuilds it on every call.

Unlike UxDataArray.neighborhood(), the result is not bound to any data, so its reduction methods take the data to reduce as an argument. That is what lets several variables share one query.

Parameters:
  • r (float, default=1.) – Radius of the neighborhood, in degrees of great-circle distance.

  • on (str, default="face centers") – Grid location to center the neighborhood on: “nodes”, “edge centers”, or “face centers”.

Return type:

Neighborhood

Examples

>>> import uxarray as ux
>>> uxds = ux.tutorial.open_dataset("outCSne30-vortex")  
>>> nb = uxds.uxgrid.neighborhood(r=5.0)  
>>> smooth = nb.mean(uxds["psi"])  
>>> p90 = nb.percentile(uxds["psi"], q=90)  

See also

Neighborhood

The reductions available on the returned object.

UxDataArray.neighborhood

Neighborhood bound to a single variable.

UxDataset.neighborhood

Neighborhood across every variable in a dataset.