Indicator Semivariogram#
- class pyinterpolate.ExperimentalIndicatorVariogram(number_of_thresholds: int, step_size: float, max_range: float, ds: ArrayLike | VariogramPoints = None, values: ArrayLike = None, geometries: ArrayLike = None, custom_weights=None, custom_bins=None, direction: float = None, tolerance: float = None, fit=True)[source]
Class describes Experimental Indicator Variogram models.
- Parameters:
- number_of_thresholds: int
The number of thresholds to model data.
- step_sizefloat
The distance between lags within each points are included in the calculations.
- max_rangefloat
The maximum range of analysis.
- dsArrayLike, optional
[x, y, value]- valuesArrayLike, optional
Observation in the i-th geometry (from
geometries). Optional parameter, if not given thendsmust be provided.- geometriesArrayLike, optional
Array or similar structure with geometries. It must have the same length as
values. Optional parameter, if not given thendsmust be provided. Point type geometry.- custom_weightsnumpy array, default=None
Weights assigned to points, index of weight must be the same as index of point.
- directionfloat (in range [0, 360]), default=None
Direction of semivariogram, values from 0 to 360 degrees:
0 or 180: is E-W,
90 or 270 is N-S,
45 or 225 is NE-SW,
135 or 315 is NW-SE.
- tolerancefloat (in range [0, 1]), default=1
If
toleranceis 0 then points must be placed at a single line with the beginning in the origin of the coordinate system and the direction given by y axis and direction parameter. Iftoleranceis> 0then the bin is selected as an elliptical area with major axis pointed in the same direction as the line for 0 tolerance.The major axis size ==
step_size.The minor axis size is
tolerance * step_sizeThe baseline point is at a center of the ellipse.
The
tolerance == 1creates an omnidirectional semivariogram.
- fitbool, default = True
Should models be fitted in the class initialization?
- Attributes:
- dsIndicatorVariogramData
Prepared indicator data.
- step_sizefloat
Derived from the
step_sizeparameter.- max_rangefloat
Derived from the
max_rangeparameter.- custom_weightsnumpy array
Derived from the
weightsparameter.- directionfloat
Derived from the
directionparameter.- tolerancefloat
Derived from the
toleranceparameter.- experimental_modelsList
The
[threshold, experimental_variogram]pairs.
Methods
fit()
Fits indicators to experimental variograms.
show()
Show experimental variograms for each indicator.
References
Goovaerts P. AUTO-IK: a 2D indicator kriging program for automated non-parametric modeling of local uncertainty in earth sciences. DOI: https://doi.org/10.1016/j.cageo.2008.08.014
Examples
>>> import numpy as np >>> from pyinterpolate import ExperimentalIndicatorVariogram >>> >>> >>> dem = np.random.random(size=(1000, 3)) >>> step_size = 0.1 >>> max_range = 0.6 >>> exp_indicator = ExperimentalIndicatorVariogram( ... values=dem[:, -1], ... geometries=dem[:, :-1], ... number_of_thresholds=5, ... step_size=step_size, ... max_range=max_range ... ) >>> print(len(exp_indicator.experimental_models)) 5 >>> exp_indicator.show() # plots variogram for each threshold
- fit()[source]
Function fits indicators to models and updates class models.
- show()[source]
Function shows generated experimental variograms for each indicator.
- class pyinterpolate.TheoreticalIndicatorVariogram(experimental_indicator_variogram: ExperimentalIndicatorVariogram)[source]
Class models indicator variograms for all indices.
- Parameters:
- experimental_indicator_variogramExperimentalIndicatorVariogram
Fitted experimanetal variograms with indicators for each threshold.
- Attributes:
- experimental_indicator_variogramExperimentalIndicatorVariogram
See
experimental_indicator_variogramparameter.- theoretical_indicator_variogramsDict
Dictionary with fitted theoretical models for each threshold.
Methods
fit()
Fits theoretical models to experimental variograms.
show()
Shows experimental and theoretical variograms for each threshold.
Examples
>>> import numpy as np >>> from pyinterpolate import ( ... ExperimentalIndicatorVariogram, ... TheoreticalIndicatorVariogram ... ) >>> >>> >>> dem = np.random.random(size=(1000, 3)) >>> step_size = 0.1 >>> max_range = 0.6 >>> exp_indicator = ExperimentalIndicatorVariogram( ... values=dem[:, -1], ... geometries=dem[:, :-1], ... number_of_thresholds=5, ... step_size=step_size, ... max_range=max_range ... ) >>> theo_indicator = TheoreticalIndicatorVariogram( ... experimental_indicator_variogram=exp_indicator ... ) >>> theo_indicator.fit() >>> print(len(theo_indicator.theoretical_indicator_variograms)) 5 >>> theo_indicator.show() # plots theoretical models' curves
- fit(models_group: str | list = 'safe', nugget=None, min_nugget=0, max_nugget=0.5, number_of_nuggets=16, rang=None, min_range=0.1, max_range=0.5, number_of_ranges=16, sill=None, n_sill_values=5, sill_from_variance=False, min_sill=0.5, max_sill=2, number_of_sills=16, direction=None, error_estimator='rmse', deviation_weighting='equal')[source]
Method tries to find the optimal range, sill and model (function) of the theoretical semivariogram.
- Parameters:
- models_groupstr or list, default=’safe’
Models group to test:
‘all’ - the same as list with all models,
‘safe’ - [‘linear’, ‘power’, ‘spherical’]
as a list: multiple model types to test
- as a single model type from:
‘circular’,
‘cubic’,
‘exponential’,
‘gaussian’,
‘linear’,
‘power’,
‘spherical’.
- nuggetfloat, optional
Nugget (bias) of a variogram. If given then it is fixed to this value.
- min_nuggetfloat, default = 0
The minimum nugget as the ratio of the parameter to the first lag variance.
- max_nuggetfloat, default = 0.5
The maximum nugget as the ratio of the parameter to the first lag variance.
- number_of_nuggetsint, default = 16
How many equally spaced nuggets tested between
min_nuggetandmax_nugget.- rangfloat, optional
If given, then range is fixed to this value.
- min_rangefloat, default = 0.1
The minimal fraction of a variogram range,
0 < min_range <= max_range.- max_rangefloat, default = 0.5
The maximum fraction of a variogram range,
min_range <= max_range <= 1. Parametermax_rangegreater than 0.5 raises warning.- number_of_rangesint, default = 16
How many bins are tested between
min_rangeandmax_range.- sillfloat, default = None
Partial sill, or sill when nugget is set to zero. Total sill is a sum of partial sill and nugget. If given, then partial sill is fixed to this value.
- n_sill_valuesint, default = 5
The last n experimental semivariance records for sill estimation. (Used only when
sill_from_varianceis set toFalse).- sill_from_variancebool, default = False
Estimate sill from the variance (semivariance at distance 0).
- min_sillfloat, default = 0.5
The minimal fraction of the variogram variance at lag 0 to find partial sill,
0 <= min_sill <= max_sill.- max_sillfloat, default = 2
The maximum fraction of the variogram variance at lag 0 to find partial sill.
- number_of_sillsint, default = 16
How many equally spaced sill values are tested between
min_sillandmax_sill.- directionfloat, in range [0, 360], default=None
The direction of a semivariogram. If
Nonegiven then semivariogram is isotropic. This parameter is required if passed experimental variogram is stored in a numpy array.- error_estimatorstr, default = ‘rmse’
A model error estimation method. Available options are:
‘rmse’: Root Mean Squared Error,
‘mae’: Mean Absolute Error,
‘bias’: Forecast Bias,
‘smape’: Symmetric Mean Absolute Percentage Error.
- deviation_weightingstr, default = “equal”
The name of the method used to weight error at a given lags. Works only with RMSE. Available methods:
equal: no weighting,
closest: lags at a close range have bigger weights,
distant: lags that are further away have bigger weights,
dense: error is weighted by the number of point pairs within lag.
- show(subplots: bool = False)[source]
Method plots experimental and theoretical variograms.
- Parameters:
- subplotsbool, default = False
If
Truethen each indicator variogram is plotted on a separate plot. Otherwise, all variograms are plotted on a single plot.