MAOS
Multithreaded Adaptive Optics Simulator
Loading...
Searching...
No Matches
recon.h File Reference

Functions

void free_recon_cxx (recon_t *recon)
recon_t * setup_recon_prep (const parms_t *parms, const map_t *aper, const powfs_t *powfs)
void setup_recon_saneai (recon_t *recon, const parms_t *parms, const powfs_t *powfs)
void setup_recon_fit (recon_t *recon, const parms_t *parms)
void setup_powfs_fit (powfs_t *powfs, const recon_t *recon, const parms_t *parms)
void free_powfs_fit (powfs_t *powfs, const parms_t *parms)
void free_fit (fit_t *fit, int nfit)
void setup_recon_GA (recon_t *recon, const parms_t *parms, const powfs_t *powfs)
void setup_recon_GF (recon_t *recon, const parms_t *parms)
void setup_recon_tomo_reg (recon_t *recon, const parms_t *parms)
void setup_recon_tomo_matrix (recon_t *recon, const parms_t *parms)
void setup_recon_update_cn2 (recon_t *recon, const parms_t *parms)
void setup_recon_tomo (recon_t *recon, const parms_t *parms, const powfs_t *powfs)
void setup_recon_lsr (recon_t *recon, const parms_t *parms)
void setup_recon_mvm (const parms_t *parms, recon_t *recon, const powfs_t *powfs)
void setup_recon_control (recon_t *recon, const parms_t *parms, const powfs_t *powfs)
void setup_recon_misc (recon_t *recon, const parms_t *parms, loc_t *locs, const powfs_t *powfs)
void setup_recon_HXW (recon_t *recon, const parms_t *parms, mapcell *atm)
void free_recon (const parms_t *parms, recon_t *recon)
void free_recon_unused (const parms_t *parms, recon_t *recon)
void setup_recon_mvst (recon_t *recon, const parms_t *parms)
void setup_recon_dither_dm (recon_t *recon, const powfs_t *powfs, const parms_t *parms)
void TomoR (dcell **xout, const void *A, const dcell *xin, const real alpha)
void TomoRt (dcell **gout, const void *A, const dcell *xin, const real alpha)
void TomoL (dcell **xout, const void *A, const dcell *xin, const real alpha)
void FitL (dcell **xout, const void *A, const dcell *xin, const real alpha)
void FitR (dcell **xout, const void *A, const dcell *xin, const real alpha)
void tomofit (dcell **dmout, sim_t *simu, dcell *gradin)
void * reconstruct (sim_t *simu)

Detailed Description

Carry out wavefront reconstruction and DM fitting.

Function Documentation

◆ free_recon_cxx()

void free_recon_cxx ( recon_t * recon)

Frees recon->invpsd or recon->fractal

Parameters
[in,out]reconThe reconstruction struct.

◆ setup_recon_prep()

recon_t * setup_recon_prep ( const parms_t * parms,
const map_t * aper,
const powfs_t * powfs )

Create reconstruction parameters that are related to the geometry only, and will not be updated when estimated WFS measurement noise changes.

This can be used to do NCPA calibration.

Parameters
[in]parmsThe parameter struct.
[in]aperThe telescope aperture amplitude map.
[in]powfsThe powfs struct array.
Returns
The reconstruction struct. Newly allocated; free it with free_recon().

◆ setup_recon_saneai()

void setup_recon_saneai ( recon_t * recon,
const parms_t * parms,
const powfs_t * powfs )

Setup the matrix of the inverse of gradient measurement noise equivalent angle covariance matrix. For physical optics wfs, the NEA is computed using matched filter output. For geometric optics, the NEA is from input.

Parameters
[in,out]reconThe reconstruction struct. recon->sanea, saneai, saneal, and neam are set.
[in]parmsThe parameter struct.
[in]powfsThe powfs struct array.

◆ setup_recon_fit()

void setup_recon_fit ( recon_t * recon,
const parms_t * parms )

Setup DM fitting parameters

Parameters
[in,out]reconThe reconstruction struct. recon->fit is allocated and set.
[in]parmsThe parameter struct.

◆ setup_powfs_fit()

void setup_powfs_fit ( powfs_t * powfs,
const recon_t * recon,
const parms_t * parms )

Setting fitting parameter for turbulence to WFS lenslet grid.

Parameters
[in,out]powfsThe powfs struct array. powfs[].fit is allocated and set for high order powfs.
[in]reconThe reconstruction struct.
[in]parmsThe parameter struct.

◆ free_powfs_fit()

void free_powfs_fit ( powfs_t * powfs,
const parms_t * parms )

Call this instead of free_fit directly to free powfs fit parameters.

Parameters
[in,out]powfsThe powfs struct array. powfs[].fit is freed.
[in]parmsThe parameter struct.

◆ free_fit()

void free_fit ( fit_t * fit,
int nfit )

Free the array of nfit fit_t. Data in entries marked isref is not freed.

Parameters
[in]fitThe array of fit_t to free, including the array itself. May be NULL.
[in]nfitNumber of entries in fit.

◆ setup_recon_GA()

void setup_recon_GA ( recon_t * recon,
const parms_t * parms,
const powfs_t * powfs )

Setup gradient operator form aloc for wfs by using GP.

Parameters
[in,out]reconThe reconstruction struct. recon->GA and related data are set.
[in]parmsThe parameter struct.
[in]powfsThe powfs struct array.

◆ setup_recon_GF()

void setup_recon_GF ( recon_t * recon,
const parms_t * parms )

From focus mode to gradients. This acts on WFS, not WFSR.

Parameters
[in,out]reconThe reconstruction struct. recon->GFall and related data are set.
[in]parmsThe parameter struct.

◆ setup_recon_tomo_reg()

void setup_recon_tomo_reg ( recon_t * recon,
const parms_t * parms )

Regularization terms for tomography. Can be called multiple times for Cn2 update.

Parameters
[in,out]reconThe reconstruction struct. recon->L2, invpsd, or fractal, and ZZT are set; recon->wt is clipped and normalized.
[in]parmsThe parameter struct.

◆ setup_recon_tomo_matrix()

void setup_recon_tomo_matrix ( recon_t * recon,
const parms_t * parms )

assemble tomography matrix. In CG mode, this function is not executed if tomo.assemble=0, Instead, the algorithm is contained in recon.c. When you modify anything, make sure you also do it there.

For integrated tomograhy:

\(\hat{x}=(G_{lgs}^{T}C_{lgs}^{-1}G_{lgs}+C_{x}^{-1}+G_{ngs}^{T}C_{ngs}^{-1} G_{ngs})^{-1}(G_{lgs}^{T}C_{lgs}^{-1}s_{lgs}+G_{ngs}^{T}C_{ngs}^{-1}s_{ngs}){\equiv}RL^{-1}RR s.\)

For split tomography, the terms regarding NGS are dropped:

\(\hat{x}_{lgs}=(G_{lgs}^{T}C_{lgs}^{-1}G_{lgs}+C_{x}^{-1})^{-1} G_{lgs}^{T}C_{lgs}^{-1}s_{lgs}\equiv R_L^{-1} R_R s.\)

The left hand side of linear equation (inside the inverse) is stored in RL. The right hand side of the linear equation (outside of the inverse) is stored in RR. The terms regarding the NGS are handled using low rank terms. The gradients from LGS and NGS and concatenated to \(s\).

In the LGS part, there is a global tip/tilt removal operator because LGS is insensitive to global tip/tilts.

For details see www.opticsinfobase.org/abstract.cfm?URI=josaa-19-9-1803

Parameters
[in,out]reconThe reconstruction struct. recon->RR and recon->RL are set.
[in]parmsThe parameter struct.

◆ setup_recon_update_cn2()

void setup_recon_update_cn2 ( recon_t * recon,
const parms_t * parms )

Update assembled tomography matrix with new L2. Called from cn2est when new profiles are available.

Parameters
[in,out]reconThe reconstruction struct.
[in]parmsThe parameter struct.

◆ setup_recon_tomo()

void setup_recon_tomo ( recon_t * recon,
const parms_t * parms,
const powfs_t * powfs )

Sets up the tomogrpahy turbulence reconstruction structs including wavefront reconstructor and DM fitting operator

Calls setup_recon_tomo_matrix() and setup_recon_fit_matrix() to setup the tomography and DM fitting matrix.

AHST is handled in setup_ngsmod().

MVST is handled in setup_recon_mvst().

MOAO is handled in setup_recon_moao().

Parameters
[in,out]reconThe reconstruction struct.
[in]parmsThe parameter struct.
[in]powfsThe powfs struct array.
Here is the call graph for this function:

◆ setup_recon_lsr()

void setup_recon_lsr ( recon_t * recon,
const parms_t * parms )

Setup the least square reconstruct by directly inverting GA matrix. The reconstructor is simply the pseudo inverse of GA matrix:

\[\hat{x}=(G_a^TC_g^{-1}G_a)^{-1}G_a^TC_g^{-1}\]

This is very close to RR except replacing GX with GA.

We use the tomograhy parameters for lsr, since lsr is simply "tomography" onto DM directly.

Parameters
[in,out]reconThe reconstruction struct. recon->LR and recon->LL are set.
[in]parmsThe parameter struct.

◆ setup_recon_mvm()

void setup_recon_mvm ( const parms_t * parms,
recon_t * recon,
const powfs_t * powfs )

Assemble matrix to do matrix vector multiply. Split from setup_recon because GPU may be used.

Parameters
[in]parmsThe parameter struct.
[in,out]reconThe reconstruction struct. recon->MVM is set if not already.
[in]powfsThe powfs struct array.

◆ setup_recon_control()

void setup_recon_control ( recon_t * recon,
const parms_t * parms,
const powfs_t * powfs )

Setup either the control matrix using either minimum variance reconstructor by calling setup_recon_mvr() or least square reconstructor by calling setup_recon_lsr() It can be called repeatedly to update the reconstructor when NEA updates.

The results are measurement noise dependent and may be updated during simulation.

Parameters
[in,out]reconThe reconstruction struct.
[in]parmsThe parameter struct.
[in]powfsThe powfs struct array.

◆ setup_recon_misc()

void setup_recon_misc ( recon_t * recon,
const parms_t * parms,
loc_t * locs,
const powfs_t * powfs )

Setup miscellaneous reconstruction data: ecnn (when sim.ecnn is set), PSD for servo gain update, and petal mode reconstruction.

Parameters
[in,out]reconThe reconstruction struct.
[in]parmsThe parameter struct.
[in]locsThe science pupil grid.
[in]powfsThe powfs struct array.

◆ setup_recon_HXW()

void setup_recon_HXW ( recon_t * recon,
const parms_t * parms,
mapcell * atm )

Setup ray tracing operator from xloc to ploc for guide stars.

Parameters
[in,out]reconThe reconstruction struct. recon->HXW and recon->HXWtomo are set.
[in]parmsThe parameter struct.
[in]atmIf set, atm[].vx,vy will be used for predictive offsetting.

◆ free_recon()

void free_recon ( const parms_t * parms,
recon_t * recon )

Free the recon struct.

Parameters
[in]parmsThe parameter struct.
[in]reconThe reconstruction struct to free, including the struct itself. May be NULL.

◆ free_recon_unused()

void free_recon_unused ( const parms_t * parms,
recon_t * recon )

Free unused object in recon struct after preparation is done.

Parameters
[in]parmsThe parameter struct.
[in,out]reconThe reconstruction struct. May be NULL.

◆ setup_recon_mvst()

void setup_recon_mvst ( recon_t * recon,
const parms_t * parms )

compute the MVST split tomography NGS mode reconstructor.

2010-03-16: New Implementation.

Definition:

  • \(G_{lgs}\) is LGS gradient operator from xloc, contained in recon->GXtomo as dspcell
  • \(G_{ngs}\) is NGS gradient operator from xloc, contained in recon->GXL as dense matrix
  • \(C_{lgs}, C_{ngs}\) is the LGS, and NGS measurement noise covariance matrix.
  • \(\hat{x}_{lgs}\) is LGS tomography output
  • \(\hat{x}_{ngs}\) is NGS minimum variance split tomography output
  • \(a_{ngs}\) is NGS minimum variance DM output.
  • \(F\) is the fitting operator
  • \(H_A\) is the ray tracing operator from aloc to ploc, contained in recon->HA.
  • \(MVModes\) is the MVST NGS modes
  • \(MVRngs\) is the MVST NGS reconstructor

We have

\begin{eqnarray*}\hat{x}_{lgs}&=&A^{-1}G^{T}_{lgs}C_{lgs}^{-1}s_{lgs}\\ Uw&=&A^{-1}G_{ngs}^TC_{ngs}^{-1}\\ \hat{x}_{ngs}&=&Uw(1+G_{ngs}Uw)^{-1}(s_{ngs}-G_{ngs}\hat{x}_{lgs});\\ a_{NGS}&=&F\hat{x}_{ngs}\\ MVModes&=&F\cdot Uw\\ MVRngs&=&(1+G_{ngs}Uw)^{-1} \end{eqnarray*}

If we want to orthnormalize the NGS modes. Propagate the NGS modes \(F\cdot Uw\) to fitting directions and compute the cross-coupling matrix with weighting on \(W_0, W_1\), we have

\begin{eqnarray*}Q&=&H_A\cdot F \cdot Uw\\ M_{CC}&=&Q^T(W_0-W_1 W_1^T)Q\\ \end{eqnarray*}

Do SVD on \(MCC\) we have \(M_{CC}=u\Sigma v^T \) where \(u{\equiv}v\) because \(MCC\) is symmetric. Redefine the NGS modes and reconstructor as

\begin{eqnarray*}MVModes&=&F\cdot Uw\cdot u \Sigma^{-1/2}\\ MVRngs&=&\Sigma^{1/2}u^T (1+G_{ngs}A^{-1}G_{ngs}^T C_{ngs}^{-1})^{-1} \end{eqnarray*}

◆ setup_recon_dither_dm()

void setup_recon_dither_dm ( recon_t * recon,
const powfs_t * powfs,
const parms_t * parms )

Dither using command path (DM) aberration

Parameters
[in,out]reconThe reconstruction struct. The dither_* members are set.
[in]powfsThe powfs struct array.
[in]parmsThe parameter struct.

◆ TomoR()

void TomoR ( dcell ** xout,
const void * A,
const dcell * gin,
const real alpha )

Apply tomography right hand operator without using assembled matrix. Fast and saves memory. The operation is the same as the Tomo_nea_gpt and Tomo_iprop in TomoL, so merge the implemenations.

xout=HXW'GP'*NEAI(1-TTF*PTTF)*gin.

Parameters
[in,out]xoutThe output on xloc. Allocated if NULL; alpha*RR*gin is accumulated into it.
[in]AThe recon_t struct.
[in]ginThe gradients.
[in]alphaScaling factor.

◆ TomoRt()

void TomoRt ( dcell ** gout,
const void * A,
const dcell * xin,
const real alpha )

Transpose operation of TomoR. From xin to gout: gout=NEAI*(1-TTF*PTTF)*GP*HXW*xin.

Parameters
[in,out]goutThe output gradients. Allocated if NULL; alpha*RR'*xin is accumulated into it.
[in]AThe recon_t struct.
[in]xinThe input on xloc.
[in]alphaScaling factor.

◆ TomoL()

void TomoL ( dcell ** xout,
const void * A,
const dcell * xin,
const real alpha )

Apply tomography left hand side operator without using assembled matrix. Fast and saves memory. Only useful in CG. Accumulates to xout;

Some timing information: Generated in T410s with Intel Core i5 520 M @ 2.4 GHz (1 T is 1 thread, 2 T is 2 thread) and Poweredge with dual Xeon X5355 2.66Ghz (1 P is 1 thread, 8 P is 8 thread) Time 1 T 2 T 1 P 8 P HXW: 7.8 5.4 7.7 5.0 GP: 4.3 2.6 3.6 1.4 remove_mode: 0.3 0.3 0.4 0.6 neai: 0.5 0.3 0.5 0.4 GP': 3.2 2.1 3.4 1.0 HXW': 5.5 4.7 7.4 4.9 cxx: 3.2 2.5 3.5 2.7

Parameters
[in,out]xoutThe output on xloc. Allocated if NULL; alpha*RL*xin is accumulated into it.
[in]AThe recon_t struct.
[in]xinThe input on xloc.
[in]alphaScaling factor.

◆ FitL()

void FitL ( dcell ** xout,
const void * A,
const dcell * xin,
const real alpha )

Apply fit left hand side matrix in CG mode without using assembled matrix. Slow. don't use. Assembled matrix is faster because of multiple directions.

Parameters
[in,out]xoutThe output; alpha*FL*xin is accumulated into it.
[in]AThe fit_t struct.
[in]xinDM commands.
[in]alphaScaling factor.

◆ FitR()

void FitR ( dcell ** xout,
const void * A,
const dcell * xin,
const real alpha )

Apply fit right hand side matrix in CG mode without using assembled matrix. Slow. don't use. Assembled matrix is faster because of multiple directions.

Parameters
[in,out]xoutThe output; alpha*FR*xin is accumulated into it.
[in]AThe fit_t struct.
[in]xinTomography output on xloc. If NULL, trace through the atmosphere directly.
[in]alphaScaling factor.

◆ tomofit()

void tomofit ( dcell ** dmout,
sim_t * simu,
dcell * gradin )

Calls tomo() and fit() to do the tomography and DM fit. Do error signal and split tomography. In closedloop mode, the gradients are from time step isim-1.

Parameters
[in,out]dmoutDM fitting output. Used as initial guess if CG is used.
[in,out]simuThe simulation struct. simu->opdr is updated by tomography.
[in]gradinThe (pseudo open loop) gradients.

◆ reconstruct()

void * reconstruct ( sim_t * simu)

Wavefront reconstruction. call tomofit() to do tomo()/fit() or lsr() to do least square reconstruction.

Parameters
[in,out]simuThe simulation struct.
Returns
NULL.