MaskSchema#
- class lsst.images.MaskSchema(planes, dtype=<class 'numpy.uint8'>)#
Bases:
objectA schema for a bit-packed mask array.
- Parameters:
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.
from_fits_header(header[, dtype])Reconstruct a schema from the
MSKN/MSKDcards written byupdate_header.interpret(value)Return the names of the mask planes that are set in the given pixel value.
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)#
Return the last array index and mask for the given mask plane.
- Parameters:
plane (
str) – Name of the mask plane.- Return type:
- bitmask(*planes)#
Return a 1-d mask array that represents the union (i.e. bitwise OR) of the planes with the given names.
- Parameters:
*planes (
str) – Mask plane names.- Returns:
A 1-d array with shape
(mask_size,).- Return type:
- static bits_per_element(dtype)#
Return the number of mask bits per array element for the given data type.
- Parameters:
dtype (
TypeAliasType) – Data type of the mask array elements.- Return type:
- classmethod from_fits_header(header, dtype=<class 'numpy.uint8'>)#
Reconstruct a schema from the
MSKN/MSKDcards written byupdate_header.- Parameters:
header (
Header) – FITS header containingMSKN{n:04d}plane-name cards andMSKD{n:04d}description cards.dtype (
TypeAliasType, default:<class 'numpy.uint8'>) – Data type of the mask arrays that will use this schema. The cards describe amask_size==1serialized form and do not record the in-memory dtype, so the caller must supply it; it defaults to the sameuint8used by theMaskconstructor.
- Returns:
Schema whose planes are ordered by their
MSKNindex, withNoneplaceholders inserted for any gaps in that numbering.- Return type:
- Raises:
ValueError – Raised if the header contains no
MSKNcards.
- interpret(value)#
Return the names of the mask planes that are set in the given pixel value.
- split(dtype)#
Split the schema into an equivalent series of schemas that each have a
mask_sizeof1, dropping allNoneplaceholders.- Parameters:
dtype (
TypeAliasType) – Data type of the new mask pixels.- Returns:
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.- Return type:
- strip_header(header)#
Remove all header cards added by
update_header.