Contents:
Remove temporal trends from blocks of data.
meansub=False – whether to zero-out the mean, or keep the means fixed
eblock=None – 1-sigma errors on the values in ‘block’ for PCA n=200 – number of wavelength bins to use for each PCA calculation
verbose=False – bool flag to spit out lots of verbose messages
Perform Swain et al.’s “Fourier Self-Complementary Spectrum” analysis.
Input: Data, numpy array – M x N: M observations of N variables
Calculate principal component analysis for an N x M input array of N observations of M variables.
(Helped function for detdata, but could eventually be stand-alone)
ord – number of principal components to remove, sorted by eigenvalue size trans – take the transpose of block and eblock (i.e., they are
M x N instead of the desired N x M)
WARNING: do not trust any PC’s with coefficient magnitudes near-zero!
Compute Principal Component Analysis on a 2D array.
NOTE: I don’t trust the MDP module (or, I don’t understand what it’s doing), since it does not agree with my hand-coded (somewhat slower) PCA routine.
block – N x M numpy array – N observations of M variables.
eblock – dummy option kept for backwards compatibility; does nothing. ord – number of Principal Components to extract svd – bool flag; whether to use SVD to compute PCA
Compute the eigenvalues of covariance matrix (i.e., the PC coefficients) for input data block.
ord – number of eigenvalues to return. If None, returns all. svd – bool flag; whether to use SVD to compute PCA retnode – also return the mdp.PCANode object
Project a given principal component eigenvector onto a block of data
pc – length-N 1D numpy array block – N x M input array of N observations of M variables.
Collect data and prepare for LSD analysis.
telcor=True – load telluric-corrected data getcal=False – load calibration spectra instead of sci. spectra divop=’median’ – by default, divide each spectrum by its
median to normalize it. Can also set to ‘none’
OUTPUT: (assume L observations of M echelle orders with N wavelength bins)
w – N-length wavelength grid for data proc – processed data cubes, L x M x N eproc – computed _instrumental_ uncertainties, L x M x N sky – sky background intensity, L x M x N hjd – L-length time array of heliocentric Julian Date airmass – L-length airmass array p – “planet” object from analysis.getobj() rv – planet’s maximal Radial Velocity at specified HJD keyvals – various specified header keywords at specified HJD spec_location – location of star along slit at given HJD, L x M
computing eigenvalues and eigenvectors of covariance matrix
Taken from http://glowingpython.blogspot.it/2011/07/pca-and-image-compression-with-numpy.html
Shift and align spectra.
Shift and align spectra.
Shift a 1D vector by an offset. Helper function for salign.
non-overlapping elements are replaced by zeros.
Get pixelwise offsets between two similar 1D vectors.
maxshift – int. Min/max of pixel correlation lags to compute.