pypfda.localization¶
Spatial localization for ensemble data assimilation.
Localization mitigates the spurious long-range correlations that arise when ensemble size is small relative to the state-space dimension. The canonical choice in geoscience DA is the fifth-order piecewise rational function of Gaspari & Cohn (1999), which is compactly supported, smooth, and a valid covariance kernel.
References
Gaspari, G. & Cohn, S. E. (1999). Construction of correlation functions in two and three dimensions. Quarterly Journal of the Royal Meteorological Society, 125, 723-757.
Module Attributes
Mean radius of Earth used by |
Functions
|
Gaspari-Cohn fifth-order piecewise rational localization function. |
|
Great-circle distance in kilometres between points on the sphere. |
|
Symmetric pairwise great-circle distance matrix. |
- pypfda.localization.EARTH_RADIUS_KM: float = 6371.0¶
Mean radius of Earth used by
haversine_distance(), in kilometres.
- pypfda.localization.haversine_distance(lat1, lon1, lat2, lon2)[source]¶
Great-circle distance in kilometres between points on the sphere.
Inputs are in degrees and may be scalars or broadcastable arrays. Result is in the same shape as the broadcast of the inputs.
- Parameters:
lat1 (array_like) – Latitudes and longitudes in degrees.
lon1 (array_like) – Latitudes and longitudes in degrees.
lat2 (array_like) – Latitudes and longitudes in degrees.
lon2 (array_like) – Latitudes and longitudes in degrees.
- Returns:
distance – Great-circle distance in kilometres.
- Return type:
ndarray
- pypfda.localization.gaspari_cohn(distance, localization_radius)[source]¶
Gaspari-Cohn fifth-order piecewise rational localization function.
The function is \(1\) at zero distance, smoothly decays to \(0\) at twice the localization radius, and is exactly zero beyond that. The half-width at half-maximum is approximately equal to the localization radius.
- Parameters:
distance (array_like) – Distance from the observation. Same units as
localization_radius.localization_radius (float) – Localization radius. Must be positive.
- Returns:
weight – Localization weight in \([0, 1]\), same shape as
distance.- Return type:
ndarray
- pypfda.localization.pairwise_distance_matrix(lats, lons)[source]¶
Symmetric pairwise great-circle distance matrix.
- Parameters:
lats (array_like, shape (n,)) – Latitudes and longitudes in degrees.
lons (array_like, shape (n,)) – Latitudes and longitudes in degrees.
- Returns:
D –
D[i, j]is the distance in kilometres between pointiand pointj. Diagonal is zero.- Return type:
ndarray, shape (n, n)