Skip to content

Neighbourhood methods

Thomas Nipen edited this page Feb 22, 2021 · 29 revisions

Gridpp supports methods that for each gridpoint computes a statistic based on values within a square neighbourhood surrounding the gridpoint.

The function in gridpp look like this:

values = gridpp.neighbourhood(input, radius, statistic)

where input is a 2D field, radius is the half-width of the neighbourhood, and statistic is one of gridpp.Mean, gridpp.Min, gridpp.Max, gridpp.Std, gridpp.Variance, or gridpp.Sum.

To compute the neighbourhood mean on a 15x15 square neighbourhood, use:

radius = 7
ovalues = gridpp.neighbourhood(ivalues, radius, gridpp.Mean)

Ensemble neighbourhoods

Neighbourhoods can also be computed by pooling ensemble members together, creating a single field (instead of one field for each ensemble member). For this use the same function, but provide a 3D input with dimensions (Y, X, num_members).

Neighbourhood quantiles

To compute neighbourhood quantiles (such as median) use:

values = gridpp.neighbourhood_quantile(input, quantile, radius)

Fast neighbourhood quantiles

The standard neighbourhood_quantile function is computationly expensive. To significantly reduce computation, at the cost of accuracy, use:

values = gridpp.neighbourhood_quantile_fast(input, quantile, radius, thresholds)

where thresholds is a vector of approximation thresholds. Gridpp computes for each threshold, the fraction of the neighbourhood that exceeds each threshold, and computes the quantile from these fractions using piecewise-linear interpolation.

Clone this wiki locally