Skip to content

Neighbourhood methods

Thomas Nipen edited this page Jun 18, 2020 · 29 revisions

Neighbourhood methods compute for each gridpoint a statistic based on values within a neighbourhood surrounding this gridpoint.

The functions 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.

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:

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

where input in this case is a 3D field, with the ensemble dimension being last.

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

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

Neighbourhood quantiles

To compute neighbourhood quantiles (such as median) use:

values = gridpp.neighbourhood_quantile(input_2d, quantile, radius)
values = gridpp.neighbourhood_quantile_ens(input_3d, quantile, radius)

To calculate quantiles, use the neighbourhood_quantile method:

radius = 7
quantile = 0.9
num_thresholds = 20
ovalues = gridpp.neighbourhood_quantile(ivalues, quantile, radius, num_thresholds)

To calculate ensemble neighbourhoods, use the _ens functions:

ivalues_ens = np.random.rand([100, 80, 10]) # 10 member ensemble
radius = 7
ovalues = gridpp.neighbourhood_ens(ivalues_ens, radius, gridpp.Mean)
Clone this wiki locally