PyramidIO

class toasty.pyramid.PyramidIO(base_dir, scheme='L/Y/YX', default_format=None)[source]

Bases: object

Manage I/O on a tile pyramid.

Parameters
base_dirstr

The base directory containing the tiles

schemestr

The tile organization scheme, should be either ‘L/Y/YX’ or ‘LXY’

default_formatstr

The file format to assume for the tiles if none is specified when reading/writing tiles. If not specified, and base_dir exists and contains files, these are used to guess default_format. Otherwise defaults to ‘png’.

Methods Summary

get_path_scheme()

Get the scheme for buiding tile paths as used in the WTML standard.

open_metadata_for_read(basename)

Open a metadata file in read mode.

open_metadata_for_write(basename)

Open a metadata file in write mode.

read_image(pos[, default, masked_mode, format])

Read an Image for the specified tile position.

tile_path(pos[, format])

Get the path for a tile, creating its containing directories.

update_image(pos[, default, masked_mode, format])

write_image(pos, image[, format, mode])

Write an Image for the specified tile position.

Methods Documentation

get_path_scheme()[source]

Get the scheme for buiding tile paths as used in the WTML standard.

Returns
The naming scheme, a string resembling {1}/{3}/{3}_{2}.

Notes

The naming scheme is currently hardcoded to be the format given above, but in the future other options might become available.

open_metadata_for_read(basename)[source]

Open a metadata file in read mode.

Parameters
basenamestr

The basename of the metadata file

Returns
A readable and closeable file-like object returning bytes.
open_metadata_for_write(basename)[source]

Open a metadata file in write mode.

Parameters
basenamestr

The basename of the metadata file

Returns
A writable and closeable file-like object accepting bytes.
read_image(pos, default='none', masked_mode=None, format=None)[source]

Read an Image for the specified tile position.

Parameters
posPos

The tile position to read.

defaultstr, defaults to “none”

What to do if the specified tile file does not exist. If this is “none”, None will be returned instead of an image. If this is “masked”, an all-masked image will be returned, using make_maskable_buffer(). Otherwise, ValueError will be raised.

masked_modetoasty.image.ImageMode

The image data mode to use if default is set to 'masked'.

tile_path(pos, format=None)[source]

Get the path for a tile, creating its containing directories.

Parameters
posPos

The tile to get a path for.test_plate_carree_ecliptic

Returns
The path as a string.

Notes

This function does I/O itself — it creates the parent directories containing the tile path. It is not an error for the parent directories to already exist.

update_image(pos, default='none', masked_mode=None, format=None)[source]
write_image(pos, image, format=None, mode=None)[source]

Write an Image for the specified tile position.

Parameters
posPos

The tile position to write.

imagetoasty.image.Image

The image to write.