Cholesky

cholesky.py

Module that implements the Cholesky functionality.

get_chi2(_L_inv: ndarray, residuals: ndarray) ndarray[source]

Compute chi-squared (chi2) from given inverse Cholesky of the covariance matrix (L^-1) and a residual vector (r = data - model). This function defines x = L^-1 * r such that chi2 = |x|^2, which guarantees that chi2 >= 0.

Parameters:
  • _L_inv (ndarray) – Inverse square root of the covariance, as computed from the function get_inverse_square_root_covariance_matrix.

  • residuals (ndarray) – Difference between the observed coefficient vector and some model prediction of it.

Returns:

Chi-squared value.

Return type:

float

get_inverse_covariance_matrix(input_object: list | Path | str, band: str | None = None)[source]

Compute the inverse covariance matrix.

Parameters:
  • input_object (object) – Path to the file containing the mean spectra as downloaded from the archive in their continuous representation, a pandas DataFrame, a list of sources ids (string or long), or an ADQL query.

  • band (str) – Chosen band: ‘bp’ or ‘rp’. If no band is passed, the function will compute the inverse covariance for both ‘bp’ and ‘rp’.

Returns:

DataFrame containing the source IDs and the output inverse covariance matrices for the

sources in the input object if it contains more than one source or no band is passed to the function. The function will return a ndarray (of shape (55, 55)) if there is only one source ID in the input data and a single band is selected.

Return type:

DataFrame or ndarray

get_inverse_square_root_covariance_matrix(input_object: list | Path | str, band: str | None = None)[source]

Compute the inverse square root covariance matrix.

Parameters:
  • input_object (list/Path/str) – Path to the file containing the mean spectra as downloaded from the archive in their continuous representation, a pandas DataFrame, a list of sources ids (string or long), or an ADQL query.

  • band (str) – Chosen band: ‘bp’ or ‘rp’. If no band is passed, the function will compute the inverse square root covariance for both ‘bp’ and ‘rp’.

Returns:

DataFrame containing the source IDs and the output inverse square root covariance matrices

for the sources in the input object if it contains more than one source or no band is passed to the function. The function will return a ndarray (of shape (55, 55)) if there is only one source ID in the input data and a single band is selected.

Return type:

DataFrame or ndarray