Beispiel #1
0
    def test_parallel_search_no_cython(self, osgs):
        """Test the parallel resampling until the cython calls."""
        from pyresample.gradient import parallel_gradient_search as pgs
        data = da.ones((100, 100), chunks=(25, 50))
        src_x = da.ones((100, 100), chunks=(25, 50))
        src_y = da.ones((100, 100), chunks=(25, 50))
        dst_x = da.ones((180, 360), chunks=(90, 90))
        dst_y = da.ones((180, 360), chunks=(90, 90))

        def fake_gradient_resample_data(*args, **kwargs):
            assert(kwargs['method'] == 'bilinear')
            assert(args[0].shape == (1, 25, 50))
            for arg in args[1:7]:
                assert(arg.shape == (25, 50))
            for arg in args[7:]:
                assert(arg.shape == (90, 90))
            return args[7][np.newaxis, :, :]
        osgs.side_effect = fake_gradient_resample_data
        res = pgs(data, src_x, src_y, dst_x, dst_y)
        res = res.compute(scheduler='single-threaded')
        assert(res.shape == (180, 360))

        data = da.ones((3, 100, 100), chunks=(3, 25, 50))

        def fake_gradient_resample_data(*args, **kwargs):
            assert(kwargs['method'] == 'bilinear')
            assert(args[0].shape == (3, 25, 50))
            for arg in args[1:7]:
                assert(arg.shape == (25, 50))
            for arg in args[7:]:
                assert(arg.shape == (90, 90))
            return args[7][np.newaxis, :, :]
Beispiel #2
0
    def test_parallel_resampling_no_blockwise(self, blockwise):
        """Test the parallel resampling until the blockwise call."""
        from pyresample.gradient import parallel_gradient_search as pgs
        data = da.ones((100, 100), chunks=(25, 50))
        src_x = da.ones((100, 100), chunks=(25, 50))
        src_y = da.ones((100, 100), chunks=(25, 50))
        dst_x = da.ones((180, 360), chunks=(90, 90))
        dst_y = da.ones((180, 360), chunks=(90, 90))

        def fake_blockwise(*args, **kwargs):
            return args[2]

        blockwise.side_effect = fake_blockwise
        res = pgs(data, src_x, src_y, dst_x, dst_y)
        assert(res.shape == (25, 50))
Beispiel #3
0
    def test_parallel_search_no_blocks(self, grd):
        """Test the parallel resampling until the blocked calls."""
        from pyresample.gradient import parallel_gradient_search as pgs
        data = da.ones((100, 100), chunks=(25, 50))
        src_x = da.ones((100, 100), chunks=(25, 50))
        src_y = da.ones((100, 100), chunks=(25, 50))
        dst_x = da.ones((180, 360), chunks=(90, 90))
        dst_y = da.ones((180, 360), chunks=(90, 90))

        def fake_gradient_resample_data(*args, **kwargs):
            assert(kwargs['method'] == 'bilinear')
            return args[7][np.newaxis, :, :, np.newaxis]
        grd.side_effect = fake_gradient_resample_data
        res = pgs(data, src_x, src_y, dst_x, dst_y)
        res = res.compute(scheduler='single-threaded')
        assert(res.shape == (180, 360))