예제 #1
0
    def setUp(self):

        aSpacing=2.5
        nElecs=5

        surveySize = nElecs*aSpacing - aSpacing
        cs = surveySize/nElecs/4

        mesh = Mesh.TensorMesh([
                [(cs,10, -1.3),(cs,surveySize/cs),(cs,10, 1.3)],
                [(cs,3, -1.3),(cs,3,1.3)],
                # [(cs,5, -1.3),(cs,10)]
            ],'CN')

        srcList = DC.Utils.WennerSrcList(nElecs, aSpacing, in2D=True)
        survey = IP.Survey(srcList)
        sigma = np.ones(mesh.nC)
        problem = IP.Problem3D_CC(mesh, rho=1./sigma)
        problem.pair(survey)
        mSynth = np.ones(mesh.nC)*0.1
        survey.makeSyntheticData(mSynth)
        # Now set up the problem to do some minimization
        dmis = DataMisfit.l2_DataMisfit(survey)
        reg = Regularization.Tikhonov(mesh)
        opt = Optimization.InexactGaussNewton(maxIterLS=20, maxIter=10, tolF=1e-6, tolX=1e-6, tolG=1e-6, maxIterCG=6)
        invProb = InvProblem.BaseInvProblem(dmis, reg, opt, beta=1e4)
        inv = Inversion.BaseInversion(invProb)

        self.inv = inv
        self.reg = reg
        self.p =     problem
        self.mesh = mesh
        self.m0 = mSynth
        self.survey = survey
        self.dmis = dmis
예제 #2
0
    def test_Problem3D_CC(self):

        problemDC = DC.Problem3D_CC(self.mesh)
        problemDC.Solver = self.Solver
        problemDC.pair(self.surveyDC)
        data0 = self.surveyDC.dpred(self.sigma0)
        finf = problemDC.fields(self.sigmaInf)
        datainf = self.surveyDC.dpred(self.sigmaInf, f=finf)
        problemIP = IP.Problem3D_CC(self.mesh,
                                    rho=1. / self.sigmaInf,
                                    Ainv=problemDC.Ainv,
                                    f=finf)
        problemIP.Solver = self.Solver
        surveyIP = IP.Survey([self.src])
        problemIP.pair(surveyIP)
        data_full = data0 - datainf
        data = surveyIP.dpred(self.eta)
        err = np.linalg.norm(
            (data - data_full) / data_full)**2 / data_full.size
        if err < 0.05:
            passed = True
            print ">> IP forward test for Problem3D_CC is passed"
        else:
            passed = False
            print ">> IP forward test for Problem3D_CC is failed"
        self.assertTrue(passed)
def IP2Dsurvey(miptrue, sigmadc, flag="PoleDipole", nmax=8):

    if flag == "PoleDipole":
        ntx = xr.size - 2
    elif flag == "DipolePole":
        ntx = xr.size - 2
    elif flag == "DipoleDipole":
        ntx = xr.size - 3
    else:
        raise Exception("Not Implemented")
    xzlocs = getPseudoLocs(xr, ntx, nmax, flag)

    txList = []
    zloc = -cs / 2.0
    for i in range(ntx):
        if flag == "PoleDipole":
            A = np.r_[xr[i], zloc]
            B = np.r_[mesh.vectorCCx.min(), zloc]
            if i < ntx - nmax + 1:
                Mx = xr[i + 1:i + 1 + nmax]
                _, Mz = get_Surface(miptrue, Mx)
                Nx = xr[i + 2:i + 2 + nmax]
                _, Nz = get_Surface(miptrue, Nx)

                M = np.c_[Mx, Mz]
                N = np.c_[Nx, Nz]
            else:
                Mx = xr[i + 1:ntx + 1]
                _, Mz = get_Surface(miptrue, Mx)
                Nx = xr[i + 2:i + 2 + nmax]
                _, Nz = get_Surface(miptrue, Nx)

                M = np.c_[Mx, Mz]
                N = np.c_[Nx, Nz]

        elif flag == "DipolePole":
            A = np.r_[xr[i], zloc]
            B = np.r_[xr[i + 1], zloc]
            if i < ntx - nmax + 1:
                Mx = xr[i + 2:i + 2 + nmax]
                _, Mz = get_Surface(miptrue, Mx)
                Nx = np.ones(nmax) * mesh.vectorCCx.max()
                _, Nz = get_Surface(miptrue, Nx)

                M = np.c_[Mx, Mz]
                N = np.c_[Nx, Nz]

            else:
                Mx = xr[i + 2:ntx + 2]
                _, Mz = get_Surface(miptrue, Mx)
                Nx = np.ones(ntx - i) * mesh.vectorCCx.max()
                _, Nz = get_Surface(miptrue, Nx)
                M = np.c_[Mx, Mz]
                N = np.c_[Nx, Nz]

        elif flag == "DipoleDipole":
            A = np.r_[xr[i], zloc]
            B = np.r_[xr[i + 1], zloc]
            if i < ntx - nmax:
                Mx = xr[i + 2:i + 2 + nmax]
                _, Mz = get_Surface(miptrue, Mx)
                Nx = xr[i + 3:i + 3 + nmax]
                _, Nz = get_Surface(miptrue, Nx)
                M = np.c_[Mx, Mz]
                N = np.c_[Nx, Nz]

            else:
                Mx = xr[i + 2:len(xr) - 1]
                _, Mz = get_Surface(miptrue, Mx)
                Nx = xr[i + 3:len(xr)]
                _, Nz = get_Surface(miptrue, Nx)
                M = np.c_[Mx, Mz]
                N = np.c_[Nx, Nz]

        rx = DC.Rx.Dipole(M, N)
        src = DC.Src.Dipole([rx], A, B)
        txList.append(src)

    survey = IP.Survey(txList)
    problem = IP.Problem3D_CC(mesh,
                              sigma=sigmadc,
                              etaMap=Maps.IdentityMap(mesh))
    problem.pair(survey)

    return survey, xzlocs
예제 #4
0
# cbar_ax = fig.add_axes([0.82, 0.15, 0.05, 0.7])
# cb = plt.colorbar(dat[0], ax=cbar_ax)
# fig.subplots_adjust(right=0.85)
# cb.set_label('rho')
# cbar_ax.axis('off')
# plt.show()

# End model creation =========================================================
# ============================================================================
actmap = Maps.InjectActiveCells(mesh,
                                indActive=actinds,
                                valInactive=np.log(1e8))  # active map
mapping = actmap  # create the mapping
mtrue_ip = mx  # create the true model
survey = IPUtils.SurveyIP.from_dc_to_ip_survey(survey, dim="3D")
problem = IPUtils.Problem3D_CC(mesh, etaMap=actmap,
                               sigma=sigma)  # assign problem
problem.pair(survey)  # pair the survey + prob
problem.Solver = Solver  # assign solver
survey.dpred(mtrue_ip)  # view predicted data
survey.makeSyntheticData(mtrue_ip, std=0.05, force=True)  # make synthetic data
# stop = clock()
# print("timing of making synthetic data:", stop)
# print("starting inversion of forward data")
# # Tikhonov Inversion
# ####################
# start = clock()
# # Initial Model
# m0 = np.median(ln_sigback) * np.ones(mtrue_ip.size)
# # Data Misfit
# dmis = DataMisfit.l2_DataMisfit(survey)
# # Regularization