Skip to content

Neighbourhood methods

Thomas Nipen edited this page Apr 7, 2020 · 29 revisions

The neighbourhood calibrator replaces each gridpoint with a value based on a square neighbourhood around this point. For example, a field can be smoothed by taking the average value in a box with a half-width of 3 gridpoints:

gridpp input.nc output.nc -v precipitation_amount -c neighbourhood radius=3

Other statistics can be specified using the stat= option, for example to find the maximum value in the neighbourhood:

gridpp input.nc output.nc -v precipitation_amount -c neighbourhood radius=3 stat=max

To compute a specific quantile, such as the 90th percentile, use:

gridpp input.nc output.nc -v precipitation_amount -c neighbourhood radius=3 stat=quantile quantile=0.9

Options

  • radius (int): Number of gridpoints.
  • stat (string): One of 'min', 'mean', 'median', 'max', 'std', 'sum', 'quantile'.
  • quantile (float): If stat=quantile, specify the quantile.
  • fast (bool): Enable fast computation of 'mean', 'min', 'max, or 'sum'. Default is true.
  • approx (bool): Compute the result approximately for 'median' or 'quantile' in order to run faster.

Parameters

Optional. Only global parameter files are supported. If provided, then the parameter set must have one value. This value represents the radius and can be used to have a leadtime-dependent smoothing radius. In this case it overrides the radius option.

Python examples

Neighbourhood calculations on square grids for 'mean', 'min', and 'max' can be calculated as follows:

radius = 7
ovalues = gridpp.neighbourhood(ivalues, radius, 'mean')

To calculate quantiles, use the neighbourhood_quantile method:

radius = 7
quantile = 0.9
num_thresholds = 20
ovalues = gridpp.neighbourhood_quantile(ivalues, quantile, radius, 'mean', num_thresholds)
Clone this wiki locally