示例#1
0
t0 = np.arange(nt0)*dt0
thetamin, thetamax = 0, 40
theta = np.linspace(thetamin, thetamax, ntheta)

# Elastic property profiles
vp = 1200 + np.arange(nt0) + filtfilt(np.ones(5)/5., 1, np.random.normal(0, 80, nt0))
vs = 600 + vp/2 + filtfilt(np.ones(5)/5., 1, np.random.normal(0, 20, nt0))
rho = 1000 + vp + filtfilt(np.ones(5)/5., 1, np.random.normal(0, 30, nt0))
vp[201:] += 500
vs[201:] += 200
rho[201:] += 100

# Wavelet
ntwav = 41
wavoff = 10
wav, twav, wavc = ricker(t0[:ntwav//2+1], 20)
wav_phase = np.hstack((wav[wavoff:], np.zeros(wavoff)))

# vs/vp profile
vsvp = 0.5
vsvp_z = np.linspace(0.4, 0.6, nt0)

# Model
m = np.stack((np.log(vp), np.log(vs), np.log(rho)), axis=1)

fig, axs = plt.subplots(1, 3, figsize=(13, 7), sharey=True)
axs[0].plot(vp, t0, 'k')
axs[0].set_title('Vp')
axs[0].set_ylabel(r'$t(s)$')
axs[0].invert_yaxis()
axs[0].grid()
示例#2
0
文件: plot_mdc.py 项目: geirev/pylops
amp_m = 1.0

t0_G = (0.2, 0.5, 0.7)
vrms_G = (1200., 1500., 2000.)
amp_G = (1., 0.6, 0.5)

# Taper
tap = taper3d(par['nt'], (par['ny'], par['nx']), (5, 5),
              tapertype='hanning',
              plotflag=False)

# Create axis
t, t2, x, y = makeaxis(par)

# Create wavelet
wav = ricker(t[:41], f0=par['f0'], plotflag=False)[0]

# Generate model
m, mwav = hyperbolic2d(x, t, t0_m, vrms_m, amp_m, wav)

# Generate operator
G, Gwav = np.zeros((par['ny'], par['nx'], par['nt'])), \
          np.zeros((par['ny'], par['nx'], par['nt']))
for iy, y0 in enumerate(y):
    G[iy], Gwav[iy] = hyperbolic2d(x - y0, t, t0_G, vrms_G, amp_G, wav)

G, Gwav = G * tap, Gwav * tap

# Add negative part to data and model
m = np.concatenate((np.zeros((par['nx'], par['nt'] - 1)), m), axis=-1)
mwav = np.concatenate((np.zeros((par['nx'], par['nt'] - 1)), mwav), axis=-1)
示例#3
0
def test_MDC_1virtualsource(par):
    """Dot-test and inversion for MDC operator of 1 virtual source
    """
    if par['twosided']:
        par['nt2'] = 2 * par['nt'] - 1
    else:
        par['nt2'] = par['nt']
    v = 1500
    t0_m = 0.2
    theta_m = 0
    amp_m = 1.

    t0_G = (0.1, 0.2, 0.3)
    theta_G = (0, 0, 0)
    phi_G = (0, 0, 0)
    amp_G = (1., 0.6, 2.)

    # Create axis
    t, _, x, y = makeaxis(par)

    # Create wavelet
    wav = ricker(t[:41], f0=par['f0'], plotflag=False)[0]

    # Generate model
    _, mwav = linear2d(x, t, v, t0_m, theta_m, amp_m, wav)
    # Generate operator
    _, Gwav = linear3d(x, y, t, v, t0_G, theta_G, phi_G, amp_G, wav)

    # Add negative part to data and model
    if par['twosided']:
        mwav = np.concatenate((np.zeros((par['nx'], par['nt'] - 1)), mwav),
                              axis=-1)
        Gwav = np.concatenate((np.zeros(
            (par['ny'], par['nx'], par['nt'] - 1)), Gwav),
                              axis=-1)

    # Define MDC linear operator
    Gwav_fft = np.fft.fft(Gwav, par['nt2'], axis=-1)
    Gwav_fft = Gwav_fft[..., :par['nfmax']]

    MDCop = MDC(Gwav_fft,
                nt=par['nt2'],
                nv=1,
                dt=par['dt'],
                dr=par['dx'],
                twosided=par['twosided'],
                dtype='float32')
    dottest(MDCop, par['nt2'] * par['ny'], par['nt2'] * par['nx'])

    # Create data
    d = MDCop * mwav.flatten()
    d = d.reshape(par['ny'], par['nt2'])

    # Apply mdd function
    minv = MDD(Gwav[:, :, par['nt'] - 1:] if par['twosided'] else Gwav,
               d[:, par['nt'] - 1:] if par['twosided'] else d,
               dt=par['dt'],
               dr=par['dx'],
               nfmax=par['nfmax'],
               twosided=par['twosided'],
               adjoint=False,
               psf=False,
               dtype='complex64',
               dottest=False,
               **dict(damp=1e-10, iter_lim=50, show=1))
    assert_array_almost_equal(mwav, minv, decimal=2)
示例#4
0
from lops.utils.wavelets import ricker

plt.close('all')

###############################################################################
# We will start by creating a zero signal of lenght :math:`nt` and we will place a
# unitary spike at its center. We also create our filter to be applied by means of
# :py:class:`lops.signalprocessing.Convolve1D` operator. Following the seismic example
# mentioned above, the filter is a `Ricker wavelet <http://subsurfwiki.org/wiki/Ricker_wavelet>`_
# with dominant frequency :math:`f_0 = 30 Hz`.
nt = 1001
dt = 0.004
t = np.arange(nt) * dt
x = np.zeros(nt)
x[int(nt / 2)] = 1
h, th, hcenter = ricker(t[:101], f0=30)

Cop = lops.signalprocessing.Convolve1D(nt,
                                       h=h,
                                       offset=hcenter,
                                       dtype='float32')
y = Cop * x

xinv = Cop / y

fig, ax = plt.subplots(1, 1, figsize=(10, 3))
ax.plot(t, x, 'k', lw=2, label=r'$x$')
ax.plot(t, y, 'r', lw=2, label=r'$y=Ax$')
ax.plot(t, xinv, '--g', lw=2, label=r'$x_{ext}$')
ax.set_title('Convolve in 1st direction', fontsize=14, fontweight='bold')
ax.legend()
示例#5
0
# 2d model
inputfile = 'testdata/avo/poststack_model.npz'
model = np.load(inputfile)
x, z, m2d = model['x'], model['z'], model['model']
nx, nz = len(x), len(z)

nt02d = nz
t02d = np.arange(nt02d) * dt0

# Background model
mback2d = filtfilt(np.ones(nsmooth) / float(nsmooth), 1, m2d, axis=0)
mback2d = filtfilt(np.ones(nsmooth) / float(nsmooth), 1, mback2d, axis=1)

# Wavelet
wav = ricker(t0[:ntwav//2+1], 20)[0]


par1 = {'explicit': True, 'epsR': None,
        'epsI': None, 'simultaneous': False} # explicit operator, unregularized
par2 = {'explicit': True, 'epsR': 1e-4,
        'epsI': 1e-6, 'simultaneous': False} # explicit operator, regularized
par3 = {'explicit': True, 'epsR': None,
        'epsI': None, 'simultaneous': True} # explicit operator, unregularized, simultaneous
par4 = {'explicit': True, 'epsR': 1e-4,
        'epsI': 1e-6, 'simultaneous': True} # explicit operator, regularized, simultaneous
par5 = {'explicit': False, 'epsR': None,
        'epsI': None, 'simultaneous': False} # linear operator, unregularized
par6 = {'explicit': False, 'epsR': 1e-4,
        'epsI': 1e-6, 'simultaneous': False} # linear operator, regularized
par7 = {'explicit': False, 'epsR': None,
import pytest

import numpy as np
from numpy.testing import assert_array_equal

from lops.utils.wavelets import ricker
from lops.utils.seismicevents import makeaxis, linear2d, linear3d
from lops.utils.seismicevents import parabolic2d, hyperbolic2d, hyperbolic3d

# Wavelet
wav = ricker(np.arange(41) * 0.004, f0=10)[0]

par1 = {
    'ot': 0,
    'dt': 1,
    'nt': 300,
    'ox': 0,
    'dx': 2,
    'nx': 200,
    'oy': 0,
    'dy': 2,
    'ny': 100
}  # even axis

par2 = {
    'ot': 0,
    'dt': 1,
    'nt': 301,
    'ox': -200,
    'dx': 2,
    'nx': 201,