frb.surveys.utils_crossmatching

Utilities for TNS Transient cross-matching with FRBs @author: Yuxin Dong last edited: May 13, 2025

frb.surveys.utils_crossmatching.cov_matrix(a, b, theta)[source]

Calculate the covariance matrix for a 2D ellipse.

Parameters: a (float): Semi-major axis of the ellipse b (float): Semi-minor axis of the ellipse theta (float): Position angle of the ellipse in degrees

Returns: np.ndarray: 2x2 covariance matrix

frb.surveys.utils_crossmatching.mahalanobis_distance(point, frbcenter, cov_matrix)[source]

Calculate the Mahalanobis distance between a given point and the center. effectively the Z-score in 1D, and it can be a proxy for how many sigma away you are from the mean.

Parameters: point (array-like): The point for which to calculate the distance (should be [RA, Dec]). frbcenter (array-like): The center point, usually the mean [RA, Dec]. cov_matrix (array-like): The covariance matrix of the data.

Returns: float: The Mahalanobis distance.

frb.surveys.utils_crossmatching.percentile(mahalanobis_distance, df=2)[source]
frb.surveys.utils_crossmatching.gauss_contour(frbcenter, cov_matrix, semi_major, transient_name, transient_position=None, levels=[0.68, 0.95, 0.99], save_fig=False)[source]

Plot Gaussian contours around a given FRB center based on its covariance matrix.

This function computes and visualizes the Gaussian contours (ellipses) that represent the uncertainty in the position of the FRB as defined by its covariance matrix. Then, it plots the position of the transient along with the Mahalanobis distance from the FRB center.

Parameters: frbcenter (Astropy SkyCoord): The central position of the FRB. cov_matrix (array-like): The covariance matrix representing the uncertainties in the FRB’s position. semi_major (float): The semi-major axis of the Gaussian ellipse in degrees. transient_name (str): The name of the transient source. transient_position (Astropy SkyCoord): Transient position. levels: List of confidence levels for the contours (default: [0.68, 0.95, 0.99]). save_fig (optional; bool): set flag to true to save the figure.