autogalaxy.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.

  • 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

all

all_false

Setup a 1D mask where all pixels are unmasked.

astype

copy

from_fits

Loads the 1D mask from a .fits file.

instance_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

reshape

sqrt

sum

with_new_array

Copy this object but give it a new array.

Attributes

array

derive_grid

Returns the DeriveGrid1D object associated with the mask, which computes derived grids of (x,) coordinates such as the unmasked pixel grid.

derive_mask

Returns the DeriveMask1D object associated with the mask, which computes derived masks such as the edge mask.

dimensions

The number of dimensions of the mask (e.g. 1 for a 1D mask, 2 for a 2D mask).

dtype

geometry

Return the 1D geometry of the mask, representing its uniform rectangular grid of (x) coordinates defined by its shape_native.

header_dict

Returns the pixel scales of the mask as a header dictionary, which can be written to a .fits file.

imag

is_all_false

Returns True if all pixels in a mask are False (i.e. every pixel is unmasked), else returns False.

is_all_true

Returns True if all pixels in a mask are True, else returns False.

is_transformed

mask

The boolean ndarray of the mask, where False entries are unmasked (used in calculations) and True entries are masked (excluded from calculations).

native

Returns the data structure in its native format which contains all unmaksed values to the native dimensions.

ndim

pixel_scale

The pixel scale of the mask as a single float value.

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 in its native representation, equal to the shape of the underlying boolean ndarray.

shape_slim

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 DeriveMask1D object associated with the mask, which computes derived masks such as the edge mask.

property derive_grid: DeriveGrid1D#

Returns the DeriveGrid1D object 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 .fits file 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 .fits file.

Return type:

Mask1D

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_native since 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.