mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
Loading...
Searching...
No Matches
mx::AO Namespace Reference

Namespaces

namespace  analysis
 
namespace  constants
 
namespace  path
 Namespace for paths.
 
namespace  sim
 

Classes

struct  influenceFunctionGaussianSpec
 

Functions

template<typename realT >
void applyPupil2Basis (eigenCube< realT > &modes, const std::string &basisName, const std::string &pupilName, realT fwhm=0)
 Multiply a raw modal basis by a pupil mask.
 
template<typename realT , typename spectRealT >
int orthogonalizeBasis (eigenCube< realT > &ortho, Eigen::Array< spectRealT, -1, -1 > &spect, eigenCube< realT > &modes, int method, realT psum=1.0)
 
template<typename realT >
void orthogonalizeBasis (const std::string &orthoName, const std::string &basisName, const std::string &pupilName, int method)
 Calculate an orthogonal projection of a basis on a pupil.
 
template<typename spectRealT , typename realT >
void normalizeSpectrum (mx::improc::eigenImage< spectRealT > &spectrum, mx::improc::eigenCube< realT > &modes, mx::improc::eigenCube< realT > &ortho, mx::improc::eigenImage< realT > &pupil)
 
template<typename realT >
int slaveBasis (const std::string &outputBasisN, const std::string &inputBasisN, const std::string &pupilN, const std::string &dmN, realT fwhm, realT fsmooth, int firstMode=0)
 
template<typename realT >
int apodizeBasis (const std::string &outputBasisN, const std::string &inputBasisN, realT tukeyAlpha, realT centralObs, realT overScan, int firstMode)
 
template<typename realT >
int subtractBasis (const std::string &basisName, const std::string &basisName1, const std::string &basisName2, const std::string &pupilName, int method)
 
template<typename realT >
void makeModfBasis (const std::string &basisName, int dim, int N, realT ang, int nZern=0)
 Make the modified Fourier basis.
 
template<typename realT >
void influenceFunctionsGaussian (const std::string &dmName, realT dmSz, int linNAct, realT diameter, realT coupling, realT couplingRange, realT pupilSz=0, bool offsetOdd=false)
 Create a set of Gaussian influence functions (IFs) on a square grid.
 
template<typename realT >
void ifPInv (const std::string &dmName, realT maxCondition=-1)
 Calculate the pseudo-inverse and mirror modes for a set of influence functions.
 
template<typename realT >
void m2cMatrix (Eigen::Array< realT, -1, -1 > &M2c, Eigen::Array< realT, -1, -1 > &Ap, mx::improc::eigenCube< realT > &M)
 Calculate the modes-to-commands matrix for a set of modes.
 
template<typename realT >
void m2cMatrix (const std::string &dmName, const std::string &basisName)
 Calculate the modes-to-commands matrix for a set of modes.
 
template<typename realT >
void modalDMM2cMatrix (const std::string &basisName)
 Generate the modes-to-commands matrix for a set of modes on the modal DM.
 
template<typename realT >
void modesOnDM (const std::string &dmName, const std::string &basisName)
 Calculate the basis set as it will be reproduced by the DM.
 
template<typename realT >
void circularPupil (const std::string &pupilName, realT pupilDiamPixels, realT pupilDiamMeters, realT centralObs=0, realT overscan=0)
 Generate a circular pupil and saves it to disk.
 
template<typename realT >
void circularApodizedPupil (const std::string &pupilName, int pupilDiamPixels, realT pupilDiamMeters, realT tukeyAlpha, realT centralObs=0, realT overScan=0)
 Generates a circular apodized pupil and saves it to disk.
 
template<typename realT >
void makeZernikeBasis (const std::string &basisName, const std::string &pupilName, int dim, int N)
 Make the Zernike basis.
 

Function Documentation

◆ apodizeBasis()

template<typename realT >
int mx::AO::apodizeBasis ( const std::string &  outputBasisN,
const std::string &  inputBasisN,
realT  tukeyAlpha,
realT  centralObs,
realT  overScan,
int  firstMode 
)

Definition at line 371 of file basis.hpp.

References mx::AO::path::basis::modes(), and mx::math::six_fifths().

◆ applyPupil2Basis()

template<typename realT >
void mx::AO::applyPupil2Basis ( eigenCube< realT > &  modes,
const std::string &  basisName,
const std::string &  pupilName,
realT  fwhm = 0 
)

Multiply a raw modal basis by a pupil mask.

Definition at line 38 of file basis.hpp.

References mx::improc::filterImage(), mx::AO::path::basis::modes(), mx::improc::padImage(), mx::AO::path::pupil::pupilFile(), and mx::math::six_fifths().

Referenced by orthogonalizeBasis().

◆ circularApodizedPupil()

template<typename realT >
void mx::AO::circularApodizedPupil ( const std::string &  pupilName,
int  pupilDiamPixels,
realT  pupilDiamMeters,
realT  tukeyAlpha,
realT  centralObs = 0,
realT  overScan = 0 
)

Generates a circular apodized pupil and saves it to disk.

Apodization is with a Tukey window.

Definition at line 62 of file pupil.hpp.

References mx::fits::fitsHeader::append(), mx::AO::path::pupil::pupilFile(), and mx::fits::fitsFile< dataT >::write().

◆ circularPupil()

template<typename realT >
void mx::AO::circularPupil ( const std::string &  pupilName,
realT  pupilDiamPixels,
realT  pupilDiamMeters,
realT  centralObs = 0,
realT  overscan = 0 
)

Generate a circular pupil and saves it to disk.

Definition at line 28 of file pupil.hpp.

References mx::fits::fitsHeader::append(), mx::wfp::circularPupil(), mx::AO::path::pupil::pupilFile(), and mx::fits::fitsFile< dataT >::write().

◆ ifPInv()

template<typename realT >
void mx::AO::ifPInv ( const std::string &  dmName,
realT  maxCondition = -1 
)

Calculate the pseudo-inverse and mirror modes for a set of influence functions.

The influence functions are a cube of 2D maps of mirror deformations, and the matrix \( A \) is formed by vectorizing the influence functions. The pseudo inverse is then calculated from the SVD as follows: \( A = U S V^T \) which gives the Moore-Penrose pseudo-inverse: \( A^+ = V S^+ U^T\). The columns of U contain the orthogonal mirror modes, and S contains the singular values. These are both written to disk along with the pseudo-inverse.

Parameters
[in]dmNameis the name of the deformable mirror.
[in]maxCondition[optional] the maximum condition number to accept for the pseudo-inverse. If < 0 [default] then the user is interactively asked what to use.
Template Parameters
realTis the real floating point type in which to do calculations.

Definition at line 366 of file influenceFunctions.hpp.

References mx::fits::fitsHeader::append(), mx::improc::eigenCube< dataT >::asVectors(), mx::improc::eigenCube< dataT >::cols(), mx::math::eigenPseudoInverse(), mx::AO::path::dm::influenceFunctions(), mx::AO::path::dm::mirrorModes(), MX_PINV_ASK, MX_PINV_NO_INTERACT, MX_PINV_PLOT, mx::improc::eigenCube< dataT >::planes(), mx::AO::path::dm::pseudoInverse(), mx::fits::fitsFile< dataT >::read(), mx::improc::eigenCube< dataT >::resize(), mx::improc::eigenCube< dataT >::rows(), mx::AO::path::dm::singularValues(), and mx::fits::fitsFile< dataT >::write().

◆ influenceFunctionsGaussian()

template<typename realT >
void mx::AO::influenceFunctionsGaussian ( const std::string &  dmName,
realT  dmSz,
int  linNAct,
realT  diameter,
realT  coupling,
realT  couplingRange,
realT  pupilSz = 0,
bool  offsetOdd = false 
)

Create a set of Gaussian influence functions (IFs) on a square grid.

The width of the IFs is specified by the coupling, which is the height of the IF at 1 actuator separation. For a FWHM = 1 actuator, coupling = 0.0625. The IFs are normalized to a height of 1.

Parameters
[in]dmNamethe name of the deformable mirror (DM) (the mx::AO path will be constructed from this).
[in]dmSzthe linear size of the DM in pixels.
[in]linNActthe linear number of actuators across the DM.
[in]diameteris the diameter of the DM, in actuators. If 0 then the DM is a square.
[in]couplingis the height of the IF at 1 actuator separation. E.G., for a FWHM = 1 actuator, set this to 0.0625.
[in]pupilSzis the size of the pupil, and therefore the size of the maps (pupilSz x pupilSz), Is set to dmSz if 0, can be pupilSz < dmSx for an oversized DM. The pupil is assumed to be centered.
Template Parameters
realTis the real floating point type in which to do calculations.

< Uniform deviate, used in shiftRandom.

Parameters
couplingRangeUniformly distributed uncertainy in coupling, in fraction of the coupling.

Definition at line 230 of file influenceFunctions.hpp.

References mx::AO::path::dm::actuatorPositions(), mx::fits::fitsHeader::append(), mx::math::func::fwhm2sigma(), mx::improc::eigenCube< dataT >::image(), mx::AO::path::dm::influenceFunctions(), mx::math::randomT< typeT, _ranengT, _randistT >::seed(), and mx::fits::fitsFile< dataT >::write().

◆ m2cMatrix() [1/2]

template<typename realT >
void mx::AO::m2cMatrix ( const std::string &  dmName,
const std::string &  basisName 
)

Calculate the modes-to-commands matrix for a set of modes.

A wrapper for m2cMatrix, where the various matrices are here specified with names, which in turn generate mx::AO paths

Parameters
[in]dmNameis the name of the deformable mirror
[in]basisNameis the name of the modal basis
[in]pupilNameis the name of the pupil
Template Parameters
realTis the real floating point type in which to do calculations.

Definition at line 470 of file influenceFunctions.hpp.

References mx::AO::path::dm::M2c(), m2cMatrix(), mx::AO::path::basis::modes(), mx::AO::path::dm::pseudoInverse(), mx::fits::fitsFile< dataT >::read(), and mx::fits::fitsFile< dataT >::write().

◆ m2cMatrix() [2/2]

template<typename realT >
void mx::AO::m2cMatrix ( Eigen::Array< realT, -1, -1 > &  M2c,
Eigen::Array< realT, -1, -1 > &  Ap,
mx::improc::eigenCube< realT > &  M 
)

Calculate the modes-to-commands matrix for a set of modes.

Given the pseudo-inverse \( A^+ \) of the influence functions, the commands to the actuators to take a mirror shape \( \vec{s} \) are calculated as

\[ \vec{c} = \mathbf{A^+} \vec{s}. \]

Now given a basis set \( \mathbf{M} \), the mirror shape is specified as

\[ \vec{s}= \sum_i m_i M_i \]

where \( \vec{m} = m_0, m_1, \cdot m_i \cdot \) are the modal coefficients. If the mirror-to-commands matrix, \( \mathbf{M2c} \) gives commands as

\[ \vec{c} = \mathbf{M2c} \vec{m} \]

then we can calculate \( \mathbf{M2c} \) as:

\[ \mathbf{M2c} = \mathbf{A}^{+T} \mathbf{M} \]

Parameters
[out]M2cis the M2c matrix, allocated during the calculationg
[in]Apis the pseudo-inverse of the influence function basis set
[in]Mis the modal basis set, a cube of shapes
Template Parameters
realTis the real floating point type used for all calculations.

Definition at line 453 of file influenceFunctions.hpp.

References mx::improc::eigenCube< dataT >::asVectors().

Referenced by m2cMatrix().

◆ makeModfBasis()

template<typename realT >
void mx::AO::makeModfBasis ( const std::string &  basisName,
int  dim,
int  N,
realT  ang,
int  nZern = 0 
)

Make the modified Fourier basis.

Parameters
[in]basisNamethe name of the basis (not including the mx::AO path)
[in]dimthe linear size of the maps, that is they will be dimxdim in size.
[in]Nis the number of degrees of freedom. Number of modes will be (N+1)(N+1) - 1.
Template Parameters
realTthe real numeric type for calculations

Definition at line 32 of file fourierBasis.hpp.

References mx::improc::eigenCube< dataT >::image(), mx::sigproc::makeFourierBasis_Rect(), mx::AO::path::basis::modes(), MX_FOURIER_MODIFIED, mx::improc::eigenCube< dataT >::resize(), and mx::fits::fitsFile< dataT >::write().

◆ makeZernikeBasis()

template<typename realT >
void mx::AO::makeZernikeBasis ( const std::string &  basisName,
const std::string &  pupilName,
int  dim,
int  N 
)

Make the Zernike basis.

Parameters
[in]basisNamethe name of the basis (not including the mx::AO path)
[in]dimthe linear size of the maps, that is they will be dimxdim in size.
[in]Nis the number of degrees of freedom. Number of modes will be (N+1)(N+1) - 1.
Template Parameters
realTthe real numeric type for calculations

Definition at line 29 of file zernikeBasis.hpp.

References mx::improc::eigenCube< dataT >::image(), mx::AO::path::basis::modes(), mx::improc::eigenCube< dataT >::planes(), mx::AO::path::pupil::pupilFile(), and mx::improc::eigenCube< dataT >::resize().

◆ modalDMM2cMatrix()

template<typename realT >
void mx::AO::modalDMM2cMatrix ( const std::string &  basisName)

Generate the modes-to-commands matrix for a set of modes on the modal DM.

Generates an Identity matrix of the appropriate size.

Parameters
[in]basisNameis the name of the modal basis
Template Parameters
realTis the real floating point type in which to do calculations.

Definition at line 502 of file influenceFunctions.hpp.

References mx::AO::path::dm::M2c(), mx::AO::path::basis::modes(), mx::improc::eigenCube< dataT >::planes(), mx::fits::fitsFile< dataT >::read(), and mx::fits::fitsFile< dataT >::write().

◆ modesOnDM()

template<typename realT >
void mx::AO::modesOnDM ( const std::string &  dmName,
const std::string &  basisName 
)

Calculate the basis set as it will be reproduced by the DM.

The projected modes are written to the path specified by mx::AO::path::dm::projectedModes().

Parameters
[in]dmNameis the name of the DM.
[in]basisNameis the name of the basis.
Template Parameters
realTis the real floating point type in which to do calculations.

Definition at line 540 of file influenceFunctions.hpp.

References mx::improc::eigenCube< dataT >::cols(), mx::improc::eigenCube< dataT >::image(), mx::AO::path::dm::influenceFunctions(), mx::AO::path::dm::M2c(), mx::AO::path::dm::projectedModes(), mx::fits::fitsFile< dataT >::read(), mx::improc::eigenCube< dataT >::resize(), mx::improc::eigenCube< dataT >::rows(), mx::improc::eigenCube< dataT >::setZero(), and mx::fits::fitsFile< dataT >::write().

◆ normalizeSpectrum()

template<typename spectRealT , typename realT >
void mx::AO::normalizeSpectrum ( mx::improc::eigenImage< spectRealT > &  spectrum,
mx::improc::eigenCube< realT > &  modes,
mx::improc::eigenCube< realT > &  ortho,
mx::improc::eigenImage< realT > &  pupil 
)

◆ orthogonalizeBasis() [1/2]

template<typename realT >
void mx::AO::orthogonalizeBasis ( const std::string &  orthoName,
const std::string &  basisName,
const std::string &  pupilName,
int  method 
)

Calculate an orthogonal projection of a basis on a pupil.

Can use either the stabilized Gramm Schmidt (SGS) procedure, or Singular Value Decomposition (SVD). This calls applyPupil2Basis as a first step..

Parameters
[in]basisNamethe name of the basis to orthogonalize
[in]pupilNamethe name of the pupil on which to orthogonalize.
[in]methodeither MXAO_ORTHO_METHOD_SGS (for SGS) or MXAO_ORTHO_METHOD_SVD (for SVD)
Template Parameters
realT

Definition at line 143 of file basis.hpp.

References applyPupil2Basis(), mx::improc::eigenCube< dataT >::image(), mx::AO::path::basis::modes(), orthogonalizeBasis(), mx::improc::eigenCube< dataT >::planes(), mx::AO::path::pupil::pupilFile(), mx::math::six_fifths(), and mx::AO::path::basis::spectrum().

◆ orthogonalizeBasis() [2/2]

template<typename realT , typename spectRealT >
int mx::AO::orthogonalizeBasis ( eigenCube< realT > &  ortho,
Eigen::Array< spectRealT, -1, -1 > &  spect,
eigenCube< realT > &  modes,
int  method,
realT  psum = 1.0 
)

◆ slaveBasis()

template<typename realT >
int mx::AO::slaveBasis ( const std::string &  outputBasisN,
const std::string &  inputBasisN,
const std::string &  pupilN,
const std::string &  dmN,
realT  fwhm,
realT  fsmooth,
int  firstMode = 0 
)

◆ subtractBasis()

template<typename realT >
int mx::AO::subtractBasis ( const std::string &  basisName,
const std::string &  basisName1,
const std::string &  basisName2,
const std::string &  pupilName,
int  method 
)