autolens.Mask1D#
- class Mask1D[source]#
Bases:
MaskA 1D mask, representing 1D data on a uniform line of pixels with equal spacing.
When applied to 1D data it extracts or masks the unmasked image pixels corresponding to mask entries that are False or 0).
The mask also defines the geometry of the 1D data structure it is paired to, for example how every pixel coordinate on the 1D line of data converts to physical units via the pixel_scales and origin parameters and a grid which is used for performing calculations.
- Parameters:
mask (
Union[ndarray,List]) – The ndarray of shape [total_pixels] containing the bool’s representing the mask, where False signifies an entry is unmasked and used in calculations.pixel_scales (
Union[Tuple[float],Tuple[float,float],float]) – The scaled units to pixel units conversion factor of each pixel.origin (
Tuple[float]) – The (x,) origin of the mask’s coordinate system in scaled units.invert (
bool) – If True, the bool’s of the input mask are inverted, so False entries become True and vice versa.xp – The array module to use (default numpy; pass jax.numpy for JAX support). Controls whether internal index arrays are computed on CPU or GPU.
Methods
allSetup a 1D mask where all pixels are unmasked.
astypecopyLoads the 1D mask from a .fits file.
instance_flattenFlatten an instance of an autoarray class into a tuple of its attributes (i.e.. a pytree).
instance_unflattenUnflatten a tuple of attributes (i.e. a pytree) into an instance of an autoarray class.
invertmaxminreshapesqrtsumwith_new_arrayCopy this object but give it a new array.
Attributes
arrayReturns the
DeriveGrid1Dobject associated with the mask, which computes derived grids of (x,) coordinates such as the unmasked pixel grid.Returns the
DeriveMask1Dobject associated with the mask, which computes derived masks such as the edge mask.dimensionsThe number of dimensions of the mask (e.g. 1 for a 1D mask, 2 for a 2D mask).
dtypeReturn the 1D geometry of the mask, representing its uniform rectangular grid of (x) coordinates defined by its
shape_native.Returns the pixel scales of the mask as a header dictionary, which can be written to a .fits file.
imagis_all_falseReturns True if all pixels in a mask are False (i.e. every pixel is unmasked), else returns False.
is_all_trueReturns True if all pixels in a mask are True, else returns False.
is_transformedmaskThe boolean ndarray of the mask, where False entries are unmasked (used in calculations) and True entries are masked (excluded from calculations).
Returns the data structure in its native format which contains all unmaksed values to the native dimensions.
ndimpixel_scaleThe pixel scale of the mask as a single float value.
pixel_scalespixels_in_maskThe total number of unmasked pixels (values are False) in the mask.
realshapeThe 1D shape of the mask in its native representation, equal to the shape of the underlying boolean ndarray.
The 1D shape of the mask in its slim representation.
size- property native: Structure#
Returns the data structure in its native format which contains all unmaksed values to the native dimensions.
- property geometry: Geometry1D#
Return the 1D geometry of the mask, representing its uniform rectangular grid of (x) coordinates defined by its
shape_native.
- property derive_mask: DeriveMask1D#
Returns the
DeriveMask1Dobject associated with the mask, which computes derived masks such as the edge mask.
- property derive_grid: DeriveGrid1D#
Returns the
DeriveGrid1Dobject associated with the mask, which computes derived grids of (x,) coordinates such as the unmasked pixel grid.
- classmethod all_false(shape_slim, pixel_scales, origin=(0.0,), invert=False)[source]#
Setup a 1D mask where all pixels are unmasked.
- Parameters:
shape_slim – The 1D shape of the mask in units of pixels.
pixel_scales (
Union[Tuple[float],Tuple[float,float],float]) – The scaled units to pixel units conversion factor of each pixel.origin (
Tuple[float]) – The (x,) scaled units origin of the mask’s coordinate system.invert (
bool) – If True, the bool’s of the input mask are inverted, so False entries become True and vice versa.
- classmethod from_fits(file_path, pixel_scales, hdu=0, origin=(0.0,))[source]#
Loads the 1D mask from a .fits file.
- Parameters:
file_path (
Union[Path,str]) – The full path of the fits file.hdu (
int) – The HDU number in the.fitsfile containing the mask array.pixel_scales (
Union[Tuple[float],Tuple[float,float],float]) – The scaled units to pixel units conversion factor of each pixel.origin (
Tuple[float]) – The (x,) scaled units origin of the mask’s coordinate system.
- Returns:
The mask loaded from the
.fitsfile.- Return type:
- property shape_native: Tuple[int]#
The 1D shape of the mask in its native representation, equal to the shape of the underlying boolean ndarray.
- property shape_slim: Tuple[int]#
The 1D shape of the mask in its slim representation. For a 1D mask this is the same as
shape_nativesince there is no native/slim distinction — every pixel is on the same 1D line.
- property header_dict: Dict#
Returns the pixel scales of the mask as a header dictionary, which can be written to a .fits file.
A 1D mask has a single pixel scale, so the header contains one pixel scale entry alongside the origin.
- Return type:
A dictionary containing the pixel scale of the mask, which can be output to a .fits file.