-
Notifications
You must be signed in to change notification settings - Fork 16
Neighbourhood methods
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
- 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.
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.
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)