velocity[100:,100:] = 0.
fc = 15.
sources = [wavefd.GaussSource(125*ds, 75*ds, area, shape,  1., fc)]
dt = wavefd.scalar_maxdt(area, shape, np.max(velocity))
duration = 2.5
maxit = int(duration/dt)
stations = [[75*ds, 125*ds]] # x, z coordinate of the seismometer
snapshots = 3 # every 3 iterations plots one
simulation = wavefd.scalar(velocity, area, dt, maxit, sources, stations, snapshots)

# This part makes an animation using matplotlibs animation API
background = (velocity-4000)*10**-1
fig = mpl.figure(figsize=(8, 6))
mpl.subplots_adjust(right=0.98, left=0.11, hspace=0.5, top=0.93)
mpl.subplot2grid((4, 3), (0,0), colspan=3,rowspan=3)
wavefield = mpl.imshow(np.zeros_like(velocity), extent=area, cmap=mpl.cm.gray_r,
                       vmin=-1000, vmax=1000)
mpl.points(stations, '^b', size=8)
mpl.ylim(area[2:][::-1])
mpl.xlabel('x (km)')
mpl.ylabel('z (km)')
mpl.m2km()
mpl.subplot2grid((4,3), (3,0), colspan=3)
seismogram1, = mpl.plot([],[],'-k')
mpl.xlim(0, duration)
mpl.ylim(-200, 200)
mpl.ylabel('Amplitude')
times = np.linspace(0, dt*maxit, maxit)
# This function updates the plot every few timesteps
def animate(i):
    t, u, seismogram = simulation.next()
    seismogram1.set_data(times[:t+1], seismogram[0][:t+1])
# Get the iterator for the simulation
dt = wavefd.maxdt(area, shape, np.max(pvel))
duration = 3.0
maxit = int(duration/dt)
stations = [[2200+i*dx, 0] for i in range(220)]  # x, z coordinate of the seismometers
snapshot = int(0.004/dt)  # Plot a snapshot of the simulation every 4 miliseconds
print "dt for simulation is ", dt
print "max iteration for simulation is ", maxit
print "duration for simulation is ", duration
simulation = wavefd.elastic_psv(lamb, mu, density, area, dt, maxit, sources,
        stations, snapshot, padding=50, taper=0.01)

# This part makes an animation using matplotlibs animation API
fig = mpl.figure(figsize=(12, 5))
# Start with everything zero and grab the plot so that it can be updated later
mpl.imshow(pvel[::-1], extent=area, alpha=0.25)
wavefield = mpl.imshow(np.zeros(shape), extent=area, vmin=-10**-7, vmax=10**-7, alpha=0.75, cmap=mpl.cm.gray_r)
mpl.points(stations, '.k')
mpl.ylim(area[2:][::-1])
mpl.xlabel('x (km)')
mpl.ylabel('z (km)')
mpl.m2km()
times = np.linspace(0, maxit*dt, maxit)
# the only way for getting the feedback response of the seimograms
global seismograms

# This function updates the plot every few timesteps
def animate(i):
    # Simulation will yield panels corresponding to P and S waves because
    # xz2ps=True
    t, ux, uz, xcomp, zcomp = simulation.next()
Exemplo n.º 3
0
mpl.title('x seismogram')
xseismogram, = mpl.plot([], [], '-k')
mpl.xlim(0, duration)
mpl.ylim(-0.05, 0.05)
mpl.ylabel('Amplitude')
mpl.subplot(3, 1, 2)
mpl.title('z seismogram')
zseismogram, = mpl.plot([], [], '-k')
mpl.xlim(0, duration)
mpl.ylim(-0.05, 0.05)
mpl.ylabel('Amplitude')
ax = mpl.subplot(3, 1, 3)
mpl.title('time: 0.0 s')
wavefield = mpl.imshow(background,
                       extent=area,
                       cmap=mpl.cm.gray_r,
                       vmin=-0.00001,
                       vmax=0.00001)
mpl.points(stations, '^b', size=8)
mpl.text(500000, 20000, 'Crust')
mpl.text(500000, 60000, 'Mantle')
fig.text(0.7, 0.31, 'Seismometer')
mpl.xlim(area[:2])
mpl.ylim(area[2:][::-1])
mpl.xlabel('x (km)')
mpl.ylabel('z (km)')
mpl.m2km()
times = np.linspace(0, dt * maxit, maxit)


# This function updates the plot every few timesteps
fig = mpl.figure(figsize=(12, 5))
mpl.subplot(2, 2, 2)
mpl.title('x component')
xseismogram, = mpl.plot([], [], '-k')
mpl.xlim(0, duration)
mpl.ylim(-10**(-3), 10**(-3))
mpl.subplot(2, 2, 4)
mpl.title('z component')
zseismogram, = mpl.plot([], [], '-k')
mpl.xlim(0, duration)
mpl.ylim(-10**(-3), 10**(-3))
mpl.subplot(1, 2, 1)
# Start with everything zero and grab the plot so that it can be updated later
wavefield = mpl.imshow(np.zeros(shape),
                       extent=area,
                       vmin=-10**-6,
                       vmax=10**-6,
                       cmap=mpl.cm.gray_r)
mpl.points(stations, '^k')
mpl.ylim(area[2:][::-1])
mpl.xlabel('x (km)')
mpl.ylabel('z (km)')
mpl.m2km()
times = np.linspace(0, maxit * dt, maxit)


# This function updates the plot every few timesteps
def animate(i):
    # Simulation will yield panels corresponding to P and S waves because
    # xz2ps=True
    t, p, s, xcomp, zcomp = simulation.next()
# This part makes an animation using matplotlibs animation API
fig = mpl.figure(figsize=(12, 5))
mpl.subplot(2, 2, 2)
mpl.title('x component')
xseismogram, = mpl.plot([], [], '-k')
mpl.xlim(0, duration)
mpl.ylim(-10 ** (-3), 10 ** (-3))
mpl.subplot(2, 2, 4)
mpl.title('z component')
zseismogram, = mpl.plot([], [], '-k')
mpl.xlim(0, duration)
mpl.ylim(-10 ** (-3), 10 ** (-3))
mpl.subplot(1, 2, 1)
# Start with everything zero and grab the plot so that it can be updated later
wavefield = mpl.imshow(np.zeros(shape), extent=area, vmin=-10 ** -6,
                       vmax=10 ** -6, cmap=mpl.cm.gray_r)
mpl.points(stations, '^k')
mpl.ylim(area[2:][::-1])
mpl.xlabel('x (km)')
mpl.ylabel('z (km)')
mpl.m2km()
times = np.linspace(0, maxit * dt, maxit)
# This function updates the plot every few timesteps


def animate(i):
    """
    Simulation will yield panels corresponding to P and S waves because
    xz2ps=True
    """
    t, p, s, xcomp, zcomp = simulation.next()
Exemplo n.º 6
0
# Get the iterator for the simulation
dt = wavefd.maxdt(area, shape, velocity)
duration = 20
maxit = int(duration / dt)
stations = [[50000, 0]]  # x, z coordinate of the seismometer
snapshot = int(0.5 / dt)  # Plot a snapshot of the simulation every 0.5 seconds
simulation = wavefd.elastic_sh(mu, density, area, dt, maxit, sources, stations,
                               snapshot, padding=50, taper=0.01)

# This part makes an animation using matplotlibs animation API
fig = mpl.figure(figsize=(14, 5))
ax = mpl.subplot(1, 2, 2)
mpl.title('Wavefield')
# Start with everything zero and grab the plot so that it can be updated later
wavefield_plt = mpl.imshow(np.zeros(shape), extent=area, vmin=-10 ** (-5),
                           vmax=10 ** (-5), cmap=mpl.cm.gray_r)
mpl.points(stations, '^b')
mpl.xlim(area[:2])
mpl.ylim(area[2:][::-1])
mpl.xlabel('x (km)')
mpl.ylabel('z (km)')
mpl.subplot(1, 2, 1)
seismogram_plt, = mpl.plot([], [], '-k')
mpl.xlim(0, duration)
mpl.ylim(-10 ** (-4), 10 ** (-4))
mpl.xlabel('time (s)')
mpl.ylabel('Amplitude')
times = np.linspace(0, duration, maxit)
# Update the plot everytime the simulation yields

Exemplo n.º 7
0
                                stations, snapshots, padding=70, taper=0.005, xz2ps=True)


# This part makes an animation using matplotlibs animation API
background = 10**-5*((pvel - pvel.min())/pvel.max())
fig = mpl.figure(figsize=(10, 8))
mpl.subplots_adjust(right=0.98, left=0.11, hspace=0.3, top=0.93)
mpl.subplot(2, 1, 1)
mpl.title('x seismogram')
xseismogram, = mpl.plot([],[],'-k')
mpl.xlim(0, duration)
mpl.ylim(-0.05, 0.05)
mpl.ylabel('Amplitude')
ax = mpl.subplot(2, 1, 2)
mpl.title('time: 0.0 s')
wavefield = mpl.imshow(density, extent=area, cmap=mpl.cm.gray_r,
                       vmin=-0.00001, vmax=0.00001)
mpl.points(stations, '^b', size=8)
#mpl.text(500000, 20000, 'Crust')
#mpl.text(500000, 60000, 'Mantle')
fig.text(0.8, 0.5, 'Seismometer')
mpl.xlim(area[:2])
mpl.ylim(area[2:][::-1])
mpl.xlabel('x (km)')
mpl.ylabel('z (km)')
mpl.m2km()
times = np.linspace(0, dt*maxit, maxit)
# This function updates the plot every few timesteps
def animate(i):
    t, p, s, xcomp, zcomp = simulation.next()
    mpl.title('time: %0.1f s' % (times[t]))
    wavefield.set_array((background + p + s)[::-1])
Exemplo n.º 8
0
dt = wavefd.scalar_maxdt(area, shape, np.max(velocity))
duration = 2.5
maxit = int(duration / dt)
stations = [[75 * ds, 125 * ds]]  # x, z coordinate of the seismometer
snapshots = 3  # every 3 iterations plots one
simulation = wavefd.scalar(velocity, area, dt, maxit, sources, stations,
                           snapshots)

# This part makes an animation using matplotlibs animation API
background = (velocity - 4000) * 10**-1
fig = mpl.figure(figsize=(8, 6))
mpl.subplots_adjust(right=0.98, left=0.11, hspace=0.5, top=0.93)
mpl.subplot2grid((4, 3), (0, 0), colspan=3, rowspan=3)
wavefield = mpl.imshow(np.zeros_like(velocity),
                       extent=area,
                       cmap=mpl.cm.gray_r,
                       vmin=-1000,
                       vmax=1000)
mpl.points(stations, '^b', size=8)
mpl.ylim(area[2:][::-1])
mpl.xlabel('x (km)')
mpl.ylabel('z (km)')
mpl.m2km()
mpl.subplot2grid((4, 3), (3, 0), colspan=3)
seismogram1, = mpl.plot([], [], '-k')
mpl.xlim(0, duration)
mpl.ylim(-200, 200)
mpl.ylabel('Amplitude')
times = np.linspace(0, dt * maxit, maxit)
# This function updates the plot every few timesteps
Exemplo n.º 9
0
mpl.subplot2grid((3, 4), (1, 0), colspan=4)  # plot zero-offset traces
traces = utils.matrix2stream(samples.transpose(), header={'delta': dt})
mpl.seismic_image(traces,
                  cmap=mpl.pyplot.cm.jet,
                  aspect='auto',
                  ranges=[0, nx])
mpl.seismic_wiggle(traces, ranges=[0, nx], normalize=True)
mpl.ylabel('twt (s)')
mpl.title("Zero-offset section amplitude",
          fontsize=13,
          family='sans-serif',
          weight='bold')
ax = mpl.subplot2grid((3, 4), (2, 0), colspan=4)  # plot vmodel
mpl.imshow(vmodel,
           extent=[0, nx, nz * ds, 0],
           cmap=mpl.pyplot.cm.bwr,
           aspect='auto',
           origin='upper')
ax.autoscale(False)
mpl.ylabel('depth (m)')
stations = [[i, 0] for i in xrange(0, nx, disc)]
mpl.points(stations, '^k', size=7)  # zero-offset station points
mpl.text(250, 120, '2900 m/s')  # model velocities
mpl.text(450, 315, '2500 m/s')
mpl.text(250, 550, '3500 m/s')
# thickness by lambda/4 2nd axis
ax2 = ax.twiny()
ax2.set_frame_on(True)
ax2.patch.set_visible(False)
ax2.xaxis.set_ticks_position('bottom')
ax2.xaxis.set_label_position('bottom')
mpl.subplots_adjust(right=0.98, left=0.11, hspace=0.3, top=0.93)
mpl.subplot(3, 1, 1)
mpl.title('x seismogram')
xseismogram, = mpl.plot([],[],'-k')
mpl.xlim(0, duration)
mpl.ylim(-0.05, 0.05)
mpl.ylabel('Amplitude')
mpl.subplot(3, 1, 2)
mpl.title('z seismogram')
zseismogram, = mpl.plot([],[],'-k')
mpl.xlim(0, duration)
mpl.ylim(-0.05, 0.05)
mpl.ylabel('Amplitude')
ax = mpl.subplot(3, 1, 3)
mpl.title('time: 0.0 s')
wavefield = mpl.imshow(background, extent=area, cmap=mpl.cm.gray_r,
                       vmin=-0.00001, vmax=0.00001)
mpl.points(stations, '^b', size=8)
mpl.text(500000, 20000, 'Crust')
mpl.text(500000, 60000, 'Mantle')
fig.text(0.7, 0.31, 'Seismometer')
mpl.xlim(area[:2])
mpl.ylim(area[2:][::-1])
mpl.xlabel('x (km)')
mpl.ylabel('z (km)')
mpl.m2km()
times = np.linspace(0, dt*maxit, maxit)
# This function updates the plot every few timesteps
def animate(i):
    t, p, s, xcomp, zcomp = simulation.next()
    mpl.title('time: %0.1f s' % (times[t]))
    wavefield.set_array((background + p + s)[::-1])
mpl.subplots_adjust(right=0.98, left=0.11, hspace=0.3, top=0.93)
mpl.subplot(3, 1, 1)
mpl.title('Seismogram 1')
seismogram1, = mpl.plot([], [], '-k')
mpl.xlim(0, duration)
mpl.ylim(-0.1, 0.1)
mpl.ylabel('Amplitude')
mpl.subplot(3, 1, 2)
mpl.title('Seismogram 2')
seismogram2, = mpl.plot([], [], '-k')
mpl.xlim(0, duration)
mpl.ylim(-0.1, 0.1)
mpl.ylabel('Amplitude')
ax = mpl.subplot(3, 1, 3)
mpl.title('time: 0.0 s')
wavefield = mpl.imshow(np.zeros_like(density), extent=area, cmap=mpl.cm.gray_r,
                       vmin=-0.005, vmax=0.005)
mpl.points(stations, '^b', size=8)
fig.text(0.82, 0.33, 'Seismometer 2')
fig.text(0.16, 0.33, 'Seismometer 1')
mpl.ylim(area[2:][::-1])
mpl.xlabel('x (km)')
mpl.ylabel('z (km)')
mpl.m2km()
times = np.linspace(0, dt * maxit, maxit)
# This function updates the plot every few timesteps
def animate(i):
    t, u, seismogram = simulation.next()
    mpl.title('time: %0.1f s' % (times[t]))
    wavefield.set_array(u[::-1])
    seismogram1.set_data(times[:t + 1], seismogram[0][:t + 1])
    seismogram2.set_data(times[:t + 1], seismogram[1][:t + 1])
Exemplo n.º 12
0
simulation = wavefd.elastic_psv(lamb,
                                mu,
                                density,
                                area,
                                dt,
                                maxit,
                                sources,
                                stations,
                                snapshot,
                                padding=50,
                                taper=0.01)

# This part makes an animation using matplotlibs animation API
fig = mpl.figure(figsize=(12, 5))
# Start with everything zero and grab the plot so that it can be updated later
mpl.imshow(pvel[::-1], extent=area, alpha=0.25)
wavefield = mpl.imshow(np.zeros(shape),
                       extent=area,
                       vmin=-10**-7,
                       vmax=10**-7,
                       alpha=0.75,
                       cmap=mpl.cm.gray_r)
mpl.points(stations, '.k')
mpl.ylim(area[2:][::-1])
mpl.xlabel('x (km)')
mpl.ylabel('z (km)')
mpl.m2km()
times = np.linspace(0, maxit * dt, maxit)
# the only way for getting the feedback response of the seimograms
global seismograms
mpl.title('Seismogram 1')
seismogram1, = mpl.plot([], [], '-k')
mpl.xlim(0, duration)
mpl.ylim(-0.1, 0.1)
mpl.ylabel('Amplitude')
mpl.subplot(3, 1, 2)
mpl.title('Seismogram 2')
seismogram2, = mpl.plot([], [], '-k')
mpl.xlim(0, duration)
mpl.ylim(-0.1, 0.1)
mpl.ylabel('Amplitude')
ax = mpl.subplot(3, 1, 3)
mpl.title('time: 0.0 s')
wavefield = mpl.imshow(np.zeros_like(density),
                       extent=area,
                       cmap=mpl.cm.gray_r,
                       vmin=-0.005,
                       vmax=0.005)
mpl.points(stations, '^b', size=8)
fig.text(0.82, 0.33, 'Seismometer 2')
fig.text(0.16, 0.33, 'Seismometer 1')
mpl.ylim(area[2:][::-1])
mpl.xlabel('x (km)')
mpl.ylabel('z (km)')
mpl.m2km()
times = np.linspace(0, dt * maxit, maxit)


# This function updates the plot every few timesteps
def animate(i):
    t, u, seismogram = simulation.next()
Exemplo n.º 14
0
                               dt,
                               maxit,
                               sources,
                               stations,
                               snapshot,
                               padding=50,
                               taper=0.01)

# This part makes an animation using matplotlibs animation API
fig = mpl.figure(figsize=(14, 5))
ax = mpl.subplot(1, 2, 2)
mpl.title('Wavefield')
# Start with everything zero and grab the plot so that it can be updated later
wavefield_plt = mpl.imshow(np.zeros(shape),
                           extent=area,
                           vmin=-10**(-5),
                           vmax=10**(-5),
                           cmap=mpl.cm.gray_r)
mpl.points(stations, '^b')
mpl.xlim(area[:2])
mpl.ylim(area[2:][::-1])
mpl.xlabel('x (km)')
mpl.ylabel('z (km)')
mpl.subplot(1, 2, 1)
seismogram_plt, = mpl.plot([], [], '-k')
mpl.xlim(0, duration)
mpl.ylim(-10**(-4), 10**(-4))
mpl.xlabel('time (s)')
mpl.ylabel('Amplitude')
times = np.linspace(0, duration, maxit)
# Update the plot everytime the simulation yields
          fontsize=13, family='sans-serif', weight='bold')
rcs = utils.matrix2stream(rc.transpose(), header={'delta': dt})
mpl.seismic_wiggle(rcs, normalize=True, scale=1.5, ranges=[0, nx])  # rc model
wavelet = signal.ricker(255, 1/(2*f*dt))  # create wavelet
samples = signal.filtfilt(wavelet, np.ones(len(wavelet)),
                          rc, axis=0, padlen=len(twt)-2)  # convolve rc*wavelet
mpl.ylabel('twt (s)')
mpl.subplot2grid((3, 4), (1, 0), colspan=4)  # plot zero-offset traces
traces = utils.matrix2stream(samples.transpose(), header={'delta': dt}) 
mpl.seismic_image(traces, cmap=mpl.pyplot.cm.jet, aspect='auto', ranges=[0, nx])
mpl.seismic_wiggle(traces, ranges=[0, nx], normalize=True)
mpl.ylabel('twt (s)')
mpl.title("Zero-offset section amplitude",
          fontsize=13, family='sans-serif', weight='bold')
ax = mpl.subplot2grid((3, 4), (2, 0), colspan=4)  # plot vmodel
mpl.imshow(vmodel, extent=[0, nx, nz*ds, 0],
           cmap=mpl.pyplot.cm.bwr, aspect='auto', origin='upper')
ax.autoscale(False)
mpl.ylabel('depth (m)')
stations = [[i, 0] for i in xrange(0, nx, disc)]
mpl.points(stations, '^k', size=7)  # zero-offset station points
mpl.text(250, 120, '2900 m/s')  # model velocities
mpl.text(450, 315, '2500 m/s')
mpl.text(250, 550, '3500 m/s')
# thickness by lambda/4 2nd axis
ax2 = ax.twiny()
ax2.set_frame_on(True)
ax2.patch.set_visible(False)
ax2.xaxis.set_ticks_position('bottom')
ax2.xaxis.set_label_position('bottom')
ax2.spines['bottom'].set_position(('outward', 20))
def thick_function_thicknessbyres(x):