In [1]:
import numpy as np
data_directory = "../testDataIP/"
import matplotlib.pyplot as plt
In [2]:
time_gates = "30:50,50:70,70:100,100:130,130:170,170:210,210:260,260:320,320:390,390:470,470:560,560:660,660:770,770:890"
data = "0.780 0.626 0.522 0.456 0.401 0.347 0.309 0.273 0.236 0.208 0.180 0.155 0.135 0.124"
Vp = 24.388
time_gates = np.array([np.array(gate.split(":"), dtype=float) for gate in time_gates.split(',')])
data = np.array(data.split(), dtype=float)
times = np.sqrt(time_gates[:,0] * time_gates[:,1]) * 1e-3
In [3]:
from simpegEM1D import DigFilter
def ColeColeSeigel(f, sigmaInf, eta, tau, c):
w = 2*np.pi*f
return eta/(1 + (1j*w*tau)**c)
In [4]:
wt, tbase, omega_int = DigFilter.setFrequency(times)
frequency = omega_int / (2*np.pi)
siginf = 1.
sigma = ColeColeSeigel(frequency, siginf, 0.06, 0.06, 0.6)
sigTCole, _ = DigFilter.transFilt(sigma, wt, tbase, omega_int, times, tol=1e-12)
In [5]:
plt.loglog(times*1e3, data/Vp * 1e3, '.-')
plt.loglog(times*1e3, sigTCole * 1e3, '.-')
plt.xlabel("time (ms)")
plt.ylabel("Voltage (mV/V)")
Out[5]:
In [21]:
from simpegEMIP.StretchedExponential import SEInvProblem, SESurvey
from SimPEG import *
def fit_with_se(time, dobs, eta0=0.01, tau0=0.1, c0=0.5):
siginf = 1.
wires = Maps.Wires(('eta', 1), ('tau', 1), ('c', 1))
taumap = Maps.ExpMap(nP=1)*wires.tau
etamap = Maps.ExpMap(nP=1)*wires.eta
cmap = Maps.ExpMap(nP=1)*wires.c
survey = SESurvey()
survey.dobs = dobs
m1D = Mesh.TensorMesh([np.ones(3)])
prob = SEInvProblem(m1D, etaMap = etamap, tauMap = taumap, cMap=cmap)
prob.time = time
prob.pair(survey)
eta0 = dobs[1]
m0 = np.log(np.r_[eta0, tau0, c0])
perc = 0.05
dmisfitpeta = DataMisfit.l2_DataMisfit(survey)
dmisfitpeta.W = 1/(abs(survey.dobs)*perc)
reg = Regularization.Simple(m1D)
opt = Optimization.ProjectedGNCG(maxIter = 20)
invProb = InvProblem.BaseInvProblem(dmisfitpeta, reg, opt)
target = Directives.TargetMisfit()
betaSch = Directives.BetaSchedule(coolingFactor=1, coolingRate=1)
opt.upper = np.log(np.r_[1., 10., 1.])
opt.lower = np.log(np.r_[1e-5, 0.001, 1e-2])
invProb.beta=0.
inv = Inversion.BaseInversion(invProb, directiveList=[target])
# reg.mref = 0.*m0
prob.counter = opt.counter = Utils.Counter()
opt.LSshorten = 0.5
opt.remember('xc')
opt.tolX = 1e-20
opt.tolF = 1e-20
opt.tolG = 1e-20
opt.eps = 1e-20
mopt = inv.run(m0)
return np.exp(mopt), survey.dobs, invProb.dpred
mopt, dobs, dpred = fit_with_se(times, data/Vp)
In [29]:
plt.semilogx(times*1e3, dobs * 1e3, '-')
plt.semilogx(times*1e3, dpred * 1e3, 'x')
plt.xlabel("time (ms)")
plt.ylabel("Voltage (mV/V)")
plt.text(
40, 6, ("eta: %.1e mV/V, tau: %.1e s, c: %.1e") % (mopt[0]*1e3, mopt[1], mopt[2]),
fontsize=14
)
Out[29]:
In [23]:
current = np.loadtxt(data_directory+"P0-R110-In.xyz")
dt = 1./150.
plt.plot(current[:,0]*dt, current[:,1])
Out[23]:
In [24]:
plt.semilogx((current[150:,0]*dt-1)*1e3, current[150:,1])
plt.xlabel("Time (ms)")
plt.ylabel("Current (mA)")
Out[24]:
In [25]:
plt.semilogx(current[:150,0]*dt*1e3, current[:150,1])
plt.xlabel("Time (s)")
plt.ylabel("Current (mA)")
Out[25]: