In [1]:
from SimPEG import *
import simpegDCIP as DC
%pylab inline
from pymatsolver import MumpsSolver
In [2]:
cs = 12.5
nc = 500/cs+1
hx = [(cs,7, -1.3),(cs,nc),(cs,7, 1.3)]
hy = [(cs,7, -1.3),(cs,int(nc/2+1)),(cs,7, 1.3)]
hz = [(cs,7, -1.3),(cs,int(nc/2+1))]
In [3]:
mesh = Mesh.TensorMesh([hx, hy, hz], 'CCN')
print mesh
In [4]:
sighalf = 1e-2
sigma = np.ones(mesh.nC)*sighalf
p0 = np.r_[-50., 50., -50.]
p1 = np.r_[ 50.,-50., -150.]
blk_ind = Utils.ModelBuilder.getIndecesBlock(p0, p1, mesh.gridCC)
sigma[blk_ind] = 1e-3
In [5]:
nElecs = 21
x_temp = np.linspace(-250, 250, nElecs)
aSpacing = x_temp[1]-x_temp[0]
y_temp = 0.
xyz = Utils.ndgrid(x_temp, np.r_[y_temp], np.r_[0.])
In [6]:
srcList = DC.Examples.WennerArray.getSrcList(nElecs,aSpacing)
survey = DC.SurveyDC(srcList)
print len(survey.srcList)
In [7]:
fig, ax = plt.subplots(1,1, figsize = (6.5,5))
indz = 22
dat = mesh.plotSlice(sigma, grid=True, ax = ax, ind=indz)
ax.set_xlim(-300, 300)
ax.set_ylim(-300, 300)
cb = plt.colorbar(dat[0])
ax.set_title('Depth at '+str(mesh.vectorCCz[indz])+' m')
txLocs = np.array([[tx.loc[0][0], tx.loc[1][0]] for tx in survey.srcList]).flatten()
ax.plot(txLocs, txLocs*0, 'w.', ms = 3)
Out[7]:
In [9]:
expmap = Maps.ExpMap(mesh)
m2to3 = Maps.Map2Dto3D(mesh,normal='Y')
imap = Maps.IdentityMap(mesh)
problem = DC.ProblemDC_CC(mesh, mapping= imap )
problem.Solver = MumpsSolver
problem.pair(survey)
In [10]:
datasyn = survey.dpred(sighalf*np.ones(mesh.nC))
survey.makeSyntheticData(sigma,std=0.01,force=True)
plot(np.log(np.c_[survey.dobs,datasyn]))
Out[10]:
In [11]:
problem.mapping = expmap * m2to3
In [12]:
dmis = DataMisfit.l2_DataMisfit(survey)
reg = Regularization.Tikhonov(mesh,mapping=m2to3)
opt = Optimization.InexactGaussNewton(maxIter=7,tolX=1e-15)
opt.remember('xc')
invProb = InvProblem.BaseInvProblem(dmis, reg, opt)
beta = Directives.BetaEstimate_ByEig(beta0_ratio=1e1)
betaSched = Directives.BetaSchedule(coolingFactor=5, coolingRate=2)
inv = Inversion.BaseInversion(invProb, directiveList=[beta,betaSched])
In [13]:
m0 = np.log(np.ones(problem.mapping.nP)*sighalf)
mopt = inv.run(m0)
In [14]:
colorbar(mesh.plotSlice(np.log10(expmap * m2to3 * mopt), normal='Y', ind=indz, grid=True)[0])
Out[14]:
In [15]:
dpred = survey.dpred(mopt)
In [16]:
plot(np.c_[dpred,survey.dobs])
Out[16]:
In [16]:
In [ ]: