def test_nonuniform_triangle_autocorrelation(): a = 0.7 b = 3 x = np.array([0, b]) t = NonuniformLineScan(x, a * x) r, A = height_height_autocorrelation(t, distances=np.linspace(-4, 4, 101)) assert_almost_equal(A[np.abs(r) < 1e-6][0], a ** 2 * b ** 3 / 3) r3, A3 = height_height_autocorrelation(t.detrend(detrend_mode='center'), distances=[0]) s, = t.physical_sizes assert_almost_equal(A3[0], t.rms_height_from_profile() ** 2 * s) x = np.array([0, 1., 1.3, 1.7, 2.0, 2.5, 3.0]) t = NonuniformLineScan(x, a * x) r2, A2 = height_height_autocorrelation(t, distances=np.linspace(-4, 4, 101)) assert_array_almost_equal(A, A2) r, A = height_height_autocorrelation(t.detrend(detrend_mode='center'), distances=[0]) s, = t.physical_sizes assert_almost_equal(A[0], t.rms_height_from_profile() ** 2 * s)
def test_nonuniform_impulse_autocorrelation(): a = 3 b = 2 x = np.array([0, a]) t = NonuniformLineScan(x, b * np.ones_like(x)) r, A = height_height_autocorrelation(t, distances=np.linspace(-4, 4, 101)) A_ref = b ** 2 * (a - np.abs(r)) A_ref[A_ref < 0] = 0 assert_array_almost_equal(A, A_ref) a = 3 b = 2 x = np.array([-a, 0, 1e-9, a - 1e-9, a, 2 * a]) y = np.zeros_like(x) y[2] = b y[3] = b t = NonuniformLineScan(x, y) r, A = height_height_autocorrelation(t, distances=np.linspace(-4, 4, 101)) A_ref = b ** 2 * (a - np.abs(r)) A_ref[A_ref < 0] = 0 assert_array_almost_equal(A, A_ref) t = t.detrend(detrend_mode='center') r, A = height_height_autocorrelation(t, distances=np.linspace(0, 10, 201)) s, = t.physical_sizes assert_almost_equal(A[0], t.rms_height_from_profile() ** 2 * s)