Пример #1
0
def test_basic3D():
    x = np.linspace(-100, 100, 1000)

    phi_peak = 10 * np.imag(1 / (25 - x - 1j * 2))
    phi_bg = np.exp(-x**2 / (2 * 30**2))
    phi = phi_peak + phi_bg
    y = 1 * np.exp(1j * phi)
    y = np.dot(np.ones((9, 1)), y[None, :]).reshape((3, 3, -1))

    # RSS
    assert np.sum((phi_peak - phi)**2) > 265.0

    pec = PhaseErrCorrectALS(smoothness_param=1,
                             asym_param=1e-8,
                             redux=1,
                             fix_end_points=False,
                             fix_rng=None,
                             verbose=True,
                             use_prev=False)

    y_pec = pec.calculate(y)
    phi_pec = np.unwrap(np.angle(y_pec))

    # RSS
    np.testing.assert_array_less(np.sum((phi_peak - phi_pec)**2, axis=-1), 4.7)
Пример #2
0
def test_rng_redux3D():
    x = np.linspace(-100, 100, 1000)

    phi_peak = 10 * np.imag(1 / (25 - x - 1j * 2))
    phi_bg = np.exp(-x**2 / (2 * 30**2))
    phi = phi_peak + phi_bg
    y = 1 * np.exp(1j * phi)
    y = np.dot(np.ones((9, 1)), y[None, :]).reshape((3, 3, -1))
    # RSS
    # assert np.sum((phi_peak-phi)**2) > 265.0

    rng = np.arange(200, 800)
    pec = PhaseErrCorrectALS(smoothness_param=1,
                             asym_param=1e-4,
                             redux=10,
                             fix_end_points=True,
                             rng=rng,
                             verbose=True)

    y_pec = pec.calculate(y)
    phi_pec = np.unwrap(np.angle(y_pec))

    assert np.allclose(np.sum(phi_pec[..., :200], axis=-1), 0)
    # RSS
    np.testing.assert_array_less(np.sum((phi_peak - phi_pec)**2, axis=-1), 3.1)
Пример #3
0
def test_rng_redux():
    x = np.linspace(-100, 100, 1000)

    phi_peak = 10 * np.imag(1 / (25 - x - 1j * 2))
    phi_bg = np.exp(-x**2 / (2 * 30**2))
    phi = phi_peak + phi_bg
    y = 1 * np.exp(1j * phi)

    # RSS
    # assert np.sum((phi_peak-phi)**2) > 265.0

    rng = np.arange(200, 800)
    pec = PhaseErrCorrectALS(smoothness_param=1,
                             asym_param=1e-4,
                             redux=10,
                             fix_end_points=True,
                             rng=rng,
                             verbose=True)

    y_pec = pec.calculate(y)
    phi_pec = np.unwrap(np.angle(y_pec))

    assert np.allclose(np.sum(phi_pec[:200]), 0)
    # RSS
    assert np.sum((phi_peak - phi_pec)**2) < 3.1
Пример #4
0
def test_fix_ends():
    x = np.linspace(-100, 100, 1000)

    phi_peak = 10*np.imag(1/(25-x-1j*2))
    phi_bg = np.exp(-x**2/(2*30**2))
    phi =  phi_peak + phi_bg
    y = 1*np.exp(1j*phi)

    # RSS
    assert np.sum((phi_peak-phi)**2) > 265.0
    
    pec = PhaseErrCorrectALS(smoothness_param=1, asym_param=1e-8, 
                                redux=1, fix_end_points=True, fix_rng=None, 
                                verbose=True)

    y_pec = pec.calculate(y)
    phi_pec = np.unwrap(np.angle(y_pec))

    # RSS
    assert np.sum((phi_peak-phi_pec)**2) < 3.3
Пример #5
0
def test_basic2D():
    x = np.linspace(-100, 100, 1000)

    phi_peak = 10*np.imag(1/(25-x-1j*2))
    phi_bg = np.exp(-x**2/(2*30**2))
    phi =  phi_peak + phi_bg
    y = 1*np.exp(1j*phi)
    y = np.dot(np.ones((10,1)), y[None,:])
    # RSS
    assert np.sum((phi_peak-phi)**2) > 265.0
    
    pec = PhaseErrCorrectALS(smoothness_param=1, asym_param=1e-8, 
                                redux=1, fix_end_points=False, fix_rng=None, 
                                verbose=True)

    y_pec = pec.calculate(y)
    phi_pec = np.unwrap(np.angle(y_pec))

    # RSS
    np.testing.assert_array_less(np.sum((phi_peak-phi_pec)**2, axis=-1), 4.7)
Пример #6
0
def test_rng_redux3D():
    x = np.linspace(-100, 100, 1000)

    phi_peak = 10*np.imag(1/(25-x-1j*2))
    phi_bg = np.exp(-x**2/(2*30**2))
    phi =  phi_peak + phi_bg
    y = 1*np.exp(1j*phi)
    y = np.dot(np.ones((9,1)), y[None,:]).reshape((3,3,-1))
    # RSS
    # assert np.sum((phi_peak-phi)**2) > 265.0
    
    rng = np.arange(200,800)
    pec = PhaseErrCorrectALS(smoothness_param=1, asym_param=1e-4, 
                             redux=10, fix_end_points=True, rng=rng, 
                             verbose=True)

    y_pec = pec.calculate(y)
    phi_pec = np.unwrap(np.angle(y_pec))

    assert np.allclose(np.sum(phi_pec[...,:200], axis=-1),0)
    # RSS
    np.testing.assert_array_less(np.sum((phi_peak-phi_pec)**2, axis=-1), 3.1)
Пример #7
0
def test_rng_redux():
    x = np.linspace(-100, 100, 1000)

    phi_peak = 10*np.imag(1/(25-x-1j*2))
    phi_bg = np.exp(-x**2/(2*30**2))
    phi =  phi_peak + phi_bg
    y = 1*np.exp(1j*phi)

    # RSS
    # assert np.sum((phi_peak-phi)**2) > 265.0
    
    rng = np.arange(200,800)
    pec = PhaseErrCorrectALS(smoothness_param=1, asym_param=1e-4, 
                             redux=10, fix_end_points=True, rng=rng, 
                             verbose=True)

    y_pec = pec.calculate(y)
    phi_pec = np.unwrap(np.angle(y_pec))

    assert np.allclose(np.sum(phi_pec[:200]),0)
    # RSS
    assert np.sum((phi_peak-phi_pec)**2) < 3.1