Atmosphere¶
The Soapy module used to simulate the atmosphere.
This module 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 with 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. It is possible to create a number of phase screens using the makePhaseScreens()
function which are saved to file in a format which can be read by the simulation.
Examples
To get the configuration objects:
from soapy import confParse, atmosphere
config = confParse.loadSoapyConfig("configfile.yaml")
Initialise the amosphere (creating or loading phase screens):
atmosphere = atmosphere.atmos(config)
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()
Atmosphere Class¶
-
class
soapy.atmosphere.
atmos
(soapyConfig)[source]¶ 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 inConfigObj.sim
andConfigObj.atmos
. These are soapy 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 inThe method
randomScrns
returns a set of random phase screens with the smame statistics as theatmos
object.Parameters: soapyConfig (ConfigObj) – The Soapy config object -
moveScrns
()[source]¶ Moves the phase screens one time-step, defined by the atmosphere object parameters.
Returned phase is in units of nana-meters
Returns: a dictionary containing the new set of phase screens Return type: dict
-
Phase Screen Creation and Saving¶
-
soapy.atmosphere.
makePhaseScreens
(nScrns, r0, N, pxlScale, L0, l0, returnScrns=True, DIR=None, SH=False)[source]¶ Creates and saves a set of phase screens to be used by the simulation.
Creates
nScrns
phase screens, with the required parameters, then saves them to the directory specified byDIR
. Each screen is given a FITS header with its value of r0, which will be scaled by on simulation when its loaded.Parameters: - nScrns (int) – The number of screens to make.
- r0 (float) – r0 value of the phase screens in metres.
- N (int) – Number of elements across each screen.
- pxlScale (float) – Size of each element in metres.
- L0 (float) – Outer scale of each screen.
- l0 (float) – Inner scale of each screen.
- returnScrns (bool, optional) – Whether to return a list of screens. True by default, but if screens are very large, False might be preferred so they aren’t kept in memory if saving to disk.
- DIR (str, optional) – The directory to save the screens.
- SH (bool, optional) – If True, add sub-harmonics to screens for more accurate power spectra, though screens no-longer periodic.
Returns: A list containing all the screens.
Return type: list