How to use the uwsift.common.Resolution function in uwsift

To help you get started, we’ve selected a few uwsift examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ssec / sift / uwsift / view / tile_calculator.py View on Github external
@jit(nb_types.UniTuple(nb_types.NamedUniTuple(float64, 2, Resolution), 2)(
    int64,
    int64,
    int64,
    int64,
    int64,
    int64,
    int64,
    int64
), nopython=True, cache=True, nogil=True)
def calc_tile_fraction(tiy, tix, stride_y, stride_x, image_y, image_x, tile_y, tile_x):  # image_shape, tile_shape):
    # def calc_tile_fraction(tiy, tix, stride, image_shape, tile_shape):
    # mt = max_tiles_available(image_shape, tile_shape, stride)
    mt = max_tiles_available(Point(image_y, image_x), Point(tile_y, tile_x), Point(stride_y, stride_x))

    if tix < -mt[1] / 2. + 0.5:
        # left edge tile
github ssec / sift / uwsift / view / tile_calculator.py View on Github external
factor_x = 1.

    if tiy < -mt[0] / 2. + 0.5:
        # left edge tile
        offset_y = -mt[0] / 2. + 0.5 - tiy
        factor_y = 1 - offset_y
    elif mt[0] / 2. + 0.5 - tiy < 1:
        # right edge tile
        offset_y = 0.
        factor_y = mt[0] / 2. + 0.5 - tiy
    else:
        # full tile
        offset_y = 0.
        factor_y = 1.

    factor_rez = Resolution(dy=factor_y, dx=factor_x)
    offset_rez = Resolution(dy=offset_y, dx=offset_x)
    return factor_rez, offset_rez
github ssec / sift / uwsift / view / tile_calculator.py View on Github external
if tiy < -mt[0] / 2. + 0.5:
        # left edge tile
        offset_y = -mt[0] / 2. + 0.5 - tiy
        factor_y = 1 - offset_y
    elif mt[0] / 2. + 0.5 - tiy < 1:
        # right edge tile
        offset_y = 0.
        factor_y = mt[0] / 2. + 0.5 - tiy
    else:
        # full tile
        offset_y = 0.
        factor_y = 1.

    factor_rez = Resolution(dy=factor_y, dx=factor_x)
    offset_rez = Resolution(dy=offset_y, dx=offset_x)
    return factor_rez, offset_rez
github ssec / sift / uwsift / view / visuals.py View on Github external
self.shape = shape or max(data.shape for data in data_arrays if data is not None)
        assert None not in (self.cell_width, self.cell_height, self.origin_x, self.origin_y, self.shape)
        # how many of the higher resolution channel tiles (smaller geographic area) make
        # up a low resolution channel tile
        self._channel_factors = tuple(
            self.shape[0] / float(chn.shape[0]) if chn is not None else 1. for chn in data_arrays)
        self._lowest_factor = max(self._channel_factors)
        self._lowest_rez = Resolution(abs(self.cell_height * self._lowest_factor),
                                      abs(self.cell_width * self._lowest_factor))

        # Where does this image lie in this lonely world
        self.calc = TileCalculator(
            self.name,
            self.shape,
            Point(x=self.origin_x, y=self.origin_y),
            Resolution(dy=abs(self.cell_height), dx=abs(self.cell_width)),
            self.tile_shape,
            self.texture_shape,
            wrap_lon=self.wrap_lon
        )

        # Reset texture state, if we change things to know which texture
        # don't need to be updated then this can be removed/changed
        self.texture_state.reset()
        self._need_texture_upload = True
        self._need_vertex_update = True
        # Reset the tiling logic to force a retile
        # even though we might be looking at the exact same spot
        self._latest_tile_box = None
github ssec / sift / uwsift / view / tile_calculator.py View on Github external
if tiy < -mt[0] / 2. + 0.5:
        # left edge tile
        offset_y = -mt[0] / 2. + 0.5 - tiy
        factor_y = 1 - offset_y
    elif mt[0] / 2. + 0.5 - tiy < 1:
        # right edge tile
        offset_y = 0.
        factor_y = mt[0] / 2. + 0.5 - tiy
    else:
        # full tile
        offset_y = 0.
        factor_y = 1.

    factor_rez = Resolution(dy=factor_y, dx=factor_x)
    offset_rez = Resolution(dy=offset_y, dx=offset_x)
    return factor_rez, offset_rez
github ssec / sift / uwsift / view / tile_calculator.py View on Github external
as measured near zero_point
            tile_shape (int, int): the pixel dimensions (h:int, w:int) of the GPU tiling we want to use
            texture_shape (int, int): the size of the texture being used (h, w) in number of tiles

        Notes:

            - Tiling is aligned to pixels, not world
            - World coordinates are eqm such that 0,0 matches 0°N 0°E, going north/south +-90° and west/east +-180°
            - Data coordinates are pixels with b l or b r corner being 0,0

        """
        super(TileCalculator, self).__init__()
        self.name = name
        self.image_shape = Point(np.int64(image_shape[0]), np.int64(image_shape[1]))
        self.ul_origin = Point(*ul_origin)
        self.pixel_rez = Resolution(np.float64(pixel_rez[0]), np.float64(pixel_rez[1]))
        self.tile_shape = Point(np.int64(tile_shape[0]), np.int64(tile_shape[1]))
        # in units of tiles:
        self.texture_shape = texture_shape
        # in units of data elements (float32):
        self.texture_size = (self.texture_shape[0] * self.tile_shape[0], self.texture_shape[1] * self.tile_shape[1])
        self.image_tiles_avail = (self.image_shape[0] / self.tile_shape[0], self.image_shape[1] / self.tile_shape[1])
        self.wrap_lon = wrap_lon

        self.proj = Proj(projection)
        self.image_extents_box = e = Box(
            bottom=np.float64(self.ul_origin[0] - self.image_shape[0] * self.pixel_rez.dy),
            top=np.float64(self.ul_origin[0]),
            left=np.float64(self.ul_origin[1]),
            right=np.float64(self.ul_origin[1] + self.image_shape[1] * self.pixel_rez.dx),
        )
        # Array of points across the image space to be used as an estimate of image coverage
github ssec / sift / uwsift / view / tile_calculator.py View on Github external
as measured near zero_point
            tile_shape (int, int): the pixel dimensions (h:int, w:int) of the GPU tiling we want to use
            texture_shape (int, int): the size of the texture being used (h, w) in number of tiles

        Notes:

            - Tiling is aligned to pixels, not world
            - World coordinates are eqm such that 0,0 matches 0°N 0°E, going north/south +-90° and west/east +-180°
            - Data coordinates are pixels with b l or b r corner being 0,0

        """
        super(TileCalculator, self).__init__()
        self.name = name
        self.image_shape = Point(np.int64(image_shape[0]), np.int64(image_shape[1]))
        self.ul_origin = Point(*ul_origin)
        self.pixel_rez = Resolution(np.float64(pixel_rez[0]), np.float64(pixel_rez[1]))
        self.tile_shape = Point(np.int64(tile_shape[0]), np.int64(tile_shape[1]))
        # in units of tiles:
        self.texture_shape = texture_shape
        # in units of data elements (float32):
        self.texture_size = (self.texture_shape[0] * self.tile_shape[0], self.texture_shape[1] * self.tile_shape[1])
        self.image_tiles_avail = (self.image_shape[0] / self.tile_shape[0], self.image_shape[1] / self.tile_shape[1])
        self.wrap_lon = wrap_lon

        self.proj = Proj(projection)
        self.image_extents_box = e = Box(
            bottom=np.float64(self.ul_origin[0] - self.image_shape[0] * self.pixel_rez.dy),
            top=np.float64(self.ul_origin[0]),
            left=np.float64(self.ul_origin[1]),
            right=np.float64(self.ul_origin[1] + self.image_shape[1] * self.pixel_rez.dx),
        )
        # Array of points across the image space to be used as an estimate of image coverage
github ssec / sift / uwsift / view / tile_calculator.py View on Github external
factor_x = 1.

    if tiy < -mt[0] / 2. + 0.5:
        # left edge tile
        offset_y = -mt[0] / 2. + 0.5 - tiy
        factor_y = 1 - offset_y
    elif mt[0] / 2. + 0.5 - tiy < 1:
        # right edge tile
        offset_y = 0.
        factor_y = mt[0] / 2. + 0.5 - tiy
    else:
        # full tile
        offset_y = 0.
        factor_y = 1.

    factor_rez = Resolution(dy=factor_y, dx=factor_x)
    offset_rez = Resolution(dy=offset_y, dx=offset_x)
    return factor_rez, offset_rez
github ssec / sift / uwsift / view / visuals.py View on Github external
if cell_width is not None:
            self.cell_width = cell_width
        if cell_height:
            self.cell_height = cell_height  # Note: cell_height is usually negative
        if origin_x:
            self.origin_x = origin_x
        if origin_y:
            self.origin_y = origin_y
        self.shape = shape or max(data.shape for data in data_arrays if data is not None)
        assert None not in (self.cell_width, self.cell_height, self.origin_x, self.origin_y, self.shape)
        # how many of the higher resolution channel tiles (smaller geographic area) make
        # up a low resolution channel tile
        self._channel_factors = tuple(
            self.shape[0] / float(chn.shape[0]) if chn is not None else 1. for chn in data_arrays)
        self._lowest_factor = max(self._channel_factors)
        self._lowest_rez = Resolution(abs(self.cell_height * self._lowest_factor),
                                      abs(self.cell_width * self._lowest_factor))

        # Where does this image lie in this lonely world
        self.calc = TileCalculator(
            self.name,
            self.shape,
            Point(x=self.origin_x, y=self.origin_y),
            Resolution(dy=abs(self.cell_height), dx=abs(self.cell_width)),
            self.tile_shape,
            self.texture_shape,
            wrap_lon=self.wrap_lon
        )

        # Reset texture state, if we change things to know which texture
        # don't need to be updated then this can be removed/changed
        self.texture_state.reset()