예제 #1
0
    def test_noisy(self):
        shape = (10, 11)

        delta_x = np.random.randint(1, 20, size=shape)
        delta_y = np.random.randint(1, 20, size=shape)

        df = DisplacementField(delta_x, delta_y)
        df_anchored = df.anchor(ds_f=1)

        assert df != df_anchored
예제 #2
0
    def test_interpolation_subgrid(self):
        shape = (14, 16)  # center is 7, 8
        eps = 1e-6

        delta_x = np.random.randint(1, 20, size=shape)
        delta_y = np.random.randint(1, 20, size=shape)

        df = DisplacementField(delta_x, delta_y)

        df_anchored_interpolated = df.anchor(h_kept=4,
                                             w_kept=4,
                                             ds_f=1,
                                             smooth=0)
        df_anchored_smoothened = df.anchor(h_kept=4,
                                           w_kept=4,
                                           ds_f=1,
                                           smooth=1)

        assert np.allclose(df_anchored_interpolated.delta_x[5:9, 6:10],
                           df.delta_x[5:9, 6:10])
        assert np.allclose(df_anchored_interpolated.delta_y[5:9, 6:10],
                           df.delta_y[5:9, 6:10])

        assert not np.allclose(df_anchored_smoothened.delta_x[5:9, 6:10],
                               df.delta_x[5:9, 6:10])
        assert not np.allclose(df_anchored_smoothened.delta_y[5:9, 6:10],
                               df.delta_y[5:9, 6:10])

        assert abs(df_anchored_interpolated.delta_x[0, 0]) < eps
        assert abs(df_anchored_interpolated.delta_x[0, -1]) < eps
        assert abs(df_anchored_interpolated.delta_x[-1, 0]) < eps
        assert abs(df_anchored_interpolated.delta_x[-1, -1]) < eps

        assert abs(df_anchored_interpolated.delta_y[0, 0]) < eps
        assert abs(df_anchored_interpolated.delta_y[0, -1]) < eps
        assert abs(df_anchored_interpolated.delta_y[-1, 0]) < eps
        assert abs(df_anchored_interpolated.delta_y[-1, -1]) < eps