8#ifndef __leakyIntegrator_hpp__
9#define __leakyIntegrator_hpp__
20#include "wavefront.hpp"
29template <
typename _realT>
36 typedef Eigen::Array<realT, Eigen::Dynamic, Eigen::Dynamic> commandT;
45template <
typename _realT>
60 typedef Eigen::Array<realT, Eigen::Dynamic, Eigen::Dynamic>
imageT;
160 int gains(
const std::vector<realT> &vgains );
168 int gains(
const std::string &ogainf );
203template <
typename realT>
216template <
typename realT>
234template <
typename realT>
240template <
typename realT>
247template <
typename realT>
253template <
typename realT>
261template <
typename realT>
267template <
typename realT>
275template <
typename realT>
281template <
typename realT>
293template <
typename realT>
307template <
typename realT>
310 for(
int i = 0; i <
_gains.cols(); ++i )
318template <
typename realT>
324 mxError(
"leakyIntegrator::gain",
MXE_SIZEERR,
"input gain vector not same size as number of modes" );
328 for(
int i = 0; i <
_gains.cols(); ++i )
336template <
typename realT>
350 for(
int i = 0; i <
_gains.cols(); ++i )
360template <
typename realT>
368template <
typename realT>
371 for(
int i = 0; i <
_leaks.cols(); ++i )
377template <
class realT>
380 filtAmps.measurement.resize( 1,
_nModes );
381 filtAmps.measurement.setZero();
383 rawAmps.measurement.resize( 1,
_nModes );
384 rawAmps.measurement.setZero();
389template <
class realT>
392 filtAmps.iterNo = rawAmps.iterNo;
396 filtAmps.measurement.setZero();
400 int topN = rawAmps.measurement.cols();
429 for(
int i = 0; i < topN; ++i )
431 if( std::isnan( rawAmps.measurement( 0, i ) ) || !std::isfinite( rawAmps.measurement( 0, i ) ) )
432 rawAmps.measurement( 0, i ) = 0.0;
437 filtAmps.measurement( 0, i ) =
_commands( 0, i );
440 for(
int i = topN; i < rawAmps.measurement.cols(); ++i )
442 if( std::isnan( rawAmps.measurement( 0, i ) ) || !std::isfinite( rawAmps.measurement( 0, i ) ) )
443 rawAmps.measurement( 0, i ) = 0.0;
446 ( 1.0 -
_leaks( 0, i ) ) *
_commands( 0, i ) + HOgainF *
_gains( 0, i ) * rawAmps.measurement( 0, i );
448 filtAmps.measurement( 0, i ) =
_commands( 0, i );
imageT _gains
Column-vector of gains.
Eigen::Array< realT, Eigen::Dynamic, Eigen::Dynamic > imageT
The image type, used here as a general storage array.
_realT realT
The real data type.
bool openLoop()
Get the value of the _openLoop flag.
wfMeasurement< realT > commandT
The command type.
int closingDelay()
Get the value of the _closingDelay.
wavefront< realT > wavefrontT
The wavefront data type.
int leaks(realT l)
Set a leak for all modes.
imageT _leaks
Column-vector of leaks.
int filterCommands(commandT &filtAmps, commandT &rawAmps, int iterNo)
Apply the leaky integrator.
int initMeasurements(commandT &filtAmps, commandT &rawAmps)
Allocate the provided command structures.
leakyIntegrator()
Default c'tor.
int initialize(int nModes)
Allocate and initialize all state.
realT gain(int i)
Get the gain for a single mode.
int gains(realT g)
Set the gain for all modes to a single value.
int leak(int i, realT l)
Set the leak for a single mode.
int _nModes
The number of modes being filtered.
bool _openLoop
If true, then commands are not integrated.
imageT _commands
Column-vector past commands.
int _closingDelay
If > 0, then the gains are ramped linearly up to this value. Default = 0.
int lowOrders()
Get the value of the _lowOrders.
int nModes()
Get the number of modes.
#define mxError(esrc, ecode, expl)
This reports an mxlib specific error.
#define MXE_INVALIDARG
An argument was invalid.
#define MXE_SIZEERR
A size was invalid or calculated incorrectly.
#define MXE_FILEOERR
An error occurred while opening a file.
typeT convertFromString(const std::string &str, error_t *errc=nullptr)
Convert a string to a numerical value.
Old version. Deprecated. Declares and defines the mxlib error reporting system.
Utilities for working with strings.
Structure containing the phase and amplitude of a wavefront.