geolime.geostats.math.neighborhood

Data:

Callable

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

List

The central part of internal API.

Classes:

MaxPerCategoryNeighborhood(dim, angles, …)

MinMaxPointsNeighborhood(dim, angles, …)

Neighborhood()

Functions:

anisotropic_distance([a])

Anisotropic distance between two points according to the anisotropy matrix a.

arg_sort_near_points(p, x[, distance])

Function to compute the indexes indicating the order in which the rows of x are close to p according to the distance distance (from small distance to large distance)

euclidian_distance(x, y)

Compute the Euclidean distance between two points.

filter_with_scales(x[, p, scales])

Function to return the indexes of the points which are in a sphere in the Euclidean space.

rot_zyx(angles[, deg, clockwise])

Example of a convention (RGeoStats)

rotational_angles(angles)

Compute the angles in radians necessary for matrix rotation operation from geographic azimuth, dip and pitch angles defined in degrees

which_in_ball(x[, p, r, distance, scales])

Function to return the indexes of the points which are in a (closed) ball in the Euclidean space.

which_nearest_in_ball(x[, p, r, distance, …])

Function to obtain the N closest points of a set of points to the center of a ball which are on that ball.

which_nearest_in_ball_with_max_per_category(x)

Function to obtain the N closest points of a set of points to the center of a ball which are on that ball with a maximum per category.

class geolime.geostats.math.neighborhood.MaxPerCategoryNeighborhood(dim: int, angles: List[float], scales: List[float], min_n: int, max_n: int, max_per_category: int, category: numpy.ndarray, convention: Callable = <function rot_zyx>)

Bases: geolime.geostats.math.neighborhood.MinMaxPointsNeighborhood

Methods:

select(x, p)

Neighborhood selection function.

select(x: numpy.ndarray, p: numpy.ndarray)

Neighborhood selection function.

Parameters
  • x (np.ndarray) – A numpy matrix where each row is a vector in the Euclidean Space

  • p (np.ndarray) – A numpy vector indicating the position (center of the ball). By default is a vector of zeros in dimension 3.

Returns

This function returns the indixes of the N rows of x which are the closest to the vector p according to the distance

Return type

np.ndarray

class geolime.geostats.math.neighborhood.MinMaxPointsNeighborhood(dim: int, angles: List[float], scales: List[float], min_n: int, max_n: int, convention: Callable = <function rot_zyx>)

Bases: geolime.geostats.math.neighborhood.Neighborhood

Methods:

select(x, p)

Neighborhood selection function.

select(x: numpy.ndarray, p: numpy.ndarray)

Neighborhood selection function.

Parameters
  • x (np.ndarray) – A numpy matrix where each row is a vector in the Euclidean Space

  • p (np.ndarray) – A numpy vector indicating the position (center of the ball). By default is a vector of zeros in dimension 3.

Returns

This function returns the indixes of the N rows of x which are the closest to the vector p according to the distance

Return type

np.ndarray

class geolime.geostats.math.neighborhood.Neighborhood

Bases: object

Methods:

select(x, p)

select(x, p)
geolime.geostats.math.neighborhood.arg_sort_near_points(p: numpy.ndarray, x: numpy.ndarray, distance: Callable = <function euclidian_distance>)

Function to compute the indexes indicating the order in which the rows of x are close to p according to the distance distance (from small distance to large distance)

Parameters
  • p (np.ndarray) – Vector with respect to which calculate the distances.

  • x (np.ndarray) – A numoy matrix with the vectors to be analyzed in its rows.

  • distance (Callable) – A Distance function.

Returns

Returns the indexes of the rows of x according to which are closer to p according to the distance Distance. Note: this function could be easily vectorized in p using the Distance Matrix

Return type

np.ndarray

geolime.geostats.math.neighborhood.filter_with_scales(x: numpy.ndarray, p: numpy.ndarray = array([0.0, 0.0, 0.0]), scales: numpy.ndarray = None)

Function to return the indexes of the points which are in a sphere in the Euclidean space.

Parameters
  • x (np.ndarray) – A numpy matrix whose rows represent vectors in the Euclidean space.

  • p (np.ndarray) – Position vector indicating the center of the ball, by default a vector of zeros in dimension 3.

  • scales (np.ndarray) – Ellipsoid scales to help filter in/out points

Returns

Return type

A numpy arrray containing indices of point x to keep.

geolime.geostats.math.neighborhood.which_in_ball(x: numpy.ndarray, p: numpy.ndarray = array([0., 0., 0.]), r: float = 1.0, distance: Callable = <function euclidian_distance>, scales: numpy.ndarray = None)

Function to return the indexes of the points which are in a (closed) ball in the Euclidean space.

Parameters
  • x (np.ndarray) – A numpy matrix whose rows represent vectors in the Euclidean space.

  • p (np.ndarray) – Position vector indicating the center of the ball, by default a vector of zeros in dimension 3.

  • r (float) – Radius of the ball, by default r = 1.

  • distance (Callable) – A distance function, by default euclidian_distance.

  • scales (np.ndarray) – Ellipsoid scales to help filter in/out points.

Returns

Return type

A numpy arrray containing indices of point x to keep.

geolime.geostats.math.neighborhood.which_nearest_in_ball(x: numpy.ndarray, p: numpy.ndarray = array([0., 0., 0.]), r: float = 1.0, distance: Callable = <function euclidian_distance>, scales: numpy.ndarray = None, min_n: int = 1, max_n: int = 100)

Function to obtain the N closest points of a set of points to the center of a ball which are on that ball.

Parameters
  • x (np.ndarray) – A numpy matrix where each row is a vector in the Euclidean Space

  • p (np.ndarray) – A numpy vector indicating the position (center of the ball). By default is a vector of zeros in dimension 3.

  • r (float) – Radius of the ball. By default r=1.

  • distance (Callable) – Distance function defining the ball. By default euclidian_distance.

  • scales (np.ndarray) – Ellipsoid scales to help filter in/out points.

  • min_n (int) – Minimum number of points in the ball to be considered otherwise returns no points.

  • max_n (int) – Maximum number of points in the ball to be considered (the N closest).

Returns

  • A numpy array. This function returns the indixes of the N rows of x

  • which are the closest to the vector p according to the distance

  • Distance and which are in the ball of center p and radius r (according

  • to that distance). If there is less points in the ball than N, the

  • indexes of all those points are returned. Points returned are ordered

  • by ascending distance.

geolime.geostats.math.neighborhood.which_nearest_in_ball_with_max_per_category(x: numpy.ndarray, p: numpy.ndarray = array([0., 0., 0.]), r: float = 1.0, distance: Callable = <function euclidian_distance>, min_n: int = 1, max_n: int = 100, max_per_category: int = None, category: numpy.ndarray = None)

Function to obtain the N closest points of a set of points to the center of a ball which are on that ball with a maximum per category.

Parameters
  • x (np.ndarray) – A numpy matrix where each row is a vector in the Euclidean Space

  • p (np.ndarray) – A numpy vector indicating the position (center of the ball). By default is a vector of zeros in dimension 3.

  • r (float) – Radius of the ball. By default r=1.

  • distance (Callable) – Distance function defining the ball. By default EucDist.

  • min_n (int) – Minimum number of points in the ball to be considered otherwise returns no points.

  • max_n (int) – Maximum number of points in the ball to be considered (the N closest).

  • max_per_category (int) – Maximum number of neighors for each category

  • category (np.ndarray) – Attribute to determine uniqueness of each category

Returns

  • A numpy array. This function returns the indixes of the N rows of x

  • which are the closest to the vector p according to the distance

  • Distance and which are in the ball of center p and radius r (according

  • to that distance). If there is less points in the ball than N, the

  • indexes of all those points are returned. Points returned are ordered

  • by ascending distance.