Other functions and classes#
Code author: Wilfried Mercier - LAM <wilfried.mercier@lam.fr>
Miscellaneous functions.
- class DETECTION_TYPE(value)[source]#
Bases:
EnumCode 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
valueis not in the segmentation map, the mask is returned asNone.- 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 tovalue.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:
Noneifvalue not in segmapelse
- Raises:
ValueErrorifsegmap.ndim != 2 or surface < 0TypeErrorifnot 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 pixelpixels (
list[(int, int)]) – (Y, X) position of all pixelsmax0 (
int) – maximum position along axis 0max1 (
int) – maximum position along axis 1noTypeCheck (
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
Truefor pixels inside the bulge andFalsefor 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 anglesshape (
(int, int)) – shape of the returned maskcosmo (Cosmology) – cosmological model used to convert physical sizes to angles
radius_kpc (
intorfloat) – radius of the bulge in \(\rm kpc\)pix_size (
intorfloat) – size of a pixel in \(\rm arcsec\)
- Returns:
boolean mask delimiting the bulge
- Return type: