StudyTiling

class toasty.study.StudyTiling(width, height)[source]

Bases: object

Information about how a WWT “study” image is broken into tiles.

In WWT a “study” is a large astronomical image projected onto the sky using a gnomonic (tangential or TAN) projection. The image may have many pixels, so it is broken up into tiles for efficient visualization.

Note that this class doesn’t know anything about how the image is projected onto the sky, or whether it is projected at all. The core tiling functionality doesn’t need to care about that.

Methods Summary

apply_to_imageset(imgset)

Fill the specific wwt_data_formats.imageset.ImageSet object with parameters defined by this tiling,

compute_for_subimage(subim_ix, subim_iy, …)

Create a new compatible tiling whose underlying image is a subset of this one.

count_populated_positions()

Count how many tiles contain image data.

generate_populated_positions()

Generate information about tiles containing image data.

image_to_tile(im_ix, im_iy)

Convert an image pixel position to a tiled pixel position.

n_deepest_layer_tiles()

Return the number of tiles in the highest-resolution layer.

tile_image(image, pio[, cli_progress])

Tile an in-memory image as a study.

Methods Documentation

apply_to_imageset(imgset)[source]

Fill the specific wwt_data_formats.imageset.ImageSet object with parameters defined by this tiling,

Parameters
imgsetwwt_data_formats.imageset.ImageSet

The object to modify

Notes

The settings currently transferred are the number of tile levels and the projection type.

compute_for_subimage(subim_ix, subim_iy, subim_width, subim_height)[source]

Create a new compatible tiling whose underlying image is a subset of this one.

Parameters
subim_ixinteger

The 0-based horizontal pixel position of the left edge of the sub-image, relative to this tiling’s image.

subim_iyinteger

The 0-based vertical pixel position of the top edge of the sub-image, relative to this tiling’s image.

subim_widthnonnegative integer

The width of the sub-image, in pixels.

subim_heightnonnegative integer

The height of the sub-image, in pixels.

Returns
A new StudyTiling with the same number of tile levels as this one.
However, the internal information about where the available data land within
that tiling will be appropriate for the specified sub-image. Methods like
count_populated_positions(), generate_populated_positions(), and
tile_image() will behave differently.
count_populated_positions()[source]

Count how many tiles contain image data.

This is used for progress reporting.

generate_populated_positions()[source]

Generate information about tiles containing image data.

Generates a sequence of tuples (pos, width, height, image_x, image_y, tile_x, tile_y) where:

  • pos is a toasty.pyramid.Pos tuple giving parameters of a tile

  • width is the width of the rectangle of image data contained in this tile, between 1 and 256.

  • height is the height of the rectangle of image data contained in this tile, between 1 and 256.

  • image_x is the pixel X coordinate of the left edge of the image data in this tile in the image rectangle, increasing from the left edge of the tile. Between 0 and self._width - 1 (inclusive).

  • image_y is the pixel Y coordinate of the top edge of the image data in this tile in the image rectangle, increasing from the top edge of the tile. Between 0 and self._height - 1 (inclusive).

  • tile_x is the pixel X coordinate of the left edge of the image data in this tile in the tile rectangle, increasing from the left edge of the tile. Between 0 and 255 (inclusive).

  • tile_y is the pixel Y coordinate of the top edge of the image data in this tile in the tile rectangle, increasing from the top edge of the tile. Between 0 and 255 (inclusive).

Tiles that do not overlap the image at all are not generated. Tiles that are completely filled with image data will yield tuples of the form (pos, 256, 256, im_x, im_y, 0, 0). An image that fits entirely in one tile will yield a tuple of the form (Pos(n=0, x=0, y=0), width, height, 0, 0, tx, ty).

image_to_tile(im_ix, im_iy)[source]

Convert an image pixel position to a tiled pixel position.

Parameters
im_ixinteger

A 0-based horizontal pixel position in the image coordinate system.

im_iyinteger

A 0-based vertical pixel position in the image coordinate system.

Notes

(0, 0) is the top-left corner of the image. The input values need not lie on the image. (I.e., they may be negative.)

Returns (tile_ix, tile_iy, subtile_ix, subtile_iy), where

  • tile_ix is X index of the matched tile in the tiling, between 0 and 2**tile_size - 1. Measured right from the left edge of the tiling.

  • tile_iy is Y index of the matched tile in the tiling, between 0 and 2**tile_size - 1. Measured down from the top of the tiling.

  • subtile_ix is the pixel X position within that tile, between 0 and 255. Measured right from the left edge of the tiling.

  • subtile_iy is the pixel Y position within that tile, between 0 and 255. Measured down from the top edge of the tiling.

n_deepest_layer_tiles()[source]

Return the number of tiles in the highest-resolution layer.

tile_image(image, pio, cli_progress=False)[source]

Tile an in-memory image as a study.

Parameters
imagetoasty.image.Image

In-memory image data. The image’s dimensions must match the ones for which this tiling was computed.

piotoasty.pyramid.PyramidIO

A handle for doing I/O on the tile pyramid

cli_progressoptional boolean, defaults False

If true, a progress bar will be printed to the terminal using tqdm.

Returns
Self.