Ejemplo n.º 1
0
                                 stepOffBoundsFact=1e-8)

invProb = InvProblem.BaseInvProblem(dmis, reg, opt)


# LIST OF DIRECTIVES
# betaest = Directives.BetaEstimate_ByEig()
IRLS = Directives.Update_IRLS(f_min_change=1e-6,
                              minGNiter=2, beta_tol=1e-2,
                              coolingRate=2)
update_SensWeight = Directives.UpdateSensWeighting()
update_Jacobi = Directives.UpdatePreCond()
ProjSpherical = Directives.ProjSpherical()
JointAmpMVI = Directives.JointAmpMVI()
betaest = Directives.BetaEstimate_ByEig(beta0_ratio = 1e+3)
saveModel = Directives.SaveUBCModelEveryIteration(mapping=actvMap,
                                                    saveComp=True)
saveModel.fileName = work_dir+out_dir + 'JOINT_MVIC_A'

inv = Inversion.BaseInversion(invProb,
                              directiveList=[betaest, IRLS, update_SensWeight,
                                             update_Jacobi, saveModel])

# Run JOINT
mrec = inv.run(mstart)

#NOTE - Would like to have dpred working on both surveys
dpred = invProb.getFields(mrec)

print('Amplitude Final phi_d: ' + str(dmis_amp(mrec)))
print('MVI Final phi_d: ' + str(dmis_MVI(mrec)))
Ejemplo n.º 2
0
betaest = Directives.BetaEstimate_ByEig(beta0_ratio=1e+1)

# Pre-conditioner
update_Jacobi = Directives.UpdatePreconditioner()

IRLS = Directives.Update_IRLS(f_min_change=1e-3,
                              minGNiter=1,
                              beta_tol=0.25,
                              maxIRLSiter=max_IRLS_iter,
                              chifact_target=target_chi,
                              betaSearch=False)

# Save model
saveDict = Directives.SaveOutputEveryIteration(save_txt=False)
saveIt = Directives.SaveUBCModelEveryIteration(
    mapping=activeCellsMap,
    fileName=outDir + input_dict["inversion_type"].lower() + "_C",
    vector=input_dict["inversion_type"].lower()[0:3] == 'mvi')

# Put all the parts together
inv = Inversion.BaseInversion(
    invProb, directiveList=[saveIt, saveDict, betaest, IRLS, update_Jacobi])

# SimPEG reports half phi_d, so we scale to matrch
print("Start Inversion\nTarget Misfit: %.2e (%.0f data with chifact = %g)" %
      (0.5 * target_chi * len(survey.std), len(survey.std), target_chi))

# Run the inversion
mrec = inv.run(mstart)

print("Target Misfit: %.3e (%.0f data with chifact = %g)" %
      (0.5 * target_chi * len(survey.std), len(survey.std), target_chi))
Ejemplo n.º 3
0
        maxIRLSiter=max_irls_iterations,
        minGNiter=1, beta_tol=0.5, prctile=90, floorEpsEnforced=True,
        coolingRate=1, coolEps_q=True, coolEpsFact=1.2,
        betaSearch=False
    )
)

if initial_beta is None:
    directiveList.append(Directives.BetaEstimate_ByEig(beta0_ratio=1e+1))

directiveList.append(Directives.UpdatePreconditioner())

directiveList.append(
    Directives.SaveUBCModelEveryIteration(
        mapping=activeCellsMap * model_map,
        mesh=mesh,
        fileName=outDir + input_dict["inversion_type"],
        vector=input_dict["inversion_type"][0:3] == 'mvi'
    )
)

directiveList.append(
    Directives.SaveUBCPredictedEveryIteration(
        survey=survey,
        fileName=outDir + input_dict["inversion_type"],
        format=input_dict["inversion_type"]
    )
)
invProb_idx = len(directiveList) - 1

directiveList.append(
    Directives.SaveOutputDictEveryIteration()
Ejemplo n.º 4
0
                                 tolCG=1e-4)
invProb = InvProblem.BaseInvProblem(ComboMisfit, reg, opt)
betaest = Directives.BetaEstimate_ByEig(beta0_ratio=1e0)

# Here is where the norms are applied
# Use pick a treshold parameter empirically based on the distribution of
#  model parameters
IRLS = Directives.Update_IRLS(f_min_change=1e-3,
                              minGNiter=1,
                              maxIRLSiter=30,
                              betaSearch=False)

IRLS.target = driver.survey.nD
update_Jacobi = Directives.UpdatePreconditioner()
saveModel = Directives.SaveUBCModelEveryIteration(mapping=actvMap,
                                                  fileName=out_dir + dsep +
                                                  "GRAV_Tile")
inv = Inversion.BaseInversion(
    invProb, directiveList=[betaest, saveModel, IRLS, update_Jacobi])

# Run the inversion
mrec = inv.run(m0)

# Export tensor model if inputMesh is tensor
if isinstance(meshInput, Mesh.TensorMesh):

    tree = cKDTree(mesh.gridCC)

    dd, ind = tree.query(meshInput.gridCC)

    mOut = (actvMap * invProb.model)[ind]
Ejemplo n.º 5
0
opt = Optimization.ProjectedGNCG(maxIter=10,
                                 lower=-10.,
                                 upper=10.,
                                 maxIterCG=20,
                                 tolCG=1e-3)

invProb = InvProblem.BaseInvProblem(dmis, reg, opt)
betaest = Directives.BetaEstimate_ByEig()

# Here is where the norms are applied
IRLS = Directives.Update_IRLS(f_min_change=1e-4, minGNiter=3, beta_tol=1e-2)

update_Jacobi = Directives.UpdatePreCond()
targetMisfit = Directives.TargetMisfit()

saveModel = Directives.SaveUBCModelEveryIteration(mapping=actvMap)
saveModel.fileName = work_dir + out_dir + 'MVI_C'
inv = Inversion.BaseInversion(
    invProb, directiveList=[betaest, IRLS, update_Jacobi, saveModel])

mrec_MVI = inv.run(mstart)

beta = invProb.beta

# %% RUN MVI-S

# # STEP 3: Finish inversion with spherical formulation
mstart = PF.Magnetics.xyz2atp(mrec_MVI)
prob.coordinate_system = 'spherical'
prob.model = mstart
Ejemplo n.º 6
0
# Target misfit to stop the inversion,
# try to fit as much as possible of the signal, we don't want to lose anything
targetMisfit = Directives.TargetMisfit(chifact=targetChi)

# Pre-conditioner
update_Jacobi = Directives.UpdatePreconditioner()

IRLS = Directives.Update_IRLS(f_min_change=1e-3,
                              minGNiter=1,
                              beta_tol=0.25,
                              maxIRLSiter=1,
                              chifact_target=targetChi)

# Save model
saveIt = Directives.SaveUBCModelEveryIteration(mapping=activeCellsMap,
                                               fileName=workDir + dsep +
                                               outDir + driver["dataFile"][0])
# Put all the parts together
inv = Inversion.BaseInversion(
    invProb, directiveList=[saveIt, betaest, IRLS, update_Jacobi])

# Run the equivalent source inversion
mstart = np.zeros(nC)
mrec = inv.run(mstart)

# Ouput result
Mesh.TreeMesh.writeUBC(
    mesh,
    workDir + dsep + outDir + 'OctreeMeshGlobal.msh',
    models={
        workDir + dsep + outDir + driver["dataFile"][0] + '.mod':
Ejemplo n.º 7
0
# Target misfit to stop the inversion,
# try to fit as much as possible of the signal, we don't want to lose anything
targetMisfit = Directives.TargetMisfit(chifact=targetChi)

# Pre-conditioner
update_Jacobi = Directives.UpdatePreconditioner()

IRLS = Directives.Update_IRLS(f_min_change=1e-3,
                              minGNiter=1,
                              beta_tol=0.25,
                              maxIRLSiter=1,
                              chifact_target=targetChi)

# Save model
saveIt = Directives.SaveUBCModelEveryIteration(mapping=activeCellsMap,
                                               fileName=workDir + dsep +
                                               outDir + 'EquivalentSource')
# Put all the parts together
inv = Inversion.BaseInversion(
    invProb, directiveList=[saveIt, betaest, IRLS, update_Jacobi])

# Run the equivalent source inversion
mstart = np.zeros(nC)
mrec = inv.run(mstart)

# Ouput result
Mesh.TreeMesh.writeUBC(mesh,
                       workDir + dsep + outDir + 'OctreeMeshGlobal.msh',
                       models={
                           workDir + dsep + outDir + 'EquivalentSource.mod':
                           activeCellsMap * invProb.model
Ejemplo n.º 8
0
invProb = InvProblem.BaseInvProblem(ComboMisfit, reg, opt)
betaest = Directives.BetaEstimate_ByEig()

# Add directives to the inversion
# Here is where the norms are applied
IRLS = Directives.Update_IRLS(f_min_change=1e-3,
                              maxIRLSiter=0,
                              minGNiter=1,
                              betaSearch=False)

# Pre-conditioner
update_Jacobi = Directives.UpdatePreconditioner()

# Output models between each iteration
saveModel = Directives.SaveUBCModelEveryIteration(mapping=actvMap, vector=True)
saveModel.fileName = out_dir + 'MVI_C'

# Put it all together
inv = Inversion.BaseInversion(
    invProb, directiveList=[betaest, IRLS, update_Jacobi, saveModel])

# Invert
mrec_MVI = inv.run(mstart)

###############################################################################
# MVI-Spherical with sparsity
# ---------------------------
#
# Finish inversion with spherical formulation
#
Ejemplo n.º 9
0
                                     maxIterCG=20,
                                     tolCG=1e-4)
    invProb = InvProblem.BaseInvProblem(ComboMisfit, reg, opt)
    betaest = Directives.BetaEstimate_ByEig()

    # Here is where the norms are applied
    # Use pick a treshold parameter empirically based on the distribution of
    #  model parameters
    IRLS = Directives.Update_IRLS(f_min_change=1e-3,
                                  minGNiter=1,
                                  maxIRLSiter=10)

    IRLS.target = driver.survey.nD
    update_Jacobi = Directives.UpdatePreconditioner()
    saveModel = Directives.SaveUBCModelEveryIteration(mapping=actvMap,
                                                      fileName=work_dir +
                                                      out_dir + "MAG_Tile")
    inv = Inversion.BaseInversion(
        invProb, directiveList=[betaest, saveModel, IRLS, update_Jacobi])

    # Run the inversion
    mrec = inv.run(m0)

    #for ind, dmis in enumerate(ComboMisfit.objfcts):
    #
    #    Mesh.TreeMesh.writeUBC(dmis.prob.mesh, work_dir + out_dir +  "Tile" + str(ind) + ".msh",
    #                           models={work_dir + out_dir + "Tile" + str(ind) + ".sus": dmis.prob.chiMap * mrec})
    # Mesh.TensorMesh.writeUBC(prob.mesh,
    #                          work_dir + out_dir + "Tile" + str(ind) + ".msh")
    # Mesh.TensorMesh.writeModelUBC(prob.mesh,
    #                               work_dir + out_dir + "Tile" + str(ind) + ".sus", prob.mapping() * mrec)
Ejemplo n.º 10
0
                                 tolCG=1e-3)

# Create the default L2 inverse problem from the above objects
invProb = InvProblem.BaseInvProblem(dmis, reg, opt)

# Specify how the initial beta is found
betaest = Directives.BetaEstimate_ByEig(beta0_ratio=1e-2)

# Beta schedule for inversion
betaSchedule = Directives.BetaSchedule(coolingFactor=2., coolingRate=1)

# Target misfit to stop the inversion,
# try to fit as much as possible of the signal, we don't want to lose anything
targetMisfit = Directives.TargetMisfit(chifact=0.1)

saveModel = Directives.SaveUBCModelEveryIteration(mapping=surfMap)
saveModel.fileName = work_dir + out_dir + 'EquivalentSource'

# Put all the parts together
inv = Inversion.BaseInversion(
    invProb, directiveList=[betaest, betaSchedule, saveModel, targetMisfit])

# Run the equivalent source inversion
mstart = np.zeros(nC)
mrec = inv.run(mstart)

# %% STEP 2: COMPUTE AMPLITUDE DATA
# Now that we have an equialent source layer, we can forward model alh three
# components of the field and add them up: |B| = ( Bx**2 + Bx**2 + Bx**2 )**0.5

# Won't store the sensitivity and output 'xyz' data.