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 - discretizemesh types.- Parameters:
- meshdiscretize.BaseMesh
- The mesh object to use for regularization. The mesh should either have a - cell_gradientor a- stencil_cell_gradientdefined.
- alphas(mesh.dim,) or(mesh.n_cells,mesh.dim) array_likeoffloat, 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_likeoffloat
- 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_dirsfor 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 - Mapping from the inversion model parameters to the regularization mesh. - The model parameters. - Number of model parameters. - The parent objective function - Reference model. - 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 - BaseRegularizationclass.- f_m_deriv(m)- Not implemented for - BaseRegularizationclass.- 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, with- alphasalong 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 - alphasparameter can also be independent for each cell. Here we set all cells lower than 0.5 in the- x2to 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) 
