Beispiel #1
0
def test_get_filter_retrograde(synthetic_data):
    TOL = 0.05
    POLARIZATION = 'retrograde'

    az_retro, n, e, v, fs = synthetic_data
    Sn = stransform(n, Fs=fs, return_time_freq=False)
    Se = stransform(e, Fs=fs)
    Sv = stransform(v, Fs=fs)
    xpr = filt.xpr(az_retro)
    with np.errstate(divide='ignore', invalid='ignore'):
        theta = filt.instantaneous_azimuth(Sv, Sn, Se, POLARIZATION, xpr)
    Sr, St = filt.rotate_NE_RT(Sn, Se, theta)
    NIP = filt.NIP(Sr, Sv, polarization=POLARIZATION, eps=0.04)

    f = filt.get_filter(NIP, POLARIZATION, threshold=0.8, width=0.1)
    Srf = Sr * f
    Svf = Sv * f

    assert abs(Srf[idx_5hz, idx_10sec]) == pytest.approx(0.0, abs=TOL)
    assert abs(Srf[idx_2hz, idx_10sec]) == pytest.approx(0.5, abs=TOL)
    assert abs(Srf[idx_1hz, idx_10sec]) == pytest.approx(0.0, abs=TOL)

    rf = istransform(Sr * f, Fs=fs)
    tf = istransform(St * f, Fs=fs)
    vf = istransform(Sv * f, Fs=fs)

    assert tf.max() == pytest.approx(0.0, abs=TOL)
    assert rf.max() == pytest.approx(0.5, abs=TOL)
    assert vf.max() == pytest.approx(1.0, abs=TOL)
Beispiel #2
0
def test_NIP_retrograde(synthetic_data):
    TOL = 0.05
    POLARIZATION = 'retrograde'

    az_retro, n, e, v, fs = synthetic_data
    Sn = stransform(n, Fs=fs, return_time_freq=False)
    Se = stransform(e, Fs=fs)
    Sv = stransform(v, Fs=fs)
    xpr = filt.xpr(az_retro)
    with np.errstate(divide='ignore', invalid='ignore'):
        theta = filt.instantaneous_azimuth(Sv, Sn, Se, POLARIZATION, xpr)
    Sr, St = filt.rotate_NE_RT(Sn, Se, theta)
    NIP = filt.NIP(Sr, Sv, polarization=POLARIZATION, eps=0.04)

    assert NIP[idx_1hz, idx_10sec] == pytest.approx(-1.0, abs=TOL)
    assert NIP[idx_2hz, idx_10sec] == pytest.approx(1.0, abs=TOL)
    assert NIP[idx_5hz, idx_10sec] == pytest.approx(0.0, abs=TOL)
Beispiel #3
0
def test_scalar_azimuth_prograde(synthetic_data):
    TOL = 1.0  # [degrees]
    POLARIZATION = 'prograde'

    az_retro, n, e, v, fs = synthetic_data
    Sn = stransform(n, Fs=fs, return_time_freq=False)
    Se = stransform(e, Fs=fs)
    Sv = stransform(v, Fs=fs)
    xpr = filt.xpr(az_retro)
    with np.errstate(divide='ignore', invalid='ignore'):
        theta = filt.instantaneous_azimuth(Sv, Sn, Se, POLARIZATION, xpr)
    Sr, St = filt.rotate_NE_RT(Sn, Se, theta)
    NIP = filt.NIP(Sr, Sv, polarization=POLARIZATION, eps=0.04)

    f = filt.get_filter(NIP, POLARIZATION, threshold=0.8, width=0.1)
    Svhat = filt.shift_phase(Sv, POLARIZATION)

    ef = istransform(Se * f, Fs=fs)
    nf = istransform(Sn * f, Fs=fs)
    vfhat = istransform(Svhat * f, Fs=fs)

    az = filt.scalar_azimuth(ef, nf, vfhat)

    assert az == pytest.approx(az_retro + 90, abs=TOL)