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

template<typename _realT>
struct mx::AO::analysis::clAOLinearPredictor< _realT >

Class to manage the calculation of linear predictor coefficients for a closed-loop AO system.

Template Parameters
_realTthe real floating point type in which to do all arithmetic.

Definition at line 46 of file clAOLinearPredictor.hpp.

#include <ao/analysis/clAOLinearPredictor.hpp>

Classes

struct  regResult
 Result from one evaluated regularization scale. More...
struct  regularizationReport
 Diagnostic summary of the most recent regularization search. More...

Public Types

enum class  regularizationStatus {
  notRun , converged , boundaryLimited , invalidControls ,
  iterationLimit , calculationFailure
}
 Termination state of the most recent regularization search. More...
typedef _realT realT
 Floating-point type used for predictor calculations.

Public Member Functions

 clAOLinearPredictor ()=default
 Construct a closed-loop linear-predictor calculator with default search controls.
mx::error_t calcCoefficients (std::vector< realT > &PSDt, std::vector< realT > &PSDn, realT PSDreg, int Nc, realT condition=0)
 Calculate the LP coefficients for a turbulence PSD and a noise PSD.
template<bool telem>
mx::error_t _regularizeCoefficients (realT &min_var, realT &min_sc, realT precision, realT max_sc, clGainOpt< realT > &go_lp, std::vector< realT > &PSDt, std::vector< realT > &PSDn, int Nc)
 Worker function for regularizing the PSD for coefficient calculation.
template<bool telem = false>
mx::error_t regularizeCoefficients (realT &gmax_lp, realT &gopt_lp, realT &var_lp, realT &min_sc, clGainOpt< realT > &go_lp, std::vector< realT > &PSDt, std::vector< realT > &PSDn, int Nc)
 Regularize the PSD and calculate the associated LP coefficients.
template<bool printout = false>
mx::error_t optimizeNc (realT &gmax_lp, realT &gopt_lp, int &Nc, realT &var_lp, clGainOpt< realT > &go_lp, std::vector< realT > &PSDt, std::vector< realT > &PSDn, int minNc, int maxNc)
 Regularize the PSD and calculate the associated LP coefficients.

Public Attributes

std::vector< realTm_PSDtn
 Working memory for the regularized PSD.
std::vector< realTm_psd2s
 Working memory for the 2-sided regularized PSD.
std::vector< realTm_ac
 Working memory to hold the autocorrelation.
sigproc::autocorrelationFromPSD< realTm_acpsd
 Converts the working PSD to an autocorrelation.
sigproc::linearPredictor< realTm_lp
 Linear predictor used to calculate coefficients.
realT m_min_var0 { 0 }
 Initial minimum variance, with zero requesting initialization.
realT m_min_sc0 { 10 }
 Initial minimum regularization scale in dB.
realT m_precision0 { 2 }
 Initial regularization scale spacing in dB.
realT m_max_sc0 { 100 }
 Initial maximum regularization scale in dB.
realT m_dPrecision { 3 }
 Divisor applied to the spacing during refinement.
realT m_gmax_lp { 5 }
 The maximum allowable gain for LP.
realT m_minPrecision { 0.001 }
 Minimum requested regularization spacing in dB.
int m_maxIts { 100 }
 Maximum number of search refinement iterations.
int m_extrap { 1 }
 The LP extrapolation length in loop steps. Normally it is 1 step.
std::vector< regResultm_regResults
 Per-scale telemetry collected when requested.
regularizationReport m_regularizationReport
 Diagnostic summary of the latest search.

Member Typedef Documentation

◆ realT

template<typename _realT>
typedef _realT mx::AO::analysis::clAOLinearPredictor< _realT >::realT

Floating-point type used for predictor calculations.

Definition at line 48 of file clAOLinearPredictor.hpp.

Member Enumeration Documentation

◆ regularizationStatus

template<typename _realT>
enum class mx::AO::analysis::clAOLinearPredictor::regularizationStatus
strong

Termination state of the most recent regularization search.

Enumerator
notRun 

No regularization search has been attempted.

converged 

The requested precision was reached.

boundaryLimited 

The optimum remained on the expanded search boundary.

invalidControls 

The configured search controls were invalid.

iterationLimit 

The search exhausted its iteration limit.

calculationFailure 

Coefficient or gain calculation failed.

Definition at line 61 of file clAOLinearPredictor.hpp.

Constructor & Destructor Documentation

◆ clAOLinearPredictor()

template<typename _realT>
mx::AO::analysis::clAOLinearPredictor< _realT >::clAOLinearPredictor ( )
default

Construct a closed-loop linear-predictor calculator with default search controls.

Member Function Documentation

◆ _regularizeCoefficients()

template<typename _realT>
template<bool telem>
mx::error_t mx::AO::analysis::clAOLinearPredictor< _realT >::_regularizeCoefficients ( realT & min_var,
realT & min_sc,
realT precision,
realT max_sc,
clGainOpt< realT > & go_lp,
std::vector< realT > & PSDt,
std::vector< realT > & PSDn,
int Nc )
inline

Worker function for regularizing the PSD for coefficient calculation.

Template Parameters
telemif true then the results are collected in m_regResults.

On first call (min_var = 0): loop over scale factors from min_sc to max_sc (<=) in steps of precision.

On subsequent calls, when min_var and min_sc are passed back in loop over scale factors from min_sc-precision to max_sc in steps of

Returns
error_t::noerror on success, otherwise the coefficient-calculation error.
Parameters
[in,out]min_varthe minimum variance found; set to 0 on initial call
[in,out]min_scthe scale factor at the minimum variance
[in]precisionthe step size for the scale factor
[in]max_scthe maximum scale factor to test
[in]go_lpthe gain optimization object
[in]PSDtthe turbulence PSD
[in]PSDnthe WFS noise PSD
[in]Ncthe number of coefficients

Definition at line 167 of file clAOLinearPredictor.hpp.

References mx::AO::analysis::clGainOpt< _realT >::a(), mx::AO::analysis::clGainOpt< _realT >::b(), calcCoefficients(), calculationFailure, m_dPrecision, m_gmax_lp, m_lp, m_regResults, m_regularizationReport, mx::AO::analysis::clGainOpt< _realT >::maxStableGain(), mx::noerror, and mx::AO::analysis::clGainOpt< _realT >::optGainOpenLoop().

Referenced by regularizeCoefficients().

◆ calcCoefficients()

template<typename _realT>
mx::error_t mx::AO::analysis::clAOLinearPredictor< _realT >::calcCoefficients ( std::vector< realT > & PSDt,
std::vector< realT > & PSDn,
realT PSDreg,
int Nc,
realT condition = 0 )
inline

Calculate the LP coefficients for a turbulence PSD and a noise PSD.

This combines the two PSDs, augments to two-sided, and calls the linearPredictor.calcCoefficients method.

A regularization constant can be added to the PSD as well.

Returns
error_t::noerror on success, otherwise error_t::liberr.
Parameters
[in]PSDtthe turbulence PSD
[in]PSDnthe WFS noise PSD
[in]PSDregthe regularizing constant. Set to 0 to not use.
[in]Ncthe number of LP coefficients
[in]conditionthe condition number for the SVD. If 0 then levinson recursion is used.

Definition at line 118 of file clAOLinearPredictor.hpp.

References mx::sigproc::augment1SidedPSD(), mx::liberr, m_ac, m_acpsd, m_extrap, m_lp, m_psd2s, m_PSDtn, mx::internal::mxlib_error_report(), and mx::noerror.

Referenced by _regularizeCoefficients(), and regularizeCoefficients().

◆ optimizeNc()

template<typename _realT>
template<bool printout = false>
mx::error_t mx::AO::analysis::clAOLinearPredictor< _realT >::optimizeNc ( realT & gmax_lp,
realT & gopt_lp,
int & Nc,
realT & var_lp,
clGainOpt< realT > & go_lp,
std::vector< realT > & PSDt,
std::vector< realT > & PSDn,
int minNc,
int maxNc )
inline

Regularize the PSD and calculate the associated LP coefficients.

The PSD is regularized by adding a constant to it. This constant is found by minimizing the variance of the residual PSD.

Template Parameters
printoutif true then per-scale results are collected in m_regResults.
Returns
error_t::noerror on success, otherwise the regularization error.
Parameters
[out]gmax_lpmaximum gain for the selected predictor
[out]gopt_lpoptimum gain for the selected predictor
[out]Ncselected number of coefficients
[out]var_lpvariance at the optimum gain
[in]go_lpthe gain optimization object
[in]PSDtthe turbulence PSD
[in]PSDnthe WFS noise PSD
[in]minNcminimum number of coefficients
[in]maxNcmaximum number of coefficients

Definition at line 400 of file clAOLinearPredictor.hpp.

References mx::noerror, and regularizeCoefficients().

◆ regularizeCoefficients()

template<typename _realT>
template<bool telem = false>
mx::error_t mx::AO::analysis::clAOLinearPredictor< _realT >::regularizeCoefficients ( realT & gmax_lp,
realT & gopt_lp,
realT & var_lp,
realT & min_sc,
clGainOpt< realT > & go_lp,
std::vector< realT > & PSDt,
std::vector< realT > & PSDn,
int Nc )
inline

Regularize the PSD and calculate the associated LP coefficients.

The PSD is regularized by adding a constant to it. This constant is found by minimizing the variance of the residual PSD.

Template Parameters
telemif true then the results are collected in m_regResults
Returns
error_t::noerror for a converged or boundary-limited search, error_t::invalidconfig for invalid controls, error_t::timeout on iteration exhaustion, or the coefficient-calculation error.
Parameters
[out]gmax_lpthe maximum gain calculated for the regularized PSD
[out]gopt_lpthe optimum gain calculated for the regularized PSD
[out]var_lpthe variance at the optimum gain
[out]min_scthe optimum regularization scale factor
[in]go_lpthe gain optimization object
[in]PSDtthe turbulence PSD
[in]PSDnthe WFS noise PSD
[in]Ncthe number of coefficients

Definition at line 276 of file clAOLinearPredictor.hpp.

References _regularizeCoefficients(), mx::AO::analysis::clGainOpt< _realT >::a(), mx::AO::analysis::clGainOpt< _realT >::b(), boundaryLimited, calcCoefficients(), calculationFailure, converged, mx::invalidconfig, invalidControls, mx::math::isFinite(), iterationLimit, m_dPrecision, m_lp, m_max_sc0, m_maxIts, m_min_sc0, m_min_var0, m_minPrecision, m_precision0, m_regResults, m_regularizationReport, mx::AO::analysis::clGainOpt< _realT >::maxStableGain(), mx::internal::mxlib_error_report(), mx::noerror, mx::AO::analysis::clGainOpt< _realT >::optGainOpenLoop(), and mx::timeout.

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

Member Data Documentation

◆ m_ac

template<typename _realT>
std::vector<realT> mx::AO::analysis::clAOLinearPredictor< _realT >::m_ac

Working memory to hold the autocorrelation.

Definition at line 83 of file clAOLinearPredictor.hpp.

Referenced by calcCoefficients().

◆ m_acpsd

template<typename _realT>
sigproc::autocorrelationFromPSD<realT> mx::AO::analysis::clAOLinearPredictor< _realT >::m_acpsd

Converts the working PSD to an autocorrelation.

Definition at line 85 of file clAOLinearPredictor.hpp.

Referenced by calcCoefficients().

◆ m_dPrecision

template<typename _realT>
realT mx::AO::analysis::clAOLinearPredictor< _realT >::m_dPrecision { 3 }

Divisor applied to the spacing during refinement.

Definition at line 93 of file clAOLinearPredictor.hpp.

Referenced by _regularizeCoefficients(), and regularizeCoefficients().

◆ m_extrap

template<typename _realT>
int mx::AO::analysis::clAOLinearPredictor< _realT >::m_extrap { 1 }

The LP extrapolation length in loop steps. Normally it is 1 step.

Definition at line 101 of file clAOLinearPredictor.hpp.

Referenced by calcCoefficients().

◆ m_gmax_lp

template<typename _realT>
realT mx::AO::analysis::clAOLinearPredictor< _realT >::m_gmax_lp { 5 }

The maximum allowable gain for LP.

Definition at line 95 of file clAOLinearPredictor.hpp.

Referenced by _regularizeCoefficients().

◆ m_lp

template<typename _realT>
sigproc::linearPredictor<realT> mx::AO::analysis::clAOLinearPredictor< _realT >::m_lp

Linear predictor used to calculate coefficients.

Definition at line 87 of file clAOLinearPredictor.hpp.

Referenced by _regularizeCoefficients(), calcCoefficients(), and regularizeCoefficients().

◆ m_max_sc0

template<typename _realT>
realT mx::AO::analysis::clAOLinearPredictor< _realT >::m_max_sc0 { 100 }

Initial maximum regularization scale in dB.

Definition at line 92 of file clAOLinearPredictor.hpp.

Referenced by regularizeCoefficients().

◆ m_maxIts

template<typename _realT>
int mx::AO::analysis::clAOLinearPredictor< _realT >::m_maxIts { 100 }

Maximum number of search refinement iterations.

Definition at line 99 of file clAOLinearPredictor.hpp.

Referenced by regularizeCoefficients().

◆ m_min_sc0

template<typename _realT>
realT mx::AO::analysis::clAOLinearPredictor< _realT >::m_min_sc0 { 10 }

Initial minimum regularization scale in dB.

Definition at line 90 of file clAOLinearPredictor.hpp.

Referenced by regularizeCoefficients().

◆ m_min_var0

template<typename _realT>
realT mx::AO::analysis::clAOLinearPredictor< _realT >::m_min_var0 { 0 }

Initial minimum variance, with zero requesting initialization.

Definition at line 89 of file clAOLinearPredictor.hpp.

Referenced by regularizeCoefficients().

◆ m_minPrecision

template<typename _realT>
realT mx::AO::analysis::clAOLinearPredictor< _realT >::m_minPrecision { 0.001 }

Minimum requested regularization spacing in dB.

Definition at line 98 of file clAOLinearPredictor.hpp.

Referenced by regularizeCoefficients().

◆ m_precision0

template<typename _realT>
realT mx::AO::analysis::clAOLinearPredictor< _realT >::m_precision0 { 2 }

Initial regularization scale spacing in dB.

Definition at line 91 of file clAOLinearPredictor.hpp.

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

◆ m_psd2s

template<typename _realT>
std::vector<realT> mx::AO::analysis::clAOLinearPredictor< _realT >::m_psd2s

Working memory for the 2-sided regularized PSD.

Definition at line 81 of file clAOLinearPredictor.hpp.

Referenced by calcCoefficients().

◆ m_PSDtn

template<typename _realT>
std::vector<realT> mx::AO::analysis::clAOLinearPredictor< _realT >::m_PSDtn

Working memory for the regularized PSD.

Definition at line 79 of file clAOLinearPredictor.hpp.

Referenced by calcCoefficients().

◆ m_regResults

template<typename _realT>
std::vector<regResult> mx::AO::analysis::clAOLinearPredictor< _realT >::m_regResults

Per-scale telemetry collected when requested.

Definition at line 103 of file clAOLinearPredictor.hpp.

Referenced by _regularizeCoefficients(), and regularizeCoefficients().

◆ m_regularizationReport

template<typename _realT>
regularizationReport mx::AO::analysis::clAOLinearPredictor< _realT >::m_regularizationReport

Diagnostic summary of the latest search.

Definition at line 105 of file clAOLinearPredictor.hpp.

Referenced by _regularizeCoefficients(), and regularizeCoefficients().


The documentation for this struct was generated from the following file: