mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
|
Utilities for generating and analyzing deformable mirror influence functions. More...
Utilities for generating and analyzing deformable mirror influence functions.
Definition in file influenceFunctions.hpp.
#include "../improc/eigenCube.hpp"
#include "../math/func/gaussian.hpp"
#include "../ioutils/fits/fitsFile.hpp"
#include <mx/math/eigenLapack.hpp>
#include <mx/ioutils/pout.hpp>
#include <mx/math/randomT.hpp>
#include <vector>
#include "aoPaths.hpp"
Go to the source code of this file.
Namespaces | |
namespace | 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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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.
[in] | dmName | is 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. |
realT | is 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::math::eigenPseudoInverse(), mx::AO::ifPInv(), mx::fits::fitsFile< dataT >::read(), and mx::fits::fitsFile< dataT >::write().
Referenced by mx::AO::ifPInv().
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.
[in] | dmName | the name of the deformable mirror (DM) (the mx::AO path will be constructed from this). |
[in] | dmSz | the linear size of the DM in pixels. |
[in] | linNAct | the linear number of actuators across the DM. |
[in] | diameter | is the diameter of the DM, in actuators. If 0 then the DM is a square. |
[in] | coupling | is the height of the IF at 1 actuator separation. E.G., for a FWHM = 1 actuator, set this to 0.0625. |
[in] | pupilSz | is 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. |
realT | is the real floating point type in which to do calculations. |
< Uniform deviate, used in shiftRandom.
couplingRange | Uniformly distributed uncertainy in coupling, in fraction of the coupling. |
Definition at line 230 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().
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
[in] | dmName | is the name of the deformable mirror |
[in] | basisName | is the name of the modal basis |
[in] | pupilName | is the name of the pupil |
realT | is the real floating point type in which to do calculations. |
Definition at line 470 of file influenceFunctions.hpp.
References mx::AO::m2cMatrix(), mx::fits::fitsFile< dataT >::read(), and mx::fits::fitsFile< dataT >::write().
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} \]
[out] | M2c | is the M2c matrix, allocated during the calculationg |
[in] | Ap | is the pseudo-inverse of the influence function basis set |
[in] | M | is the modal basis set, a cube of shapes |
realT | is the real floating point type used for all calculations. |
Definition at line 453 of file influenceFunctions.hpp.
References mx::improc::eigenCube< dataT >::asVectors(), and mx::AO::m2cMatrix().
Referenced by mx::AO::m2cMatrix(), and mx::AO::m2cMatrix().
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.
[in] | basisName | is the name of the modal basis |
realT | is the real floating point type in which to do calculations. |
Definition at line 502 of file influenceFunctions.hpp.
References mx::AO::modalDMM2cMatrix(), mx::fits::fitsFile< dataT >::read(), and mx::fits::fitsFile< dataT >::write().
Referenced by mx::AO::modalDMM2cMatrix().
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().
[in] | dmName | is the name of the DM. |
[in] | basisName | is the name of the basis. |
realT | is the real floating point type in which to do calculations. |
Definition at line 540 of file influenceFunctions.hpp.
References mx::improc::eigenCube< dataT >::image(), mx::AO::modesOnDM(), mx::fits::fitsFile< dataT >::read(), and mx::fits::fitsFile< dataT >::write().
Referenced by mx::AO::modesOnDM().