예제 #1
0
    def test_xarray_raw_to_rgba_pyramid(self):
        image = ds.XarrayImage(self.xr_da, tile_size=(270, 270))
        pyramid = image.create_pyramid()
        import numpy as np
        # TODO fillvalue ?
        pyramid = pyramid.apply(lambda image: ColorMappedRgbaImage(
            image, value_range=(0.0, 2.0), no_data_value=np.nan))
        self.assertEqual((270, 270), pyramid.tile_size)
        self.assertEqual((2, 1), pyramid.num_level_zero_tiles)
        self.assertEqual(5, pyramid.num_levels)

        level_image = pyramid.get_level_image(0)

        t1 = time.clock()
        tile00 = level_image.get_tile(0, 0)
        tile10 = level_image.get_tile(1, 0)
        t2 = time.clock()
        print("opt RGBA pyramid took: ", t2 - t1)

        t1 = time.clock()
        num_tiles_x, num_tiles_y = image.num_tiles
        for tile_y in range(num_tiles_y):
            for tile_x in range(num_tiles_x):
                tile = image.get_tile(tile_x, tile_y)
        t2 = time.clock()
        print("opt max level tiles took: ", t2 - t1)
예제 #2
0
    def test_xarray_rgba_image(self):
        image = ColorMappedRgbaImage(ds.XarrayImage(self.xr_da))
        self.assertEqual('ndarray', image.format)
        self.assertEqual('RGBA', image.mode)
        self.assertEqual((8640, 4320), image.size)
        self.assertEqual((270, 270), image.tile_size)
        self.assertEqual((32, 16), image.num_tiles)

        tile00 = image.get_tile(0, 0)
        self.assertIsNotNone(tile00)
        tileNN = image.get_tile(33, 16)
        self.assertIsNotNone(tileNN)
예제 #3
0
    def test_xarray_raw_pyramid(self):
        image = ds.XarrayImage(self.xr_da)
        pyramid = image.create_pyramid()
        self.assertEqual((270, 270), pyramid.tile_size)
        self.assertEqual((2, 1), pyramid.num_level_zero_tiles)
        self.assertEqual(5, pyramid.num_levels)

        level_image = pyramid.get_level_image(0)

        t1 = time.clock()
        tile00 = level_image.get_tile(0, 0)
        tile10 = level_image.get_tile(1, 0)
        t2 = time.clock()
        print("ndarray pyramid took: ", t2 - t1)
예제 #4
0
    def test_xarray_raw_image(self):
        image = ds.XarrayImage(self.xr_da)
        self.assertEqual('ndarray', image.format)
        self.assertEqual('float64',
                         image.mode)  # TODO why float64 and not float32
        self.assertEqual((8640, 4320), image.size)
        self.assertEqual((270, 270), image.tile_size)
        self.assertEqual((32, 16), image.num_tiles)

        tile00 = image.get_tile(0, 0)
        self.assertIsNotNone(tile00)
        self.assertEqual((1, 270, 270), tile00.shape)
        tileNN = image.get_tile(33, 16)
        self.assertIsNotNone(tileNN)
        self.assertEqual((1, 270, 270), tileNN.shape)
예제 #5
0
    def test_xarray_rgba_pyramid(self):
        image = ColorMappedRgbaImage(
            ds.XarrayImage(self.xr_da, tile_size=(270, 270)))
        pyramid = image.create_pyramid()
        self.assertEqual((270, 270), pyramid.tile_size)
        self.assertEqual((2, 1), pyramid.num_level_zero_tiles)
        self.assertEqual(5, pyramid.num_levels)

        level_image = pyramid.get_level_image(0)

        t1 = time.clock()
        tile00 = level_image.get_tile(0, 0)
        tile10 = level_image.get_tile(1, 0)
        t2 = time.clock()
        print("RGBA pyramid took: ", t2 - t1)

        t1 = time.clock()
        num_tiles_x, num_tiles_y = image.num_tiles
        for tile_y in range(num_tiles_y):
            for tile_x in range(num_tiles_x):
                tile = image.get_tile(tile_x, tile_y)
        t2 = time.clock()
        print("max level tiles took: ", t2 - t1)