Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40,458 changes: 20,223 additions & 20,235 deletions notebooks/SeismicFWD.ipynb

Large diffs are not rendered by default.

12,283 changes: 12,283 additions & 0 deletions notebooks/SeismicRefraction_model1.ipynb

Large diffs are not rendered by default.

8,144 changes: 8,144 additions & 0 deletions notebooks/SeismicRefraction_model2.ipynb

Large diffs are not rendered by default.

10,514 changes: 10,514 additions & 0 deletions notebooks/SeismicRefraction_model3.ipynb

Large diffs are not rendered by default.

96 changes: 49 additions & 47 deletions simpegseis/SeisAcousticTime.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import matplotlib.pyplot as plt
from time import clock

class AcousticTx(Survey.BaseTx):
class AcousticSrc(Survey.BaseSrc):


def __init__(self, loc, time, rxList, **kwargs):
Expand Down Expand Up @@ -45,9 +45,9 @@ def Wave(self, tInd):

def getq(self, mesh):

txind = Utils.closestPoints(mesh, self.loc, gridLoc='CC')
srcind = Utils.closestPoints(mesh, self.loc, gridLoc='CC')
q = sdiag(1/mesh.vol)*np.zeros(mesh.nC)
q[txind] = 1.
q[srcind] = 1.

return q

Expand Down Expand Up @@ -80,15 +80,15 @@ class SurveyAcoustic(Survey.BaseSurvey):

"""

def __init__(self, txList,**kwargs):
self.txList = txList
def __init__(self, srcList,**kwargs):
self.srcList = srcList
Survey.BaseSurvey.__init__(self, **kwargs)

def projectFields(self, u):
data = []

for i, tx in enumerate(self.txList):
Proj = tx.rxList[0].getP(self.prob.mesh)
for i, src in enumerate(self.srcList):
Proj = src.rxList[0].getP(self.prob.mesh)
data.append(Proj*u[i])
return data

Expand Down Expand Up @@ -179,7 +179,8 @@ def fields(self, v):

Grad = self.mesh.cellGrad
Div = self.mesh.faceDiv
AvF2CC = self.mesh.aveF2CC
# Be careful about averaging operator
AvF2CC = self.mesh.dim*self.mesh.aveF2CC
rho = 0.27*np.ones(self.mesh.nC)
mu = rho*v**2
DSig = sdiag(self.sig)
Expand All @@ -201,20 +202,20 @@ def fields(self, v):
if self.storefield==True:
P = []
#TODO: parallize in terms of sources
ntx = len(self.survey.txList)
for itx, tx in enumerate(self.survey.txList):
print (" Tx at (%7.2f, %7.2f): %4i/%4i")%(tx.loc[0], tx.loc[0], itx+1, ntx)
nsrc = len(self.survey.srcList)
for isrc, src in enumerate(self.survey.srcList):
print (" Src at (%7.2f, %7.2f): %4i/%4i")%(src.loc[0], src.loc[0], isrc+1, nsrc)
pn = np.zeros(self.mesh.nC)
p0 = np.zeros_like(pn)
un = np.zeros(self.mesh.nF)
u0 = np.zeros_like(un)
time = tx.time
dt = tx.dt
time = src.time
dt = src.dt
p = np.zeros((self.mesh.nC, time.size))
q = tx.getq(self.mesh)
q = src.getq(self.mesh)
for i in range(time.size-1):
sn = tx.Wave(i+1)
s0 = tx.Wave(i)
sn = src.Wave(i+1)
s0 = src.Wave(i)
pn = p0-dt*DSig*p0+Drhoi*dt*(Div*un+(sn-s0)/dt*q)
p0 = pn.copy()
# un = u0 - dt*sdiag(AvF2CC.T*self.sig)*u0 + dt*MfmuiI*Grad*p0
Expand All @@ -232,21 +233,21 @@ def fields(self, v):

Data = []

ntx = len(self.survey.txList)
for itx, tx in enumerate(self.survey.txList):
print (" Tx at (%7.2f, %7.2f): %4i/%4i")%(tx.loc[0], tx.loc[0], itx+1, ntx)
nsrc = len(self.survey.srcList)
for isrc, src in enumerate(self.survey.srcList):
print (" Src at (%7.2f, %7.2f): %4i/%4i")%(src.loc[0], src.loc[0], isrc+1, nsrc)
pn = np.zeros(self.mesh.nC)
p0 = np.zeros_like(pn)
un = np.zeros(self.mesh.nF)
u0 = np.zeros_like(un)
time = tx.time
dt = tx.dt
data = np.zeros((time.size, tx.nD))
q = tx.getq(self.mesh)
Proj = tx.rxList[0].getP(self.mesh)
time = src.time
dt = src.dt
data = np.zeros((time.size, src.nD))
q = src.getq(self.mesh)
Proj = src.rxList[0].getP(self.mesh)
for i in range(time.size-1):
sn = tx.Wave(i+1)
s0 = tx.Wave(i)
sn = src.Wave(i+1)
s0 = src.Wave(i)
pn = p0-dt*DSig*p0+Drhoi*dt*(Div*un+(sn-s0)/dt*q)
p0 = pn.copy()
# un = u0 - dt*sdiag(AvF2CC.T*self.sig)*u0 + dt*MfmuiI*Grad*p0
Expand Down Expand Up @@ -342,7 +343,8 @@ def fields(self, v):
self.mesh.setCellGradBC([['dirichlet', 'neumann'], ['dirichlet', 'neumann']])

Grad = self.mesh.cellGrad
AvF2CC = self.mesh.aveF2CC
# Be careful about averaging operator
AvF2CC = self.mesh.dim*self.mesh.aveF2CC
AvF2CCv = self.mesh.aveF2CCV
rho = 0.27*np.ones(self.mesh.nC)
mu = rho*v**2
Expand Down Expand Up @@ -370,22 +372,22 @@ def fields(self, v):
if self.storefield==True:
Phi = []
#TODO: parallize in terms of sources
ntx = len(self.survey.txList)
for itx, tx in enumerate(self.survey.txList):
print (" Tx at (%7.2f, %7.2f): %4i/%4i")%(tx.loc[0], tx.loc[0], itx+1, ntx)
phi = np.zeros((self.mesh.nC, tx.time.size))
nsrc = len(self.survey.srcList)
for isrc, src in enumerate(self.survey.srcList):
print (" Src at (%7.2f, %7.2f): %4i/%4i")%(src.loc[0], src.loc[0], isrc+1, nsrc)
phi = np.zeros((self.mesh.nC, src.time.size))
phin = np.zeros(self.mesh.nC*2)
phi0 = np.zeros_like(phin)
un = np.zeros(self.mesh.nF)
u0 = np.zeros_like(un)
time = tx.time
dt = tx.dt
q = tx.getq(self.mesh)
time = src.time
dt = src.dt
q = src.getq(self.mesh)
qvec = np.r_[q, q]*1/2

for i in range(time.size-1):
sn = tx.Wave(i+1)
s0 = tx.Wave(i)
sn = src.Wave(i+1)
s0 = src.Wave(i)
phin = phi0-dt*(Msigcc*phi0)+dt*MrhoccI*(1/dt*(sn-s0)*qvec+Divvec*un)
phi0 = phin.copy()
un = u0 - dt*Msigf*u0 + dt*MmuifvecI*Grad*(Ivec*phi0)
Expand All @@ -401,22 +403,22 @@ def fields(self, v):

Data = []

ntx = len(self.survey.txList)
for itx, tx in enumerate(self.survey.txList):
print (" Tx at (%7.2f, %7.2f): %4i/%4i")%(tx.loc[0], tx.loc[0], itx+1, ntx)
nsrc = len(self.survey.srcList)
for isrc, src in enumerate(self.survey.srcList):
print (" Src at (%7.2f, %7.2f): %4i/%4i")%(src.loc[0], src.loc[0], isrc+1, nsrc)
phi = np.zeros((mesh.nC, time.size))
phin = np.zeros(mesh.nC*2)
phi0 = np.zeros_like(phin)
un = np.zeros(mesh.nF)
u0 = np.zeros_like(un)
time = tx.time
dt = tx.dt
time = src.time
dt = src.dt
p = np.zeros((self.mesh.nC, time.size))
q = tx.getq(self.mesh)
q = src.getq(self.mesh)
qvec = np.r_[q, q]*1/2
for i in range(time.size-1):
sn = tx.Wave(i+1)
s0 = tx.Wave(i)
sn = src.Wave(i+1)
s0 = src.Wave(i)
phin = phi0-dt*(Msigcc*phi0)+dt*MrhoccI*(1/dt*(sn-s0)*qvec+Divvec*un)
phi0 = phin.copy()
un = u0 - dt*Msigf*u0 + dt*MmuifvecI*Grad*(Ivec*phi0)
Expand All @@ -436,9 +438,9 @@ def fields(self, v):
dt = time[1]-time[0]
options={'tlag':0.0025, 'fmain':400}
rx = AcousticRx(np.vstack((np.r_[0, 1], np.r_[0, 1])))
tx = AcousticTx(np.r_[0, 1], time, [rx], **options)
survey = SurveyAcoustic([tx])
wave = tx.RickerWavelet()
src = AcousticSrc(np.r_[0, 1], time, [rx], **options)
survey = SurveyAcoustic([src])
wave = src.RickerWavelet()
cs = 0.5
hx = np.ones(150)*cs
hy = np.ones(150)*cs
Expand Down
55 changes: 55 additions & 0 deletions simpegseis/UtilsSeis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import numpy as np
import matplotlib.pyplot as plt

def clipsign (value, clip):
clipthese = abs(value) > clip
return value * ~clipthese + np.sign(value)*clip*clipthese

def wiggle (traces, skipt=1,scale=1.,lwidth=.1,offsets=None,redvel=0., manthifts=None, tshift=0.,sampr=1.,clip=10., dx=1., color='black',fill=True,line=True, ax=None):

ns = traces.shape[1]
ntr = traces.shape[0]
t = np.arange(ns)*sampr
timereduce = lambda offsets, redvel, shift: [float(offset) / redvel + shift for offset in offsets]

if (offsets is not None):
shifts = timereduce(offsets, redvel, tshift)
elif (manthifts is not None):
shifts = manthifts
else:
shifts = np.zeros((ntr,))

for i in range(0, ntr, skipt):
trace = traces[i].copy()
trace[0] = 0
trace[-1] = 0

if ax == None:
if (line):
plt.plot(i*dx + clipsign(trace / scale, clip), t - shifts[i], color=color, linewidth=lwidth)
if (fill):
for j in range(ns):
if (trace[j] < 0):
trace[j] = 0
plt.fill(i*dx + clipsign(trace / scale, clip), t - shifts[i], color=color, linewidth=0)
else:
if (line):
ax.plot(i*dx + clipsign(trace / scale, clip), t - shifts[i], color=color, linewidth=lwidth)
if (fill):
for j in range(ns):
if (trace[j] < 0):
trace[j] = 0
ax.fill(i*dx + clipsign(trace / scale, clip), t - shifts[i], color=color, linewidth=0)

def PrimaryWave(x, velocity, tinterp):
return tinterp + 1./velocity*x

def ReflectedWave(x, velocity, tinterp):
time = np.sqrt(x**2/velocity**2+tinterp**2)
return time






1 change: 1 addition & 0 deletions simpegseis/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from SeisAcousticTime import *
from UtilsSeis import *