Exemple #1
0
    def test_mappings_and_cell_weights(self):
        mesh = discretize.TensorMesh([8, 7, 6])
        m = np.random.rand(2 * mesh.nC)
        v = np.random.rand(2 * mesh.nC)

        cell_weights = np.random.rand(mesh.nC)

        wires = maps.Wires(("sigma", mesh.nC), ("mu", mesh.nC))

        reg = regularization.SimpleSmall(mesh,
                                         mapping=wires.sigma,
                                         cell_weights=cell_weights)

        objfct = objective_function.L2ObjectiveFunction(W=utils.sdiag(
            np.sqrt(cell_weights)),
                                                        mapping=wires.sigma)

        self.assertTrue(reg(m) == objfct(m))
        self.assertTrue(np.all(reg.deriv(m) == objfct.deriv(m)))
        self.assertTrue(np.all(reg.deriv2(m, v=v) == objfct.deriv2(m, v=v)))
Exemple #2
0
dobs = fields_tot[survey_vrm.t_active]
rel_err = 0.05
eps = 1e-11
data_vrm = data.Data(dobs=dobs,
                     survey=survey_vrm,
                     relative_error=rel_err,
                     noise_floor=eps)

# Setup and run inversion
dmis = data_misfit.L2DataMisfit(simulation=problem_inv, data=data_vrm)

w = utils.mkvc((np.sum(np.array(problem_inv.A)**2, axis=0)))**0.5
w = w / np.max(w)
w = w

reg = regularization.SimpleSmall(mesh=mesh, indActive=actCells, cell_weights=w)
opt = optimization.ProjectedGNCG(maxIter=20,
                                 lower=0.0,
                                 upper=1e-2,
                                 maxIterLS=20,
                                 tolCG=1e-4)
invProb = inverse_problem.BaseInvProblem(dmis, reg, opt)
directives = [
    directives.BetaSchedule(coolingFactor=2, coolingRate=1),
    directives.TargetMisfit(),
]
inv = inversion.BaseInversion(invProb, directiveList=directives)

xi_0 = 1e-3 * np.ones(actCells.sum())
xi_rec = inv.run(xi_0)