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

Functions

void addnoise (dmat *A, rand_t *rstat, const real bkgrnd, const real bkgrndc, const dmat *bkgrnd2, const dmat *bkgrnd2c, const dmat *qe, real rne, real excess)
void addnoise_grad (dmat *grad, const dmat *neal, rand_t *srand)
int cog_multi (dmat **cg, const dmat *im, const dmat *loc, int wsize)
void cog_nea (real *nea, const dmat *ints, const dmat *cogmask, real cogthres, real cogoff, int ntry, rand_t *rstat, real bkgrnd, real bkgrndc, const dmat *bkgrnd2i, const dmat *bkgrnd2ic, real rne)
dmat * poly2fit (const dmat *in, const dmat *out, int maxorder)
dmat * loc_calib (const dsp *GA, propdata_t *propdata, int maxorder)
dmat * polyfit (const dmat *x, const dmat *y, int maxorder)
dmat * polyval (const dmat *x, const dmat *coeff, int separate)
int wrap_seq (long index, long n)
real wrap2range (real val, real low, real high)
real pchip_wt (int i, float u)
 compute p-chip interpolation weighting See https://en.wikipedia.org/wiki/Cubic_Hermite_spline
int atm_interp (real *wt, int ips, int isim, int dtrat, int natm, int interp)
 Compute dome seeing turbulence interpolation parameters.
dccell * wfe_fov_prep (const dmat *thetax, const dmat *thetay, real unit, int npath, int nwvl)
void wfe_fov_fill (dccell *res, const dcell *clep, int ipath, int isim)

Function Documentation

◆ addnoise()

void addnoise ( dmat * A,
rand_t * rstat,
const real bkgrnd,
const real bkgrndc,
const dmat * bkgrnd2,
const dmat * bkgrnd2c,
const dmat * qe,
const real rne,
real excess )

add photon and read out noise. pcalib part of bkgrnd is calibrated out. pcalib2 part of bkgrnd2 is calibrated out.

Parameters
A[in/out]The pixel intensity array
[in]rstatThe random stream
[in]bkgrndReal background in PDEs per pixel per frame
[in]bkgrndcRemoved background in PDEs per pixel per frame
[in]bkgrnd2Real background in PDEs of each pixel per frame.
[in]bkgrnd2cRemoved background in PDEs of each pixel per frame.
[in]qePixel dependent Quantum Efficiency
[in]rneRead out noise per pixel per read
[in]excessExcess noise factor

◆ addnoise_grad()

void addnoise_grad ( dmat * grad,
const dmat * neal,
rand_t * srand )

Add noise to gradients according to neal, which is LL' decomposition of the sanea

◆ cog_multi()

int cog_multi ( dmat ** cg,
const dmat * im,
const dmat * loc,
int wsize )

Determine the CoG on multiple locations near the nominal position.

Parameters
[out]cgn*3 The determined position and total intensity.
[in]im2-d array contains the image
[in]locn*2 array. contains the nominal position of each peak
[in]wsizewindow size

◆ poly2fit()

dmat * poly2fit ( const dmat * in,
const dmat * out,
int maxorder )

Determine the polynomial coefficients that transforms 2-d coordinate (of a grid) in to out.

Parameters
[in]ininput grid. n*2
[in]outdistorted grid, n*2
[in]maxorderMaximum order

◆ loc_calib()

dmat * loc_calib ( const dsp * GA,
propdata_t * propdata,
int maxorder )

Calibrate the distortion as measured using interaction matrix.

Parameters
[in]GAMeasured interaction matrix
propdatain] See accphi.h
[in]maxorderMaximum power of x/y. Negative to limit total power

◆ polyfit()

dmat * polyfit ( const dmat * x,
const dmat * y,
const int maxorder )

Determine the polynomial coefficients that transforms vector in to out. Both column and row vectors are allowed.

Parameters
[in]xinput vector
[in]youtput
[in]maxordermaximum order to fit

◆ polyval()

dmat * polyval ( const dmat * x,
const dmat * coeff,
int separate )
Parameters
[in]xinput vector
[in]coeffthe coefficient from polyfit
[in]separateif set, separately for each order

◆ wrap_seq()

int wrap_seq ( long index,
long n )

Wrap the index for dataset with total of n frames for continuity. For example, if n is 4, the result is 0 1 2 3 2 1 0 1 2 3 2 1 0 ...

◆ wrap2range()

real wrap2range ( real val,
real low,
real high )

wrap val to between low and high Notice the difference between remainder() and fmod(). remainder(a,b) wraps a to [-b/2, b/2) fmod(a,b) wraps a to [-b,b)

◆ pchip_wt()

real pchip_wt ( int i,
float u )

compute p-chip interpolation weighting See https://en.wikipedia.org/wiki/Cubic_Hermite_spline

Parameters
iindex into p[], p[i] with i from -1 to 2
ufractional distance from i. between [0,1)
Returns
real the weighting function

◆ atm_interp()

int atm_interp ( real * wt,
int ips,
int isim,
int dtrat,
int natm,
int interp )

Compute dome seeing turbulence interpolation parameters.

Parameters
wtReturned weight
ipsCurrent layer index
isimCurrent simulation frame index
dtratTurbulence dtrat
natmTurbulence frame count
interpInterpolation method: 0: no interpolation. 1: linear. 2: sin^2. 3: p-chip.
Returns
int Turbulence frame to use

◆ wfe_fov_prep()

dccell * wfe_fov_prep ( const dmat * thetax,
const dmat * thetay,
real unit,
int npath,
int nwvl )

Prepare data structure to plot WFE vs field angle. Use together with wfe_fov_fill()

Parameters
npathNumber of simulation directories

◆ wfe_fov_fill()

void wfe_fov_fill ( dccell * reseach,
const dcell * clep,
int ipath,
int isim )

Compute RMS WFE for each direction. Use together with wfe_fov_prep()