GUIBRUSHR.core.functions.pca module

PCA utility functions for systematic noise removal in light curve residuals.

This module provides Principal Component Analysis (PCA) based functions for processing light curve residuals and removing systematic components in spectroscopic data analysis.

GUIBRUSHR.core.functions.pca.linear_solver(topca_l: ndarray, res_l: ndarray)[source]

Solve a linear system using Singular Value Decomposition (SVD).

This function solves the linear system Ax = b using SVD decomposition, where A is the design matrix (res_l) and b is the target vector (topca_l). The solution is computed in a numerically stable way using SVD.

Parameters:
  • topca_l (np.ndarray) – Target vector b in the system Ax = b

  • res_l (np.ndarray) – Design matrix A in the system Ax = b

Returns:

The reconstructed array after solving the linear system Error: Whether the linear system was solved successfully

Return type:

Results

GUIBRUSHR.core.functions.pca.trpca(lcr_mask: ndarray, lcrm_mask_nomask: ndarray, good_pixel: ndarray, ncomp: int, smooth_on: bool, smooth_size: int, apply_standardize: bool, model_reprocessing_type: str, subtract_mean_spectrum: bool = False, pca_mode: str = 'spatial')[source]

Process light curve residuals by removing systematic components using PCA.

This function processes light curve residuals by: 1. Normalizing the data by subtracting column-wise means 2. Optionally applying PCA-based component removal 3. Updating the output array for good pixels 4. Optionally applying smoothing

Parameters:
  • lcr_mask (np.ndarray) – 2D array of light curve residuals with telluric mask

  • lcrm_mask_nomask (np.ndarray) – 2D array to store processed residuals

  • good_pixel (np.ndarray) – Boolean mask or indices of good pixels

  • ncomp (int) – Number of PCA components to use

  • smooth_on (bool) – Whether to apply smoothing

  • smooth_size (int) – Window size for smoothing filter

  • apply_standardize (bool) – Whether to apply standardization

  • model_reprocessing_type (str) – Processing mode, either “hard” or “soft”

  • subtract_mean_spectrum (bool) – Whether to subtract mean spectrum

  • pca_mode (str) – PCA mode - “spatial” (samples=images, features=pixels) or “temporal” (samples=pixels, features=images). Default: “spatial”

Returns:

Processed light curve residuals error: Whether the processing was successful

Return type:

np.ndarray