MaskSchema#

class lsst.images.MaskSchema(planes: ~collections.abc.Iterable[~lsst.images._mask.MaskPlane | None], dtype: type[~typing.Any] | ~numpy.dtype[~typing.Any] | ~numpy._typing._dtype_like._SupportsDType[~numpy.dtype[~typing.Any]] | tuple[~typing.Any, ~typing.Any] | list[~typing.Any] | ~numpy._typing._dtype_like._DTypeDict | str | None = <class 'numpy.uint8'>)#

Bases: object

A schema for a bit-packed mask array.

Parameters#

planes

Iterable of MaskPlane instances that define the schema. None values may be included to reserve bits for future use.

dtype

The numpy data type of the mask arrays that use this schema.

Notes#

A MaskSchema is a collection of mask planes, which each correspond to a single bit in a mask array. Mask schemas are immutable and associated with a particular array data type, allowing them to safely precompute the index and bitmask for each plane.

MaskSchema indexing is by integer (the overall index of a plane in the schema). The descriptions attribute may be indexed by plane name to get the description for that plane, and the bitmask method can be used to obtain an array that can be used to select one or more planes by name in a mask array that uses this schema.

If no mask planes are provided, a None placeholder is automatically added.

Attributes Summary

descriptions

A mapping from plane name to description.

dtype

The numpy data type of the mask arrays that use this schema.

mask_size

The number of elements in the last dimension of any mask array that uses this schema.

names

The names of the mask planes, in bit order.

Methods Summary

bit(plane)

Return the last array index and mask for the given mask plane.

bitmask(*planes)

Return a 1-d mask array that represents the union (i.e. bitwise OR) of the planes with the given names.

bits_per_element(dtype)

Return the number of mask bits per array element for the given data type.

split(dtype)

Split the schema into an equivalent series of schemas that each have a mask_size of 1, dropping all None placeholders.

strip_header(header)

Remove all header cards added by update_header.

update_header(header)

Add a description of this mask schema to a FITS header.

Attributes Documentation

descriptions#

A mapping from plane name to description.

dtype#

The numpy data type of the mask arrays that use this schema.

mask_size#

The number of elements in the last dimension of any mask array that uses this schema.

names#

The names of the mask planes, in bit order.

Methods Documentation

bit(plane: str) MaskPlaneBit#

Return the last array index and mask for the given mask plane.

bitmask(*planes: str) ndarray#

Return a 1-d mask array that represents the union (i.e. bitwise OR) of the planes with the given names.

Parameters#

*planes

Mask plane names.

Returns#

numpy.ndarray

A 1-d array with shape (mask_size,).

static bits_per_element(dtype: type[Any] | dtype[Any] | _SupportsDType[dtype[Any]] | tuple[Any, Any] | list[Any] | _DTypeDict | str | None) int#

Return the number of mask bits per array element for the given data type.

split(dtype: type[Any] | dtype[Any] | _SupportsDType[dtype[Any]] | tuple[Any, Any] | list[Any] | _DTypeDict | str | None) list[MaskSchema]#

Split the schema into an equivalent series of schemas that each have a mask_size of 1, dropping all None placeholders.

Parameters#

dtype

Data type of the new mask pixels.

Returns#

list [MaskSchema]

A list of mask schemas that together include all planes in self and have mask_size equal to 1. If there are no mask planes (only None placeholders) in self, a single mask schema with a None placeholder is returned; otherwise None placeholders are returned.

strip_header(header: Header) None#

Remove all header cards added by update_header.

update_header(header: Header) None#

Add a description of this mask schema to a FITS header.