GUIBRUSHR.GUI.Input_Output_Panels.Input_Panels.TabPanels.FrameTellRem.tell_rem_pca_wl_log_final module¶
Telluric removal module using PCA (Principal Component Analysis) in the wavelength domain. This module processes spectroscopic data to remove telluric features using PCA decomposition.
- GUIBRUSHR.GUI.Input_Output_Panels.Input_Panels.TabPanels.FrameTellRem.tell_rem_pca_wl_log_final.combine(path_night_completef, name, transpose_read, repeatf=None, sort_indices=None)[source]¶
Combine A and B channel data into a single dataset.
- Parameters:
path_night_completef – Path to the night’s data
name – Base name for the files
transpose_read – Whether to transpose the data during reading
repeatf – Optional file name for repeating dimensions
sort_indices – Optional indices to sort the combined data (if None, interleave A and B)
- GUIBRUSHR.GUI.Input_Output_Panels.Input_Panels.TabPanels.FrameTellRem.tell_rem_pca_wl_log_final.combine_nfc(path_night_completef)[source]¶
Copy A_nfc.fits to nfc.fits.
- Parameters:
path_night_completef – Path to the night’s data
- GUIBRUSHR.GUI.Input_Output_Panels.Input_Panels.TabPanels.FrameTellRem.tell_rem_pca_wl_log_final.load_fase_data(file_path)[source]¶
Load phase data from file, handling both dictionary and legacy formats.
- GUIBRUSHR.GUI.Input_Output_Panels.Input_Panels.TabPanels.FrameTellRem.tell_rem_pca_wl_log_final.combine_fase(path_night_completef)[source]¶
Combine phase data from A and B channels into a single file.
Handles both new dictionary format and legacy sequential format for backward compatibility.
- Parameters:
path_night_completef – Path to the night directory
- Returns:
Indices used to sort the combined data based on hjd
- Return type:
sort_indices
- GUIBRUSHR.GUI.Input_Output_Panels.Input_Panels.TabPanels.FrameTellRem.tell_rem_pca_wl_log_final.combine_maskinv_err_pca(path_night_completef)[source]¶
Combine mask_good and error information from A and B channels.
- Parameters:
path_night_completef – Path to the night’s data
- GUIBRUSHR.GUI.Input_Output_Panels.Input_Panels.TabPanels.FrameTellRem.tell_rem_pca_wl_log_final.median_idl(arr)[source]¶
Calculate median using IDL-like tell_rm_method.
- Parameters:
arr – Input array
- Returns:
Median value
- GUIBRUSHR.GUI.Input_Output_Panels.Input_Panels.TabPanels.FrameTellRem.tell_rem_pca_wl_log_final.linear_solver(topca_l, res_l)[source]¶
Solve linear system using SVD decomposition.
- Parameters:
topca_l – Input data matrix
res_l – Result matrix
- Returns:
Reconstructed array
- GUIBRUSHR.GUI.Input_Output_Panels.Input_Panels.TabPanels.FrameTellRem.tell_rem_pca_wl_log_final.plot_tangent(pdf_tangentf, current_order, tan_sncf, der_secf, tangent_thresholdf, n_components_pcaf)[source]¶
Plot tangent information for PCA component selection.
- Parameters:
pdf_tangentf – PDF file to save plot
current_order – Order
tan_sncf – Tangent signal-to-noise curve
der_secf – Second derivative
tangent_thresholdf – Threshold for tangent
n_components_pcaf – Number of PCA components
- GUIBRUSHR.GUI.Input_Output_Panels.Input_Panels.TabPanels.FrameTellRem.tell_rem_pca_wl_log_final.plot_process(initial_spectrum, spectrum_after_mask, log_spectrum_after_mask, log_normalized_spectrum_after_mask, log_residuals_after_reconstruction, log_residuals_after_reconstruction_and_eventual_smooth, wl_order, pdf_processf, n_pixels, oi, phases)[source]¶
Plot processing steps for telluric removal.
- Parameters:
initial_spectrum – Initial data
spectrum_after_mask – Data after masking
log_spectrum_after_mask – Logarithmic of data after masking
log_normalized_spectrum_after_mask – Logarithmic of normalized data after masking
log_residuals_after_reconstruction – Residuals after reconstruction
log_residuals_after_reconstruction_and_eventual_smooth – Residuals after reconstruction and eventual smoothing
wl_order – Wavelength array for order
pdf_processf – PDF file to save plots
n_pixels – Number of pixels
oi – Order index
phases – Planetary orbital phases
- GUIBRUSHR.GUI.Input_Output_Panels.Input_Panels.TabPanels.FrameTellRem.tell_rem_pca_wl_log_final.plot_process2(initial_spectrum, log_spectrum_after_mask, log_residuals_after_reconstruction, array_reconstructed_from_PCA_components, wl_order, pdf_processf, n_pixels, oi, phases)[source]¶
Plot processing steps for telluric removal.
- Parameters:
initial_spectrum – Initial data
log_spectrum_after_mask – Logarithmic of data after masking
log_residuals_after_reconstruction – Residuals after reconstruction
array_reconstructed_from_PCA_components – array reconstructed from PCA components
wl_order – Wavelength array for order
pdf_processf – PDF file to save plots
n_pixels – Number of pixels
oi – Order index
phases – Planetary orbital phases
- GUIBRUSHR.GUI.Input_Output_Panels.Input_Panels.TabPanels.FrameTellRem.tell_rem_pca_wl_log_final.plot_order(current_order, x_arrf, maskf, resf, pdff)[source]¶
Plot order information.
- Parameters:
current_order – Order index
x_arrf – X-axis array
maskf – Mask array
resf – Result array
pdff – PDF file to save plot
- GUIBRUSHR.GUI.Input_Output_Panels.Input_Panels.TabPanels.FrameTellRem.tell_rem_pca_wl_log_final.plot_mean_sp(current_order, meanspf, normmeansp, continuumf, sigma_coefff, maskinv1f, maskinv2f, cutofff, threshold_mean, pdf_mean_spf, wlen)[source]¶
Plot mean spectrum with masks.
- Parameters:
current_order – Order
meanspf – Mean spectrum
normmeansp – Normalized Mean spectrum
continuumf – Continuum
sigma_coefff – Sigma coefficient for variance-based masking
maskinv1f – First mask inverse (cutoff + threshold)
maskinv2f – Second mask inverse (sigma-based)
cutofff – Cutoff value for telluric masking
threshold_mean – Threshold for mean spectrum masking
pdf_mean_spf – PDF file to save plot
wlen – Wavelength array for order
- GUIBRUSHR.GUI.Input_Output_Panels.Input_Panels.TabPanels.FrameTellRem.tell_rem_pca_wl_log_final.divide_by_brightest(spectra_order, n_images, n_brightest=50)[source]¶
Normalize spectra by dividing each exposure by the median of its brightest pixels.
- Parameters:
spectra_order – 2D array of spectral data (pixels x images)
n_images – Number of images (exposures)
n_brightest – Number of brightest pixels to use for normalization
- Returns:
(spectra_order, spectra_order_before_mask) - cleaned input and normalized spectra
- Return type:
tuple
- GUIBRUSHR.GUI.Input_Output_Panels.Input_Panels.TabPanels.FrameTellRem.tell_rem_pca_wl_log_final.masking_function(masking, spectra_order_before_mask, cutoff, threshold_mean_spec, sigma_coeff, checkbox_save_plot, good_order_oi, pdf_mean_sp, n_pixels, do_not_fit_continuum, wlen)[source]¶
Apply spectral masking based on telluric absorption and variance criteria.
- Parameters:
masking – Whether to apply masking
spectra_order_before_mask – Normalized spectral data (pixels x images)
cutoff – Cutoff threshold for telluric line detection
threshold_mean_spec – Threshold for mean spectrum signal level
sigma_coeff – Coefficient for variance-based masking
checkbox_save_plot – Whether to save diagnostic plots
good_order_oi – Order index for plot labeling
pdf_mean_sp – PDF file for saving mean spectrum plots
n_pixels – Number of spectral pixels
do_not_fit_continuum – Whether to skip continuum fitting
wlen – Wavelength array for order
- Returns:
- (std_after_full_norm, spectra_order_after_mask, mask_inv,
count_mask_inv, mask_good, amount_good_pixels)
- Return type:
tuple
- GUIBRUSHR.GUI.Input_Output_Panels.Input_Panels.TabPanels.FrameTellRem.tell_rem_pca_wl_log_final.tangent_method_for_PCA(pca_obj, log_spectra_order_after_mask, max_n_components_per_order, spectra_order_after_mask, result_first_pca, mask_good, epsilon, tangent_threshold, substitute_for_comp, current_order, checkbox_save_plot, pdf_tangent, pca_mode)[source]¶
Determine optimal number of PCA components using the tangent method.
Analyzes the variance reduction curve to find where adding more PCA components provides diminishing returns, using derivatives of the standard deviation.
- Parameters:
pca_obj – Fitted PCA object with
explained_variance_attributelog_spectra_order_after_mask – Log-transformed masked spectral data
max_n_components_per_order – Range of component numbers to test
spectra_order_after_mask – Masked spectral data (used for shape)
result_first_pca – PCA components from initial fit
mask_good – Indices of good (unmasked) pixels
epsilon – Small value to avoid division by zero
tangent_threshold – Threshold for second derivative test
substitute_for_comp – Fallback number of components
current_order – Current order index for logging
checkbox_save_plot – Whether to save tangent diagnostic plot
pdf_tangent – PDF file for saving tangent plot
pca_mode – PCA decomposition mode (‘spatial’ or ‘temporal’)
- Returns:
Optimal number of PCA components
- Return type:
int
- GUIBRUSHR.GUI.Input_Output_Panels.Input_Panels.TabPanels.FrameTellRem.tell_rem_pca_wl_log_final.cross_val_score_components(pca_obj, pca_scores, max_n_components_per_order, log_spectra_order_after_mask)[source]¶
- GUIBRUSHR.GUI.Input_Output_Panels.Input_Panels.TabPanels.FrameTellRem.tell_rem_pca_wl_log_final.get_number_of_components_PCA(auto_components, log_spectra_order_after_mask, max_n_components_per_order, spectra_order_after_mask, mask_good, epsilon, tangent_threshold, substitute_for_comp, current_order, checkbox_save_plot, pdf_tangent, entry_min_comp, entry_max_comp, entry_fixed_comp, tangent_method, apply_standardize, pca_mode)[source]¶
- GUIBRUSHR.GUI.Input_Output_Panels.Input_Panels.TabPanels.FrameTellRem.tell_rem_pca_wl_log_final.apply_smooth(log_final_pca, smooth_size, mask_good)[source]¶
- GUIBRUSHR.GUI.Input_Output_Panels.Input_Panels.TabPanels.FrameTellRem.tell_rem_pca_wl_log_final.tell_rem_wl_log2(exchange_pathf)[source]¶
Main function for telluric removal using PCA with wavelength calibration.
- Parameters:
exchange_pathf – Path to exchange directory containing parameters
- GUIBRUSHR.GUI.Input_Output_Panels.Input_Panels.TabPanels.FrameTellRem.tell_rem_pca_wl_log_final.main()[source]¶
Main function for telluric removal using PCA in wavelength domain.
- Command line usage:
python tell_rem_pca_wl_log_final.py <exchange_path> <path_default>
- Args (from command line):
exchange_path: Path to exchange directory with input data path_default: Default path for GUIBRUSHR modules