MAOS
Multithreaded Adaptive Optics Simulator
|
Macros | |
#define | locfree(A) if(A){locfree_do(A);A=NULL;} |
#define | ptsfree(A) if(A){locfree_do((loc_t*)A);A=NULL;} |
#define | locarrfree(A, B) ({locarrfree_do(A,B);A=NULL;}) |
#define | loc_create_stat(loc) if(!loc->stat) loc_create_stat_do(loc); |
#define | ptsresize(pts, nsa) if(pts) locresize(pts->loc, nsa) |
Functions | |
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_do (anydmat _dest, const loc_t *loc, const_anydmat in, 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 * | map2loc (map_t *amp, real thres) |
void | loc_free_map (loc_t *loc) |
void | locfree_do (loc_t *loc) |
void | locarrfree_do (loc_t **loc, int nloc) |
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) |
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 * | d2loc (const dmat *A) |
loc_t * | locreaddata (file_t *fp, header_t *header) |
void | locwritedata (file_t *fp, const loc_t *loc) |
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.
[out] | nembed | size of square array |
[in] | loc | irregular grid |
[in] | oversize | ratio of oversizing. 2 for FFT to achieve Nyquist sampling. |
[in] | fftpad | pad to size that is fast for FFT. |
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.
void loc_create_map | ( | const loc_t * | loc | ) |
Create a map for loc with padding of 1.
uint32_t lochash | ( | const loc_t * | loc, |
uint32_t | key | ||
) |
apply hashlittle() to loc_t.
void loc_embed_do | ( | anydmat | _dest, |
const loc_t * | loc, | ||
const_anydmat | in, | ||
int | add | ||
) |
Embed in into dest according to map defined in loc->map. The two arrays are assumed to be concentric.
A convenient wrapper for loc_embed to be called by matlab or python
[in] | loc | The location coordinate |
[in] | arr | The points defined on loc to be embeded to 2-d array. May have multiple vectors. |
Embed in into dest according to map defined in loc->map for cells. Arbitraty map cannot be used here for mapping.
Embed in into dest according to map defined in loc->map. Arbitraty map cannot be used here for mapping.
Convert a map to a loc that collects all positive entries.
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.
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.
Create a pts with nsa, dsa, nx, dx
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!
assemble modes of piston/tip/tilt into Nx3 matrix M, and compute their inverse covariance matrix. mcc=M'*(amp.*M)
same as loc_mcc_ptt, except using pts instead of loc. this is used to build imcc for TT/F powfs ztilt imcc
Subtract Piston/Tip/Tilt (in radian) from OPD
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.
Remove focus mode from gradients. Do not consider noise weighting
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
Create 1 dimensional loc with origin at x0, sampling of dx, and nx numbers.
Create a loc array of size nx*ny at sampling dx with origin at (nx/2, ny/2)
Create a loc array that covers the map_t. Notice that it is different from map2loc which only covers valid (value>0) regions.
Create a loc array contains coorindates in a square map of size nx*ny, with sampling dx, and at origin ox,oy
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.
void loc_create_stat_do | ( | loc_t * | loc | ) |
Gather information about the starting of each column in loc.
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
Apply an annular mask in phi.
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
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.
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.
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.
Add val amount of focus to opd. The unit is in radian like. Piston is removed.
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.
Determine the angle of rotation from loc1 to loc2. CCW is positive.
void locstretch | ( | loc_t * | loc, |
const real | theta, | ||
const real | frac | ||
) |
Stretch the coordinate by frac along theta (radian) CCW.
void locmean | ( | real * | xm, |
real * | ym, | ||
const loc_t * | loc | ||
) |
Compute average of locx, locy
dmat* parse_poly | ( | const char * | _ps | ) |
Parse string representation of polynominal to array representation.
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.
Transform coordinate with coefficients. See loctransform()
loc | Input loc_t |
coeff | n*4 matrix |
void locshift | ( | loc_t * | loc, |
real | sx, | ||
real | sy | ||
) |
Shift a loc coordinate by sx and sy.
Compute the size of a map that is used to build loc or can fully contain loc (embed)
void loc_dxdy | ( | loc_t * | out | ) |
Determine dx and dy from data.
Verify the magic, dimension and read in the loc_t by calling locreaddata2().
void locwritedata | ( | file_t * | fp, |
const loc_t * | loc | ||
) |
Write the actual data to file pointer.