Exemplo n.º 1
0
def test_despike2():
    dt = 0.001
    t = np.arange(1000) * dt
    y = np.sin(2 * np.pi * 5 * t)
    y[400:500] = 0.0
    y[450] = 0.3
    y1 = np.concatenate((y[:450], y[451:]))
    pv = np.zeros(1000, bool)
    pv[450] = True
    desp = dsp.despike(y, 15)
    assert np.all(desp.x == y1)
    assert np.all(desp.pv == pv)

    desp = dsp.despike(y, 15, threshold_value=0.29)
    assert np.all(desp.x == y1)
    assert np.all(desp.pv == pv)

    desp = dsp.despike(y, 15, threshold_value=0.31)
    assert np.all(desp.x == y)
    pv = np.zeros(1000, bool)
    assert np.all(desp.pv == pv)

    y[450] = 0.05
    desp = dsp.despike(y, 15, threshold_value=0.051)
    assert np.all(desp.x == y)
    assert np.all(desp.pv == pv)
Exemplo n.º 2
0
def test_despike3():
    # tests the sweep_out_priors feature:
    a = np.ones(1500)
    a[75:100] = 5.0
    a[115:125] = 5.0
    a[575:600] = 5.0
    desp = dsp.despike(a, 35)
    assert desp.niter < 5
    pv = np.zeros(1500)
    pv[75:100] = True
    pv[115:125] = True
    pv[575:600] = True
    assert (desp.pv == pv).all()
Exemplo n.º 3
0
def test_despike1():
    x = np.arange(100.0)
    x[45] = 4.5
    x[0] = -20
    x[-1] = 110
    s = dsp.despike(x, 9, sigma=4)
    pv = np.zeros(x.shape, bool)
    pv[0] = True
    pv[45] = True
    pv[-1] = True
    assert (s.pv == pv).all()
    assert (s.x == x[~pv]).all()
    assert_raises(ValueError, dsp.despike, np.ones((5, 5)), 3)
Exemplo n.º 4
0
def test_despike4():
    # tests the sweep_out_nexts feature:
    a = np.ones(1500)
    a[75:100] = 5.0
    a[115:125] = 5.0
    a[575:600] = 5.0
    desp = dsp.despike(a, 35, exclude_point="last")
    assert desp.niter < 5

    pv = np.zeros(1500)
    pv[75:100] = True
    pv[115:125] = True
    pv[575:600] = True
    assert (desp.pv == pv).all()
    assert desp.niter < 5