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

Macros

#define locwrite(out, A...)
#define locread(A...)
#define loccellread(A...)
#define loccellnew   (loccell*)cellnew
#define locccellnew   (locccell*)cellnew
#define loccellfree(A)
#define locfree(A)
#define ptsfree(A)
#define loc_create_stat(loc)
#define ptsresize(pts, nsa)

Functions

loc_t * loc_convert (dmat *A)
 Convert a dmat in place to loc_t object.
lmat * loc_create_embed (long *nembed, const loc_t *loc, real oversize, int fftpad)
void loc_create_map_npad (const loc_t *loc, int npad, int nx, int ny)
void loc_create_map (const loc_t *loc)
uint32_t lochash (const loc_t *loc, uint32_t key)
void loc_embed (anydmat _dest, const loc_t *loc, const_anydmat in, int expanded, int add)
dcell * loc_embed2 (const loc_t *loc, const dmat *arr)
void loc_embed_cell (dcell **dest, const loc_t *loc, const dcell *in)
void loc_extract (dmat *dest, const loc_t *loc, map_t *in)
loc_t * loc_from_map (map_t *amp, real thres)
void loc_free_map (loc_t *loc)
void locfree_do (cell *loc)
real loc_diam (const loc_t *loc)
int loccenter (const loc_t *loc)
loc_t * locnew (long nloc, real dx, real dy)
loc_t * locref (loc_t *in)
pts_t * ptsnew (long nsa, real dsax, real dsay, long nxsa, long nysa, real dx, real dy)
void loc_calc_ptt (real *out, real *coeffout, const loc_t *loc, real ipcc, const dmat *imcc, const real *amp, const real *opd)
void loc_calc_mod (real *out, real *coeffout, const dmat *mod, const real *amp, real *opd)
dmat * loc_mcc_ptt (const loc_t *loc, const real *amp)
dcell * pts_mcc_ptt (const pts_t *pts, const real *amp)
void loc_sub_ptt (dmat *opd, const real *ptt, const loc_t *loc)
void loc_add_ptt (dmat *opd, const real *ptt, const loc_t *loc)
void loc_remove_ptt (dmat *opd, const loc_t *loc, const real *amp, const dmat *imcc, int both)
real loc_remove_focus_grad (dmat *grad, const loc_t *saloc, real factor)
void pts_ztilt (dmat **out, const pts_t *pts, const dcell *imcc, const real *amp, const real *opd)
loc_t * mk1dloc_vec (real *x, long nx)
loc_t * mk1dloc (real x0, real dx, long nx)
loc_t * mksqloc_auto (long nx, long ny, real dx, real dy)
loc_t * mksqloc_map (const map_t *map)
loc_t * mksqloc (long nx, long ny, real dx, real dy, real ox, real oy)
loc_t * mkannloc (real D, real Din, real dx, real thres)
void loc_create_stat_do (loc_t *loc)
void loc_free_stat (loc_t *loc)
void loc_circle_add (dmat *phi, const loc_t *loc, real cx, real cy, real r, real rin, real val)
void loc_circle_mul (dmat *phi, const loc_t *loc, real cx, real cy, real r, real rin, real val)
void loc_ellipse_add (dmat *phi, const loc_t *loc, real cx, real cy, real rx, real ry, real val)
void loc_reduce (loc_t *loc, dmat *amp, real thres, int cont, int **skipout)
void loc_reduce_spcell (loc_t *loc, dspcell *sp, int dim, int cont)
void loc_reduce_sp (loc_t *loc, dsp *sp, int dim, int cont)
void loc_add_focus (const dmat *opd, const loc_t *loc, real val)
void loc_add_focus_offset (const dmat *opd, const loc_t *loc, real val, real ox, real oy)
dmat * loc2mat (loc_t *loc, int piston)
loc_t * pts2loc (pts_t *pts)
void locrot (loc_t *loc, const real theta)
real loc_angle (const loc_t *loc1, const loc_t *loc2)
void locstretch (loc_t *loc, const real theta, const real frac)
loc_t * locdup (loc_t *loc)
void locmean (real *xm, real *ym, const loc_t *loc)
dmat * parse_poly (const char *_ps)
loc_t * loctransform (const loc_t *loc, const char *ps)
loc_t * loctransform2 (const loc_t *loc, const dmat *coeff)
void locshift (loc_t *loc, real sx, real sy)
void loc_nxny (long *nx, long *ny, const loc_t *loc)
void locresize (loc_t *loc, long nloc)
void dembed_locstat (dmat **out, real alpha, loc_t *loc, real *oin, real beta, int reverse)
void cembed_locstat (cmat **out, real alpha, loc_t *loc, real *oin, real beta, int reverse)
void loc_dxdy (loc_t *loc)
loc_t * locreaddata (file_t *fp, header_t *header)
void loc_keywords (cell *loc)
lmat * loc_coord2ind (loc_t *aloc, dmat *dead)

Detailed Description

This file defines functions relates to pts_t, loc_t, map_t, etc.

Macro Definition Documentation

◆ locwrite

#define locwrite ( out,
A... )
Value:
writebin(out, A)

◆ locread

#define locread ( A...)
Value:
loc_convert(dread(A))
#define dread(A...)
Definition mathdef.h:87

◆ loccellread

#define loccellread ( A...)
Value:
(loccell*)cellconvert(readbin_id(M_LOC, 1, A), (cell*(*)(cell*))loc_convert)
Definition type.h:64
Definition type.h:262

◆ loccellfree

#define loccellfree ( A)
Value:
#define cellfree(A)
Definition cell.h:40

◆ locfree

#define locfree ( A)
Value:

◆ ptsfree

#define ptsfree ( A)
Value:

◆ loc_create_stat

#define loc_create_stat ( loc)
Value:
if(!loc->stat) loc_create_stat_do(loc);

◆ ptsresize

#define ptsresize ( pts,
nsa )
Value:
if(pts) locresize(pts->loc, nsa)

Function Documentation

◆ loc_convert()

loc_t * loc_convert ( dmat * A)

Convert a dmat in place to loc_t object.

Parameters
AInput array to be changed in place.
Returns
loc_t*

◆ loc_create_embed()

lmat * loc_create_embed ( long * nembed,
const loc_t * loc,
real oversize,
int fftpad )

Create an vector to embed OPD into a square array for FFT purpose. This is reverse operation from loc_create_map which maps 2d array indexing info loc indexing.

Parameters
[out]nembedsize of square array
[in]locirregular grid
[in]oversizeratio of oversizing. 2 for FFT to achieve Nyquist sampling.
[in]fftpadpad to size that is fast for FFT.
Returns
embed has the same length of loc, contains 1d index into the squre array.

◆ loc_create_map_npad()

void loc_create_map_npad ( const loc_t * loc,
int npad,
int nx,
int ny )

Create a map for loc so that we can obtain the index in loc by x,y coordinate. Useful in ray tracing (accphi.c). If extend is true, the invalid region in the map is replaced with closest valid point. This extends the coverage of the grid automatically.

◆ loc_create_map()

void loc_create_map ( const loc_t * loc)

Create a map for loc with padding of 1.

◆ lochash()

uint32_t lochash ( const loc_t * loc,
uint32_t key )

apply hashlittle() to loc_t.

◆ loc_embed()

void loc_embed ( anydmat _dest,
const loc_t * loc,
const_anydmat _in,
int expanded,
int add )

Embed in into dest according to map defined in loc->map. The two arrays are assumed to be concentric.

◆ loc_embed2()

dcell * loc_embed2 ( const loc_t * loc,
const dmat * arr )

A convenient wrapper for loc_embed to be called by matlab or python

Parameters
[in]locThe location coordinate
[in]arrThe points defined on loc to be embeded to 2-d array. May have multiple vectors.
Returns
The embeded 2-d array.

◆ loc_embed_cell()

void loc_embed_cell ( dcell ** pdest,
const loc_t * loc,
const dcell * in )

Embed in into dest according to map defined in loc->map for cells. Arbitraty map cannot be used here for mapping.

◆ loc_extract()

void loc_extract ( dmat * dest,
const loc_t * loc,
map_t * in )

Embed in into dest according to map defined in loc->map. Arbitraty map cannot be used here for mapping.

◆ loc_from_map()

loc_t * loc_from_map ( map_t * map,
real thres )

Convert a map to a loc that collects all positive entries while keep each row continuous

◆ loc_free_map()

void loc_free_map ( loc_t * loc)

Free the MAP in loc_t

◆ locfree_do()

void locfree_do ( cell * p)

Free loc_t data.

◆ loc_diam()

real loc_diam ( const loc_t * loc)

Estimate the diameter of loc. 2021-09-03: corrected calculation for square grid. Use the inscribed diameter but not circumcircle.

◆ loccenter()

int loccenter ( const loc_t * loc)

Find the point that closes to origin (0,0) in loc. Useful in single point piston constraint in creating reconstructor.

◆ locnew()

loc_t * locnew ( long nloc,
real dx,
real dy )

Create a loc with nloc elements.

◆ locref()

loc_t * locref ( loc_t * in)

Reference an existing loc. map and stat are not referenced.

◆ ptsnew()

pts_t * ptsnew ( long nsa,
real dsax,
real dsay,
long nxsa,
long nysa,
real dx,
real dy )

Create a pts with nsa, dsa, nx, dx

◆ loc_calc_mod()

void loc_calc_mod ( real * rmsout,
real * coeffout,
const dmat * mod,
const real * amp,
real * opd )

Calculate variance of OPD in modes defined in mod.

Notice the difference in rmsout for loc_calc_ptt and this loc_calc_mode. in loc_calc_ptt, out[0] is PR, out[1] is TT, out[2] is PTTR in loc_calc_mod, out[0] is PR, out[1] is PTR, out[2] is PTTR, etc

The mod is already orth-noramlized so that we have the following simple forms.

coeffout is in unit of zernike!

◆ loc_mcc_ptt()

dmat * loc_mcc_ptt ( const loc_t * loc,
const real * amp )

assemble modes of piston/tip/tilt into Nx3 matrix M, and compute their inverse covariance matrix. mcc=M'*(amp.*M)

◆ pts_mcc_ptt()

dcell * pts_mcc_ptt ( const pts_t * pts,
const real * amp )

same as loc_mcc_ptt, except using pts instead of loc. this is used to build imcc for TT/F powfs ztilt imcc

◆ loc_sub_ptt()

void loc_sub_ptt ( dmat * opd,
const real * ptt,
const loc_t * loc )

Subtract Piston/Tip/Tilt (in radian) from OPD

◆ loc_add_ptt()

void loc_add_ptt ( dmat * opd,
const real * ptt,
const loc_t * loc )

Add Piston/Tip/Tilt from OPD

◆ loc_remove_ptt()

void loc_remove_ptt ( dmat * opd,
const loc_t * loc,
const real * amp,
const dmat * imcc,
int cov )

Project piston/tip/tilt from opd which may have multiple independent columns. If cov is set, opd should be symmetric (covariance) and ptt is removed from left and right side.

◆ loc_remove_focus_grad()

real loc_remove_focus_grad ( dmat * grad,
const loc_t * saloc,
real factor )

Remove focus mode from gradients. Do not consider noise weighting

◆ pts_ztilt()

void pts_ztilt ( dmat ** out,
const pts_t * pts,
const dcell * imcc,
const real * amp,
const real * opd )

Compute zernike best fit for all subapertures. add result to out. returns radians not zernike modes of tip/tilt. Used in wfsgrad

◆ mk1dloc_vec()

loc_t * mk1dloc_vec ( real * x,
long nx )

Create 1 dimensional loc with given vector.

◆ mk1dloc()

loc_t * mk1dloc ( real x0,
real dx,
long nx )

Create 1 dimensional loc with origin at x0, sampling of dx, and nx numbers.

◆ mksqloc_auto()

loc_t * mksqloc_auto ( long nx,
long ny,
real dx,
real dy )

Create a loc array of size nx*ny at sampling dx with origin at (nx/2, ny/2)

◆ mksqloc_map()

loc_t * mksqloc_map ( const map_t * map)

Create a loc array that covers the map_t. Notice that it is different from loc_from_map which only covers valid (value>0) regions.

◆ mksqloc()

loc_t * mksqloc ( long nx,
long ny,
real dx,
real dy,
real ox,
real oy )

Create a loc array contains coorindates in a square map of size nx*ny, with sampling dx, and at origin ox,oy

◆ mkannloc()

loc_t * mkannloc ( real D,
real Din,
real dx,
real thres )

Create a loc array within diameter D, and inner diameter Din, with spacing dx.

◆ loc_create_stat_do()

void loc_create_stat_do ( loc_t * loc)

Gather information about the starting of each column in loc.

◆ loc_free_stat()

void loc_free_stat ( loc_t * loc)

Free the stat in loc_t

◆ loc_circle_add()

void loc_circle_add ( dmat * phi,
const loc_t * loc,
real cx,
real cy,
real r,
real rin,
real val )

Add a gray pixel circular map in phi using coordinates defined in loc, center defined using cx, cy, radius of r, and value of val

◆ loc_circle_mul()

void loc_circle_mul ( dmat * phi,
const loc_t * loc,
real cx,
real cy,
real r,
real rin,
real val )

Apply an annular mask in phi.

◆ loc_ellipse_add()

void loc_ellipse_add ( dmat * phi,
const loc_t * loc,
real cx,
real cy,
real rx,
real ry,
real val )

Create a gray pixel elliptical map in phi using coordinates defined in loc, center defined using cx, cy, radii of rx, ry, and value of val

◆ loc_reduce()

void loc_reduce ( loc_t * loc,
dmat * amp,
real thres,
int cont,
int ** skipout )

Remove points in loc that have zero value in amp and modify amp in the same time. Keep each row continuous if cont==1. Return in skipout the index of skipped points if skipout is not NULL.

◆ loc_reduce_spcell()

void loc_reduce_spcell ( loc_t * loc,
dspcell * spc,
int dim,
int cont )

Remove uncoupled points in loc and modify spc in the same time. debugged on 2009-12-20. Not used often. using a dspcell, to compute the coupling which is modified accordingly.

◆ loc_reduce_sp()

void loc_reduce_sp ( loc_t * loc,
dsp * sp,
int dim,
int cont )

Remove uncoupled points in loc and modify sp in the same time. debugged on 2009-12-20. use single sparse matrix, which is modified accordingly.

◆ loc_add_focus_offset()

void loc_add_focus_offset ( const dmat * opd,
const loc_t * loc,
const real val,
const real ox,
const real oy )

Add val amount of focus to opd. The unit is in radian like. Piston is removed. The focus is centered at ox, oy

◆ loc2mat()

dmat * loc2mat ( loc_t * loc,
int piston )

Create a dmat containing locx and locy in two columns

◆ pts2loc()

loc_t * pts2loc ( pts_t * pts)

Convert pts_t to loc_t. Each entry in pts recors the lower left point in each subaperture.

◆ locrot()

void locrot ( loc_t * loc,
const real theta )

Rotate the coordinate by theta (radian) CCW which is equivalent to rotate the points by theta -CCW.

◆ loc_angle()

real loc_angle ( const loc_t * loc1,
const loc_t * loc2 )

Determine the angle of rotation from loc1 to loc2. CCW is positive.

◆ locstretch()

void locstretch ( loc_t * loc,
const real theta,
const real frac )

Stretch the coordinate by frac along theta (radian) CCW.

◆ locdup()

loc_t * locdup ( loc_t * loc)

duplicate a loc_t object;

◆ locmean()

void locmean ( real * xm,
real * ym,
const loc_t * loc )

Compute average of locx, locy

◆ parse_poly()

dmat * parse_poly ( const char * _ps)

Parse string representation of polynominal to array representation.

◆ loctransform()

loc_t * loctransform ( const loc_t * loc,
const char * polycoeff )

Transform coordinate. loc (input) contains x,y; locm (return) contains xm, ym. polyn contains the formula

\[xm{ip}=\sum_{ic}(coeff[0](0,ic)*pow(x,coeff[0](1,ic))*pow(y,coeff[0](2,ic))) ym{ip}=\sum_{ic}(coeff[1](0,ic)*pow(x,coeff[1](1,ic))*pow(y,coeff[1](2,ic))) \]

was using string input. New scheme uses bin files to preserve precision.

◆ loctransform2()

loc_t * loctransform2 ( const loc_t * loc,
const dmat * coeff )

Transform coordinate with coefficients. See loctransform()

Parameters
locInput loc_t
coeffn*4 matrix

◆ locshift()

void locshift ( loc_t * loc,
real sx,
real sy )

Shift a loc coordinate by sx and sy.

◆ loc_nxny()

void loc_nxny ( long * nx,
long * ny,
const loc_t * loc )

Compute the size of a map that is used to build loc or can fully contain loc (embed)

◆ locresize()

void locresize ( loc_t * loc,
long nloc )

Resize a loc_t by shrinking.

◆ loc_dxdy()

void loc_dxdy ( loc_t * out)

Determine dx and dy from data.

◆ loc_coord2ind()

lmat * loc_coord2ind ( loc_t * aloc,
dmat * dead )

Parse the input dead actuator location to actuator indices based on aloc. 2015-03-30: build a mask for dead actuators based on coordinate.

Parameters
[in]alocAloc
[in]deadn*2 or n*3 matrix containing dead actuators