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

Here is how to get started working with the mx::AO library.

Define the MX_AO_DATADIR environment variable in .bashrc or .bash_alias like so:

export MX_AO_DATADIR=/path/to/mxao/data/

The following program will create a pupil and a modified Fourier basis set, including the orthogonalization of the basis on the pupil.

#include "pupil.hpp"
#include "fourierBasis.hpp"
#include "basis.hpp"
int main()
{
typedef double realT; //It is generally best to do all preparatory work in double precision.
//Assign descriptive names to each component
std::string basis = "modf_150_48";
std::string pupil = "circular_29percent_150";
//Generate a centrally obscured pupil.
mx::AO::circularPupil<realT>(pupil, 150, 6.5, 0.29);
//Note: these functions generally require an explicit template parameter.
//Make a modified Fourier basis
mx::AO::makeModfBasis<realT>( basis, 150, 48 );
//Apply the pupil to the basis
//Now orthogonalize the basis on the pupil
mx::AO::orthogonalizeBasis<realT>(basis, pupil, MXAO_ORTHO_METHOD_SGS);
return 0;
}
Utilities for working with a modal basis.
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.
Definition basis.hpp:38
#define MXAO_ORTHO_METHOD_SGS
Constant to specify using the stabilized Gramm Schmidt (SGS) orthogonalization procedure.
Definition basis.hpp:81
Generating a fourier basis.
void makeModfBasis(const std::string &basisName, int dim, int N, realT ang, int nZern=0)
Make the modified Fourier basis.
Utilities for specifying pupils.
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.
Definition pupil.hpp:28

Next, the following code creates a DM and characterize it so that it can be used with the basis just created.

int main()
{
typedef double realT;
std::string basis = "modf_150_48";
std::string pupil = "circular_29percent_150";
std::string dm = "circular2k_magaox";
//Create a 2048 actuator circular DM with 50 actuators across, with a 150 pixel pupil only 48 actuators across.
//The actuator's influence function is 15% high at the nearest actuator.
//Based on the BMC 2k.
mx::AO::influenceFunctionsGaussian<realT>(dm, 150.0*50.0/48.0, 50.0, 51.3, 0.15, 150.0);
//Now calculate the pseudo-inverse, with interaction with the user.
//And then calculate the modes-to-command matrix for the unaltered basis.
mx::AO::m2cMatrix<realT>(dm, basis, pupil);
//And do the same for the pupil-orthogonalized basis.
mx::AO::m2cMatrix<realT>(dm, basis, pupil, true);
//Now test the M2C by recreating the basis using the influence influence functions.
//First, for the unaltered basis
mx::AO::modesOnDM<realT>(dm, basis, pupil, false);
//And then for the orthogonalized version.
mx::AO::modesOnDM<realT>(dm, basis, pupil, true);
return 0;
}
Utilities for generating and analyzing deformable mirror influence functions.
void modesOnDM(const std::string &dmName, const std::string &basisName)
Calculate the basis set as it will be reproduced by the DM.
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.
void ifPInv(const std::string &dmName, realT maxCondition=-1)
Calculate the pseudo-inverse and mirror modes for a set of influence functions.
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.