MAOS
Multithreaded Adaptive Optics Simulator
pywfs.h File Reference

Data Structures

struct  pywfs_cfg_t
 
struct  pywfs_t
 

Macros

#define pywfs_ng(pycfg)   ((pycfg && (pycfg->raw||pycfg->nside<3))?pycfg->nside:2)
 

Functions

pywfs_tpywfs_new (pywfs_cfg_t *pycfg, loc_t *loc, const dmat *amp)
 
void pywfs_free (pywfs_t *pywfs)
 
void pycfg_free (pywfs_cfg_t *pycfg)
 
void pywfs_grad (dmat **pgrad, const pywfs_t *pywfs, const dmat *ints)
 
void pywfs_ints (dmat **ints, const pywfs_t *pywfs, const dmat *opd, real siglev)
 
dmatpywfs_mkg (pywfs_t *pywfs, const loc_t *ploc, const char *distortion, const dmat *mod, const dmat *opdadd, real displacex, real displacey)
 
dmatpywfs_tt (const pywfs_t *pywfs)
 
void pywfs_simu (dmat **ints, dmat **grad, pywfs_cfg_t *pycfg, int order, dmat *wvl, real siglev, loc_t *loc, const dmat *amp, const dmat *opd)
 
void pywfs_gain_calibrate (pywfs_t *pywfs, const dmat *grad, real r0)
 
void pywfs_test (pywfs_t *pywfs)
 Test PYWFS implementation.
 

Detailed Description

Setup pyramid WFS and do simulation.


Data Structure Documentation

◆ pywfs_cfg_t

struct pywfs_cfg_t

Pyramid WFS configurations. //Todo: move to pywfs.h after pywfs.h is moved to lib folder

+ Collaboration diagram for pywfs_cfg_t:
Data Fields
int order

Number of pixels per pupil in each dimension.

real siglev

Nominal siglev per subaperture

dmat * wvl

wavelength

real dx

OPD sampling. Use loc->dx if not present

real D

Aperture diameter. Use loc_diam if not present

int nside

Number of sides. can be 4 (default) or 3. 4-side is traditional pyramid while 3-side is much easier to make.

int raw

1: use normalized ints of each sub-pupil as gradient. 0 (default): use difference between sub-pupils

real dsa

Subaperture size (default is D/order)

real saat

drop subapertures below this fraction (default is 0)

real hs

Height of guide star (default is inf)

real hc

Conjugation height of WFS pupil (default is 0)

real modulate

Amount of modulation in radian (default is 5 lambda/D)

int modulpos

Number of positions per modulation cycle per ring(default is 32)

int modulring

Number of rings within the maximum radius to modulate (default is 1, use more to simulate extended object)

int sigmatch

Scale gradients by matching intensity (1: locally, 2 (default): globally).

real poke

How much to poke for mkg. (default is 1e-7 m)

dmat * wvlwts

Wavelength weights

real pixblur

pixel blur (default is 0.3)

real fieldstop

size of field stop in arcsec (default is none).

int modulpos_i

For testing: Index of modulate position to use between 0 and modulpos

dmat * psx

pyramid WFS pupil shift along x (in pixel). pupil ordering: -x+y, +x+y, -x-y, +x-y.

dmat * psy

pyramid WFS pupil shift along y (in pixel).

real flate

pyramid flat edge angular width (in arcsec)

real flatv

pyramid flat vertex angular width (in arcsec)

real pupelong

pyramid pupil (detector) elongation ratio (long axis / short axis - 1).

◆ pywfs_t

struct pywfs_t

Parameters used by Pyramid WFS.

+ Collaboration diagram for pywfs_t:
Data Fields
const pywfs_cfg_t * cfg

Configuration. do not try to free.

int iwfs0

First iwfs for this powfs

int gpu

Whether GPU can be used

loc_t * loc

Pupil plane grid

dmat * amp

Pupil plane amplitude map

loc_t * saloc

powfs.saloc

locfft_t * locfft

First fft to form PSF

ccell * pyramid

OPD of pyramid. Angular size of clear aperture is different

cmat * nominal

For sampling results onto detector

dspcell * si

For sampling results onto detector

dmat * sioff

Offset for si

dmat * saa

Subaperture area. Average is one

dmat * gradoff

Gradient of a flat wavefront

dmat * GTT

Response of TT mode.

dmat * pupilshift

Pupil shift. 4x2.

loccell * msaloc

Mishaped saloc of each sub-pupil due to optical effects

dmat * opdadd

Aberrations along the WFS path (on locfft grid)

real gain

Optical gain of PYWFS

Function Documentation

◆ pywfs_free()

void pywfs_free ( pywfs_t pywfs)

frees pywfs_t

◆ pywfs_grad()

void pywfs_grad ( dmat **  pgrad,
const pywfs_t pywfs,
const dmat ints 
)

Compute gradients. It replaces the result, not accumulate.

◆ pywfs_ints()

void pywfs_ints ( dmat **  ints,
const pywfs_t pywfs,
const dmat opd,
real  siglev 
)

Perform FFT over the complex PSF with additional phases caused by the pyramid. FFT on each quadrant of the PSF creates diffraction effects.

Parameters
[in/out]intsThe intensity. Accumulate.
[in]pywfsPYWFS parameters
[in]opdThe OPD
[in]siglevThe signal level.

◆ pywfs_mkg()

dmat* pywfs_mkg ( pywfs_t pywfs,
const loc_t locin,
const char *  distortion,
const dmat mod,
const dmat opdadd,
real  displacex,
real  displacey 
)

locin is on pupil.

◆ pywfs_tt()

dmat* pywfs_tt ( const pywfs_t pywfs)

Return measurement of T/T mode, normalized for 1 unit of input.

◆ pywfs_simu()

void pywfs_simu ( dmat **  ints,
dmat **  grad,
pywfs_cfg_t pycfg,
int  order,
dmat wvl,
real  siglev,
loc_t loc,
const dmat amp,
const dmat opd 
)

A convenient wrapper to simulate pywfs from Python.

Parameters
[out]intsSubaperture images
[out]gradSubaperture gradients
[in]pycfgConfiguration struct. Optional if order, wvl, siglev are all set
[in]orderPWFS order. optional if pycfg is set
[in]wvlWavelength. optional if pycfg is set
[in]siglevSignal level of each subaperture. optional if pycfg is set
[in]locOPD loc.
[in]ampOPD amplitude map.
[in]opdOPD.

◆ pywfs_gain_calibrate()

void pywfs_gain_calibrate ( pywfs_t pywfs,
const dmat grad,
real  r0 
)

PYWFS gain calibrate using measurements. The idea is as follows. With a given input OPD, the PWFS measures OPDR. Feed OPDR to PWFS, it measures OPDR2. Optionally add a fitting error to the input. Scale OPDR by alpha, it measures OPDR3. Iterate the alpha until OPDR3 has the same magnitude as OPDR. The final alpha is the gain adjustment. This does not quite work because the original input OPD and OPDR has different spatial frequency content. Most of OPD is not measurable.