sl.spatialfilter.getweights: Compute Spatial Filter Weights

sl.spatialfilter.getweightsR Documentation

Compute Spatial Filter Weights

Description

Compute spatial filter weights for a field on an unstructured grid on a sphere.

Usage

sl.spatialfilter.getweights(lon, lat, neighmat, areas, Rsphere = 1, method = "gauss", gauss.sigma = 2 * pi * Rsphere/360, cutoff = 3 * gauss.sigma)

Arguments

lon

a vector of length N specifying the longitudes of the grid points.

lat

a vector of length N specifying the latitudes of the grid points.

neighmat

an NxM matrix with each row containing all neighbours of one node (grid point). See sl.findneighbours for details.

areas

a vector of length N specifying the areas which the grid point values represent.

Rsphere

the radius of the sphere.

method

a character specifying the filter type: one of 'gauss' (Gaussian), 'lin' (linear), and 'const' (constant).

gauss.sigma

the sigma (width in terms of standard deviation in radians) of the Gaussian. Used only if method='gauss'.

cutoff

the distance at which the filter is truncated.

Details

This function generates filter weights and the corresponding source and destination index information for an unstructured mesh on a sphere. Implemented filters are the Gaussian filter, a linear filter, and a constant (i.e., running mean) filter. In each case the filter weights take grid point areas (the areas for which the grid point values are assumed to hold) into account. This implies that, e.g., in case of the constant filter the weights are in fact not constant but proportional to the areas.

The argument cutoff is also used to define where the linear filter assumes zero if method='lin', and determines the level of the constant (although area-weighted) weights if method='const'.

It is M = n * N where n, in the range [1,N], is the average number of source points for each destination point. For the identity filter, it is n=1 and all weights equal 1. For an untruncated filter it is n=N, but that's not recommended as the generation of the filter - and in particular its subsequent application - will be slowed down very much.

The generated filter information can be applied to a numerical field on the corresponding grid using sl.spatialfilter. However, the filter information has (not accidentally) the same format as used by the Climate Data Operators (CDO) and can be written to a NetCDF file that can be used with CDO to filter large amounts of data much faster than with spheRlab. A corresponding function to write the output into NetCDF still needs to be added.

Value

A list with the following three elements:

src_address

an integer vector of length M giving the indices of the source points.

dst_address

an integer vector of length M giving the indices of the destination points corresponding to the source points.

filter_weights

an integer vector of length M giving the filter weights.

Note

A function that facilitates writing the resulting filter information into a CDO-readable NetCDF file needs to be added to spheRlab asap.

Author(s)

Helge Goessling

See Also

sl.spatialfilter

Examples

## To be provided ...

FESOM/spheRlab documentation built on April 6, 2024, 6:52 p.m.