LoopStructural.interpolators.DiscreteFoldInterpolator#

class LoopStructural.interpolators.DiscreteFoldInterpolator(support, fold: FoldEvent | None = None)#

Bases: P1Interpolator

A piecewise linear interpolator that can also use fold constraints defined in Laurent et al., 2016

Parameters:
  • support – discrete support with nodes and elements etc

  • FoldEvent (fold) – a fold event with a valid geometry

__init__(support, fold: FoldEvent | None = None)#

A piecewise linear interpolator that can also use fold constraints defined in Laurent et al., 2016

Parameters:
  • support – discrete support with nodes and elements etc

  • FoldEvent (fold) – a fold event with a valid geometry

Methods

__init__(support[, fold])

A piecewise linear interpolator that can also use fold constraints defined in Laurent et al., 2016

add_constraints_to_least_squares(A, B, idc)

Adds constraints to the least squares system.

add_equality_block(A, B)

add_equality_constraints(node_idx, values[, ...])

Adds hard constraints to the least squares system.

add_fold_constraints([fold_orientation, ...])

add_gradient_constraints([w])

add_gradient_orthogonal_constraints(points, ...)

constraints scalar field to be orthogonal to a given vector

add_inequality_constraints_to_matrix(A, ...)

Adds constraints for a matrix where the linear function l < Ax > u constrains the objective function

add_inequality_feature(feature[, lower, mask])

Add an inequality constraint to the interpolator using an existing feature.

add_inequality_pairs_constraints([w, ...])

add_interface_constraints([w])

add_norm_constraints([w])

add_tangent_constraints([w])

Adds the constraints \(f(X)\cdotT=0\)

add_value_constraints([w])

add_value_inequality_constraints([w])

build_inequality_matrix()

build_matrix()

Assemble constraints into interpolation matrix.

calculate_residual_for_constraints()

Calculates Ax-B for all constraints added to the interpolator This could be a proxy to identify which constraints are controlling the model

check_array(array)

clean()

Removes all of the data from an interpolator

debug()

Helper function for debugging when the interpolator isn't working

evaluate_gradient(locations)

Evaluate the gradient of the scalar field at the evaluation points :param evaluation_points: xyz locations to evaluate the gradient :type evaluation_points: np.array

evaluate_value(locations)

Evaluate the value of the interpolator at location

get_data_locations()

Get the location of all data points

get_gradient_constraints()

get_inequality_pairs_constraints()

get_inequality_value_constraints()

get_interface_constraints()

Get the location of interface constraints

get_norm_constraints()

get_tangent_constraints()

get_value_constraints()

minimise_edge_jumps([w, vector_func, ...])

reset()

Reset the interpolation constraints

set_gradient_constraints(points)

set_inequality_pairs_constraints(points)

set_interface_constraints(points)

set_interpolation_weights(weights)

Set the interpolation weights dictionary

set_normal_constraints(points)

set_region([region])

Set the region of the support the interpolator is working on

set_tangent_constraints(points)

set_value_constraints(points)

set_value_inequality_constraints(points)

setup(**kwargs)

Runs all of the required setting up stuff

setup_interpolator(**kwargs)

Searches through kwargs for any interpolation weights and updates the dictionary.

solve_system([solver, solver_kwargs])

Main entry point to run the solver and update the node value attribute for the discreteinterpolator class

to_dict()

to_json()

Returns a json representation of the geological interpolator

update()

Check if the solver is up to date, if not rerun interpolation using the previously used solver.

update_fold(fold)

Attributes

data

nx

Number of degrees of freedom for the interpolator

region

The active region of the interpolator.

region_map

add_constraints_to_least_squares(A, B, idc, w=1.0, name='undefined')#

Adds constraints to the least squares system. Automatically works out the row index given the shape of the input arrays

Parameters:
  • A (numpy array / list) – RxC numpy array of constraints where C is number of columns,R rows

  • B (numpy array /list) – B values array length R

  • idc (numpy array/list) – RxC column index

Returns:

list of constraint ids

add_equality_constraints(node_idx, values, name='undefined')#

Adds hard constraints to the least squares system. For now this just sets the node values to be fixed using a lagrangian.

Parameters:
  • node_idx (numpy array/list) – int array of node indexes

  • values (numpy array/list) – array of node values

add_fold_constraints(fold_orientation=10.0, fold_axis_w=10.0, fold_regularisation=[0.1, 0.01, 0.01], fold_normalisation=1.0, fold_norm=1.0, step=2)#
Parameters:
  • fold_orientation (double) – weight for the fold direction/orientation in the least squares system

  • fold_axis_w (double) – weight for the fold axis in the least squares system

  • fold_regularisation (list) – weight for the fold regularisation in the least squares system

  • fold_normalisation (double) – weight for the fold norm constraint in the least squares system

  • fold_norm – length of the interpolation norm in the least squares system

  • step (int) – array step for adding constraints

Notes

For more information about the fold weights see EPSL paper by Gautier Laurent 2016

add_gradient_orthogonal_constraints(points: ndarray, vectors: ndarray, w: float = 1.0, B: float = 0, name='undefined gradient orthogonal constraint')#

constraints scalar field to be orthogonal to a given vector

Parameters:
  • points (np.darray) – location to add gradient orthogonal constraint

  • vector (np.darray) – vector to be orthogonal to, should be the same shape as points

  • w (double)

  • B (np.array)

add_inequality_constraints_to_matrix(A: ndarray, bounds: ndarray, idc: ndarray, name: str = 'undefined')#

Adds constraints for a matrix where the linear function l < Ax > u constrains the objective function

Parameters:
  • A (numpy array) – matrix of coefficients

  • bounds (numpy array) – nx3 lower, upper, 1

  • idc (numpy array) – index of constraints in the matrix

add_inequality_feature(feature: Callable[[ndarray], ndarray], lower: bool = True, mask: ndarray | None = None)#

Add an inequality constraint to the interpolator using an existing feature. This will make the interpolator greater than or less than the exising feature. Evaluate the feature at the interpolation nodes. Can provide a boolean mask to restrict to only some parts

Parameters:
  • feature (BaseFeature) – the feature that will be used to constraint the interpolator

  • lower (bool, optional) – lower or upper constraint, by default True

  • mask (np.ndarray, optional) – restrict the nodes to evaluate on, by default None

add_tangent_constraints(w=1.0)#

Adds the constraints \(f(X)\cdotT=0\)

Parameters:

w (double)

build_matrix()#

Assemble constraints into interpolation matrix. Adds equaltiy constraints using lagrange modifiers if necessary

Parameters:

damp (bool) – Flag whether damping should be added to the diagonal of the matrix

Returns:

Interpolation matrix and B

calculate_residual_for_constraints()#

Calculates Ax-B for all constraints added to the interpolator This could be a proxy to identify which constraints are controlling the model

Returns:

np.ndarray – vector of Ax-B

clean()#

Removes all of the data from an interpolator

debug()#

Helper function for debugging when the interpolator isn’t working

evaluate_gradient(locations: ndarray) ndarray#

Evaluate the gradient of the scalar field at the evaluation points :param evaluation_points: xyz locations to evaluate the gradient :type evaluation_points: np.array

evaluate_value(locations: ndarray) ndarray#

Evaluate the value of the interpolator at location

Parameters:

evaluation_points (np.ndarray) – location to evaluate the interpolator

Returns:

np.ndarray – value of the interpolator

get_data_locations()#

Get the location of all data points

Returns:

numpy array – Nx3 - X,Y,Z location of all data points

get_gradient_constraints()#
Returns:

numpy array

get_interface_constraints()#

Get the location of interface constraints

Returns:

numpy array – Nx4 - X,Y,Z,id location of all interface constraints

get_norm_constraints()#
Returns:

numpy array

get_tangent_constraints()#
Returns:

numpy array

get_value_constraints()#
Returns:

numpy array

property nx: int#

Number of degrees of freedom for the interpolator

Returns:

int – number of degrees of freedom, positve

property region: ndarray#

The active region of the interpolator. A boolean mask for all elements that are interpolated

Returns:

np.ndarray

reset()#

Reset the interpolation constraints

set_gradient_constraints(points: ndarray)#
Parameters:

points (np.ndarray) – array containing the value constraints usually 7-8 columns. X,Y,Z,gx,gy,gz,weight

set_interpolation_weights(weights)#

Set the interpolation weights dictionary

Parameters:

dictionary (weights -) – Entry of new weights to assign to self.interpolation_weights

set_normal_constraints(points: ndarray)#
Parameters:

points (np.ndarray) – array containing the value constraints usually 7-8 columns. X,Y,Z,nx,ny,nz,weight

set_region(region=None)#

Set the region of the support the interpolator is working on

Parameters:

function(position) (region -) – return true when in region, false when out

set_tangent_constraints(points: ndarray)#
Parameters:

points (np.ndarray) – array containing the value constraints usually 7-8 columns. X,Y,Z,nx,ny,nz,weight

set_value_constraints(points: ndarray)#
Parameters:

points (np.ndarray) – array containing the value constraints usually 4-5 columns. X,Y,Z,val,weight

setup(**kwargs)#

Runs all of the required setting up stuff

setup_interpolator(**kwargs)#

Searches through kwargs for any interpolation weights and updates the dictionary. Then adds the constraints to the linear system using the interpolation weights values :param kwargs -: interpolation weights

solve_system(solver: Callable[[csr_matrix, ndarray], ndarray] | str | None = None, solver_kwargs: dict = {}) bool#

Main entry point to run the solver and update the node value attribute for the discreteinterpolator class

Parameters:
  • solver (string/callable) – solver ‘cg’ conjugate gradient, ‘lsmr’ or callable function

  • solver_kwargs – kwargs for solver check scipy documentation for more information

Returns:

bool – True if the interpolation is run

to_json()#

Returns a json representation of the geological interpolator

Returns:

json (dict) – json representation of the geological interpolator

update() bool#

Check if the solver is up to date, if not rerun interpolation using the previously used solver. If the interpolation has not been run before it will return False

Returns:

bool

update_fold(fold)#
Parameters:

fold (FoldEvent) – a fold that contrains the geometry we are trying to add