Utility m-Files for Visualizing AO Quantities

Top  Previous  Next

Above, we have discussed the main computational routines that comprise the LightLike AO configuration tools.  In addition to these, the AO toolset contains several utility routines that are helpful in visualizing AO variables.  The utility routines are also Matlab m-files.  The following list identifies and describes several such utility routines.  A key purpose of the utility routines is to manipulate and plot 2D AO data that is stored in specialized 1D formats.  As discussed elsewhere in this Guide, the 1D formats are the most practical method for storing data for generalized AO geometries.

 

actmap

Suppose we have any triple of 1D column vectors {F,x,y}, where vectors x and y contain a paired set of coordinates (x(i),y(i)), and where F(i) is the value of a scalar field at (x(i),y(i)).

Two typical AO examples are:

(1)  {F,x,y} = {x-tilts or y-tilts at the subap centers, x-coords of subap centers, y-coords of subap centers};

(2)  {F,x,y} = {surface displacements (opds) at actuators, x-coords of actuators, y-coords of actuators}.

In any such example, we often wish to make an image or mesh plot of the F data, using for example Matlab's imagesc function.  But, to use imagesc or related display commands, we must rearrange the F vector into a 2D array with its elements in the correct spatial layout. actmap performs this rearrangement.

The Matlab calling syntax is:

>> F2D = actmap(F, x, y, {bval}, {reltol}, {padact});

where

F, x, y  =  three vectors of equal length, as described above.

bval = optional argument:  value to assign to F2D at indices where no F data exists (default is NaN).

reltol = optional argument:  not needed by user.

padact = optional argument:  integer dimension of padding band to be added outside the support of F (default is 0).

F2D = 2D array containing the F values in the proper spatial layout.  A typical use of F2D would be to serve as the input matrix to Matlab's imagesc plot function.

Note 1:  To specify a later optional argument while defaulting a former, specify the empty matrix [ ] for the input argument to be defaulted.

Note 2:  in the case of slope fields, another useful type of plot is the vector field plot, or "quiver" plot as it is called in Matlab.  For example, to plot a slope field with the Matlab "quiver" function, only the 1D input vectors discussed above are required.

 

dmmap

Suppose we have a DM opd influence matrix computed using aoinf, and we also have a 1D vector of actuator displacements dact, which act at positions specified by the 1D coordinate vectors xactand yact.  The dact may be actual displacement commands obtained from a LightLike simulation, or just an arbitrary set of test values constructed by the user.  We may wish to make an image or mesh plot of the resulting DM displacement on the full influence function mesh (the "DM opd mesh").  As discussed previously, the DM opd mesh may be considerably denser than the dact mesh.  In terms of notation introduced previously, what we want to do amounts to first computing the matrix product dsrf  = Adact , and then converting the 1D dsrf  to a 2D format suitable for input to a Matlab plot routine like imagesc.  The function dmmap carries out these operations. dmmap requires the preliminary use of two other utility routines, opdc and actind.

The Matlab calling syntax is:

>> opd = dmmap(ixact, iyact, xopd, yopd, opdif, dact);

where

ixact, iyact  =  influence function actuator indices

xopd, yopd  =  opd mesh coordinates

To compute xopd, yopd, ixact, and iyact, use the helper routines actind and opdc as follows:

>> xopd = opdc(nxopd, dxopd);  %nxopd, dxopd = dimension, spacing(m) of full DM opd mesh

                                                        %(see aoinf for discussion).

>> yopd = opdc(nyopd, dyopd);  %aoinf only allows nyopd=nxopd, dyopd=dxopd

>> ixact = actind(xact, xopd);

>> iyact = actind(yact, yopd);

opdif =  DM opd influence function matrix computed and saved by aoinf

dact  =  1D vector of actuator displacements, acting at the xact, yact positions.

CAUTION:  a complication may arise if slave actuators exist.  Part of dmmap's action is to multiplyopdif times the dact vector:  to have the required length, dact must include all the actuators (master and slave).  Depending on its source, a given dact may include only the masters (e.g., if dact comes from recording of LightLike simulated actuator commands).  Therefore, depending on the source ofdact, it may be necessary to first compute a modified dact via the multiplication dact_all = mvtov *dact_master.  Then, dact_all is the quantity that must be entered into the dact input slot of dmmap.  

opd  =  2D array containing the DM displacements on the full opd mesh.  The format of opd is suitable to serve as the input matrix to Matlab's imagesc or related plot functions.