In [1]:
import toolbox
from IPython.display import HTML
import matplotlib.pyplot as pylab

convolution of a wavelet

Remember that the convolutional model states that

$$Y(t) = S(t) * E(t) * R(t) + N(t)$$

where

  • Y(t) = recorded signal
  • E(t) = earth response
  • S(t) = source wavelet
  • R(t) = reciever response
  • N(t) = some noise

So what actually is convolution?


In [73]:
HTML('<iframe src=http://en.wikipedia.org/wiki/Convolution#Definition width=1000 height=240</iframe>')


Out[73]:

In [74]:
%pylab tk
x = np.linspace(start=0, stop=1, num=500)
y1 = np.zeros(500)
y1[200:300] = 1.0
y2 = np.zeros(500)
y2[:50] = 0.5

y3 = np.zeros(500)
y3[225:275] = 0.5
y4 = np.convolve(y1, y3, mode='same')

roll = 0
loc = 25

def key_event(e):
    global roll, y2, loc
    if e.key == "right":
        roll = 10
    elif e.key == "left":
        roll= -10
    else:
        return
    
    loc += roll
    
    y2 = np.roll(y2, roll)
    
    
    
    ax.cla()
    ax.plot(x, y2, 'r')
    ax.plot(x, y1, 'b')
    ax.fill_between(x, 0, y2, where=(y1 != 0) & (y2 != 0))
    ax.set_ylim(-0.5, 2)
    ax1.cla()
    ax1.plot(x[:loc], y4[:loc])
    ax1.set_xlim(0, 1)
    ax1.set_ylim(-1, 50)
    fig.canvas.draw()

fig = plt.figure()
fig.canvas.mpl_connect('key_press_event', key_event)
ax = fig.add_subplot(211)
ax.plot(x, y1, 'b')
ax.plot(x, y2, 'r')
ax.set_ylim(-0.5, 2)
ax1 = fig.add_subplot(212)
plt.show()


Populating the interactive namespace from numpy and matplotlib
WARNING: pylab import has clobbered these variables: ['roll']
`%matplotlib` prevents importing * from pylab and numpy

In [3]:
%pylab inline

pylab.rcParams['figure.figsize'] = (10.0, 8.0)
wavelet = toolbox.ricker(60)
plot(wavelet)


Populating the interactive namespace from numpy and matplotlib
WARNING: pylab import has clobbered these variables: ['pylab']
`%matplotlib` prevents importing * from pylab and numpy
Out[3]:
[<matplotlib.lines.Line2D at 0x7f34cd9ea550>]

In [75]:
x = np.linspace(start=0, stop=1, num=1000)
y1 = np.zeros(1000)
y1[200] = -0.5
y1[250] = 0.3
y1[400] = 0.1
noise = np.random.normal(0.0, 1e-2, size=(1000))
y1 += noise
y2 = np.zeros(1000)
y2[:wavelet.size] = wavelet

y3 = y2.copy()
y3 = np.roll(y3, 500- wavelet.size/2 -5)
y4 = np.convolve(y1, y3, mode='same')

roll = 0
loc = 25

def key_event(e):
    global roll, y2, loc
    if e.key == "right":
        roll = 10
    elif e.key == "left":
        roll= -10
    else:
        return
    
    loc += roll
    
    y2 = np.roll(y2, roll)
    
    
    
    ax.cla()
    ax.plot(x, y2, 'r')
    ax.plot(x, y1, 'b')
    ax.fill_between(x, 0, y1, where=(y1 != 0) & (y2 != 0))
    ax.set_ylim(-1, 1)
    ax1.cla()
    ax1.plot(x[:loc], y4[:loc])
    ax1.set_xlim(0, 1)
    ax1.set_ylim(-1, 1)
    fig.canvas.draw()

fig = plt.figure()
fig.canvas.mpl_connect('key_press_event', key_event)
ax = fig.add_subplot(211)
ax.plot(x, y1, 'b')
ax.plot(x, y2, 'r')
ax.set_ylim(-1, 1)
ax1 = fig.add_subplot(212)
plt.show()

In [ ]: