pyAOS Documentation Release 0.6.1 Andrew Reeves October 14, 2014

pyAOS Documentation
Release 0.6.1
Andrew Reeves
October 14, 2014
Contents
1
Introduction
1.1 Quick-Start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3
3
2
Installation
2.1 Required Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5
5
3
Configuration
3.1 Simulation Parameters . . . . .
3.2 Telescope Parameters . . . . .
3.3 Atmosphere Parameters . . . .
3.4 Wave-front Sensor Parameters .
3.5 Laser Guide Star Parameters . .
3.6 Deformable Mirror Parameters .
3.7 Science Camera Parameters . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
7
7
8
8
8
9
10
10
4
Simulation
13
5
Atmosphere
5.1 pyAOS.atmosphere module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
19
19
6
Wave-front Sensors
6.1 WFS Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.2 Shack-Hartmann WFS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.3 Adding new WFSs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21
21
21
22
7
Laser Guide Stars
7.1 pyAOS.LGS module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
25
25
8
Deformable Mirrors
8.1 pyAOS.DM module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
27
27
9
Reconstructors
9.1 pyAOS.RECON module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
29
29
10 Science Camera
10.1 pyAOS.SCI module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
31
31
11 Utilities
11.1 pyAOS.logger module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
33
33
i
11.2
11.3
11.4
11.5
pyAOS.AOFFT module . . . . . . . .
pyAOS.aoSimLib module . . . . . . .
pyAOS.opticalPropagationLib module .
pyAOS.confParse module . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
33
34
36
36
12 Indices and tables
41
Python Module Index
43
ii
pyAOS Documentation, Release 0.6.1
Contents:
Contents
1
pyAOS Documentation, Release 0.6.1
2
Contents
CHAPTER 1
Introduction
pyAOS is a Monte-Carlo Adaptive Optics Simulation toolkit written in Python. pyAOS can be used as a conventional
end-to-end simulation, where a large number of AO configurations can be created simply by editing a configuration
file. Its real power lays in modular nature of objects, such as WFSs, DMs and reconstructors which can be taken and
used as building blocks to construct for new and complex AO ideas and configurations.
1.1 Quick-Start
Try out some of the code examples in the conf directory, either run the pyAOS script in bin, or load a python or IPython
terminal:
import pyAOS
sim = pyAOS.Sim("configFilename")
sim.aoinit()
sim.makeIMat()
sim.aoloop()
3
pyAOS Documentation, Release 0.6.1
4
Chapter 1. Introduction
CHAPTER 2
Installation
2.1 Required Libraries
pyAOS doesn’t have too many requirements in terms of external libraries, though it does rely on some. There are also
some optional libraries which are recommended for plotting or performance.
2.1.1 Required
‘‘numpy‘‘
scipy pyfits
2.1.2 Recommended
for performance
pyfftw (Highly Recommended!)
for gui
PyQt4 pyqtgraph (http://www.pyqtgraph.org) matplotlib ipython
If your starting with python from scratch, there a couple of options. For Ubuntu (and probably debian) linux users, all
these packages can be installed via apt-get:
sudo apt-get install python-numpy python-scipy python-fftw python-pyfits python-qt4 python-matplotlib
for pyqtgraph, go to http://www.pyqtgraph.org and download the .deb file
for Red-hat based systems these packages should also be available from repositories, though I’m not sure of they’re
names. Again, get pyqtgraph from http://www.pyqtgraph.org, but download the source. pyqtgraph, like most python
packages is pretty easy to install from source, just download the package, unpack, navigate into the package and run
sudo python setup.py install
for mac os, all of these packages can be install via macports, with:
sudo port install python27 py27-numpy py27-scipy py27-pyfits py27-pyfftw py27-pyqt4 py27-ipython
5
pyAOS Documentation, Release 0.6.1
again, pyqtgraph must be downloaded from http://www.pyqtgraph.org and installed with sudo python
setup.py install
For any OS (including Windows), python distributions exist which include lots of python packages useful for science.
A couple of good examples are Enthought Canopy (https://www.enthought.com), which is free for academics, and
Anaconda (https://store.continuum.io/cshop/anaconda/) which is also free.
A lot of python packages are listed on https://pypi.python.org/pypi. Usually when python is installed, a script
called easy_install is installed also, which can be used to get any package on pypi with easy_install
<package>.
6
Chapter 2. Installation
CHAPTER 3
Configuration
Configuration of the system is handled by the confParse module. This module reads the simulation parameters
from a given configuration file. This file must contain a simConfiguration dictionary, which contains subdictionaries for each simulation sub-module. Where a sub-module consists of multiple components i.e. Wave-front
sensors, parameters must be given as lists at least as long as the number of components. Example configuration files
can be found in the conf directory of the pyAOS package.
Below is a list of all possible simulation parameters.
3.1 Simulation Parameters
class pyAOS.confParse.SimConfig
Configuration parameters relavent for the entire simulation. These should be held in the Sim sub-dictionary of
the simConfiguration dictionary in the parameter file.
Required:
Parameter
pupilSize
nIters
loopTime
Parameter
Optional:
Description
int: Number of phase points across the simulation pupil
int: Number of iteration to run simulation
float: Time between simulation frames (1/framerate)
Description
nGS
int: Number of Guide Stars and WFS
nDM
int: Number of deformable Mirrors
nSci
int: Number of Science Cameras
gain
float: loop gain of system
reconstructor
string: name of reconstructor class to use. See reconstructor module
for available reconstructors.
filePrefix string: directory name to store simulation data
tipTilt
bool: Does system use tip-tilt Mirror
ttGain
float: loop gain of tip-tilt Mirror
wfsMP
bool: Each WFS uses its own process
verbosity
int: debug output for the simulation ranging from 0 (no-ouput) to 3 (all
debug output)
logfile
string: name of file to store logging data,
learnIters int: Number of learn iterations for Learn & Apply reconstructor
learnAtmos string: if random, then random phase screens used for learn
Default
0
0
0
0.6
"MVM"
None
False
0.6
False
2
None
0
random
7
pyAOS Documentation, Release 0.6.1
Parameter
Description
saveSlopes
Save all WFS slopes. Accessed from sim with sim.allSlopes
saveDmCommands
Saves all DM Commands. Accessed from sim with sim.allDmComma
saveWfsFramesSaves all WFS pixel data. Saves to disk a after every frame to avoid usin
memory
saveStrehl
Saves the science camera Strehl Ratio. Accessed from sim with
sim.longStrehl and sim.instStrehl
saveSciPsf
Saves the science PSF.
saveSciRes
Save Science residual phase
Data Saving (all default to False):
3.2 Telescope Parameters
class pyAOS.confParse.TelConfig
Configuration parameters characterising the Telescope. These should be held in the Tel subdictionary of the simConfiguration dictionary in the parameter file.
Required:
Parameter
telDiam
Description
float: Diameter of telescope pupil in metres
Optional:
Parameter
obs
mask
Description
float: Diameter of central obscuration
string: Shape of pupil (only accepts circle currently)
Default
0
circle
3.3 Atmosphere Parameters
class pyAOS.confParse.AtmosConfig
Configuration parameters characterising the atmosphere. These should be held in the Atmosphere subdictionary of the simConfiguration dictionary in the parameter file.
Required:
Parameter
scrnNo
scrnHeights
scrnStrength
windDirs
windSpeeds
r0
wholeScrnSize
Parameter
Optional:
Description
int: Number of turbulence layers
list, int: Phase screen heights in metres
list, float: Relative layer scrnStrength
list, float: Wind directions in degrees.
list, float: Wind velocities in m/s
float: integrated seeing strength (metres at 550nm)
int: Size of the phase screens to store in the atmosphere object
Description
scrnNames list, string: filenames of phase if loading from fits files. If None will make
new screens.
subHarmonics
bool: Use sub-harmonic screen generation algorithm for better tip-tilt
statistics - useful for small phase screens.
Default
None
False
3.4 Wave-front Sensor Parameters
class pyAOS.confParse.WfsConfig(N)
Configuration parameters characterising Wave-front Sensors. These should be held in the WFS sub-dictionary
8
Chapter 3. Configuration
pyAOS Documentation, Release 0.6.1
of the simConfiguration dictionary in the parameter file. Each parameter must be in the form of a list,
where each entry corresponds to a WFS. Any entries above sim.nGS will be ignored.
Required:
Parameter
GSPosition
wavelength
subaps
pxlsPerSubap
subapFOV
Description
tuple: position of GS on-sky in arc-secs
float: wavelength of GS light in metres
int: number of SH sub-apertures
int: number of pixels per sub-apertures
float: Field of View of sub-aperture in arc-secs
Parameter
type
propagationMode
bitDepth
removeTT
subapOversamp
GSHeight
subapThreshold
Optional:
lgs
centMethod
angleEquivNoise
centThreshold
fftwThreads
Description
string: Which WFS object to load
from WFS.py?
string: Mode of light propogation
from GS. Can be “physical” or
“geometric”.
int: bitdepth of WFS detector
bool: if True, remove TT signal
from WFS slopes before reconstruction.
int: Multiplied by the number of
of phase points required for FOV
to increase fidelity from FFT.
float: Height of GS beacon. 0 if
at infinity.
float: How full should subap be to
be used for wavefront sensing?
bool: is WFS an LGS?
string: Method used for Centroiding. Can be simple or brightestPxl
float: width of gaussian noise
added to slopes measurements in
arc-secs
float: Centroiding threshold as a
fraction of the max subap value.
int: number of threads for fftw to
use. If 0, will use system processor number.
fftwFlag
Default
ShackHartmann
"geometric"
32
False
2
0
0.5
False
simple
0
0.1
1
FFTW_PATIENT
string: Flag to pass to
FFTW
when preparing plan.
3.5 Laser Guide Star Parameters
class pyAOS.confParse.LgsConfig(N)
Configuration parameters characterising the Laser Guide Stars. These should be held in the LGS
sub-dictionary of the simConfiguration dictionary in the parameter file. Each parameter must
be in the form of a list, where each entry corresponds to a WFS. Any entries above sim.nGS will
be ignored.
3.5. Laser Guide Star Parameters
9
pyAOS Documentation, Release 0.6.1
Optional:
Parameter
Description
lgsUplink
bool: Include LGS uplink effects
lgsPupilDiam float: Diameter of LGS launch aperture in metres.
wavelength
float: Wavelength of laser beam in metres
propagationMode
string: Mode of light propogation from GS. Can be “physical” or
“geometric”
height
float: Height to use physical propogation of LGS (does not effect
cone-effect) in metres
elongationDepth
float: Depth of LGS elongation in metres
elongationLayers
int: Number of layers to simulate for elongation.
launchPositiontuple: The launch position of the LGS in units of the pupil,
where (0,0) is the centre.
fftwThreads
int: number of threads for fftw to use. If 0, will use system
processor number.
fftwFlag
string: Flag to pass to FFTW when preparing plan.
Default
False
0.3
600e-9
"phsyical"
90000
0
10
(0,0)
1
FFTW_PATIENT
3.6 Deformable Mirror Parameters
class pyAOS.confParse.DmConfig(N)
Configuration parameters characterising Deformable Mirrors. These should be held in the DM sub-dictionary of
the simConfiguration dictionary in the parameter file. Each parameter must be in the form of a list, where
each entry corresponds to a DM. Any entries above sim.nDM will be ignored.
Required:
PaDescription
rameter
dmType string: Type of DM. This must the name of a class in the DM module.
dmActs int: Number independent DM shapes. e.g., for stack-array DMs this is number of actuators,
for Zernike DMs this is number of Zernike modes.
dmCond float: The conditioning parameter used in the pseudo inverse of the interaction matrix. this
is performed by numpy.linalg.pinv.
Optional:
Parameter
closed
iMatValue
Description
bool:Is DM closed loop of WFS?
float: Value to push actuators when making iMat
Default
True
10
3.7 Science Camera Parameters
class pyAOS.confParse.SciConfig(N)
Configuration parameters characterising Science Cameras. These should be held in the Science subdictionary of the simConfiguration dictionary in the parameter file. Each parameter must be in the form
of a list, where each entry corresponds to a science camera. Any entries above sim.nSci will be ignored.
Required:
10
Parameter
position
FOV
wavelength
pxls
Description
tuple: The position of the science camera in the field in arc-seconds
float: The field of fiew of the science detector in arc-seconds
float: The wavelength of the science detector light
int: Number of pixels in the science detector
Chapter 3. Configuration
pyAOS Documentation, Release 0.6.1
Parameter
oversamp
Optional:
Description
int: Multiplied by the number of of phase points required for FOV to
increase fidelity from FFT.
fftwThreadsint: number of threads for fftw to use. If 0, will use system processor
number.
fftwFlag string: Flag to pass to FFTW when preparing plan.
3.7. Science Camera Parameters
Default
2
1
FFTW_MEASURE
11
pyAOS Documentation, Release 0.6.1
12
Chapter 3. Configuration
CHAPTER 4
Simulation
High level interface to run and examine a simulation The main pyAOS Simulation module
This module contains the Sim class, which can be used to run an end-to-end simulation. Initally, a configuration file
is read, the system is initialised, interaction and command matrices calculated and finally a loop run. The simulation
outputs some information to the console during the simulation.
The Sim class holds all configuration information and data from the simulation.
Examples
To initialise the class:
import pyAOS
sim = pyAOS.Sim("sh_8x8_4.2m.py")
Configuration information has now been loaded, and can be accessed through the config attribute of the sim class. In
fact, each sub-module of the system has a configuration object accessed through this config attribute:
sim.config.sim.pupilSize
sim.config.sim.wfs[0].pxlsPerSubap = 10
Next, the system is initialised, this entails calculating various parameters in the system sub-modules, so must be done
after changing some simulation parameters:
sim.aoinit()
DM Interation and command matrices are calculated now. If sim.config.sim.filePrefix is not None, then these matrices
will be saved in ‘data/filePrefix‘(data will be saved here also in a time-stamped directory):
sim.makeIMat()
Finally, the loop is run with the command:
sim.aoloop()
Some output will be printed to the console. After the loop has finished, data specified to be saved in the config file
will be saved to data/filePrefix (if it is not set to None). Data can also be accessed from the simulation class, e.g.
sim.allSlopes, sim.longStrehl
Author Andrew Reeves
Version 0.6.1
13
pyAOS Documentation, Release 0.6.1
class pyAOS.Sim(configFile=None)
Bases: object
The pyAOS Simulation class.
This class holds all configuration information, data and control methods of the simulation. It contains high level
methods dealing with initialising all component objects, making reconstructor control matrices, running the loop
and saving data after the loop has run.
Can be sub-classed and the ‘aoloop’ method overwritten for different loops to be used
Parameters configFile (string) – The filename of the AO configuration file
addToGuiQueue()
Adds data to a Queue object provided by the pyAOS GUI.
The pyAOS GUI doesn’t need to plot every frame from the simulation. When it wants a frame, it will
request if by setting waitingPlot = True. As this function is called on every iteration, data is passed
to the GUI only if waitingPlot = True. This allows efficient and abstracted interaction between the
GUI and the simulation
aoinit()
Initialises all simulation objects.
Initialises and passes relevant data to sim objects. This does important pre-run tasks, such as creating
or loading phase screens, determining WFS geometry, setting propagation modes and pre-allocating data
arrays used later in the simulation.
finishUp()
Prints a message to the console giving timing data. Used on sim end.
initSaveData()
Initialise data structures used for data saving.
Initialise the data structures which will be used to store data which will be saved or analysed once the
simulation has ended. If the filePrefix = None, no data is saved, other wise a directory called
filePrefix is created, and data from simulation runs are saved in a time-stamped directory inside this.
loop()
Main AO Loop - loop open
Runs a WFS iteration, reconstructs the phase, runs DMs and finally the science cameras. Also makes some
nice output to the console and can add data to the Queue for the GUI if it has been requested. Repeats for
nIters. Runs sim Open loop, i.e., the WFSs are executed before the DM with no DM information being
sent back to the WFSs.
makeIMat(forceNew=False, progressCallback=None)
Creates interaction and control matrices for simulation reconstruction
Makes and inverts Interaction matrices for each DM in turn to create a DM control Matrix for each DM.
Each DM’s control Matrix is independent of the others, so care must be taken so DM correction modes
do not “overlap”. Some reconstruction modes may require WFS frames to be taken for the creation of a
control matrix. Depending on set parameters, can load previous control and interaction matrices.
Parameters
• forceNew (bool) – if true, will force making of new iMats and cMats, otherwise will
attempt to load previously made matrices from same filePrefix
• progressCallback (func) – function called to report progress of interaction matrix construction
14
Chapter 4. Simulation
pyAOS Documentation, Release 0.6.1
printOutput(label, iter, strehl=False)
Prints simulation information to the console
Called on each iteration to print information about the current simulation, such as current strehl ratio, to the
console. Still under development :param label: Simulation Name :type label: str :param iter: simulation
frame number :type iter: int :param strehl: current strehl ration if science cameras are present to record it.
readParams(configFile=None)
Reads configuration file parameters
Calls the radParams function in confParse to read, parse and if required set reasonable defaults to AO
parameters
runDM(dmCommands, closed=True)
Runs a single frame of the deformable mirrors
Calculates the total combined shape of all deformable mirrors (DMs), given an array of DM commands.
DM commands correspond to shapes generated during the making of interaction matrices, the final DM
shape for each DM is a combination of these. The DM commands will have already been calculated by
the systems reconstructor.
Parameters
• dmCommands (ndarray) – an array of dm commands corresponding to dm shapes
• closed (bool) – if True, indicates to DM that slopes are residual errors from previous frame,
if False, slopes correspond to total phase error over pupil.
Returns the combined DM shape
Return type ndArray
runSciCams(dmShape=None)
Runs a single frame of the science Cameras
Calculates the image recorded by all science cameras in the system for the current phase over the telescope
one frame. If a dmShape is present (which it usually will be in AO!) this correction is applied to the science
phase before the image is calculated.
Parameters dmShape (ndarray, optional) – An array of the combined system DM shape to
correct the science path. If not given science cameras are in open loop.
runTipTilt(slopes, closed=True)
Runs a single frame of the Tip-Tilt Mirror
Uses a previously created interaction matrix to calculate the correction required for the given slopes from
a tip-tilt (TT) mirror. Returns the phase of the TT mirror and also the now TT corrected slopes. If no TT
mirror is present in the system, then an array of zeros is returns and the slopes are unchanged.
Parameters
• slopes (ndarray) – An array of WFS slope values
• closed (bool, optional) – if True, TT acts in closed loop and the mirror shape is only
updated from previous shape based on set TT gain value
Returns New shape of the TT mirror ndArray: TT corrected slopes
Return type ndArray
runWfs_MP(scrns=None, dmShape=None, wfsList=None)
Runs all WFSs using multiprocessing
15
pyAOS Documentation, Release 0.6.1
Runs a single frame for each WFS in wfsList, passing the given phase screens and optional dmShape (if
WFS in closed loop). If LGSs are present it will also deals with LGS propagation. Finally, the slopes
from all WFSs are returned. Each WFS is allocated a seperate process to complete the frame, giving a
significant increase in speed, expecially for computationally heavy WFSs.
Parameters
• scrns (list) – List of phase screens passing over telescope
• dmShape (np array) – 2-dimensional array of the total corrector shape
• wfsList (list) – A list of the WFSs to be run
Returns The slope data return from the WFS frame (may not be actual slopes if WFS other than
SH used)
Return type ndarray
runWfs_noMP(scrns=None, dmShape=None, wfsList=None)
Runs all WFSs
Runs a single frame for each WFS in wfsList, passing the given phase screens and optional dmShape (if
WFS in closed loop). If LGSs are present it will also deals with LGS propagation. Finally, the slopes from
all WFSs are returned.
Parameters
• scrns (list) – List of phase screens passing over telescope
• dmShape (np array) – 2-dimensional array of the total corrector shape
• wfsList (list) – A list of the WFSs to be run
Returns The slope data return from the WFS frame (may not be actual slopes if WFS other than
SH used)
Return type array
saveData()
Saves all recorded data to disk
Called once simulation has ended to save the data recorded during the simulation to disk in the directories
created during initialisation.
storeData(i)
Stores data from each frame in an appropriate data structure.
Called on each frame to store the simulation data into various data structures corresponding to different
data sources in the system.
Parameters i (int) – The system iteration number
timeStamp()
Returns a formatted timestamp
Returns nicely formatted timestamp of current time.
Return type string
pyAOS.multiWfs(scrns, wfsObj, dmShape, queue)
Function to run the WFS in multiprocessing mode.
Function is called by each of the new WFS processes spawned to run each WFS. Does the same job as the sim
runWfs_noMP method of running LGS, then getting slopes from each WFS.
Parameters
16
Chapter 4. Simulation
pyAOS Documentation, Release 0.6.1
• scrns (list) – list of the phase screens over the WFS
• wfsObj (WFS object) – the WFS object being run
• dmShape (ndArray) – shape of system DMs for WFS phase correction
• queue (Queue object) – a multiprocessing Queue object used to pass data back to host
process.
17
pyAOS Documentation, Release 0.6.1
18
Chapter 4. Simulation
CHAPTER 5
Atmosphere
Class to simulate atmosphere above an AO system
5.1 pyAOS.atmosphere module
The pyAOS module simulating the atmosphere.
Contains an atmos object, which can be used to create or load a specified number of phase screens corresponding
to atmospheric turbulence layers. The layers can then be moved wiht the moveScrns method, at a specified wind
velocity and direction, where the screen is interpolated if it does not fall on an integer number of pixels. Alternatively,
random screens with the same statistics as the global phase screens can be generated using the randomScrns method.
The module also contains a number of functions used to create the phase screens, many of these are ported from the
book Numerical Simulation of Optical Propagation, Schmidt, 2010.
Examples
To get the configuration objects:
from pyAOS import confParse, atmosphere
config = confParse.Configurator("sh_8x8.py")
config.readfile()
config.loadSimParams()
Initialise the amosphere (creating or loading phase screens):
atmosphere = atmosphere.atmos(config.sim, config.atmos)
Run the atmosphere for 10 time steps:
for i in range(10):
phaseScrns = atmosphere.moveScrns()
or create 10 sets of random screens:
for i in range(10):
randomPhaseScrns = atmosphere.randomScrns()
class pyAOS.atmosphere.Screen(scrn, subscrnSize, order=3)
Bases: object
19
pyAOS Documentation, Release 0.6.1
getSlice(xstart, xstop, xsize, ystart, ystop, ysize)
subScrnCoords
class pyAOS.atmosphere.atmos(simConfig, atmosConfig)
Class to simulate atmosphere above an AO system.
On initialisation of the object, new phase screens can be created, or others loaded from .fits file. The atmosphere is created with parameters given in simConfig and atmosConfig. These are pyAOS configuration
objects, which can be created by the :ref:confParse module, or could be created manually. If created manually, check the :ref: confParse section to see which attributes the configuration objects must contain.
If loaded from file, the screens should have a header with the parameter R0 specifying the r0 fried parameter of
the screen in pixels.
The method moveScrns can be called on each iteration of the AO system to move the scrns forward by one
time step. The size of this is defined by parameters given in
The method randomScrns returns a set of random phase screens with the smame statistics as the atmos
object.
moveScrns()
Moves the phase screens one time-step, defined by the atmosphere object parameters.
Returns a dictionary containing the new set of phase screens
Return type dict
randomScrns(subharmonics=True, L0=30.0, l0=0.01)
Generated random phase screens defined by the atmosphere object parameters.
Returns a dictionary containing the new set of phase screens
Return type dict
pyAOS.atmosphere.ft_phase_screen(r0, N, delta, L0, l0, FFT=None)
pyAOS.atmosphere.ft_sh_phase_screen(r0, N, delta, L0, l0, FFT=None)
Creates a random phase screen with Von Karmen statistics with added sub-harmonics to augment tip-tilt modes
Parameters
• r0 (float) – r0 parameter of scrn in metres
• N (int) – Size of phase scrn in pxls
• delta (float) – size in Metres of each pxl
• L0 (float) – Size of outer-scale in metres
• l0 (float) – inner scale in metres
Returns numpy array representing phase screen
Return type ndarray
pyAOS.atmosphere.ift2(G, delta_f, FFT=None)
pyAOS.atmosphere.pool_ft_sh_phase_screen(args)
20
Chapter 5. Atmosphere
CHAPTER 6
Wave-front Sensors
Classes simulating AO WFSs The pyAOS Wavefront Sensor module.
6.1 WFS Class
This module contains a number of classes which simulate different adaptive optics wavefront sensor (WFS) types. All
wavefront sensor classes can inherit from the base WFS class. The class provides the methods required to calculate
phase over a WFS pointing in a given WFS direction and accounts for Laser Guide Star (LGS) geometry such as cone
effect and elongation. This is If only pupil images (or complex amplitudes) are required, then this class can be used
stand-alone.
Example
Make configuration objects:
from pyAOS import WFS, confParse
config = confParse.Configurator("config_file.py")
config.readFile()
config.loadSimParams()
config.calcParams()
Initialise the wave-front sensor:
wfs = WFS.WFS(config.sim, config.wfs[0], config.atmos, config.lgs[0], mask)
Set the WFS scrns (these should be made in advance, perhaps by the atmosphere module). Then run the WFS:
wfs.scrns = phaseScrnList
wfs.makePhase()
Now you can view data from the WFS frame:
frameEField = wfs.EField
6.2 Shack-Hartmann WFS
A Shack-Hartmann WFS is also included in the module, this contains further methods to make the focal plane, then
calculate the slopes to send to the reconstructor.
21
pyAOS Documentation, Release 0.6.1
Example
Using the config objects from above...:
shWfs = WFS.ShackHartmann(config.sim, config.wfs[0], config.atmos, config.lgs[0], mask)
As we are using a full WFS with focal plane making methods, the WFS base classes frame method can be used to
take a frame from the WFS:
slopes = shWfs.frame(phaseScrnList)
All the data from that WFS frame is available for inspection. For instance, to obtain the electric field across the WFS
and the image seen by the WFS detector:
EField = shWfs.EField
wfsDetector = shWfs.wfsDetectorPlane
6.3 Adding new WFSs
New WFS classes should inherit the WFS class, then create methods which deal with creating the focal plane and
making a measurement from it. To make use of the base-classes frame method, which will run the WFS entirely, the
new class must contain the following methods:
calcFocalPlane(self)
makeDetectorPlane(self)
calculateSlopes(self)
The Final calculateSlopes method must set self.slopes to be the measurements made by the WFS. If LGS
elongation is to be used for the new WFS, create a detectorPlane, which is added to for each LGS elongation
propagation. Have a look at the code for the Shack-Hartmann and experimental Pyramid WFSs to get some
ideas on how to do this.
Author Andrew Reeves
class pyAOS.WFS.WFS(simConfig, wfsConfig, atmosConfig, lgsConfig, mask)
A WFS class.
This is a base class which contains methods to initialise the WFS, and calculate the phase across the WFSs input
aperture, given the WFS guide star geometry.
Parameters
• simConfig (confObj) – The simulation configuration object
• wfsConfig (confObj) – The WFS configuration object
• atmosConfig (confObj) – The atmosphere configuration object
• lgsConfig (confObj) – The Laser Guide Star configuration object
• mask (ndarray) – An array or size (simConfig.pupilSize, simConfig.pupilSize) which is 1
at the telescope aperture and 0 else-where.
calcElongPos(elongLayer)
Calculates the difference in GS position for each elongation layer only makes a difference if LGS launched
off-axis
Parameters elongLayer (int) – which elongation layer
Returns The effect position of that layer GS
22
Chapter 6. Wave-front Sensors
pyAOS Documentation, Release 0.6.1
Return type float
findActiveSubaps()
Finds the subapertures which are not empty space determined if mean of subap coords of the mask is above
threshold
findMetaPupilSize(GSHeight)
Function to evaluate the sizes of the effective metePupils at each screen height if an GS of finite height is
used.
frame(scrns, correction=None)
Runs one WFS frame
Runs a single frame of the WFS with a given set of phase screens and some optional correction. If elongation is set, will run the phase calculating and focal plane making methods multiple times for a few different
heights of LGS, then sum these onto a wfsDetectorPlane.
Parameters
• scrns (list) – A list or dict containing the phase screens
• correction (ndarray, optional) – The correction term to take from the phase screens before
the WFS is run.
Returns WFS Measurements
Return type ndarray
getMetaPupilPhase(scrn, height, radius=None, pupilSize=None, GSPos=None)
Returns the phase across a metaPupil at some height and angular offset in arcsec. Interpolates if cone effect
is required
getMetaPupilPos(height, GSPos=None)
Finds the centre of a metapupil at a given height, when offset by a given angle in arcsecs
iMatFrame(phs)
Runs an iMat frame - essentially gives slopes for given “phs” so useful for other stuff too!
Parameters phs (ndarray) – The phase to apply to the WFS. Should be of shape (simConfig.pupilSize, simConfig.pupilSize)
Returns A 1-d array of WFS measurements
Return type ndarray
makePhaseGeo(radii=None, GSPos=None)
Creates the total phase on a wavefront sensor which is offset by a given angle
makePhasePhysical(radii=None, GSPos=None)
Finds total WFS complex amplitude by propagating light down phase scrns
class pyAOS.WFS.ShackHartmann(simConfig, wfsConfig, atmosConfig, lgsConfig, mask)
Class to simulate a Shack-Hartmann WFS
LGSUplink()
A method to deal with convolving the LGS PSF with the subap focal plane.
calcFocalPlane()
Calculates the wfs focal plane, given the phase across the WFS
calcTiltCorrect()
Calculates the required tilt to add to avoid the PSF being centred on only 1 pixel
calculateSlopes()
returns wfs slopes from wfsFocalPlane
6.3. Adding new WFSs
23
pyAOS Documentation, Release 0.6.1
makeDetectorPlane()
if required, will convolve final psf with LGS psf, then bins psf down to detector size. Finally puts back
into wfsFocalPlane Array in correct order.
oneSubap(phs)
Processes one subaperture only, with given phase
photonNoise()
Photon Noise
class pyAOS.WFS.Pyramid(simConfig, wfsConfig, atmosConfig, lgsConfig, mask)
calcFocalPlane()
takes the calculated pupil phase, and uses FFT to transform to the focal plane, and scales for correct FOV.
calcTiltCorrect()
Calculates the required tilt to add to avoid the PSF being centred on only 1 pixel
24
Chapter 6. Wave-front Sensors
CHAPTER 7
Laser Guide Stars
Classes simulating Laser guide stars - usually contained by a WFS object.
7.1 pyAOS.LGS module
class pyAOS.LGS.GeometricLGS(simConfig, wfsConfig, lgsConfig, atmosConfig)
Bases: pyAOS.LGS.LGSObj
LGSPSF(scrns=None, phs=None)
optFunc(A, X, Y, O)
Function the <optimiseTilt> function uses to optimise corrective even pixel number tilt
optimiseTilt()
Finds the optimimum correction tilt to apply to each subap to account for an odd even number of points in
the subap FFT. to be executed during WFS initialisation.
setWFSParams(subapFOVRad, subapOversamp, subapFFTPadding)
class pyAOS.LGS.LGSObj(simConfig, wfsConfig, lgsConfig, atmosConfig)
Bases: object
A class to simulate the propogation of a laser up through turbulence. given a set of phase screens, this will
return the PSF which would be present on-sky. This class gives a simple, stacked wavefront approach, with no
deviation between each layer. it assumes that the laser is focussed at the height it is propogated to.
getPupilPhase(scrns)
metaPupilPhase(scrn, height, pos)
metaPupilPos(height)
setWFSParams(subapFOVRad, subapOversamp, subapFFTPadding)
class pyAOS.LGS.PhysicalLGS(simConfig, wfsConfig, lgsConfig, atmosConfig)
Bases: pyAOS.LGS.LGSObj
LGSPSF(scrns)
Computes the LGS PSF for each frame by propagating light to each turbulent layer with a fresnel algorithm
angularSpectrum(Uin, wvl, d1, d2, z)
ft2(g, delta)
ift2(G, delta_f )
setWFSParams(subapFOVRad, subapOversamp, subapFFTPadding)
25
pyAOS Documentation, Release 0.6.1
26
Chapter 7. Laser Guide Stars
CHAPTER 8
Deformable Mirrors
Classes simulating different types of deformable mirror. The DM class provides a base class for other types of DM.
8.1 pyAOS.DM module
The module simulating Deformable Mirrors in pyAOS
class pyAOS.DM.DM(simConfig, dmConfig, wfss, mask, wfslist=[0])
dmFrame(dmCommands, gain, closed=False)
Uses interaction matrix to calculate the final DM shape
getActiveActs()
Method returning the total number of actuators used by the DM - May be overwritten in DM classes
Returns number of active DM actuators
Return type int
makeIMat(callback=None, progressCallback=None)
makes IMat
class pyAOS.DM.Piezo(simConfig, dmConfig, wfss, mask, wfslist=[0])
Bases: pyAOS.DM.DM
getActiveActs()
makeIMatShapes()
class pyAOS.DM.TT(simConfig, dmConfig, wfss, mask, wfslist=[0])
Bases: pyAOS.DM.DM
getActiveActs()
makeIMat(callback=None, progressCallback=None)
makes IMat
makeIMatShapes()
class pyAOS.DM.TT1(pupilSize, wfs, mask)
dmFrame(slopes, gain, closed=False)
getActiveActs()
27
pyAOS Documentation, Release 0.6.1
makeIMat(callback=None, progressCallback=None)
makeIMatShapes()
class pyAOS.DM.Zernike(simConfig, dmConfig, wfss, mask, wfslist=[0])
Bases: pyAOS.DM.DM
makeIMatShapes()
Creates all the DM shapes which are required for creating the interaction Matrix
28
Chapter 8. Deformable Mirrors
CHAPTER 9
Reconstructors
Classes simulating AO reconstructors.
9.1 pyAOS.RECON module
class pyAOS.RECON.ANN(simConfig, dms, wfss, atmos, runWfsFunc=None)
Bases: pyAOS.RECON.Reconstructor
Reconstructs using a neural net Assumes on axis slopes are WFS 0
Net must be set by setting sim.recon.net = net before loop is run net object must have a run method,
which accepts slopes and returns on Axis slopes
calcCMat(callback=None, progressCallback=None)
reconstruct(slopes)
Determine DM commands using previously made reconstructor from slopes. Uses Artificial Neural Network. :param slopes: array of slopes to reconstruct from :type slopes: ndarray
Returns array to comands to be sent to DM
Return type ndarray
class pyAOS.RECON.LearnAndApply(simConfig, dms, wfss, atmos, runWfsFunc=None)
Bases: pyAOS.RECON.Reconstructor
Class to perform a simply learn and apply algorithm, where “learn” slopes are recorded, and an interaction
matrix between off-axis and on-axis WFS is computed from these slopes.
Assumes that on-axis sensor is WFS 0
calcCMat(callback=None, progressCallback=None)
Uses the slopes recorded in the “learn” and DM interaction matrices to create a CMat.
initControlMatrix()
learn(callback=None, progressCallback=None)
Takes “self.learnFrames” WFS frames, and computes the tomographic reconstructor for the system. This
method uses the “truth” sensor, and assumes that this is WFS0
loadCMat()
reconstruct(slopes)
Determine DM commands using previously made reconstructor from slopes. :param slopes: array of
slopes to reconstruct from :type slopes: ndarray
29
pyAOS Documentation, Release 0.6.1
Returns array to comands to be sent to DM
Return type ndarray
saveCMat()
class pyAOS.RECON.LearnAndApplyLGS(simConfig, dms, wfss, atmos, runWfsFunc=None)
Bases: pyAOS.RECON.Reconstructor
Class to perform a simply learn and apply algorithm, where “learn” slopes are recorded, and an interaction
matrix between off-axis and on-axis WFS is computed from these slopes.
Assumes that on-axis sensor is WFS 0
Only works for 1 DM at present
This is a specific implementation designed to test LGS tip tilt prediction. It uses the last 10 frames of off-axis
slopes to help predict the on-axis slopes.
calcCMat()
Uses the slopes recorded in the “learn” and DM interaction matrices to create a CMat.
learn()
Takes “self.learnFrames” WFS frames, and computes the tomographic reconstructor for the system. This
method uses the “truth” sensor, and assumes that this is WFS0
reconstruct(slopes)
class pyAOS.RECON.MVM(simConfig, dms, wfss, atmos, runWfsFunc=None)
Bases: pyAOS.RECON.Reconstructor
calcCMat(callback=None, progressCallback=None)
Uses DM object makeIMat methods, then inverts each to create a control matrix
reconstruct(slopes)
class pyAOS.RECON.Reconstructor(simConfig, dms, wfss, atmos, runWfsFunc=None)
initControlMatrix()
loadCMat()
loadIMat()
makeCMat(loadIMat=True, loadCMat=True, callback=None, progressCallback=None)
makeIMat(callback, progressCallback)
reconstruct(slopes)
saveCMat()
saveIMat()
class pyAOS.RECON.WooferTweeter(simConfig, dms, wfss, atmos, runWfsFunc=None)
Bases: pyAOS.RECON.Reconstructor
Reconstructs a 2 DM system, where 1 DM is of low order, high stroke and the other has a higher, but low stroke.
Reconstructs dm commands for each DM, then removes the low order component from the high order commands
by propagating back to the slopes corresponding to the lower order DM shape, and propagating to the high order
DM shape.
calcCMat(callback=None, progressCallback=None)
Creates control Matrix. Assumes that DM 0 (or 1 if TT used) is low order, and DM 1 (or 2 if TT used) is
high order.
30
Chapter 9. Reconstructors
CHAPTER 10
Science Camera
A science camera class to measure system performance
10.1 pyAOS.SCI module
class pyAOS.SCI.scienceCam(simConfig, telConfig, atmosConfig, sciConfig, mask)
calcFocalPlane()
takes the calculated pupil phase, and uses FFT to transform to the focal plane, and scales for correct FOV.
calcPupilPhase()
Returns the total phase on a science Camera which is offset by a given angle
frame(scrns, phaseCorrection=None)
metaPupilPhase(scrn, height)
Returns the phase across a metaPupil at some height and angular offset in arcsec
metaPupilPos(height)
Finds the centre of a metapupil at a given height, when offset by a given angle in arcsecs
31
pyAOS Documentation, Release 0.6.1
32
Chapter 10. Science Camera
CHAPTER 11
Utilities
Modules containing some functions and classes commonly used throughout the simulation.
11.1 pyAOS.logger module
A module to provide a common logging interface for all simulation code.
Contains a Logger object, which can either, print information, save to file or both. The verbosity can also be adjusted
between 0 and 3, where all is logged when verbosity is 3, debugging and warning information is logged when verbosity
is 2, warnings logged when verbosity is 1 and nothing is logged when verbosity is 0.
pyAOS.logger.debug(message)
Logs messages if debug level is 3. Intended for very detailed debugging information.
Parameters message (string) – The message to log
pyAOS.logger.info(message)
Logs message if verbosity is 2 or higher. Useful for information which is not vital, but good to know.
Parameters message (string) – The message to log
pyAOS.logger.print_(message)
Always logs message, regardless of verbosity level
Parameters message (str) – The message to log
pyAOS.logger.setLoggingFile(logFile)
pyAOS.logger.setLoggingLevel(level)
pyAOS.logger.setStatusFunc(func)
pyAOS.logger.statusMessage(i, maxIter, message)
pyAOS.logger.warning(message)
Logs messages if debug level is 1 or over. Intended for warnings
Parameters message (string) – The message to log
11.2 pyAOS.AOFFT module
A Module to perform FFTs, wrapping a variety of FFT Backends in a common interface. Currently supports either
pyfftw (requires FFTW3), the scipy fftpack or some GPU algorithms
33
pyAOS Documentation, Release 0.6.1
class pyAOS.AOFFT.Convolve(shape, mode=’pyfftw’, fftw_FLAGS=(‘FFTW_MEASURE’, ), threads=0)
Bases: object
class pyAOS.AOFFT.FFT(inputSize,
axes=(-1,
),
mode=’pyfftw’,
dtype=’complex64’,
direction=’FORWARD’,
fftw_FLAGS=(‘FFTW_MEASURE’,
‘FFTW_DESTROY_INPUT’), THREADS=None, loggingLevel=None)
Bases: object
Class for performing FFTs in a variety of ways, with the same API.
Initialise the class, (only needs to be done once if problem size stays the same) then set data to fftobj.inputData
FFT performed by calling the class (i.e. ‘fftObj()’) and output data is returned.
fft(data=None)
pyAOS.AOFFT.ftShift2d(inputData, outputData=None)
Helper function to shift and array of 2-D FFT data
Parameters
• inputData (ndarray) – array of data to be shifted. Will shift final 2 axes
• outputData (ndarray, optional) – array to place data. If not given, will overwrite inputData
class pyAOS.AOFFT.mpFFT(inputSize, axes=(-1, ), mode=’pyfftw’, dtype=’complex64’, direction=’FORWARD’, fftw_FLAGS=(‘FFTW_MEASURE’, ), processes=None)
Bases: object
Class to perform FFTs on a large number of problems, using the FFT class, and seperate processes for different
problems. The input array will be split in the 0 axis onto different processes
doMpFFT(fftObj, data, Q)
fft()
11.3 pyAOS.aoSimLib module
A module containing useful functions used throughout pyAOS
Author Andrew Reeves
pyAOS.aoSimLib.binImgs(data, n)
Bins one or more images down by the given factor bins. n must be a factor of data.shape, who knows what
happens otherwise......
pyAOS.aoSimLib.brtPxlCentroid(img, nPxls)
Centroids using brightest Pixel Algorithm (A. G. Basden et al, 2011)
Finds the nPxlsth brightest pixel, subtracts that value from frame, sets anything below 0 to 0, and finally takes
centroid
pyAOS.aoSimLib.circle(radius, size, centre_offset=(0, 0))
Create a 2-dimensional array equal to 1 in a circle and 0 outside
Parameters
• radius (float) – The radius in pixels of the circle
• size (int) – The size of the the array for the circle
• centre_offset (tuple) – The coords of the centre of the circle
Returns The circle array
34
Chapter 11. Utilities
pyAOS Documentation, Release 0.6.1
Return type ndarray
pyAOS.aoSimLib.convolve(img1, img2,
threads=0)
Convolves 2, 2 dimensional arrays
mode=’pyfftw’,
fftw_FLAGS=(‘FFTW_MEASURE’, ),
Uses the AOFFT library to do fast convolution of 2, 2-dimensional numpy ndarrays. The FFT mode, and some
parameters can be set in the arguments.
Parameters
• img1 (ndarray) – 1st array to be convolved
• img2 (ndarray) – 2nd array to be convolved
• mode (string, optional) – The fft mode used, defaults to fftw
• fftw_FLAGS (tuple, optional) – flags for fftw, defaults to (“FFTW_MEASURE”,)
• threads (int, optional) – Number of threads used if mode is fftw
Returns The convolved 2-dimensional array
Return type ndarray
pyAOS.aoSimLib.findActiveSubaps(subaps, mask, threshold)
Finds the subapertures which are “seen” be through the pupil function. Returns the coords of those subaps
pyAOS.aoSimLib.simpleCentroid(img, threshold_frac=0)
Centroids an image, or an array of images. Centroids over the last 2 dimensions. Sets all values under “threshold_frac*max_value” to zero before centroiding
pyAOS.aoSimLib.zernIndex(j, sign=0)
returns the [n,m] list giving the radial order n and azimutal order of the zernike polynomial of index j if sign is
set, will also return a 1 for cos, -1 for sine or 0 when m==0.
pyAOS.aoSimLib.zernike(j, N)
Creates the Zernike polynomial with mode index j, where i = 1 corresponds to piston
pyAOS.aoSimLib.zernikeArray(J, N)
Creates an array of Zernike Polynomials
Parameters
• maxJ (int or list) – Max Zernike polynomial to create, or list of zernikes J indices to create
• N (int) – size of created arrays
Returns array of Zerkike Polynomials
Return type ndarray
pyAOS.aoSimLib.zernikeRadialFunc(n, m, r)
Fucntion to calculate the Zernike radial function
pyAOS.aoSimLib.zoom(array, newSize, order=3)
A Class to zoom 2-dimensional arrays using interpolation
Uses the scipy RectBivariateSpline interpolation routine to zoom into an array. Can cope with real of complex
data.
Parameters
• array (ndarray) – 2-dimensional array to zoom
• newSize (tuple) – the new size of the required array
• order (int, optional) – Order of interpolation to use. default is 3
11.3. pyAOS.aoSimLib module
35
pyAOS Documentation, Release 0.6.1
Returns zoom array of new size.
Return type ndarray
11.4 pyAOS.opticalPropagationLib module
A library of optical propagation methods.
Many extracted from the book by Schmidt, 2010: Numerical Methods of optical proagation
pyAOS.opticalPropagationLib.angularSpectrum(Uin, wvl, d1, d2, z)
pyAOS.opticalPropagationLib.ft2(g, delta, padFactor=1)
pyAOS.opticalPropagationLib.ift2(G, delta_f, padFactor=1)
pyAOS.opticalPropagationLib.lensAgainst(Uin, wvl, d1, f )
Propagates from the pupil plane to the focal plane for an object placed against (and just before) a lens
pyAOS.opticalPropagationLib.oneStepFresnel(Uin, wvl, d1, z)
pyAOS.opticalPropagationLib.twoStepFresnel(Uin, wvl, d1, d2, Dz)
11.5 pyAOS.confParse module
A module to generate configuration objects for the pyAOS, given a parameter file.
This module defines a number of classes, which when instantiated, create objects used to configure the entire simulation, or just submodules. All configuration objects are stored in the Configurator object which deals with loading
parameters from file, checking some potential conflicts and using parameters to calculate some other parameters used
in parts of the simulation.
The ConfigObj provides a base class used by other module configuration objects, and provides methods to read the
parameters from the dictionary read from file, and set defaults if appropriate. Each other module in the system has its
own configuration object, and for components such as wave-front sensors (WFSs), Deformable Mirrors (DMs), Laser
Guide Stars (LGSs) and Science Cameras, lists of the config objects for each component are created.
class pyAOS.confParse.AtmosConfig
Bases: pyAOS.confParse.ConfigObj
Configuration parameters characterising the atmosphere. These should be held in the Atmosphere subdictionary of the simConfiguration dictionary in the parameter file.
Required:
Parameter
scrnNo
scrnHeights
scrnStrength
windDirs
windSpeeds
r0
wholeScrnSize
Parameter
Optional:
36
Description
int: Number of turbulence layers
list, int: Phase screen heights in metres
list, float: Relative layer scrnStrength
list, float: Wind directions in degrees.
list, float: Wind velocities in m/s
float: integrated seeing strength (metres at 550nm)
int: Size of the phase screens to store in the atmosphere object
Description
scrnNames list, string: filenames of phase if loading from fits files. If None will make
new screens.
subHarmonics
bool: Use sub-harmonic screen generation algorithm for better tip-tilt
statistics - useful for small phase screens.
Default
None
False
Chapter 11. Utilities
pyAOS Documentation, Release 0.6.1
class pyAOS.confParse.ConfigObj
Bases: object
calcParams()
Dummy method to be overidden if required
initParams()
loadParams(configDict)
warnAndDefault(param, newValue)
warnAndExit(param)
exception pyAOS.confParse.ConfigurationError
Bases: exceptions.Exception
class pyAOS.confParse.Configurator(filename)
Bases: object
The configuration class holding all simulation configuration information
This class is used to load the parameter dictionary from file, instantiate each configuration object and calculate
some other parameters from the parameters given.
The configuration file given to this class must contain a python dictionary, named simConfiguration. This
must contain other dictionaries for each sub-module of the system, Sim, Atmosphere, Telescope, WFS,
LGS, DM, Science. For the final 4 sub-dictionaries, each entry must be formatted as a list (or numpy array)
where each value corresponds to that component.
The number of components on the module will only depend on the number set in the Sim dict. For example,
if nGS is set to 2 in Sim, then in the WFS dict, each parameters must have at least 2 entries, e.g. subaps :
[10,10]. If the parameter has more than 2 entries, then only the first 2 will be noted and any others discarded.
Descriptions of the available parameters for each sub-module are given in that that config classes documentation
Parameters filename (string) – The name of the configuration file
calcParams()
Calculates some parameters from the configuration parameters.
loadSimParams()
readfile()
class pyAOS.confParse.DmConfig(N)
Bases: pyAOS.confParse.ConfigObj
Configuration parameters characterising Deformable Mirrors. These should be held in the DM sub-dictionary of
the simConfiguration dictionary in the parameter file. Each parameter must be in the form of a list, where
each entry corresponds to a DM. Any entries above sim.nDM will be ignored.
Required:
PaDescription
rameter
dmType string: Type of DM. This must the name of a class in the DM module.
dmActs int: Number independent DM shapes. e.g., for stack-array DMs this is number of actuators,
for Zernike DMs this is number of Zernike modes.
dmCond float: The conditioning parameter used in the pseudo inverse of the interaction matrix. this
is performed by numpy.linalg.pinv.
Optional:
Parameter
closed
iMatValue
Description
bool:Is DM closed loop of WFS?
float: Value to push actuators when making iMat
11.5. pyAOS.confParse module
Default
True
10
37
pyAOS Documentation, Release 0.6.1
class pyAOS.confParse.LgsConfig(N)
Bases: pyAOS.confParse.ConfigObj
Configuration parameters characterising the Laser Guide Stars. These should be held in the LGS
sub-dictionary of the simConfiguration dictionary in the parameter file. Each parameter must
be in the form of a list, where each entry corresponds to a WFS. Any entries above sim.nGS will
be ignored.
Optional:
Parameter
Description
lgsUplink
bool: Include LGS uplink effects
lgsPupilDiam float: Diameter of LGS launch aperture in metres.
wavelength
float: Wavelength of laser beam in metres
propagationMode
string: Mode of light propogation from GS. Can be “physical” or
“geometric”
height
float: Height to use physical propogation of LGS (does not effect
cone-effect) in metres
elongationDepth
float: Depth of LGS elongation in metres
elongationLayers
int: Number of layers to simulate for elongation.
launchPositiontuple: The launch position of the LGS in units of the pupil,
where (0,0) is the centre.
fftwThreads
int: number of threads for fftw to use. If 0, will use system
processor number.
fftwFlag
string: Flag to pass to FFTW when preparing plan.
Default
False
0.3
600e-9
"phsyical"
90000
0
10
(0,0)
1
FFTW_PATIENT
class pyAOS.confParse.SciConfig(N)
Bases: pyAOS.confParse.ConfigObj
Configuration parameters characterising Science Cameras. These should be held in the Science subdictionary of the simConfiguration dictionary in the parameter file. Each parameter must be in the form
of a list, where each entry corresponds to a science camera. Any entries above sim.nSci will be ignored.
Required:
Parameter
position
FOV
wavelength
pxls
Description
tuple: The position of the science camera in the field in arc-seconds
float: The field of fiew of the science detector in arc-seconds
float: The wavelength of the science detector light
int: Number of pixels in the science detector
Parameter
oversamp
Optional:
Description
int: Multiplied by the number of of phase points required for FOV to
increase fidelity from FFT.
fftwThreadsint: number of threads for fftw to use. If 0, will use system processor
number.
fftwFlag string: Flag to pass to FFTW when preparing plan.
Default
2
1
FFTW_MEASURE
class pyAOS.confParse.SimConfig
Bases: pyAOS.confParse.ConfigObj
Configuration parameters relavent for the entire simulation. These should be held in the Sim sub-dictionary of
the simConfiguration dictionary in the parameter file.
Required:
38
Parameter
pupilSize
nIters
loopTime
Description
int: Number of phase points across the simulation pupil
int: Number of iteration to run simulation
float: Time between simulation frames (1/framerate)
Chapter 11. Utilities
pyAOS Documentation, Release 0.6.1
Parameter
Optional:
Description
nGS
int: Number of Guide Stars and WFS
nDM
int: Number of deformable Mirrors
nSci
int: Number of Science Cameras
gain
float: loop gain of system
reconstructor
string: name of reconstructor class to use. See reconstructor module
for available reconstructors.
filePrefix string: directory name to store simulation data
tipTilt
bool: Does system use tip-tilt Mirror
ttGain
float: loop gain of tip-tilt Mirror
wfsMP
bool: Each WFS uses its own process
verbosity
int: debug output for the simulation ranging from 0 (no-ouput) to 3 (all
debug output)
logfile
string: name of file to store logging data,
learnIters int: Number of learn iterations for Learn & Apply reconstructor
learnAtmos string: if random, then random phase screens used for learn
Data Saving (all default to False):
Default
0
0
0
0.6
"MVM"
None
False
0.6
False
2
None
0
random
Parameter
Description
saveSlopes
Save all WFS slopes. Accessed from sim with sim.allSlopes
saveDmCommands
Saves all DM Commands. Accessed from sim with sim.allDmComma
saveWfsFramesSaves all WFS pixel data. Saves to disk a after every frame to avoid usin
memory
saveStrehl
Saves the science camera Strehl Ratio. Accessed from sim with
sim.longStrehl and sim.instStrehl
saveSciPsf
Saves the science PSF.
saveSciRes
Save Science residual phase
class pyAOS.confParse.TelConfig
Bases: pyAOS.confParse.ConfigObj
Configuration parameters characterising the Telescope. These should be held in the Tel subdictionary of the simConfiguration dictionary in the parameter file.
Required:
Parameter
telDiam
Description
float: Diameter of telescope pupil in metres
Optional:
Parameter
obs
mask
Description
float: Diameter of central obscuration
string: Shape of pupil (only accepts circle currently)
Default
0
circle
class pyAOS.confParse.WfsConfig(N)
Bases: pyAOS.confParse.ConfigObj
Configuration parameters characterising Wave-front Sensors. These should be held in the WFS sub-dictionary
of the simConfiguration dictionary in the parameter file. Each parameter must be in the form of a list,
where each entry corresponds to a WFS. Any entries above sim.nGS will be ignored.
Required:
Parameter
GSPosition
wavelength
subaps
pxlsPerSubap
subapFOV
11.5. pyAOS.confParse module
Description
tuple: position of GS on-sky in arc-secs
float: wavelength of GS light in metres
int: number of SH sub-apertures
int: number of pixels per sub-apertures
float: Field of View of sub-aperture in arc-secs
39
pyAOS Documentation, Release 0.6.1
Parameter
type
propagationMode
bitDepth
removeTT
subapOversamp
GSHeight
subapThreshold
Optional:
lgs
centMethod
angleEquivNoise
centThreshold
fftwThreads
Description
string: Which WFS object to load
from WFS.py?
string: Mode of light propogation
from GS. Can be “physical” or
“geometric”.
int: bitdepth of WFS detector
bool: if True, remove TT signal
from WFS slopes before reconstruction.
int: Multiplied by the number of
of phase points required for FOV
to increase fidelity from FFT.
float: Height of GS beacon. 0 if
at infinity.
float: How full should subap be to
be used for wavefront sensing?
bool: is WFS an LGS?
string: Method used for Centroiding. Can be simple or brightestPxl
float: width of gaussian noise
added to slopes measurements in
arc-secs
float: Centroiding threshold as a
fraction of the max subap value.
int: number of threads for fftw to
use. If 0, will use system processor number.
fftwFlag
Default
ShackHartmann
"geometric"
32
False
2
0
0.5
False
simple
0
0.1
1
FFTW_PATIENT
string: Flag to pass to
FFTW
when preparing plan.
pyAOS.confParse.test()
40
Chapter 11. Utilities
CHAPTER 12
Indices and tables
• genindex
• modindex
• search
41
pyAOS Documentation, Release 0.6.1
42
Chapter 12. Indices and tables
Python Module Index
p
pyAOS, 13
pyAOS.AOFFT, 33
pyAOS.aoSimLib, 34
pyAOS.atmosphere, 19
pyAOS.DM, 27
pyAOS.LGS, 25
pyAOS.logger, 33
pyAOS.opticalPropagationLib, 36
pyAOS.RECON, 29
pyAOS.SCI, 31
pyAOS.WFS, 21
43
pyAOS Documentation, Release 0.6.1
44
Python Module Index
Index
A
D
addToGuiQueue() (pyAOS.Sim method), 14
debug() (in module pyAOS.logger), 33
angularSpectrum()
(in
module DM (class in pyAOS.DM), 27
pyAOS.opticalPropagationLib), 36
DmConfig (class in pyAOS.confParse), 10
angularSpectrum() (pyAOS.LGS.PhysicalLGS method), dmFrame() (pyAOS.DM.DM method), 27
25
dmFrame() (pyAOS.DM.TT1 method), 27
ANN (class in pyAOS.RECON), 29
doMpFFT() (pyAOS.AOFFT.mpFFT method), 34
aoinit() (pyAOS.Sim method), 14
F
atmos (class in pyAOS.atmosphere), 20
AtmosConfig (class in pyAOS.confParse), 8
FFT (class in pyAOS.AOFFT), 34
fft() (pyAOS.AOFFT.FFT method), 34
B
fft() (pyAOS.AOFFT.mpFFT method), 34
binImgs() (in module pyAOS.aoSimLib), 34
findActiveSubaps() (in module pyAOS.aoSimLib), 35
brtPxlCentroid() (in module pyAOS.aoSimLib), 34
findActiveSubaps() (pyAOS.WFS.WFS method), 23
findMetaPupilSize() (pyAOS.WFS.WFS method), 23
C
finishUp() (pyAOS.Sim method), 14
frame() (pyAOS.SCI.scienceCam method), 31
calcCMat() (pyAOS.RECON.ANN method), 29
calcCMat() (pyAOS.RECON.LearnAndApply method), frame() (pyAOS.WFS.WFS method), 23
ft2() (in module pyAOS.opticalPropagationLib), 36
29
calcCMat()
(pyAOS.RECON.LearnAndApplyLGS ft2() (pyAOS.LGS.PhysicalLGS method), 25
ft_phase_screen() (in module pyAOS.atmosphere), 20
method), 30
ft_sh_phase_screen() (in module pyAOS.atmosphere), 20
calcCMat() (pyAOS.RECON.MVM method), 30
calcCMat() (pyAOS.RECON.WooferTweeter method), ftShift2d() (in module pyAOS.AOFFT), 34
30
G
calcElongPos() (pyAOS.WFS.WFS method), 22
calcFocalPlane() (pyAOS.SCI.scienceCam method), 31
GeometricLGS (class in pyAOS.LGS), 25
calcFocalPlane() (pyAOS.WFS.Pyramid method), 24
getActiveActs() (pyAOS.DM.DM method), 27
calcFocalPlane() (pyAOS.WFS.ShackHartmann method), getActiveActs() (pyAOS.DM.Piezo method), 27
23
getActiveActs() (pyAOS.DM.TT method), 27
calcPupilPhase() (pyAOS.SCI.scienceCam method), 31
getActiveActs() (pyAOS.DM.TT1 method), 27
calcTiltCorrect() (pyAOS.WFS.Pyramid method), 24
getMetaPupilPhase() (pyAOS.WFS.WFS method), 23
calcTiltCorrect() (pyAOS.WFS.ShackHartmann method), getMetaPupilPos() (pyAOS.WFS.WFS method), 23
23
getPupilPhase() (pyAOS.LGS.LGSObj method), 25
calculateSlopes()
(pyAOS.WFS.ShackHartmann getSlice() (pyAOS.atmosphere.Screen method), 19
method), 23
I
circle() (in module pyAOS.aoSimLib), 34
Convolve (class in pyAOS.AOFFT), 33
ift2() (in module pyAOS.atmosphere), 20
convolve() (in module pyAOS.aoSimLib), 35
ift2() (in module pyAOS.opticalPropagationLib), 36
ift2() (pyAOS.LGS.PhysicalLGS method), 25
iMatFrame() (pyAOS.WFS.WFS method), 23
45
pyAOS Documentation, Release 0.6.1
info() (in module pyAOS.logger), 33
initControlMatrix() (pyAOS.RECON.LearnAndApply
method), 29
initControlMatrix()
(pyAOS.RECON.Reconstructor
method), 30
initSaveData() (pyAOS.Sim method), 14
oneSubap() (pyAOS.WFS.ShackHartmann method), 24
optFunc() (pyAOS.LGS.GeometricLGS method), 25
optimiseTilt() (pyAOS.LGS.GeometricLGS method), 25
M
R
makeCMat() (pyAOS.RECON.Reconstructor method),
30
makeDetectorPlane()
(pyAOS.WFS.ShackHartmann
method), 23
makeIMat() (pyAOS.DM.DM method), 27
makeIMat() (pyAOS.DM.TT method), 27
makeIMat() (pyAOS.DM.TT1 method), 27
makeIMat() (pyAOS.RECON.Reconstructor method), 30
makeIMat() (pyAOS.Sim method), 14
makeIMatShapes() (pyAOS.DM.Piezo method), 27
makeIMatShapes() (pyAOS.DM.TT method), 27
makeIMatShapes() (pyAOS.DM.TT1 method), 28
makeIMatShapes() (pyAOS.DM.Zernike method), 28
makePhaseGeo() (pyAOS.WFS.WFS method), 23
makePhasePhysical() (pyAOS.WFS.WFS method), 23
metaPupilPhase() (pyAOS.LGS.LGSObj method), 25
metaPupilPhase() (pyAOS.SCI.scienceCam method), 31
metaPupilPos() (pyAOS.LGS.LGSObj method), 25
metaPupilPos() (pyAOS.SCI.scienceCam method), 31
moveScrns() (pyAOS.atmosphere.atmos method), 20
mpFFT (class in pyAOS.AOFFT), 34
multiWfs() (in module pyAOS), 16
MVM (class in pyAOS.RECON), 30
randomScrns() (pyAOS.atmosphere.atmos method), 20
readParams() (pyAOS.Sim method), 15
reconstruct() (pyAOS.RECON.ANN method), 29
reconstruct() (pyAOS.RECON.LearnAndApply method),
29
reconstruct()
(pyAOS.RECON.LearnAndApplyLGS
method), 30
reconstruct() (pyAOS.RECON.MVM method), 30
reconstruct() (pyAOS.RECON.Reconstructor method),
30
Reconstructor (class in pyAOS.RECON), 30
runDM() (pyAOS.Sim method), 15
runSciCams() (pyAOS.Sim method), 15
runTipTilt() (pyAOS.Sim method), 15
runWfs_MP() (pyAOS.Sim method), 15
runWfs_noMP() (pyAOS.Sim method), 16
P
photonNoise() (pyAOS.WFS.ShackHartmann method),
24
L
PhysicalLGS (class in pyAOS.LGS), 25
learn() (pyAOS.RECON.LearnAndApply method), 29
Piezo (class in pyAOS.DM), 27
learn() (pyAOS.RECON.LearnAndApplyLGS method), pool_ft_sh_phase_screen()
(in
module
30
pyAOS.atmosphere), 20
LearnAndApply (class in pyAOS.RECON), 29
print_() (in module pyAOS.logger), 33
LearnAndApplyLGS (class in pyAOS.RECON), 30
printOutput() (pyAOS.Sim method), 14
lensAgainst() (in module pyAOS.opticalPropagationLib), pyAOS (module), 13
36
pyAOS.AOFFT (module), 33
LgsConfig (class in pyAOS.confParse), 9
pyAOS.aoSimLib (module), 34
LGSObj (class in pyAOS.LGS), 25
pyAOS.atmosphere (module), 19
LGSPSF() (pyAOS.LGS.GeometricLGS method), 25
pyAOS.DM (module), 27
LGSPSF() (pyAOS.LGS.PhysicalLGS method), 25
pyAOS.LGS (module), 25
LGSUplink() (pyAOS.WFS.ShackHartmann method), 23 pyAOS.logger (module), 33
loadCMat() (pyAOS.RECON.LearnAndApply method), pyAOS.opticalPropagationLib (module), 36
29
pyAOS.RECON (module), 29
loadCMat() (pyAOS.RECON.Reconstructor method), 30 pyAOS.SCI (module), 31
loadIMat() (pyAOS.RECON.Reconstructor method), 30
pyAOS.WFS (module), 21
loop() (pyAOS.Sim method), 14
Pyramid (class in pyAOS.WFS), 24
O
oneStepFresnel()
(in
pyAOS.opticalPropagationLib), 36
46
S
saveCMat() (pyAOS.RECON.LearnAndApply method),
30
saveCMat() (pyAOS.RECON.Reconstructor method), 30
saveData() (pyAOS.Sim method), 16
saveIMat() (pyAOS.RECON.Reconstructor method), 30
SciConfig (class in pyAOS.confParse), 10
scienceCam (class in pyAOS.SCI), 31
module Screen (class in pyAOS.atmosphere), 19
setLoggingFile() (in module pyAOS.logger), 33
Index
pyAOS Documentation, Release 0.6.1
setLoggingLevel() (in module pyAOS.logger), 33
setStatusFunc() (in module pyAOS.logger), 33
setWFSParams() (pyAOS.LGS.GeometricLGS method),
25
setWFSParams() (pyAOS.LGS.LGSObj method), 25
setWFSParams() (pyAOS.LGS.PhysicalLGS method), 25
ShackHartmann (class in pyAOS.WFS), 23
Sim (class in pyAOS), 13
SimConfig (class in pyAOS.confParse), 7
simpleCentroid() (in module pyAOS.aoSimLib), 35
statusMessage() (in module pyAOS.logger), 33
storeData() (pyAOS.Sim method), 16
subScrnCoords (pyAOS.atmosphere.Screen attribute), 20
T
TelConfig (class in pyAOS.confParse), 8
timeStamp() (pyAOS.Sim method), 16
TT (class in pyAOS.DM), 27
TT1 (class in pyAOS.DM), 27
twoStepFresnel()
(in
pyAOS.opticalPropagationLib), 36
module
W
warning() (in module pyAOS.logger), 33
WFS (class in pyAOS.WFS), 22
WfsConfig (class in pyAOS.confParse), 8
WooferTweeter (class in pyAOS.RECON), 30
Z
Zernike (class in pyAOS.DM), 28
zernike() (in module pyAOS.aoSimLib), 35
zernikeArray() (in module pyAOS.aoSimLib), 35
zernikeRadialFunc() (in module pyAOS.aoSimLib), 35
zernIndex() (in module pyAOS.aoSimLib), 35
zoom() (in module pyAOS.aoSimLib), 35
Index
47