uxarray.grid.neighbors.Neighborhood#
- class uxarray.grid.neighbors.Neighborhood(grid, r=1.0, on='face centers')#
The set of grid elements within a radius
rof every element of one grid location, ready to be reduced over.Building this queries a
BallTreeonce, which is by far the dominant cost of a neighborhood reduction — typically far more than the reduction itself. Holding onto the result lets several reductions, or several variables, share that one query instead of repeating it.Each reduction is a method:
mean(),std(),percentile()and so on run a compiled kernel, andreduce()takes an arbitrary callable for anything without one. Every one takes the data to reduce as its first argument, so several variables can share one query.- Parameters:
Examples
>>> import uxarray as ux >>> uxds = ux.tutorial.open_dataset("outCSne30-vortex") >>> nb = uxds.uxgrid.neighborhood(r=5.0) >>> smooth = nb.mean(uxds["psi"]) >>> spread = nb.std(uxds["psi"], ddof=1)
See also
UxDataArray.neighborhoodNeighborhood around a single variable’s elements.
UxDataset.neighborhoodNeighborhood around every variable in a dataset.
- __init__(grid, r=1.0, on='face centers')#
Methods
__init__(grid[, r, on])max(uxda)Largest value in each neighborhood.
mean(uxda)Mean of each neighborhood.
median(uxda)Median of each neighborhood.
min(uxda)Smallest value in each neighborhood.
percentile(uxda, q)Percentile
q(between 0 and 100) of each neighborhood.ptp(uxda)Peak-to-peak spread (
max - min) of each neighborhood.quantile(uxda, q)Quantile
q(between 0 and 1) of each neighborhood.reduce(uxda, func)Reduces each neighborhood with an arbitrary callable.
std(uxda[, ddof])Standard deviation of each neighborhood, with
ddofdelta degrees of freedom.sum(uxda)Sum of each neighborhood.
var(uxda[, ddof])Variance of each neighborhood, with
ddofdelta degrees of freedom.Attributes
gridGrid the neighborhood was built from.
grid_dimName of the grid dimension this reduces over.
Number of elements in each neighborhood, itself a grid-mapped field.
onGrid location the neighborhood is centered on.
rNeighborhood radius, in degrees.