mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
fourierModes.hpp File Reference

Functions for generating 2D Fourier modes. More...

Functions for generating 2D Fourier modes.

Author
Jared R. Males

Definition in file fourierModes.hpp.

Go to the source code of this file.

Classes

struct  mx::sigproc::fourierModeDef
 Structure to contain the parameters of a Fourier mode. More...
 

Namespaces

 mx
 The mxlib c++ namespace.
 

Functions

template<class typeN >
int mx::sigproc::makeFourierModeC (typeN im, typename typeN::Scalar m, typename typeN::Scalar n)
 Populate a single cosine mode. More...
 
template<class typeN >
int mx::sigproc::makeFourierModeS (typeN im, typename typeN::Scalar m, typename typeN::Scalar n)
 Populate a single sine mode. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
bool mx::sigproc::comp_fourierModeDef_PandV (const fourierModeDef &spf1, const fourierModeDef &spf2)
 Sorting functor for modes according to the Poyner and Veran (2005) standard. More...
 
int mx::sigproc::makeFourierModeFreqs_PandV (std::vector< fourierModeDef > &spf, int N)
 Generate a Poyneer and Veran spatial frequency grid. More...
 
bool mx::sigproc::comp_fourierModeDef (const fourierModeDef &spf1, const fourierModeDef &spf2)
 Sorting functor for modes according to the mx::AO standard. More...
 
int mx::sigproc::makeFourierModeFreqs_Circ (std::vector< fourierModeDef > &spf, int N)
 Generate a circular spatial frequency grid. More...
 
int mx::sigproc::fourierModeNumber (int m, int n, int p)
 Calculate the index of a Fourier mode given its (m,n,p) coordinates. More...
 
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. More...
 
int mx::sigproc::makeFourierModeFreqs_Rect (std::vector< fourierModeDef > &spf, int N)
 Generate a rectangular spatial frequency grid. More...
 
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. More...
 
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. More...
 
template<typename cubeT >
int mx::sigproc::makeFourierBasis_Circ (cubeT &cube, int dim, int N, int basisType)
 Generate a circular Fourier basis. More...
 
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. More...
 

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 410 of file fourierModes.hpp.

References mx::sigproc::comp_fourierModeDef(), mx::sigproc::fourierModeDef::m, mx::sigproc::fourierModeDef::n, and mx::sigproc::fourierModeDef::p.

Referenced by mx::sigproc::comp_fourierModeDef(), and 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) [19]

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 321 of file fourierModes.hpp.

References mx::sigproc::comp_fourierModeDef_PandV(), mx::sigproc::fourierModeDef::m, mx::sigproc::fourierModeDef::n, and mx::sigproc::fourierModeDef::p.

Referenced by mx::sigproc::comp_fourierModeDef_PandV(), and 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 639 of file fourierModes.hpp.

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

Referenced by mx::sigproc::fillFourierBasis(), 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 545 of file fourierModes.hpp.

References mx::sigproc::fourierModeCoordinates().

Referenced by mx::sigproc::fourierModeCoordinates(), and 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 498 of file fourierModes.hpp.

References mx::sigproc::fourierModeNumber().

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

◆ 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 703 of file fourierModes.hpp.

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

Referenced by mx::sigproc::makeFourierBasis_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) [19] 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 677 of file fourierModes.hpp.

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

Referenced by mx::sigproc::makeFourierBasis_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 730 of file fourierModes.hpp.

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

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

◆ 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 170 of file fourierModes.hpp.

References mx::sigproc::makeFourierMode(), mx::sigproc::makeFourierModeC(), and mx::sigproc::makeFourierModeS().

Referenced by mx::sigproc::fillFourierBasis(), and mx::sigproc::makeFourierMode().

◆ 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 79 of file fourierModes.hpp.

References mx::sigproc::makeFourierModeC().

Referenced by mx::sigproc::makeFourierMode(), and mx::sigproc::makeFourierModeC().

◆ 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 441 of file fourierModes.hpp.

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

Referenced by mx::sigproc::makeFourierBasis_Circ(), and mx::sigproc::makeFourierModeFreqs_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) [19]

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

Definition at line 347 of file fourierModes.hpp.

References mx::sigproc::comp_fourierModeDef_PandV(), mx::astro::constants::k(), and mx::sigproc::makeFourierModeFreqs_PandV().

Referenced by mx::sigproc::makeFourierBasis_PandV(), and mx::sigproc::makeFourierModeFreqs_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 602 of file fourierModes.hpp.

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

Referenced by mx::sigproc::makeFourierBasis_Rect(), and mx::sigproc::makeFourierModeFreqs_Rect().

◆ 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 129 of file fourierModes.hpp.

References mx::sigproc::makeFourierModeS().

Referenced by mx::sigproc::makeFourierMode(), and mx::sigproc::makeFourierModeS().

◆ 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 199 of file fourierModes.hpp.

References mx::sigproc::makeModifiedFourierMode().

Referenced by mx::sigproc::fillFourierBasis(), mx::sigproc::makeModifiedFourierMode(), 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 286 of file fourierModes.hpp.

References mx::sigproc::makeModifiedFourierMode(), and mx::sigproc::makeModifiedFourierModeM().

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

◆ 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 267 of file fourierModes.hpp.

References mx::sigproc::makeModifiedFourierMode(), and mx::sigproc::makeModifiedFourierModeP().

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