Other functions and classes#

Code author: Wilfried Mercier - LAM <wilfried.mercier@lam.fr>

Miscellaneous functions.

class DETECTION_TYPE(value)[source]#

Bases: Enum

Code author: Wilfried Mercier - LAM <wilfried.mercier@lam.fr>

Various types of detection techniques. See Mercier et al. (2025).

INTRINSIC = 2#

Intrinsic detection

OPTIMAL = 1#

Optimal detection

compute_surface_mask(segmap, value=1, surface=0)[source]#

Code author: Wilfried Mercier - LAM <wilfried.mercier@lam.fr>

Compute a mask that keeps pixels that satisfy the surface threshold described below. Each independent structure will have a unique integer associated to it.

Important

Pixels are selected by the mask if they form a contiguous structure whose surface is larger than the given minimum surface. Contiguity is defined here as adjacent pixels along the left, right, bottom, and top directions (i.e. no diagonal).

Note

If the given value is not in the segmentation map, the mask is returned as None.

Parameters:
  • segmap (NDArray) – segmentation map used to select the pixels forming contiguous structures

  • value (int) – value in the segmentation mask that is used to select the pixels. In other words, the mask will only be computed for pixels whose value is equal to value.

  • surface (int) – minimum surface in \(\rm pixels\) that a contiguous structure must have in order to be kept in the output mask

Returns:

Mask (with a shape equal to segmap.shape) with one integer per structure that matches the surface criterion. A value of 0 means no structure (i.e. background pixels).

Return type:

  • None if value not in segmap else

  • NDArray

Raises:
  • ValueError if segmap.ndim != 2 or surface < 0

  • TypeError if not isinstance(surface, int)

find_neighbours(pixel, pixels, max0, max1, noTypeCheck=False)[source]#

Code author: Wilfried Mercier - LAM <wilfried.mercier@lam.fr>

Given a pixel position and a list of all pixel positions, find neighbours that are in the list.

Note

Neighbours means adjacent pixels to the left, right, bottom, and top only.

Parameters:
  • pixel ((int, int)) – (Y, X) position of the given pixel

  • pixels (list[(int, int)]) – (Y, X) position of all pixels

  • max0 (int) – maximum position along axis 0

  • max1 (int) – maximum position along axis 1

  • noTypeCheck (bool) – whether not to perform type conversion. Type conversion slows down the code but ensures data are properly cast to the right format to find neighbours.

Returns:

List of the (Y, X) positions of the adjacent pixels in the input pixel list.

Return type:

list[(int, int)]

generate_bulge_mask(ra_pix, dec_pix, z, shape, cosmo, radius_kpc=1, pix_size=0.03)[source]#

Code author: Wilfried Mercier - LAM <wilfried.mercier@lam.fr>

Generate a mask encompassing a circular bulge of a given size with True for pixels inside the bulge and False for those outside.

Parameters:
  • ra_pix (int) – position along the RA axis in \(\rm pixels\)

  • dec_pix (int) – position along the Declination axis in \(\rm pixels\)

  • z (float) – redshift of the source used to convert physical sizes to angles

  • shape ((int, int)) – shape of the returned mask

  • cosmo (Cosmology) – cosmological model used to convert physical sizes to angles

  • radius_kpc (int or float) – radius of the bulge in \(\rm kpc\)

  • pix_size (int or float) – size of a pixel in \(\rm arcsec\)

Returns:

boolean mask delimiting the bulge

Return type:

NDArray