verde.variance_to_weights#
- verde.variance_to_weights(variance, tol=1e-15, dtype='float64')[source]#
Converts data variances to weights for gridding.
Weights are defined as the inverse of the variance, scaled to the range [0, 1], i.e.
variance.min()/variance
.Any variance that is smaller than tol will automatically receive a weight of 1 to avoid zero division or blown up weights.
- Parameters:
- variance
array
ortuple
of
arrays
An array with the variance of each point. If there are multiple arrays in a tuple, will calculated weights for each of them separately. Can have NaNs but they will be converted to zeros and therefore receive a weight of 1.
- tol
float
The tolerance, or cutoff threshold, for small variances.
- dtype
str
ornumpy
dtype
The type of the output weights array.
- variance
- Returns:
Examples
>>> print(variance_to_weights([0, 2, 0.2, 1e-16])) [1. 0.1 1. 1. ] >>> print(variance_to_weights([0, 0, 0, 0])) [1. 1. 1. 1.] >>> for w in variance_to_weights(([0, 1, 10], [2, 4.0, 8])): ... print(w) [1. 1. 0.1] [1. 0.5 0.25]
Examples using verde.variance_to_weights
#
Trends in vector data
Using Weights