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:
objectA schema for a bit-packed mask array.
Parameters#
- planes
Iterable of
MaskPlaneinstances that define the schema.Nonevalues may be included to reserve bits for future use.- dtype
The numpy data type of the mask arrays that use this schema.
Notes#
A
MaskSchemais 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.MaskSchemaindexing is by integer (the overall index of a plane in the schema). Thedescriptionsattribute may be indexed by plane name to get the description for that plane, and thebitmaskmethod 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
Noneplaceholder is automatically added.Attributes Summary
A mapping from plane name to description.
The numpy data type of the mask arrays that use this schema.
The number of elements in the last dimension of any mask array that uses this schema.
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_sizeof1, dropping allNoneplaceholders.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_sizeof1, dropping allNoneplaceholders.Parameters#
- dtype
Data type of the new mask pixels.
Returns#
list[MaskSchema]A list of mask schemas that together include all planes in
selfand havemask_sizeequal to1. If there are no mask planes (onlyNoneplaceholders) inself, a single mask schema with aNoneplaceholder is returned; otherwiseNoneplaceholders 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.