autolens.Mask1D#
- class Mask1D[source]#
Bases:
Mask
A 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.
Methods
all
Setup a 1D mask where all pixels are unmasked.
astype
copy
flip_hdu_for_ds9
Loads the 1D mask from a .fits file.
Returns an
Mask1D
by from a PrimaryHDU object which has been loaded via astropy.fitsinstance_flatten
Flatten an instance of an autoarray class into a tuple of its attributes (i.e.. a pytree).
instance_unflatten
Unflatten a tuple of attributes (i.e. a pytree) into an instance of an autoarray class.
invert
max
min
Write the 1D mask to a .fits file.
reshape
sqrt
sum
with_new_array
Copy this object but give it a new array.
Attributes
array
derive_grid
derive_mask
dimensions
dtype
Return the 1D geometry of the mask, representing its uniform rectangular grid of (x) coordinates defined by its
shape_native
.The mask as a HDU object, which can be output to a .fits file.
imag
is_all_false
Returns False if all pixels in a mask are False, else returns True.
is_all_true
Returns True if all pixels in a mask are True, else returns False.
mask
Returns the data structure in its native format which contains all unmaksed values to the native dimensions.
ndim
pixel_scale
For a mask with dimensions two or above check that are pixel scales are the same, and if so return this single value as a float.
pixel_scale_header
Returns the pixel scale of the mask as a header dictionary, which can be written to a .fits file.
pixel_scales
pixels_in_mask
The total number of unmasked pixels (values are False) in the mask.
real
shape
shape_native
The 1D shape of the mask, which is equivalent to the total number of unmasked pixels in the mask.
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
.
- classmethod all_false(shape_slim, pixel_scales, origin=(0.0,), invert=False)[source]#
Setup a 1D mask where all pixels are unmasked.
- classmethod from_fits(file_path, pixel_scales, hdu=0, origin=(0.0,))[source]#
Loads the 1D mask from a .fits file.
- classmethod from_primary_hdu(primary_hdu, origin=(0.0, 0.0))[source]#
Returns an
Mask1D
by from a PrimaryHDU object which has been loaded via astropy.fitsThis assumes that the header of the PrimaryHDU contains an entry named PIXSCALE which gives the pixel-scale of the array.
For a full description of
Mask1D
objects, including a description of theslim
andnative
attribute used by the API, see theMask1D class API documentation
.- Parameters:
- Return type:
Examples
from astropy.io import fits import autoarray as aa primary_hdu = fits.open("path/to/file.fits") array_1d = aa.Mask1D.from_primary_hdu( primary_hdu=primary_hdu, )
- property shape_slim: Tuple[int]#
The 1D shape of the mask, which is equivalent to the total number of unmasked pixels in the mask.
- property hdu_for_output: PrimaryHDU#
The mask as a HDU object, which can be output to a .fits file.
The header of the HDU is used to store the pixel_scale of the array, which is used by the Array1D.from_hdu.
This method is used in other projects (E.g. PyAutoGalaxy, PyAutoLens) to conveniently output the array to .fits files.
- Return type:
The HDU containing the data and its header which can then be written to .fits.