<commit_before>#! /usr/bin/env python

"""
Full-frame PCA algorithm for ADI, ADI+RDI and ADI+mSDI (IFS data) cubes.
"""

__author__ = '<NAME>'
__all__ = ['pca']

import numpy as np
from multiprocessing import cpu_count
from .svd import svd_wrapper, SVDecomposer
from .utils_pca import pca_incremental, pca_grid
from ..preproc.derotation import _find_indices_adi, _compute_pa_thresh
from ..preproc import cube_rescaling_wavelengths as scwave
from ..preproc import (cube_derotate, cube_collapse, check_pa_vector,
                       check_scal_vector, cube_crop_frames, 
                       cube_subtract_sky_pca)
from ..conf import (timing, time_ini, check_enough_memory, Progressbar,
                    check_array)
from ..conf.utils_conf import pool_map, iterable
from ..var import (frame_center, dist, prepare_matrix, reshape_matrix,
                   cube_filter_lowpass, mask_circle)
from ..stats import descriptive_stats


def pca(cube, angle_list, cube_ref=None, scale_list=None, ncomp=1,
        svd_mode='lapack', scaling=None, mask_center_px=None, source_xy=None,
        delta_rot=1, fwhm=4, adimsdi='single', crop_ifs=True, imlib='opencv',
        imlib2='opencv', interpolation='lanczos4', collapse='median', 
        ifs_collapse_range='all', mask_rdi=None, check_memory=True, batch=None, 
        nproc=1, full_output=False, verbose=True, weights=None, conv=False,
        cube_sig=None):
    """ Algorithm where the reference PSF and the quasi-static speckle pattern
    are modeled using Principal Component Analysis. Depending on the input
    parameters this PCA function can work in ADI, RDI or SDI (IFS data) mode.

    ADI: the target ``cube`` itself is used to learn the PCs and to obtain a
    low-rank approximation model PSF (star + speckles). Both `cube_ref`` and
    ``scale_list`` must be None. The full-frame ADI-PCA implementation is based
    on Soummer et al. 2012 (http://arxiv.org/abs/1207.4197) and Amara & Quanz<commit_msg>new default imlib 'vip-fft' applied to PCA function<commit_after>#! /usr/bin/env python

"""
Full-frame PCA algorithm for ADI, ADI+RDI and ADI+mSDI (IFS data) cubes.
"""

__author__ = '<NAME>'
__all__ = ['pca']

import numpy as np
from multiprocessing import cpu_count
from .svd import svd_wrapper, SVDecomposer
from .utils_pca import pca_incremental, pca_grid
from ..preproc.derotation import _find_indices_adi, _compute_pa_thresh
from ..preproc import cube_rescaling_wavelengths as scwave
from ..preproc import (cube_derotate, cube_collapse, check_pa_vector,
                       check_scal_vector, cube_crop_frames, 
                       cube_subtract_sky_pca)
from ..conf import (timing, time_ini, check_enough_memory, Progressbar,
                    check_array)
from ..conf.utils_conf import pool_map, iterable
from ..var import (frame_center, dist, prepare_matrix, reshape_matrix,
                   cube_filter_lowpass, mask_circle)
from ..stats import descriptive_stats


def pca(cube, angle_list, cube_ref=None, scale_list=None, ncomp=1,
        svd_mode='lapack', scaling=None, mask_center_px=None, source_xy=None,
        delta_rot=1, fwhm=4, adimsdi='single', crop_ifs=True, imlib='vip-fft',
        imlib2='vip-fft', interpolation='lanczos4', collapse='median', 
        ifs_collapse_range='all', mask_rdi=None, check_memory=True, batch=None, 
        nproc=1, full_output=False, verbose=True, weights=None, conv=False,
        cube_sig=None):
    """ Algorithm where the reference PSF and the quasi-static speckle pattern
    are modeled using Principal Component Analysis. Depending on the input
    parameters this PCA function can work in ADI, RDI or SDI (IFS data) mode.

    ADI: the target ``cube`` itself is used to learn the PCs and to obtain a
    low-rank approximation model PSF (star + speckles). Both `cube_ref`` and
    ``scale_list`` must be None. The full-frame ADI-PCA implementation is based
    on Soummer et al. 2012 (http://arxiv.org/abs/1207.4197) and Amara & Quanz
{'fraction_non_alphanumeric': 0.09235027679919476, 'fraction_numerical': 0.009058882737795673, 'mean_word_length': 3.88929889298893, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4861159', 'n_tokens_mistral': 1354, 'n_tokens_neox': 1266, 'n_words': 380}