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

Data Structures

struct  locfft_t

Functions

locfft_t * locfft_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. Initialize the locfft_t struct that embeds OPD on loc into square arrays for FFT.

Parameters
[in]locThe loc (referenced, not copied).
[in]ampThe amplitude (referenced, not copied).
[in]wvlThe wavelength (m).
[in]fftsizeThe suggested size for FFT, nwvl values. Can be NULL.
[in]oversizeFactor of oversize. 2 for Nyquist sampling.
[in]fieldstopSize of field stop (radian) if used. 0 to disable.
Returns
Newly allocated struct; free with locfft_free().

◆ locfft_free()

void locfft_free ( locfft_t * locfft)

Frees the struct

Parameters
[in]locfftThe struct to free. Can be NULL.

◆ 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.

Parameters
[in,out]psf2spThe complex PSF for each wavelength. Allocated if NULL, otherwise overwritten.
[in]locfftThe locfft struct.
[in]opdThe OPD defined on locfft->loc (m).
[in]psfsizeSize of PSF to extract for each wavelength. NULL for full size. 1 for Strehl only.
[in]sum2oneIf set, normalize PSF to sum to 1; otherwise peak is Strehl.

◆ locfft_fieldstop()

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

Apply a field stop to the OPD.

Parameters
[in]locfftThe locfft struct with fieldmask set.
[in,out]opdThe OPD (m), replaced by the field stop filtered OPD.
[in]wvlwtsWeights of each wavelength.

◆ 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. The angular spectrum method is unitary (propagating by -z reverses it) and its output 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
[in,out]poutOutput complex field. Sampling depends on method. Allocated if NULL (32x32 for method 0, same size as in otherwise).
[in,out]pdxoutSampling of output. For method=0 it can be supplied, otherwise z*wvl/(dxin*nx) is used. Set on output.
[in]inInput complex field, Amp*exp(-i*k*opd).
[in]dxinSpatial sampling of in (m).
[in]wvlWavelength (m).
[in]zPropagation distance (m).
[in]scaleScaling to be applied to out to preserve energy. 0: determine from input.
[in]methodPropagation method, 0: brutal force, 1: FFT, 2: angular spectrum, -1: auto between 1 and 2.