def test_multilinear2d(par):
    """Create small dataset with several horizontal events and check that output
    contains the events at correct time and correct amplitude
    """
    # Data creation
    v = 1
    t0 = (50, 130)
    theta = (0., 0.)
    amp = (0.6, 1)

    # Create axes
    t, _, x, _ = makeaxis(par)

    # Create data
    d, dwav = linear2d(x, t, v, t0, theta, amp, wav)

    # Assert shape
    assert d.shape[0] == par['nx']
    assert d.shape[1] == par['nt']

    assert dwav.shape[0] == par['nx']
    assert dwav.shape[1] == par['nt']

    # Assert correct position of event
    assert_array_equal(d[:, t0[0]], amp[0] * np.ones(par['nx']))
    assert_array_equal(d[:, t0[1]], amp[1] * np.ones(par['nx']))
def test_linear2d(par):
    """Create small dataset with an horizontal event and check that output
    contains the event at correct time and correct amplitude
    """
    # Data creation
    v = 1
    t0 = 50
    theta = 0.
    amp = 0.6

    # Create axes
    t, _, x, _ = makeaxis(par)

    # Create data
    d, dwav = linear2d(x, t, v, t0, theta, amp, wav)

    # Assert shape
    assert d.shape[0] == par['nx']
    assert d.shape[1] == par['nt']

    assert dwav.shape[0] == par['nx']
    assert dwav.shape[1] == par['nt']

    # Assert correct position of event
    assert_array_equal(d[:, t0], amp * np.ones(par['nx']))
def test_hyperbolic3d(par):
    """Create small dataset with several hyperbolic events and check output
    contains the events at correct time and correct amplitude
    """
    # Data creation
    t0 = 50
    vrms_x = 1.
    vrms_y = 1.
    amp = 0.6

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

    # Create data
    d, dwav = hyperbolic3d(x, y, t, t0, vrms_x, vrms_y, amp, wav)

    #Assert shape
    assert d.shape[0] == par['ny']
    assert d.shape[1] == par['nx']
    assert d.shape[2] == par['nt']

    assert dwav.shape[0] == par['ny']
    assert dwav.shape[1] == par['nx']
    assert dwav.shape[2] == par['nt']

    # Assert correct position of event
    assert_array_equal(d[par['ny'] // 2, par['nx'] // 2, t0], amp)
def test_hyperbolic2d(par):
    """Create small dataset with a hyperbolic event and check that output
    contains the event apex at correct time and correct amplitude
    """
    # Data creation
    t0 = 50
    vrms = 1
    amp = 0.6

    # Create axes
    t, _, x, _ = makeaxis(par)

    # Create data
    d, dwav = hyperbolic2d(x, t, t0, vrms, amp, wav)

    # Assert shape
    assert d.shape[0] == par['nx']
    assert d.shape[1] == par['nt']

    assert dwav.shape[0] == par['nx']
    assert dwav.shape[1] == par['nt']

    # Assert correct position of event
    assert_array_equal(d[par['nx'] // 2, t0], amp)
    assert_array_equal(dwav[par['nx'] // 2, t0], amp)
def test_parabolic2d(par):
    """Create small dataset with a parabolic event and check that output
    contains the event apex at correct time and correct amplitude
    """
    # Data creation
    t0 = 50
    px = 0
    pxx = 1e-1
    amp = 0.6

    # Create axes
    t, _, x, _ = makeaxis(par)

    # Create data
    d, dwav = parabolic2d(x, t, t0, px, pxx, amp, np.ones(1))

    # Assert shape
    assert d.shape[0] == par['nx']
    assert d.shape[1] == par['nt']

    assert dwav.shape[0] == par['nx']
    assert dwav.shape[1] == par['nt']

    # Assert correct position of event
    assert_array_equal(d[par['nx'] // 2, t0], amp)
def test_makeaxis(par):
    """Verify makeaxis creation
    """
    # Create t, x, and y axis
    t, _, x, y = makeaxis(par)

    # Check axis lenght
    assert len(t) == par['nt']
    assert len(x) == par['nx']
    assert len(y) == par['ny']

    # Check axis initial and end values
    assert t[0] == par['ot']
    assert t[-1] == par['ot'] + par['dt'] * (par['nt'] - 1)
    assert x[0] == par['ox']
    assert x[-1] == par['ox'] + par['dx'] * (par['nx'] - 1)
    assert y[0] == par['oy']
    assert y[-1] == par['oy'] + par['dy'] * (par['ny'] - 1)
Example #7
0
t0_m = 0.2
vrms_m = 1100.0
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
Example #8
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)