mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
Loading...
Searching...
No Matches
The Fourier Basis

Macro Definition Documentation

◆ MX_FOURIER_BASIC

#define MX_FOURIER_BASIC   0

Signifies the basic sine/cosine Fourier basis.

Todo:
need to handle references and r-values so this works directly with Eigen arrays.

Definition at line 55 of file fourierModes.hpp.

◆ MX_FOURIER_MODIFIED

#define MX_FOURIER_MODIFIED   1

Signifies the modified Fourier basis.

Definition at line 60 of file fourierModes.hpp.

Function Documentation

◆ comp_fourierModeDef()

bool mx::sigproc::comp_fourierModeDef ( const fourierModeDef spf1,
const fourierModeDef spf2 
)

Sorting functor for modes according to the mx::AO standard.

Given a spatial frequency vector \( \vec{k} = k_u \hat{u} + k_v \hat{v} \), sorts first by \( | \vec{k} | \), then by the angle from the u axis. Results in mode numbers increasing radially and counter-clockwise from the \( u \) axis.

Parameters
[in]spf1is an object of type fourierModeDef to compare with spf2
[in]spf2is an object of type fourierModeDef to compare with spf1
Returns
the result of (spf1 < spf2) according to the above rules.

Definition at line 408 of file fourierModes.hpp.

References mx::sigproc::fourierModeDef::m, mx::sigproc::fourierModeDef::n, and mx::sigproc::fourierModeDef::p.

Referenced by mx::sigproc::makeFourierModeFreqs_Circ().

◆ comp_fourierModeDef_PandV()

bool mx::sigproc::comp_fourierModeDef_PandV ( const fourierModeDef spf1,
const fourierModeDef spf2 
)

Sorting functor for modes according to the Poyner and Veran (2005) standard.

Follows the conventions of Poyneer & Veran (2005) [18]

Parameters
[in]spf1is an object of type fourierModeDef to compare with spf2
[in]spf2is an object of type fourierModeDef to compare with spf1
Returns
the result of (spf1 < spf2) according to the above rules.

Definition at line 313 of file fourierModes.hpp.

References mx::sigproc::fourierModeDef::m, mx::sigproc::fourierModeDef::n, and mx::sigproc::fourierModeDef::p.

Referenced by mx::sigproc::makeFourierModeFreqs_PandV().

◆ fillFourierBasis()

template<typename cubeT >
int mx::sigproc::fillFourierBasis ( cubeT &  cube,
int  dim,
std::vector< fourierModeDef spf,
int  basisType,
typename cubeT::Scalar  ang = 0 
)

Fill in a cube with a Fourier basis.

Fills the cube with either the basic or modified Fourier basis for the modes specified.

Parameters
[out]cubewill be allocated to hold and will be filled with the modes
[in]dimis the linear size of the maps, each is
[in]spfis a vector of mode definitions to use for each mode
[in]basisTypeis either MX_FOURIER_MODIFIED or MX_FOURIER_BASIC
Template Parameters
cubeTis an eigen-like cube, e.g. mx::eigenCube.

Definition at line 625 of file fourierModes.hpp.

References mx::sigproc::makeFourierMode(), mx::sigproc::makeModifiedFourierMode(), and MX_FOURIER_MODIFIED.

Referenced by mx::sigproc::makeFourierBasis_Circ(), mx::sigproc::makeFourierBasis_PandV(), and mx::sigproc::makeFourierBasis_Rect().

◆ fourierModeCoordinates()

int mx::sigproc::fourierModeCoordinates ( int &  m,
int &  n,
int &  p,
int  i 
)

Calculate the (m,n,p) coordinates of a Fourier mode given its index.

The index increases counter-clockwise from the m axis in squares, with p==-1 being even and p==1 being odd.

Returns
0 on success, a negative number otherwise
Return values
-1if i < 0
Parameters
[out]mis the m spatial frequency coordinate
[out]nis the n spatial frequency coordinage
[out]pis the parity, +/-1, for sine or cosine or specifiying the modified Fourier mode.
[in]iis the mode index.

Definition at line 541 of file fourierModes.hpp.

References MXE_INVALIDARG, and mxError.

Referenced by mx::sigproc::makeFourierModeFreqs_Rect().

◆ fourierModeNumber()

int mx::sigproc::fourierModeNumber ( int  m,
int  n,
int  p 
)

Calculate the index of a Fourier mode given its (m,n,p) coordinates.

The index increases counter-clockwise from the m axis in squares, with p==-1 being even and p==1 being odd.

Parameters
[in]mis the m spatial frequency coordinate
[in]nis the n spatial frequency coordinage
[in]pis the parity, +/-1, for sine or cosine or specifiying the modified Fourier mode.
Returns
the index of the Fourier mode on success
-1 on an error.

Definition at line 497 of file fourierModes.hpp.

References MXE_INVALIDARG, and mxError.

◆ makeFourierBasis_Circ()

template<typename cubeT >
int mx::sigproc::makeFourierBasis_Circ ( cubeT &  cube,
int  dim,
int  N,
int  basisType 
)

Generate a circular Fourier basis.

Fills the cube with modes generated by makeFourierMode or makeModifiedFourierMode using the mode grid generated by makeFourierModeFreqs_Circ.

Parameters
[out]cubewill be allocated to hold and will be filled with the modes
[in]dimis the linear size of the maps, each is
[in]Nis the linear number of degrees of freedom. The number of modes is ((N+1)(N+1) - 1).
[in]basisTypeis either MX_FOURIER_MODIFIED or MX_FOURIER_BASIC
Template Parameters
cubeTis an eigen-like cube, e.g. mx::eigenCube.

Definition at line 686 of file fourierModes.hpp.

References mx::sigproc::fillFourierBasis(), and mx::sigproc::makeFourierModeFreqs_Circ().

◆ makeFourierBasis_PandV()

template<typename cubeT >
int mx::sigproc::makeFourierBasis_PandV ( cubeT &  cube,
int  dim,
int  N,
int  basisType 
)

Generate a rectangular modified Fourier basis with the Poyneer and Veran ordering.

Fills the cube with modes generated by makeFourierMode or makeModifiedFourierMode using the mode grid generated by makeFourierModeFreqs_PandV. This follows the convention of Poyneer and Veran (2005) [18] for mode numbering.

Parameters
[out]cubewill be allocated to hold and will be filled with the modes
[in]dimis the linear size of the maps, each is
[in]Nis the linear number of degrees of freedom. The number of modes is ((N+1)(N+1) - 1).
[in]basisTypeis either MX_FOURIER_MODIFIED or MX_FOURIER_BASIC
Template Parameters
cubeTis an eigen-like cube, e.g. mx::eigenCube.

Definition at line 662 of file fourierModes.hpp.

References mx::sigproc::fillFourierBasis(), and mx::sigproc::makeFourierModeFreqs_PandV().

◆ makeFourierBasis_Rect()

template<typename cubeT >
int mx::sigproc::makeFourierBasis_Rect ( cubeT &  cube,
int  dim,
int  N,
int  basisType,
typename cubeT::Scalar  ang = 0 
)

Generate a rectangular Fourier basis.

Fills the cube with modes generated by makeFourierMode or makeModifiedFourierMode using the mode grid generated by makeFourierModeFreqs_Rect.

Parameters
[out]cubewill be allocated to hold and will be filled with the modes
[in]dimis the linear size of the maps, each is
[in]Nis the linear number of degrees of freedom. The number of modes is ((N+1)(N+1) - 1).
[in]basisTypeis either MX_FOURIER_MODIFIED or MX_FOURIER_BASIC
Template Parameters
cubeTis an eigen-like cube, e.g. mx::eigenCube.

Definition at line 710 of file fourierModes.hpp.

References mx::sigproc::fillFourierBasis(), and mx::sigproc::makeFourierModeFreqs_Rect().

Referenced by mx::AO::makeModfBasis().

◆ makeFourierMode()

template<class typeN >
int mx::sigproc::makeFourierMode ( typeN  im,
typename typeN::Scalar  m,
typename typeN::Scalar  n,
int  p 
)

Populate a single basic Fourier mode.

Makes a 2D image of the basic sine or cosine mode. Calls makeFourierModeC and makeFourierModeS.

Parameters
[out]imis an Eigen-like image
[in]mspecifies the spatial frequency in the u direction
[in]nspecifies the spatial frequency in the v direction
[in]pspecies sine (-1) or cosine (+1)
Return values
0on success
Template Parameters
typeNis an Eigen-like reference type.

Definition at line 169 of file fourierModes.hpp.

References mx::sigproc::makeFourierModeC(), mx::sigproc::makeFourierModeS(), MXE_INVALIDARG, and mxError.

Referenced by mx::sigproc::fillFourierBasis().

◆ makeFourierModeC()

template<class typeN >
int mx::sigproc::makeFourierModeC ( typeN  im,
typename typeN::Scalar  m,
typename typeN::Scalar  n 
)

Populate a single cosine mode.

Makes a 2D image of the cosine mode:

\[ M_c(\vec{q}) = \cos\left( 2\pi\frac{m}{D}u + 2\pi\frac{n}{D}v \right) \]

where

\[ \vec{q} = u \hat{u} + v \hat{v} \]

and \( D \) is taken to be the maximum of the number of columns and rows in the image.

Return values
0on success
Template Parameters
typeNis an Eigen-like reference type.
Parameters
[out]imis an Eigen-like image
[in]mspecifies the spatial frequency in the u direction
[in]nn specifies the spatial frequency in the v direction

Definition at line 78 of file fourierModes.hpp.

References mx::math::six_fifths().

Referenced by mx::sigproc::makeFourierMode().

◆ makeFourierModeFreqs_Circ()

int mx::sigproc::makeFourierModeFreqs_Circ ( std::vector< fourierModeDef > &  spf,
int  N 
)

Generate a circular spatial frequency grid.

Todo:
use push_back instead of resize
Parameters
spf
Nis the linear number of degrees of freedom. The number of modes is ((N+1)(N+1) - 1).

Definition at line 440 of file fourierModes.hpp.

References mx::sigproc::comp_fourierModeDef(), MXE_SIZEERR, and mxError.

Referenced by mx::sigproc::makeFourierBasis_Circ().

◆ makeFourierModeFreqs_PandV()

int mx::sigproc::makeFourierModeFreqs_PandV ( std::vector< fourierModeDef > &  spf,
int  N 
)

Generate a Poyneer and Veran spatial frequency grid.

Follows the convention of Poyneer and Veran (2005) [18]

Todo:
use push_back instead of resize
Parameters
spf
Nis the linear number of degrees of freedom.

Definition at line 340 of file fourierModes.hpp.

References mx::sigproc::comp_fourierModeDef_PandV(), MXE_SIZEERR, and mxError.

Referenced by mx::sigproc::makeFourierBasis_PandV().

◆ makeFourierModeFreqs_Rect()

int mx::sigproc::makeFourierModeFreqs_Rect ( std::vector< fourierModeDef > &  spf,
int  N 
)

Generate a rectangular spatial frequency grid.

Parameters
spfis a vector of fourierModeDef structures, which will be resized and populated.
Nis the linear number of degrees of freedom. The number of modes is ((N+1)(N+1) - 1).

Definition at line 592 of file fourierModes.hpp.

References mx::sigproc::fourierModeCoordinates().

Referenced by mx::AO::analysis::fourierTemporalPSD< _realT, aosysT >::analyzePSDGrid(), mx::AO::analysis::fourierCovarMap(), mx::AO::analysis::fourierTemporalPSD< _realT, aosysT >::intensityPSD(), mx::sigproc::makeFourierBasis_Rect(), and mx::AO::analysis::fourierTemporalPSD< _realT, aosysT >::makePSDGrid().

◆ makeFourierModeS()

template<class typeN >
int mx::sigproc::makeFourierModeS ( typeN  im,
typename typeN::Scalar  m,
typename typeN::Scalar  n 
)

Populate a single sine mode.

Makes a 2D image of the cosine mode:

\[ M_s(\vec{q}) = \sin\left( 2\pi\frac{m}{D}u + 2\pi\frac{n}{D}v \right) \]

where

\[ \vec{q} = u \hat{u} + v \hat{v} \]

and \( D \) is taken to be the maximum of the number of columns and rows in the image.

Parameters
[out]imis an Eigen-like image
[in]mspecifies the spatial frequency in the u direction
[in]nspecifies the spatial frequency in the v direction
Return values
0on success
Template Parameters
typeNis an Eigen-like reference type.

Definition at line 128 of file fourierModes.hpp.

References mx::math::six_fifths().

Referenced by mx::sigproc::makeFourierMode().

◆ makeModifiedFourierMode()

template<class typeN >
int mx::sigproc::makeModifiedFourierMode ( typeN  im,
typename typeN::Scalar  m,
typename typeN::Scalar  n,
int  p,
typename typeN::Scalar  ang = 0 
)

Populate a single modified Fourier mode.

Makes a 2D image of the modified fourier mode:

\[ M_p(\vec{q}) = \cos\left( 2\pi \frac{m}{D}u + 2\pi\frac{n}{D}v \right) + p \sin\left( 2\pi\frac{m}{D}u + 2\pi\frac{n}{D}v \right) \]

where \( p = \pm 1 \), \( \vec{q} = u \hat{u} + v \hat{v} \), and \( D \) is taken to be the maximum of the number of columns in the image.

Parameters
[out]imis an Eigen-like image
[in]mspecifies the spatial frequency in the u direction
[in]nspecifies the spatial frequency in the v direction
[in]pis +/- 1 specifying which modified Fourier mode
Return values
0on success
Template Parameters
typeNis an Eigen-like reference type.

Definition at line 200 of file fourierModes.hpp.

References mx::math::dtor(), MXE_INVALIDARG, mxError, and mx::math::six_fifths().

Referenced by mx::sigproc::fillFourierBasis(), mx::sigproc::makeModifiedFourierModeM(), and mx::sigproc::makeModifiedFourierModeP().

◆ makeModifiedFourierModeM()

template<class typeN >
int mx::sigproc::makeModifiedFourierModeM ( typeN  im,
typename typeN::Scalar  m,
typename typeN::Scalar  n,
typename typeN::Scalar  ang = 0 
)

Populate a single modified Fourier -1 mode.

See makeModifiedFourierMode.

Parameters
[out]imis an Eigen-like image
[in]mspecifies the spatial frequency in the u direction
[in]nspecifies the spatial frequency in the v direction
Template Parameters
typeNis an Eigen-like reference type.

Definition at line 281 of file fourierModes.hpp.

References mx::sigproc::makeModifiedFourierMode().

◆ makeModifiedFourierModeP()

template<class typeN >
int mx::sigproc::makeModifiedFourierModeP ( typeN  im,
typename typeN::Scalar  m,
typename typeN::Scalar  n,
typename typeN::Scalar  ang = 0 
)

Populate a single modified Fourier +1 mode.

See makeModifiedFourierMode.

Parameters
[out]imis an Eigen-like image
[in]mspecifies the spatial frequency in the u direction
[in]nspecifies the spatial frequency in the v direction
Template Parameters
typeNis an Eigen-like reference type.

Definition at line 263 of file fourierModes.hpp.

References mx::sigproc::makeModifiedFourierMode().