simpeg.regularization.SmoothnessFullGradient#
- class simpeg.regularization.SmoothnessFullGradient(mesh, alphas=None, reg_dirs=None, ortho_check=True, **kwargs)[source]#
Bases:
BaseRegularization
Measures the gradient of a model using optionally anisotropic weighting.
This regularizer measures the first order smoothness in a mesh ambivalent way by observing that the N-d smoothness operator can be represented as an inner product with an arbitrarily anisotropic weight.
By default it assumes uniform weighting in each dimension, which works for most
discretize
mesh types.- Parameters:
- mesh
discretize.BaseMesh
The mesh object to use for regularization. The mesh should either have a
cell_gradient
or astencil_cell_gradient
defined.- alphas(mesh.dim,)
or
(mesh.n_cells
,mesh.dim
) array_likeof
float
, optional. The weights of the regularization for each axis. This can be defined for each cell in the mesh. Default is uniform weights equal to the smallest edge length squared.
- reg_dirs(
mesh.dim
,mesh.dim
)or
(mesh.n_cells
,mesh.dim
,mesh.dim
) array_likeof
float
Matrix or list of matrices whose columns represent the regularization directions. Each matrix should be orthonormal. Default is Identity.
- ortho_checkbool,
optional
Whether to check
reg_dirs
for orthogonality.- **kwargs
Keyword arguments passed to the parent class
BaseRegularization
.
- mesh
Attributes
The inner product operator using rotated coordinates
Active cells defined on the regularization mesh.
The (approximate) cell gradient operator
Deprecated property for 'volume' and user defined weights.
active_cells.indActive has been deprecated.
Mapping from the inversion model parameters to the regularization mesh.
The model parameters.
reference_model.mref has been deprecated.
Number of model parameters.
The parent objective function
Reference model.
regularization_mesh.regmesh has been deprecated.
Regularization mesh.
Units for the model parameters.
Return the keys for the existing cell weights
Methods
__call__
(m)Evaluate the regularization function for the model provided.
deriv
(m)Gradient of the regularization function evaluated for the model provided.
deriv2
(m[, v])Hessian of the regularization function evaluated for the model provided.
f_m
(m)Not implemented for
BaseRegularization
class.f_m_deriv
(m)Not implemented for
BaseRegularization
class.get_weights
(key)Cell weights for a given key.
map_class
alias of
IdentityMap
remove_weights
(key)Removes the weights for the key provided.
set_weights
(**weights)Adds (or updates) the specified weights to the regularization.
test
([x, num, random_seed])Run a convergence test on both the first and second derivatives.
Notes
The regularization object is the discretized form of the continuous regularization
\[f(m) = \int_V \nabla m \cdot \mathbf{a} \nabla m \, \text{d} V\]The tensor quantity \(\mathbf{a}\) is used to represent the potential preferential directions of regularization. \(\mathbf{a}\) must be symmetric positive semi-definite with an eigendecomposition of:
\[\mathbf{a} = \mathbf{Q}\mathbf{L}\mathbf{Q}^{-1}\]\(\mathbf{Q}\) is then the regularization directions
reg_dirs
, and \(\mathbf{L}\) is represents the weighting along each direction, withalphas
along its diagonal. These are multiplied to form the anisotropic alpha used for rotated gradients.Examples
Construct of 2D measure with uniform smoothing in each direction.
>>> from discretize import TensorMesh >>> from simpeg.regularization import SmoothnessFullGradient >>> mesh = TensorMesh([32, 32]) >>> reg = SmoothnessFullGradient(mesh)
We can instead create a measure that smooths twice as much in the 1st dimension than it does in the second dimension.
>>> reg = SmoothnessFullGradient(mesh, [2, 1])
The
alphas
parameter can also be independent for each cell. Here we set all cells lower than 0.5 in thex2
to twice as much in the first dimension otherwise it is uniform smoothing.>>> alphas = np.ones((mesh.n_cells, mesh.dim)) >>> alphas[mesh.cell_centers[:, 1] < 0.5] = [2, 1] >>> reg = SmoothnessFullGradient(mesh, alphas)
We can also rotate the axis in which we want to preferentially smooth. Say we want to smooth twice as much along the +x1,+x2 diagonal as we do along the -x1,+x2 diagonal, effectively rotating our smoothing 45 degrees. Note and the columns of the matrix represent the directional vectors (not the rows).
>>> sqrt2 = np.sqrt(2) >>> reg_dirs = np.array([ ... [sqrt2, -sqrt2], ... [sqrt2, sqrt2], ... ]) >>> reg = SmoothnessFullGradient(mesh, alphas, reg_dirs=reg_dirs)