CASgm¶
Module contains routines to calculate CAS parameters, as well as Gini, M20, R20, R80.
-
pawlikMorphLSST.casgm.
gini
(image: numpy.ndarray, mask: numpy.ndarray) → float Calculation of the Gini index of a Galaxy.
\[g = \frac{1}{2 \bar{X} n(n-1)} \sum (2i - n - 1) \left|X_i\right|\]Where \(\bar{X}\) is the mean over all intensities n is the total number of pixels \(X_i\) are the pixel intensities in increasing order
see Lotz et al. 2004 https://doi.org/10.1086/421849
- Parameters
image (float, 2d np.ndarray) – Image from which the Gini index shall be calculated
mask (int, 2D np.ndarray) – TMask which contains the galaxies pixels
- Returns
G – The Gini index.
- Return type
float
-
pawlikMorphLSST.casgm.
m20
(image: numpy.ndarray, mask: numpy.ndarray) → float Calculate the M20 statistic.
\[M_{20} = log_{10} \left(\frac{\sum M_i} {M_{tot}}\right)\]\[While \sum f_i < 0.2 f_{tot}\]\[M_{tot} = \sum M_i = \sum f_i [(x - x_c)^2 + (y - y_c)^2]\]see Lotz et al. 2004 https://doi.org/10.1086/421849
Adapted from statmorph: https://github.com/vrodgom/statmorph
- Parameters
image (float, 2d np.ndarray) – Image of galaxy
mask (float [0. - 1.], 2d np.ndarray) – Mask which contains the pixels belonging to the galaxy of interest.
- Returns
m20 – M20 statistic
- Return type
float
-
pawlikMorphLSST.casgm.
concentration
(r20: float, r80: float) → float Calculation of the concentration of light in a galaxy.
\[C = 5log_{10}(\frac{r_{80}}{r_{20}})\]see Lotz et al. 2004 https://doi.org/10.1086/421849
- Parameters
r20 (float) – Radius at 20% of light
r80 (float) – Radius at 80% of light
- Returns
C – The concentration index
- Return type
float
-
pawlikMorphLSST.casgm.
smoothness
(image: numpy.ndarray, mask: numpy.ndarray, centroid: List[float], Rmax: float, r20: float, sky: float) → float Calculate the smoothness or clumpiness of the galaxy of interest.
\[S = \frac{\sum \left|I - I_s\right| - B_s} {\sum \left|I\right|}\]Where I is the image \(I_s\) is the smoothed image \(B_s\) is the background smoothness
see Lotz et al. 2004 https://doi.org/10.1086/421849
- Parameters
image (float, 2d np.ndarray) – Image of galaxy
mask (float [0. - 1.], 2d np.ndarray) – Mask which contains the pixels belonging to the galaxy of interest.
centroid (List[float]) – Pixel location of the brightest pixel in galaxy.
Rmax (float) – Distance from brightest pixel to furthest pixel in galaxy
r20 (float) – Distance from brightest pixel to radius at which 20% of light of galaxy is enclosed.
sky (float) – Value of the sky background.
- Returns
Result – The smoothness or clumpiness parameter, S.
- Return type
float
-
pawlikMorphLSST.casgm.
calcR20_R80
(image: numpy.ndarray, centroid: List[float], radius: float) → Tuple[float, float] Calculation of \(r_{20}\), and \(r_{80}\)
- Parameters
image (float, 2d np.ndarray) – Image of galaxy
centroid (List[float]) – Location of the brightest pixel
radius (float) – Radius in which to measure galaxy light out to.
- Returns
r20, r80 – The radii where 20% and 80% light falls within
- Return type
Tuple[float, float]
-
pawlikMorphLSST.casgm.
calculateCSGM
(image: numpy.ndarray, mask: numpy.ndarray, skybgr: float) → Tuple[float] Helper function that calculates the CSGM parameters
- Parameters
image (np.ndarray, 2D float) – Image of a galxy for which the CSGM parameters are to be calculated
mask (np.ndarray, 2D uint8) – Image for which only the pixels that belong to the galaxy in “image” are “hot”.
skybgr (float) – The value of the sky background in the given image
- Returns
C, S, gini, m20 – The CSGM parameters
- Return type
Tuple[float]