# PDAF_local_weight

This page documents the routine `PDAF_local_weight`

of PDAF.

The routine is used for localization in the analysis step of a filter and computes a weight according to the specified distance and the settings for the localizing function. Typically the routine is called in prodRinvA_l_pdaf in the domain-localized filters. Also, the routine is typically called for the LEnKF in the routine localize_covar_pdaf.

This routine is usually only used in user-codes that do not use PDAF-OMI.

The interface is the following:

SUBROUTINE PDAF_local_weight(wtype, rtype, cradius, sradius, distance, & nrows, ncols, A, var_obs, weight, verbose)

with the following arguments:

`wtype`

:`integer, intent(in)`

Type of weight function:

(0) unit weight (=1 up to radius`cradius`

)

(1) exponential decrease (1/e at distance=sradius; 0 for distance>cradius)

(2) 5th order polynomial with support radius sradius (Gaspari&Cohn 1999; 0 for distance>sradius)`rtype`

:`integer, intent(in)`

Type of regulated weighting:

(0) no regulation

(1) regulation using mean variances

`cradius`

:`real, intent(in)`

Cut-off radius (weight is always =0 for distance>cradius)`sradius`

:`real, intent(in)`

Support radius of weight function`distance`

:`real, intent(in)`

Distance to observation`nrows`

:`integer, intent(in)`

Number of rows in matrix A`ncols`

:`integer, intent(in)`

Number of columns in matrix A`A`

:`real, intent(in), dimension(nrows,ncols)`

Input matrix (only used for regulated localization)`var_obs`

:`real, intent(in)`

Observation variance (only used for regulated localization)`weight`

:`real, intent(out)`

computed localization weight`verbose`

:`integer, intent(in)`

Verbosity flag

Notes:

- the regulated localization computes an alternative localization function based on the ration of state error variances to observation error variances. the regulated localization method is described in the paper Nerger et al. (Quarterly Journal of the Royal Meteorological Society, 138 (2012) 802-812; see publications.
`PDAF_local_weight`

is called with a single distance and return a single weight. In some cases the alternative routine PDAF_local_weights can be used which computes the weights for a vector of distances.- for
`rtype=1`

the mean variance is computed as the square-root of the sum of squared entries in the array`A`

. - Array
`A`

is usually the array`A_l`

that is an input argument to the routine prodRinvA_l_pdaf.

Examples of using `PDAF_local_weight`

can be found in the files `prodrinva_l_pdaf.F90`

in the tutorial cases for the 'classical' (non-OMI) implentations in `tutorial/classical`

and in the templates in `templates/classical/`

.