radarx.retrieve.gauge.gauge_variogram#
- radarx.retrieve.gauge.gauge_variogram(gauges, *, radar=None, model='exponential', n_lags=None, max_lag=None, radius=None, x=None, y=None, site=None, n_threads=None, engine='auto')[source]#
Empirical and fitted variogram of the gauge values.
The semivariance \(\hat\gamma(h) = \frac{1}{2N(h)}\sum (z_i - z_j)^2\) over the pairs of gauges at distance \(h\) (Matheron 1963) in equally wide lag bins, and an isotropic model with a nugget fitted by the weighted least squares of Cressie (1985). The fit is repeated for every time of the gauge series, with the gauges that have a value then.
- Parameters:
gauges (
xarray.DataArray) – Gauge values on a station dimension with the coordinates of the stations (x,yin m orlon,latin degrees), and optionally leading dimensions such astime. Stations with a NaN value are left out for that time.radar (
xarray.DataArray, optional) – A rain field on a grid. If given, the variogram is that of the residuals of the regression of the gauge values on the radar values at the gauges, which is the variogram of kriging with an external drift (method="ked"ofgauge_adjust()).model (
{"linear", "spherical", "exponential", "gaussian"}, optional) – Variogram model. Default"exponential". The practical range of the exponential and gaussian models is where they reach 95 % of the sill.n_lags (
int, optional) – Number of lag bins, at least 3. Default 15, fewer for few gauges.max_lag (
float, optional) – Largest distance (m). Default half the largest distance between gauges.radius (
float, optional) – Withradar: averaging radius (m), seeradar_at_gauges().x, y, site (optional) – See
radar_at_gauges().n_threads (
int, optional) – Threads for the compiled kernel. Default: all cores.engine (
{"auto", "compiled", "numpy"}, optional) – Implementation to use."auto"(default) prefers the compiled kernel and falls back to NumPy.
- Returns:
xarray.Dataset– On the dimensionlag(the bin centres in m) and the leading dimensions ofgauges:semivariance,distance(mean distance of the pairs of the bin, m),pairs,fitted(the model atdistance), andnugget,partial_sill(the units ofgaugessquared; the slope in units per m for the linear model) andrange(m; 0 for the linear model) on the leading dimensions. The attributemodelnames the model. The Dataset can be passed togauge_adjust()asvariogram.- Raises:
ValueError – For an unknown
modelorengine,n_lagsbelow 3, a non-positivemax_lag, or fewer than 3 gauges with a value.
Notes
Dask. This function computes the dask array: it fits the variogram to all gauges of every time. The input is loaded into memory and the result is held in memory.
References
Matheron, G., 1963: Principles of geostatistics. Econ. Geol., 58 (8), 1246-1266, https://doi.org/10.2113/gsecongeo.58.8.1246
Cressie, N., 1985: Fitting variogram models by weighted least squares. J. Int. Assoc. Math. Geol., 17 (5), 563-586, https://doi.org/10.1007/BF01032109
Goovaerts, P., 2000: Geostatistical approaches for incorporating elevation into the spatial interpolation of rainfall. J. Hydrol., 228 (1-2), 113-129, https://doi.org/10.1016/S0022-1694(00)00144-X
Examples
>>> vario = gauge_variogram(gauges) >>> adjusted = gauge_adjust(rain, gauges, method="ok", variogram=vario)