geolime.geostats.variogram.variogram

Data:

Callable

Callable type; Callable[[int], str] is a function of (int) -> str.

List

The central part of internal API.

Classes:

Enum(value)

Generic enumeration.

Functions:

angle_between_vectors(v1, v2)

Compute the angle between two vectors using the dot product

covariance(values, indices)

Compute the covariance given an array of values for a set of pairs

directional_vector(dimension, …[, deg])

Compute directional vector from angles

generate_lags(lag, plag, nlags)

Generate lags array to be used with variogram

in_angle(vdir, atol)

Return a function that checks for an index vector if it belongs to an angular range.

in_range(target, atol)

Check if target angle lies within a range of angles (defined by an angle tolerance)

in_slice(trend, plunge, vdir[, width, height])

Return a function that check whether a vector (cartesian coordinates) lies within a slice (defined by a width and a height in meters)

norm(x[, ord, axis, keepdims])

Matrix or vector norm.

normalize(a, center)

(Adapted from Apach Commons normalizeAngle, MathUtils sources) Normalize an angle in a 2pi; wide interval around a center value.

pairwise(coords)

Computes pairwise distances

plane_to_dir(azimuth, dip, pitch[, deg])

Convert plane angles to line angles.

rot_z(alpha[, deg, clockwise])

Rotation againt the Z axis

rot_zyx(angles[, deg, clockwise])

Example of a convention (RGeoStats)

select_index_from_slice(idx, f)

Compare vectors from a set of indices

select_indices(coords, pwdist, lag, tol, …)

Check whether a set of points (linked to their distances) match the input restricted boundaries.

select_indices_from_angle(idx, f)

Compare vectors from a set of indices

select_indices_from_lag(pwdist, lag, tol)

Check whether a set of distances lie within a lag-range.

semivariance(values, indices[, weights])

Compute the semivariance given an array of values for a set of pairs

variogram(coords, values, lags, tol, …[, …])

Given boundary input arguments (lag and its associated tolerance, angular reference and its associated tolerance), compute the variogram for a set of points (value associated with cartesian coordinates for a specific point)

geolime.geostats.variogram.variogram.covariance(values: numpy.ndarray, indices: numpy.ndarray)

Compute the covariance given an array of values for a set of pairs

Parameters
  • values (np.ndarray) – Array of float values

  • indices (np.ndarray) – List of pairs (couple of integers) for a specific lag

Returns

Covariance

Return type

float

geolime.geostats.variogram.variogram.directional_vector(dimension: int, geographic_azimuth: float, dip: float, pitch: float, deg: bool = True)

Compute directional vector from angles

Parameters
  • dimension (int) – Angle dimension to be set for rotation convention

  • geographic_azimuth (float) – z-axis rotation angle

  • dip (float) – y-axis rotation angle

  • pitch – x-axis rotation angle

  • deg – Indicates if input angles are in degrees or not

Returns

Directional vector, trend and plunge

Return type

np.ndarray, float, float

geolime.geostats.variogram.variogram.generate_lags(lag: float, plag: float, nlags: int)

Generate lags array to be used with variogram

Parameters
  • lag (float) – Calculation lag in meters

  • plag (float) – Tolerance (percentage of lag)

  • nlags (int) – Length of array to be generated

Returns

An array of lags and the tolerance in meters

Return type

np.ndarray, float

geolime.geostats.variogram.variogram.in_angle(vdir: numpy.ndarray, atol: float)

Return a function that checks for an index vector if it belongs to an angular range. Intended to be used for performance vectorization.

Parameters
  • vdir (np.ndarray) – Directional vector, computed once during initialization

  • atol (float) – Angular tolerance in radians

Returns

A function that returns True if vector is in the angular range, False if the vector is outside

Return type

Callable

geolime.geostats.variogram.variogram.in_range(target: float, atol: float)

Check if target angle lies within a range of angles (defined by an angle tolerance)

Parameters
  • target (float) – Angle to be checked (in radians)

  • atol (float) – Angular tolerance in radians

Returns

if True: target is in range, if False: target is outside range

Return type

bool

geolime.geostats.variogram.variogram.in_slice(trend: float, plunge: float, vdir: numpy.ndarray, width: float = inf, height: float = inf)

Return a function that check whether a vector (cartesian coordinates) lies within a slice (defined by a width and a height in meters)

Parameters
  • trend (float) – Angle for y-axis rotation (in radians)

  • plunge (float) – Angle for y-axis rotation (in radians)

  • vdir (np.ndarray) – Directional vector array

  • plunge

  • width (float) – Slicing width (in meters)

  • height (float) – Slicing height (in meters)

Returns

A function that returns True if vector is in the slice, False if the vector is outside slice

Return type

Callable

geolime.geostats.variogram.variogram.select_index_from_slice(idx: pandas.core.frame.DataFrame, f: Callable)

Compare vectors from a set of indices

Parameters
  • idx (pd.DataFrame) – Dataframe containing indices to be checked

  • f (Callable) – Index selector function

Returns

a selection of indices

Return type

pd.DataFrame

geolime.geostats.variogram.variogram.select_indices(coords: numpy.ndarray, pwdist: numpy.ndarray, lag: float, tol: float, atol: float, f_in_angle: Callable, f_in_slice: Callable)

Check whether a set of points (linked to their distances) match the input restricted boundaries. This function will first check if a set of points lie in a lag range. Then will process the indices for angular range conformity. Lastly, the resulting indices are tested against slicing boundaries (if slicing arguments are provided)

Parameters
  • coords (np.ndarray) – Cartesian coordinates in float

  • pwdist (np.ndarray) – N * N matrix of pairwise distances (in float)

  • lag (float) – Lag in meters

  • tol (float) – Lag tolerance in meters

  • f_in_angle (Callable) – Index selector function for angle

  • f_in_slice (Callable) – Index selector function for slice

  • atol (float) – Angular tolerance in degrees

Returns

Array of indices (couple of integers)

Return type

np.ndarray

geolime.geostats.variogram.variogram.select_indices_from_angle(idx: pandas.core.frame.DataFrame, f: Callable)

Compare vectors from a set of indices

Parameters
  • idx (pd.DataFrame) – Dataframe containing indices to be checked

  • f (Callable) – Index selector function

Returns

a selection of indices

Return type

pd.DataFrame

geolime.geostats.variogram.variogram.select_indices_from_lag(pwdist: numpy.ndarray, lag: float, tol: float)

Check whether a set of distances lie within a lag-range.

From geostatsmodels original comment: grab the coordinates in a given range: lag +/- tolerance and take out the repeated elements, since p is a symmetric distance matrix

Parameters
  • pwdist (np.ndarray) – N * N pairwise distances

  • lag (float) – lag to be compared to (in meters)

  • tol (float) – lag tolerance (in meters)

Returns

dataframe of indices lying in a lag tolerance

Return type

pd.DataFrame

geolime.geostats.variogram.variogram.semivariance(values: numpy.ndarray, indices: numpy.ndarray, weights: numpy.ndarray = None)

Compute the semivariance given an array of values for a set of pairs

Parameters
  • values (np.ndarray) – Array of float values

  • indices (np.ndarray) – List of pairs (couple of integers) for a specific lag

  • weights (np.ndarray) – Optional weights array for semivariance computation

Returns

Semivariance value

Return type

float

geolime.geostats.variogram.variogram.variogram(coords: numpy.ndarray, values: numpy.ndarray, lags: List[float], tol: float, geographic_azimuth: float, dip: float, pitch: float, atol: float, slice_width: float = inf, slice_height: float = inf, method: enum.Enum = 'semivariogram', weights: numpy.ndarray = None)

Given boundary input arguments (lag and its associated tolerance, angular reference and its associated tolerance), compute the variogram for a set of points (value associated with cartesian coordinates for a specific point)

Parameters
  • coords (np.ndarray) – Array of cartesian coordinates (in float)

  • values (np.ndarray) – Array of values associated with points

  • lags (List[float]) – List of lags (in meters)

  • tol (float) – Lag tolerance in meters

  • geographic_azimuth (float) – z-axis rotation angle in degrees

  • dip (float) – y-axis rotation angle in degrees

  • pitch (float) – x-axis rotation angle in degrees

  • atol (float) – Angular tolerance in degrees

  • slice_width (float) – Slicing width (in meters)

  • slice_height (float) – Slicing height (in meters)

  • method (Enum) – Computation method

  • weights (np.ndarray) – Optional weights array for semivariance computation

Returns

A variogram dataframe, Isatis compliant output (rank, number of pairs, input lag, average distance, variogram value and indices)

Return type

pd.DataFrame