MAOS
Multithreaded Adaptive Optics Simulator
locfft.h File Reference

Data Structures

struct  locfft_t
 

Functions

locfft_tlocfft_init (loc_t *loc, const dmat *amp, const dmat *wvl, const lmat *fftsize, real oversize, real fieldstop)
 
void locfft_free (locfft_t *locfft)
 
void locfft_psf (ccell **psfs, const locfft_t *locfft, const dmat *opd, const lmat *psfsize, int sum2one)
 
void locfft_fieldstop (const locfft_t *locfft, dmat *opd, const dmat *wvlwts)
 
void fresnel_prop (cmat **out, real *dxout, const cmat *in, real dxin, real wvl, real z, real scale, int method)
 

Detailed Description

Routines used to embed OPDs defined on loc_t to square array with embeding factor and compute PSF using FFT.


Data Structure Documentation

◆ locfft_t

struct locfft_t
+ Collaboration diagram for locfft_t:
Data Fields
loc_t * loc
const dmat * amp
dmat * wvl
lmat * nembed

size of embedding array (square)

lcell * embed

embedding index

real ampsum

sum(amp)

real ampnorm

sum(amp.*amp)

dcell * fieldmask

Masking the PSF in fourier domain

real fieldstop

Function Documentation

◆ locfft_init()

locfft_t* locfft_init ( loc_t loc,
const dmat amp,
const dmat wvl,
const lmat fftsize,
const real  oversize,
real  fieldstop 
)

For routines that embed OPDs defined on loc to square(rectangular) array and do fft on it.

Parameters
[in]locThe loc
[in]ampThe amplitude
[in]wvlThe wavelength
[in]fftsizeThe suggested size for FFT, nwvl values
[in]oversizeFactor of oversize. 2 fot FFT
[in]fieldstopSize of field stop (radian) if used

◆ locfft_free()

void locfft_free ( locfft_t locfft)

Frees the struct

◆ locfft_psf()

void locfft_psf ( ccell **  psf2sp,
const locfft_t locfft,
const dmat opd,
const lmat psfsize,
int  sum2one 
)

Computes PSF from OPD by FFT. The PSF is computed as

\(\textrm{PSF}=\mathcal{F}[A\times exp[\frac{2\pi i}{\lambda}*\textrm{OPD}]]\)

The peak value (center) in the computed PSF is normalized by the peak value in the differaction limited PSF. In other words, the peak value in the computed PSF is the Strehl. Keep this in mind when you compute enclosed energy.

Extract center part of psfsize.

◆ locfft_fieldstop()

void locfft_fieldstop ( const locfft_t locfft,
dmat opd,
const dmat wvlwts 
)

Apply a field stop to the OPD.

◆ fresnel_prop()

void fresnel_prop ( cmat **  pout,
real *  pdxout,
const cmat in,
real  dxin,
real  wvl,
real  z,
real  scale,
int  method 
)

Fresnel propagation using either FFT or angular spectrum method.

For FFT method, the output sampling is z*wvl/(dxin*nxin). For angular spectrum method, the output sampling equals to the input sampling. When the output sampling equals, the two methods agree. Notice that at near field when dp is smaller than dx, the output of angular spectrum method is periodic.

The output is normalized so that its squared sum equals to nx*ny*sum(abs(in)^2). Input argument scale should be supplied to cancel this scaling.

The brutal force method (method=0) has the exact solution without using fresnel approximation. It is however very slow. The results agrees with method=1 or 2 when the sampling agrees and the approximation holds.

Parameters
poutOutput complex field. Sampling depends on method. Should not be empty if method is 0.
pdxoutSampling of output, can be supplied if method=0, use dp if not supplied.
inInput complex field, , Amp*exp(-i*k*opd)
dxinSpatial sampling of in
wvlWavelength
zPropagation distance
scaleScaling to be applied to out to preserve energy. 0: determine from input
methodPropagation method, 0: brutal force, 1: FFT, 2: angular spectrum, -1: auto between 1 and 2.