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

Utilities for generating and analyzing deformable mirror influence functions. More...

Utilities for generating and analyzing deformable mirror influence functions.

Author
Jared R. Males (jared.nosp@m.male.nosp@m.s@gma.nosp@m.il.c.nosp@m.om)

Definition in file influenceFunctions.hpp.

Go to the source code of this file.

Namespaces

 mx
 The mxlib c++ namespace.
 

Functions

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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 

Function Documentation

◆ 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 369 of file influenceFunctions.hpp.

References mx::AO::ifPInv(), and mx::fits::fitsFile< dataT >::read().

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

◆ 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 234 of file influenceFunctions.hpp.

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

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

◆ 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 480 of file influenceFunctions.hpp.

References mx::AO::m2cMatrix().

◆ 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 461 of file influenceFunctions.hpp.

References mx::improc::eigenCube< dataT >::asVectors(), and mx::AO::m2cMatrix().

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

◆ 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 514 of file influenceFunctions.hpp.

References mx::AO::modalDMM2cMatrix(), and mx::fits::fitsFile< dataT >::read().

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

◆ 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 555 of file influenceFunctions.hpp.

References mx::AO::modesOnDM().

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