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

Namespaces

namespace  impl
 
namespace  PSDComponent
 

Classes

class  aoAtmosphere
 A class to specify atmosphere parameters and perform related calculations. More...
 
class  aoSystem
 Describes an analytic adaptive optics (AO) system. More...
 
struct  calculatedWFS
 The calculated WFS uses sensitivities provided by FITS files. More...
 
struct  clAOLinearPredictor
 Class to manage the calculation of linear predictor coefficients for a closed-loop AO system. More...
 
struct  clGainOpt
 A class to manage optimizing closed-loop gains. More...
 
struct  clGainOptOptGain_OL
 Bisection worker struct for finding optimum closed loop gain from open loop PSDs. More...
 
struct  fourierCovariance
 Structure to manage the Fourier mode covariance calculation, passed to integration functions. More...
 
struct  fourierTemporalPSD
 Class to manage the calculation of temporal PSDs of the Fourier modes in atmospheric turbulence. More...
 
struct  pywfsModAsymptotic
 The asymptotic modulated pyramid wavefront sensor sensitivity function. More...
 
struct  pywfsUnmod
 The unmodulated pyramid wavefront sensor sensitivity function. More...
 
struct  shwfs
 The shack hartmann wavefront sensor sensitivity function. More...
 
struct  vonKarmanSpectrum
 Manage calculations using the von Karman spatial power spectrum. More...
 
struct  wfs
 The ideal wavefront sensor sensitivity function. More...
 
struct  zernikeCovariance
 Structure to manage the zernike mode covariance calculation, passed to integration functions. More...
 
struct  zernikeTemporalPSD
 Class to manage the calculation of temporal PSDs of the Fourier modes in atmospheric turbulence. More...
 

Enumerations

enum  basis : unsigned int { basic , modified }
 

Functions

template<typename realT >
realT maxStableGain (const realT &ll, const realT &ul)
 
template<typename realT , typename aosysT >
realT phiInt_basic (realT phi, void *params)
 Worker for the azimuthal integral (in phi) for the basic Fourier mode covariance.
 
template<typename realT , typename aosysT >
realT phiInt_mod (realT phi, void *params)
 Worker for the azimuthal integral (in phi) for the modified Fourier mode covariance.
 
template<typename realT , typename aosysT >
realT kInt (realT k, void *params)
 Worker function for the radial integral in the covariance calculation.
 
template<typename realT , typename aosysT >
int fourierVarVec (const std::string &fname, int N, aosysT &aosys, realT absTol, realT relTol, bool modifed=true)
 Calculate a vector of Fourier mode variances.
 
template<typename realT , typename aosysT >
int fourierPSDMap (improc::eigenImage< realT > &var, improc::eigenImage< realT > &psd, int N, int overSample, aosysT &aosys)
 Calculate a map of Fourier variances by convolution with the PSD.
 
template<typename realT >
int fourierCovarMap (const std::string &fname, int N, realT D, realT L_0, bool subPist, bool subTilt, realT absTol, realT relTol, bool modified=true)
 
template<typename realT , typename aosysT >
int fourierCovarMapSeparated (const std::string &fname, int N, aosysT &aosys, realT absTol, realT relTol, bool modified=true)
 
template<typename realT >
void calcKLCoeffs (const std::string &outFile, const std::string &cvFile)
 
template<typename eigenArrT1 , typename eigenArrT2 , typename eigenArrT3 >
void makeKL (eigenArrT1 &kl, eigenArrT2 &evecs, eigenArrT3 &&rvecs)
 
template<typename realT >
void makeFKL (const std::string &outFile, const std::string &coeffs, int N, int pupSize)
 
template<typename realT , typename aosysT >
realT F_basic (realT kv, void *params)
 Worker function for GSL Integration for the basic sin/cos Fourier modes.
 
template<typename realT , typename aosysT >
realT F_mod (realT kv, void *params)
 Worker function for GSL Integration for the modified Fourier modes.
 
template<typename realT >
void turbBoilCubic (realT &a, realT &b, realT &c, realT &d, const realT &kv, const realT &f, const realT &Vu, const realT &f0, int pm)
 
template<typename realT >
int jincFuncs (realT &Jp, realT &Jm, int mpos, int npos, int mmode, int nmode)
 The +/- Jinc functions for analyzing contrast.
 
template<typename realT >
int speckleAmpPSD (std::vector< realT > &spFreq, std::vector< realT > &spPSD, const std::vector< realT > &freq, const std::vector< realT > &fmPSD, const std::vector< std::complex< realT > > &fmXferFxn, const std::vector< realT > &nPSD, const std::vector< std::complex< realT > > &nXferFxn, int N, std::vector< realT > *vars=nullptr, std::vector< realT > *bins=nullptr, bool noPSD=false)
 Calculate the PSD of the speckle intensity given the PSD of Fourier mode amplitude.
 
template<typename realT >
int speckleAmpVarMean (std::vector< realT > &vars, std::vector< realT > &bins, std::vector< realT > &freq, std::vector< realT > &fmPSD, std::vector< std::complex< realT > > &fmXferFxn, std::vector< realT > &nPSD, std::vector< std::complex< realT > > &nXferFxn, int N)
 Calculate the variance of the mean vs bin size in a speckle time-series.
 
template<typename imageT >
void varmapToImage (imageT &im, imageT &varmap, imageT &psf)
 Convert a wavefront variance map to an intensity image by convolving with the PSF.
 
template<typename realT >
void wfsNoisePSD (std::vector< realT > &PSD, realT beta_p_k, realT Fg, realT tau, realT npx, realT Fb, realT ron)
 Populate a vector with the PSD of measurement noise given WFS parameters.
 
template<typename realT , typename aosysT >
realT F_zernike (realT kv, void *params)
 Worker function for GSL Integration for the Zernike modes.
 

Enumeration Type Documentation

◆ basis

enum mx::AO::analysis::basis : unsigned int
Enumerator
basic 

The basic sine and cosine Fourier modes.

modified 

The modified Fourier basis from [males_guyon_2017].

Definition at line 81 of file fourierTemporalPSD.hpp.

Function Documentation

◆ calcKLCoeffs()

template<typename realT >
void mx::AO::analysis::calcKLCoeffs ( const std::string &  outFile,
const std::string &  cvFile 
)

◆ fourierCovarMap()

template<typename realT >
int mx::AO::analysis::fourierCovarMap ( const std::string &  fname,
int  N,
realT  D,
realT  L_0,
bool  subPist,
bool  subTilt,
realT  absTol,
realT  relTol,
bool  modified = true 
)
Parameters
[out]fnamethe path where the output FITS file will be written
[in]Nthe linear number of Fourier modes across the aperture. The Nyquist frequency is set by N/2.

Definition at line 463 of file fourierCovariance.hpp.

References mx::AO::analysis::fourierCovariance< realT, aosysT >::absTol, mx::AO::analysis::fourierCovariance< realT, aosysT >::aosys, mx::fits::fitsHeader::append(), mx::AO::analysis::aoSystem< _realT, _inputSpectT, iosT >::atm, mx::AO::analysis::aoSystem< _realT, _inputSpectT, iosT >::D(), mx::error, mx::AO::analysis::fourierCovariance< realT, aosysT >::getVariance(), mx::ipc::ompLoopWatcher< _outputT, _printPretty, _printLoops, _printPercent, _printNLine, _time >::incrementAndOutputStatus(), mx::AO::analysis::aoAtmosphere< _realT >::L_0(), mx::AO::analysis::aoSystem< _realT, _inputSpectT, iosT >::loadMagAOX(), mx::AO::analysis::fourierCovariance< realT, aosysT >::m, mx::sigproc::makeFourierModeFreqs_Rect(), modified, mx::AO::analysis::fourierCovariance< realT, aosysT >::mp, mx::mxlib_comp_current_sha1(), mx::mxlib_comp_repo_modified(), mx::AO::analysis::fourierCovariance< realT, aosysT >::n, mx::AO::analysis::fourierCovariance< realT, aosysT >::np, mx::AO::analysis::fourierCovariance< realT, aosysT >::p, mx::AO::analysis::fourierCovariance< realT, aosysT >::pp, mx::AO::analysis::aoSystem< _realT, _inputSpectT, iosT >::psd, mx::AO::analysis::aoAtmosphere< _realT >::r_0(), mx::AO::analysis::fourierCovariance< realT, aosysT >::relTol, mx::AO::analysis::fourierCovariance< realT, aosysT >::useBasic, and mx::fits::fitsFile< dataT >::write().

◆ fourierCovarMapSeparated()

◆ fourierPSDMap()

template<typename realT , typename aosysT >
int mx::AO::analysis::fourierPSDMap ( improc::eigenImage< realT > &  var,
improc::eigenImage< realT > &  psd,
int  N,
int  overSample,
aosysT &  aosys 
)

Calculate a map of Fourier variances by convolution with the PSD.

Uses the Airy pattern for the circularly unobstructed aperture.

Returns
0 on success
-1 on error
Parameters
[out]varThe variance estimated by convolution with the PSD
[out]psdthe PSD map
[in]Nthe number of components to analyze
aosys[in[ the AO system defining the PSD characteristics.

Definition at line 405 of file fourierCovariance.hpp.

References mx::math::func::airyPattern(), mx::math::six_fifths(), and varmapToImage().

◆ fourierVarVec()

◆ jincFuncs()

template<typename realT >
int mx::AO::analysis::jincFuncs ( realT Jp,
realT Jm,
int  mpos,
int  npos,
int  mmode,
int  nmode 
)

The +/- Jinc functions for analyzing contrast.

See Males and Guyon

Parameters
[out]Jp
[out]Jm
[in]mpos
[in]npos
[in]mmode
[in]nmode

Definition at line 26 of file jincFuncs.hpp.

References mx::math::func::jinc(), and mx::math::six_fifths().

◆ kInt()

template<typename realT , typename aosysT >
realT mx::AO::analysis::kInt ( realT  k,
void *  params 
)

Worker function for the radial integral in the covariance calculation.

Parameters
kthe spatial frequency at which to evaluate the integrand
paramsa pointer to a object of type fourierCovariance<realT, aosyT>
Template Parameters
realTa floating point type used for all calculations. As of Nov 2016 must be double due to gsl_integration.
aosysTthe type of the AO system structure

Definition at line 205 of file fourierCovariance.hpp.

References mx::error, mx::AO::analysis::fourierCovariance< realT, aosysT >::k, mx::AO::analysis::fourierCovariance< realT, aosysT >::phi_w, mx::math::two_pi< double >(), mx::AO::analysis::fourierCovariance< realT, aosysT >::useBasic, and WSZ.

◆ makeFKL()

◆ makeKL()

template<typename eigenArrT1 , typename eigenArrT2 , typename eigenArrT3 >
void mx::AO::analysis::makeKL ( eigenArrT1 &  kl,
eigenArrT2 &  evecs,
eigenArrT3 &&  rvecs 
)

Definition at line 673 of file fourierCovariance.hpp.

References mx::math::six_fifths().

Referenced by makeFKL().

◆ maxStableGain()

template<typename realT >
realT mx::AO::analysis::maxStableGain ( const realT ll,
const realT ul 
)

◆ phiInt_mod()

template<typename realT , typename aosysT >
realT mx::AO::analysis::phiInt_mod ( realT  phi,
void *  params 
)

Worker for the azimuthal integral (in phi) for the modified Fourier mode covariance.

Parameters
phithe angle at which to evaluate the integrand
paramsa pointer to a object of type fourierCovariance<realT, aosyT>
Template Parameters
realTa floating point type used for all calculations
aosysTthe type of the AO system structure

Definition at line 127 of file fourierCovariance.hpp.

References mx::AO::analysis::fourierCovariance< realT, aosysT >::aosys, mx::math::func::jinc(), mx::AO::analysis::fourierCovariance< realT, aosysT >::k, mx::AO::analysis::fourierCovariance< realT, aosysT >::m, mx::AO::analysis::fourierCovariance< realT, aosysT >::mnCon, mx::AO::analysis::fourierCovariance< realT, aosysT >::mp, mx::AO::analysis::fourierCovariance< realT, aosysT >::n, mx::AO::analysis::fourierCovariance< realT, aosysT >::np, mx::AO::analysis::fourierCovariance< realT, aosysT >::p, mx::AO::analysis::fourierCovariance< realT, aosysT >::pp, and mx::math::six_fifths().

◆ speckleAmpPSD()

template<typename realT >
int mx::AO::analysis::speckleAmpPSD ( std::vector< realT > &  spFreq,
std::vector< realT > &  spPSD,
const std::vector< realT > &  freq,
const std::vector< realT > &  fmPSD,
const std::vector< std::complex< realT > > &  fmXferFxn,
const std::vector< realT > &  nPSD,
const std::vector< std::complex< realT > > &  nXferFxn,
int  N,
std::vector< realT > *  vars = nullptr,
std::vector< realT > *  bins = nullptr,
bool  noPSD = false 
)

Calculate the PSD of the speckle intensity given the PSD of Fourier mode amplitude.

Does so by generating a time-series from the PSD using Fourier-domain convolution, and calculating the average periodogram.

A Hann window is used.

Statistics are not currently normalized. You need to normalize to match expected contrast if desired.

Will also calculate the binned-variances in the generated time-series, if the arguments vars and bins are not null pointers.

Todo:

Figure out what's going on with psdFilter normalization!

probably need to not do overlapped averaging in periodogram. Could drop mean-sub then.

Parameters
[out]spFreqThe frequency grid of the output PSD
[out]spPSDThe speckle amplitude PSD corresponding to the freq coordinates. Will be resized.
[in]freqThe Frequency grid of the input PSD
[in]fmPSDThe Fourier mode PSD.
[in]fmXferFxnThe complex error transfer function, as a function of freq
[in]nPSDThe open-loop noise PSD
[in]nXferFxnThe noise transfer function, as a function of freq
[in]NThe number of trials to use in calculating the amplitude PSD.
[out]vars[optional] The binned variances of the time series generated.
[in]bins[optional] The bin sizes to use in calculating vars.
[in]noPSD[optional] if true then the PSD is not actually calculated, only the binned variances

Definition at line 50 of file speckleAmpPSD.hpp.

References mx::sigproc::augment1SidedPSD(), mx::math::ft::backward, mx::sigproc::window::hann(), mx::sigproc::psdVar(), mx::sigproc::averagePeriodogram< realT >::resize(), mx::math::randomT< typeT, _ranengT, _randistT >::seed(), mx::math::six_fifths(), mx::sigproc::averagePeriodogram< realT >::size(), mx::math::vectorBinMeans(), mx::math::vectorMeanSub(), mx::math::vectorVariance(), and mx::sigproc::averagePeriodogram< realT >::win().

Referenced by mx::AO::analysis::fourierTemporalPSD< _realT, aosysT >::analyzePSDGrid(), and speckleAmpVarMean().

◆ speckleAmpVarMean()

template<typename realT >
int mx::AO::analysis::speckleAmpVarMean ( std::vector< realT > &  vars,
std::vector< realT > &  bins,
std::vector< realT > &  freq,
std::vector< realT > &  fmPSD,
std::vector< std::complex< realT > > &  fmXferFxn,
std::vector< realT > &  nPSD,
std::vector< std::complex< realT > > &  nXferFxn,
int  N 
)

Calculate the variance of the mean vs bin size in a speckle time-series.

Does so by generating a time-series from the PSD using Fourier-domain convolution, then calculates the binned-variances in the generated time-series.

This is just a wrapper for speckleAmpPSD, with no actual PSD calculation.

Parameters
[out]varsThe binned variances of the time series generated.
[in]binsThe bin sizes to use to calculate the variances.
[in]freqThe Frequency grid of the input PSD
[in]fmPSDThe open-loop Fourier mode PSD.
[in]fmXferFxnThe complex error transfer function, as a function of freq
[in]nPSDThe open-loop noise PSD
[in]nXferFxnThe noise transfer function, as a function of freq
[in]NThe number of trials to use in calculating the amplitude time-series.

Definition at line 277 of file speckleAmpPSD.hpp.

References speckleAmpPSD().

◆ turbBoilCubic()

template<typename realT >
void mx::AO::analysis::turbBoilCubic ( realT a,
realT b,
realT c,
realT d,
const realT kv,
const realT f,
const realT Vu,
const realT f0,
int  pm 
)

Definition at line 2256 of file fourierTemporalPSD.hpp.

Referenced by F_mod().