mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
Signal Processing

Tools for processing signals

Classes

struct  mx::sigproc::autocorrelationFromPSD< T >
 Functor for calculating the autocorrelation given a PSD. More...
 
struct  mx::sigproc::linearPredictor< _realT >
 A class to support linear prediction.
More...
 

Modules

 Power Spectra
 
 The Fourier Basis
 
 The Zernike Basis
 
 Window Functions
 
 Image Filters
 
 Signal Processing Files
 
 Circular Buffer
 A circular buffer class.
 

Functions

template<typename T >
void mx::sigproc::autocorrelation (T *ac, size_t Nac, T *sig, size_t Nsig)
 Calculate the autocorrelation of a time-series. More...
 
template<typename T >
void mx::sigproc::autocorrelation (std::vector< T > &ac, std::vector< T > &sig)
 Calculate the autocorrelation of a time-series. More...
 
template<typename realT >
int mx::sigproc::basisMask (improc::eigenCube< realT > &modes, improc::eigenImage< realT > &mask)
 Mask a basis set. More...
 
template<typename realT >
int mx::sigproc::basisMeanSub (improc::eigenCube< realT > &modes, improc::eigenImage< realT > &mask, bool postMult=true)
 Mean-subtract a basis set. More...
 
template<typename realT >
int mx::sigproc::basisNormalize (improc::eigenCube< realT > &modes, improc::eigenImage< realT > &mask)
 Normalize a basis set. More...
 
template<typename realT >
int mx::sigproc::basisAmplitudes (std::vector< realT > &amps, improc::eigenImage< realT > &im, improc::eigenCube< realT > &modes, improc::eigenImage< realT > &mask, bool subtract=false, int meanIgnore=0, int N=-1)
 Measure the amplitudes of a set of basis modes fit to an image. Optionally subtract them. More...
 
template<int progress = 0, typename eigenTout , typename eigenTin >
void mx::sigproc::gramSchmidt (eigenTout &out, const eigenTin &in)
 Perform Gram-Schmidt ortogonalization of a basis set, and normalize the result. More...
 
template<int progress = 0, typename eigenTout , typename eigenTin , typename eigenTWin >
void mx::sigproc::gramSchmidt (eigenTout &out, const eigenTin &in, const eigenTWin &window)
 Perform Gram-Schmidt ortogonalization of a basis set on a window, and normalize the result. More...
 
template<int progress = 0, typename eigenTout , typename eigenTout2 , typename eigenTin >
void mx::sigproc::gramSchmidtSpectrum (eigenTout &out, eigenTout2 &spect, const eigenTin &in, typename eigenTin::Scalar normPix=1.0)
 Perform Gram-Schmidt ortogonalization of a basis set, and normalize the result, while recording the spectrum. More...
 

Function Documentation

◆ autocorrelation() [1/2]

template<typename T >
void mx::sigproc::autocorrelation ( std::vector< T > &  ac,
std::vector< T > &  sig 
)

Calculate the autocorrelation of a time-series.

Template Parameters
Tis the real type of the data and autocorrelation.
Todo:
this should probably re-allocate if ac.size() != sig.size(), or at least <
Parameters
[out]acwill contain the autocorrelation on return. If ac.size()==0 then it is resized to sig.size().
[in]sigis the input time-series (signal)

Definition at line 79 of file autocorrelation.hpp.

◆ autocorrelation() [2/2]

template<typename T >
void mx::sigproc::autocorrelation ( T *  ac,
size_t  Nac,
T *  sig,
size_t  Nsig 
)

Calculate the autocorrelation of a time-series.

Template Parameters
Tis the real type of the data and autocorrelation.
Parameters
[out]acis the pre-allocated array of length Nac which will contain the autocorrelation on return
[in]Nacis the length of ac
[in]sigis the input time-series (signal)
[in]Nsigis the length of the input time-series

Definition at line 48 of file autocorrelation.hpp.

◆ basisAmplitudes()

template<typename realT >
int mx::sigproc::basisAmplitudes ( std::vector< realT > &  amps,
improc::eigenImage< realT > &  im,
improc::eigenCube< realT > &  modes,
improc::eigenImage< realT > &  mask,
bool  subtract = false,
int  meanIgnore = 0,
int  N = -1 
)

Measure the amplitudes of a set of basis modes fit to an image. Optionally subtract them.

Mode subtraction occurs one by one, so subtraction will work with non-orthogonal basis sets.

Returns
0 on success
-1 on error
Template Parameters
realTthe floating point type.
Parameters
[out]ampsthe amplitudes of each mode fit to the image (will be resized).
im[in.out] the image to fit. Is subtracted in place if desired.
[in]modesthe modes to fit.
[in]maskthe 1/0 mask which defines the domain of the fit.
[in]subtract[optional] if true then the modes are subtracted as they are fit to the image
[in]meanIgnore[optional] if 1 then the mean, or if 2 the median, value is subtracted before fitting. If subtract is false, this value is added back after the subtraction.
[in]N[optional] the number of modes to actually fit. If N < 0 then all modes are fit.

Definition at line 129 of file basisUtils2D.hpp.

◆ basisMask()

template<typename realT >
int mx::sigproc::basisMask ( improc::eigenCube< realT > &  modes,
improc::eigenImage< realT > &  mask 
)

Mask a basis set.

Multiplies each mode in a basis set by a mask.

Returns
0 on success
-1 on error
Template Parameters
realTa real floating point type.
Parameters
modes[in.out] the basis to normalize.
[in]mask1/0 mask defining the domain of the basis

Definition at line 51 of file basisUtils2D.hpp.

◆ basisMeanSub()

template<typename realT >
int mx::sigproc::basisMeanSub ( improc::eigenCube< realT > &  modes,
improc::eigenImage< realT > &  mask,
bool  postMult = true 
)

Mean-subtract a basis set.

Subtracts the mean of each mode calculated over a domain defined by a mask.

Returns
0 on success
-1 on error
Template Parameters
realTa real floating point type.
Parameters
modes[in.out] the basis to normalize.
[in]mask1/0 mask defining the domain of the basis
[in]postMult[optional] if true, then each image is multiplied by the mask after subtraction.

Definition at line 74 of file basisUtils2D.hpp.

◆ basisNormalize()

template<typename realT >
int mx::sigproc::basisNormalize ( improc::eigenCube< realT > &  modes,
improc::eigenImage< realT > &  mask 
)

Normalize a basis set.

RMS normalize each mode over a domain defined by a mask.

Returns
0 on success
-1 on error
Template Parameters
realTa real floating point type.
Parameters
modes[in.out] the basis to normalize.
[in]mask1/0 mask defining the domain of the normalization

Definition at line 103 of file basisUtils2D.hpp.

◆ gramSchmidt() [1/2]

template<int progress = 0, typename eigenTout , typename eigenTin >
void mx::sigproc::gramSchmidt ( eigenTout &  out,
const eigenTin &  in 
)

Perform Gram-Schmidt ortogonalization of a basis set, and normalize the result.

Performs the stabilized Gram-Schmidt procedure on the input basis set, followed by normalization of the result.

Parameters
out[out] is the orthonormal basis set constructed from the input
int[in] is a basis set, where each column represents one vector.
Template Parameters
progressif true, then the loop index is printed for progress reporting
eigenToutis the Eigen array type of the desired output
eigenTinis the Eigen array type of the input

Definition at line 52 of file gramSchmidt.hpp.

◆ gramSchmidt() [2/2]

template<int progress = 0, typename eigenTout , typename eigenTin , typename eigenTWin >
void mx::sigproc::gramSchmidt ( eigenTout &  out,
const eigenTin &  in,
const eigenTWin &  window 
)

Perform Gram-Schmidt ortogonalization of a basis set on a window, and normalize the result.

Performs the stabilized Gram-Schmidt procedure on the input basis set over a window (or weight function), followed by normalization of the result.

Parameters
out[out] is the orthonormal basis set constructed from the input
in[in] is a basis set, where each column represents one vector.
window[in] is the window, or weighting function
Template Parameters
progressif true, then the loop index is printed for progress reporting
eigenToutis the Eigen array type of the desired output
eigenTinis the Eigen array type of the input
eigenTWinis the Eigen array type of the window

Definition at line 98 of file gramSchmidt.hpp.

◆ gramSchmidtSpectrum()

template<int progress = 0, typename eigenTout , typename eigenTout2 , typename eigenTin >
void mx::sigproc::gramSchmidtSpectrum ( eigenTout &  out,
eigenTout2 &  spect,
const eigenTin &  in,
typename eigenTin::Scalar  normPix = 1.0 
)

Perform Gram-Schmidt ortogonalization of a basis set, and normalize the result, while recording the spectrum.

Performs the stabilized Gram-Schmidt procedure on the input basis set, followed by normalization of the result. Also records the spectrum, that is the coefficients of the linear expansion in the orginal basis set for the resultant basis set.

Template Parameters
progressif true, then the loop index is printed for progress reporting
eigenToutis the Eigen array type of the output orthogonalized array
eigenTout2is the Eigen array type of the spectrum
eigenTinis the Eigen array type of the input
Parameters
[out]outthe orthonormal basis set constructed from the input
[out]spectthe spectrum
[in]ina basis set, where each column represents one vector
[in]normPix[optional] area of (usually number of pixels in) the orthogonal region for normalization.

Definition at line 163 of file gramSchmidt.hpp.