aotools / soapy Goto Github PK
View Code? Open in Web Editor NEWA Python Adaptive Optics Simulation
License: GNU General Public License v3.0
A Python Adaptive Optics Simulation
License: GNU General Public License v3.0
In the documentation PATH should be / instead of /soapy
OS: Debian Wheezy
Software configuration: from repository plus compiled-from-source numpy 1.9.2 and ipython-qtconsole from backports (sid) -- the latter only to operate the GUI.
Trying to run any supplied python code (testSimulation.py, testWfs.py) with or without the GUI stalls after the line 'Initialising WFS' or after print two full stops.
I am using the sopay 0.13.1 and it is work pretty well but exist a problem when I try to switch to singleModeFibre.
Science:
0:
position: [0, 0]
FOV: 3.0
wavelength: 1.65e-6 #H-Band
pxls: 128
instStrehlWithTT: True
1:
position: [0, 0]
FOV: 3.0
wavelength: 1.65e-6 #H-Band
pxls: 128
instStrehlWithTT: True
type: singleModeFibre
when I run soapy the gui only shows the psf but no iformation about the fibre. After run the simulation I go to folder to see if the data is in a .fits file but there is no file regarding the fiber.
Need some different declaration in the .yaml file??
Thank you very much!
Soapy needs a website - @matthewtownson needs a hobby. Match made in heaven?
The counter which is used to assess long exposure strehl ratios is currently broken, so strehl ratios will be underestimated if multiple science targets are used
Correlation centroider currently works by manually setting a reference image of zeros, with the center region set to ones.
Change to read in a perfect wfs image of lgs and use them as the reference image for the different sub-aps
In the Numba branch, the aoSimLib.linterp2d
gives an enormous computational performance boost vs scipy.interp2d. Unfortunately, it also seems to harm AO performance, giving a drop of ~10% strehl for a 4" off-axis, 8x8 WFS in some of the example config files.
Requires a better look at the algorithm to see where I've gone wrong with it.
Within atmosphere.py (lines 526 and 536) numpy.rot90 should have k=3 and k=0 for wind directions of 90 and 270 degrees, respectively.
There is no way of manually selecting the field stop of the Shack-Hartmann Wavefront Sensor. I will attempt to implement and add as an argument in the config file.
Since updating scipy everything has broken!
Seems to be to do with combining arrays of different dtypes.(e.g summing an array of ints with an array of floats no longer just works).
The current configuration format can be a bit clunky. The is especially the case for components like WFSs and DMs, where you have to supply an array for every parameter. This gets silly when you combine different types, like a tip-tilt and Piezo DM which require different parameter sets, but all are required for both anyway. For example, you end up setting the number of actuators on a tip-tilt mirror.
This could be changed relatively easily so that you provide each component separately, e.g.
"DM":{
0: {
'type': "TipTilt",
'gain': 0.7
},
1: {
'type': "Peizo",
'nxActuators': 10,
'gain': 0.6,
}
}
This is better, but a lot of dictionaries are required! Perhaps this is a good oppertunity to adopt something like YAML for configuration, so it becomes:
- dm:
- TipTilt:
- gain: 0.7
- Peizo:
- nxActuators: 10
- gain: 0.6
The downside of this is that you can no-longer write any quick python code to set a number of parameters in the config file. Perhaps this is actually a good though to stop messy config files....?
If others have thoughts, I'd be eager to hear them!
It would be really nice if there was a suite of comprehensive tests of the physics underlying the simulation. This is a list of such tests which do just that. It will be added to as I (or anyone else!) think or more.
Atmosphere
Science Detector
For vaguely historical reasons, the number of DM actuators for stackarray DMs is expressed as nx**2
, whereas the number of wfs subaps for SH WFSs is expressed as nx
. Perhaps these should be made consistent?
Though in the past, I'd been worried about making multi-processing "built-in", seeing as its already built into python anyway, it might as well be. The general plan would be to make a multiprocessing "pool" which can be passed around various objects if they want to do some multi-processing stuff.
The pyMultiprocessing branch is the starting point for this.
Soapy is approaching being "stable" enough to release a version 1, thats not flagged as being volatile. v1 doesn't necessarily mean that there are no bugs and certainly not that the project is finished, but that there are going to be no more "breaking" changes, and that the API is stable.
This issue is be a tracker for the various big changes that are required.
/soapy/soapy/lineofsight.py(85):
self.config.launchPosition * self.telescope_diameter needs to be changed to numpy.array(self.config.launchPosition) * self.telescope_diameter
Also in the online documentation, would it be better to have the launch position as [0,0] instead of (0,0)? Just so the launch positions are arrays within the yaml config file.
At the moment, the long exposure calculations are performed in the simulation loop. It would make more sense to let the science camera class take care of it directly. The way, long exposure Strehl could be adapted to the type of science camera.
Any objection to a PR that would make this change?
Would be a lot less daunting to add new centroiders if the WFS source code didn't have to be edited. This could instead be achieved by specifying a function name in the config file, which the SH WFS class evals.
GUI goes blank sometimes when moving around and changing it. This is fixed by a quick resize of it, but its not ideal. I'm not sure what the problem with this is so any suggestions would be appreciated!
And the badge in README.md updated as well.
So that the config from that run is known
When I attempt to run soapy in GUI mode (as per the docs), I get the following error:
D:\Anaconda2\lib\site-packages\IPython\qt.py:13: ShimWarning: The IPython.qt
package has been deprecated. You should import from qtconsole instead.
"You should import from qtconsole instead.", ShimWarning)
Traceback (most recent call last):
File "soapy", line 12, in
from soapy import gui
File "D:\Anaconda2\lib\site-packages\soapy-0.13.1-py2.7.egg\soapy\gui.py", line 40, in
from IPython.qt.console.rich_ipython_widget import RichIPythonWidget
ImportError: No module named rich_ipython_widget
Any ideas on a work around?
Thanks
Do the tests pass on windows? I can't be bothered to do it manually. There must be a better way...
Dear Sir,
Why I got this error?
First I clone it then installed required package and finally python setup.py install.
I am in ubuntu 16.04 64-bit
python test/testSimulation.py
Traceback (most recent call last):
File "test/testSimulation.py", line 3, in
import soapy
File "/usr/local/lib/python2.7/dist-packages/soapy/init.py", line 22, in
from .simulation import Sim
File "/usr/local/lib/python2.7/dist-packages/soapy/simulation.py", line 63, in
from . import atmosphere, logger, wfs, DM, RECON, SCI, confParse, aotools
File "/usr/local/lib/python2.7/dist-packages/soapy/atmosphere.py", line 60, in
from .aotools import phasescreen
ImportError: cannot import name phasescreen
@andrewpaulreeves - Would you consider a PR adding a latency parameter to the loop?
Skimming through the code, I would add a fifo of configurable size to Sim.loopFrame()
, between the calls to reconstruct()
and runDM()
. The parameter would be the latency as an integer multiple of loopTime
.
PS: Thank so much! Finally a python tool for AO simulations. \o/
Soapy doesn't list aotools as a dependency, despite now requiring it.
Unit tests are great to ensure new additions and changes don't break existing code. They're also pretty easy to do when writing new code. Writing them all out for old code is pretty dull, but we should probably do anyway....
This issue can be used to keep track of the current state of unit testing.
/soapy/soapy/wfs/base.py(290):
self.los.telDiam needs to be self.los.telescope_diameter
s/soapy/soapy/wfs/base.py(322):
phaseAddition = interp.zoom(phaseAddition, self.los.nx_out_pixels)
NameError: name 'interp' is not defined
is this supposed to be scipy.ndimage.interpolation.zoom? If so, the zoom factor should be self.los.nx_out_pixels/phaseAddition.shape[0] (instead of self.los.nx_out_pixels).
A Unit test system would be really useful. At the very least, it would run a few config files which checked most of the features of the simulation, including those which are rarely used. A more advanced system would check against expected performance, and warn if AO performance changed much (and fail if its awful!)
Some of the names of parameters are not very clear and are a simply an artifact of some earlier development. Perhaps these should be changed to something better @matthewtownson ?
Some which could be changed:
sim
filePrefix --> dataDir
tel
obs --> obsDiam
wfs
subapOversamp --> fftOversamp
lgs
lgsUplink --> uplink
lgsPupilDiam --> pupilDiam
dm
dmType --> type
dmActs --> nActuators
dmCond --> svdConditioning
sci
oversamp --> fftOversamp
Hello,
I have installed soapy both under python2.7 and python 3.5 through the specific anaconda distributions. Indeed the proposed test runs fine in both cases.
However, as soon as I try to start soapy with the GUI I have errors in both environments.
For python2.7:
soapy -g conf/sh_8x8.yaml
Traceback (most recent call last):
File "/Users/covino/anaconda/bin/soapy", line 12, in
from soapy import gui
File "/Users/covino/anaconda/lib/python2.7/site-packages/soapy/gui.py", line 52, in
from . import pyqtgraph
File "/Users/covino/anaconda/lib/python2.7/site-packages/soapy/pyqtgraph/init.py", line 30, in
from . import python2_3
ImportError: cannot import name python2_3
and for python3.5:
soapy -g conf/sh_8x8.yaml
Traceback (most recent call last):
File "/Users/covino/owncloud/Pacchetti/anaconda3/bin/soapy", line 12, in
from soapy import gui
File "/Users/covino/owncloud/Pacchetti/anaconda3/lib/python3.5/site-packages/soapy/gui.py", line 52, in
from . import pyqtgraph
File "/Users/covino/owncloud/Pacchetti/anaconda3/lib/python3.5/site-packages/soapy/pyqtgraph/init.py", line 204, in
from .graphicsItems.VTickGroup import *
ImportError: No module named 'soapy.pyqtgraph.graphicsItems'
Is there anything I can do?
Bye,
Stefano
Dear Andrew,
I am new to use SOAPY, so first of all thank you very much for all the gresat job done inside.
I was trying to make a short introduction to SOAPY for local users (Pontificia Universidad de Chile), but I just got stucked at the very beginning. I designed a config with 8-m telescope and "no atmosphere" (hoping that r0 set to 10km would allow such approximation), no WFS, no DM. And I look at a centered Science Camera PSF. I obtain the following shape, which is not circularly symmetric.
I understand the problem may come from a wrong setting of the sampling parameters. Could you help me understand how should the configuration be set to get an Airy pattern PSF, please?
AOTools aims to be a nice collection of Python tools for AO that should be re-used by Soapy rather than the slightly odd 'aoSimLib.py' library. There are a couple of options to integrate it, either
Not sure which to go with
@matthewtownson noticed a bug in the numba
branch, where aoSimLib.zoom_numba would give
AttributeError: Failed at nopython (nopython mode backend)
'Module' object has no attribute 'global_variables'
This is confirmed on MacOSX, macports numba version 0.17.0.
The error indicates that the function is not fully reducable down to native code, and python objects have been used as a fall back. As nopython
is set, this calls an exception.
I'm sure it worked a couple of days ago, and it still works on linux builds. I did notice an update to llvm3.5 this morning, so perhaps its something to do with that....
Dear Sir,
I am starting to use the soapy library. I have installed the 'master' branch and I can run the 'python testSimulation.py' without problems, but I am having problems to start the GUI. The problem is on this line of the bin/soapy script:
from soapy import gui
I am using ubuntu 16.04 64-bit, but I have tried also the 32-bit version with the same result. It seems there is a problem with the QT library and Ipython, but I have not been able to find a solution.
Here is the traceback:
Traceback (most recent call last):
File "/usr/local/bin/soapy", line 4, in <module>
__import__('pkg_resources').run_script('soapy===v0.13.1-2-gd1d68a0', 'soapy')
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 719, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1504, in run_script
exec(code, namespace, namespace)
File "/usr/local/lib/python2.7/dist-packages/soapy-v0.13.1_2_gd1d68a0-py2.7.egg/EGG-INFO/scripts/soapy", line 12, in <module>
from soapy import gui
File "/usr/local/lib/python2.7/dist-packages/soapy-v0.13.1_2_gd1d68a0-py2.7.egg/soapy/gui.py", line 40, in <module>
from IPython.qt.console.rich_ipython_widget import RichIPythonWidget
File "/home/user/.local/lib/python2.7/site-packages/IPython/qt/console/rich_ipython_widget.py", line 8, in <module>
from IPython.external.qt import QtCore, QtGui
File "/home/user/.local/lib/python2.7/site-packages/IPython/external/qt.py", line 23, in <module>
QtCore, QtGui, QtSvg, QT_API = load_qt(api_opts)
File "/home/user/.local/lib/python2.7/site-packages/IPython/external/qt_loaders.py", line 296, in load_qt
api_options))
ImportError:
Could not load requested Qt binding. Please ensure that
PyQt4 >= 4.7, PyQt5 or PySide >= 1.0.3 is available,
and only one is imported per session.
Currently-imported Qt library: 'pyqtv1'
PyQt4 installed: True
PyQt5 installed: False
PySide >= 1.0.3 installed: False
Tried to load: ['pyside', 'pyqt', 'pyqt5']
It looks like the recording of the residual wavefront does not work anymore, I believe since the introduction of the "line of sight" object. See the error message below:
Traceback (most recent call last):
File "/Users/jwoillez/Library/Python/3.6/lib/python/site-packages/soapy-v0.13.1_245_ge072290-py3.6.egg/soapy/gui.py", line 722, in run
self.sim.aoloop()
File "/Users/jwoillez/Library/Python/3.6/lib/python/site-packages/soapy-v0.13.1_245_ge072290-py3.6.egg/soapy/simulation.py", line 573, in aoloop
self.loopFrame()
File "/Users/jwoillez/Library/Python/3.6/lib/python/site-packages/soapy-v0.13.1_245_ge072290-py3.6.egg/soapy/simulation.py", line 552, in loopFrame
self.storeData(self.iters)
File "/Users/jwoillez/Library/Python/3.6/lib/python/site-packages/soapy-v0.13.1_245_ge072290-py3.6.egg/soapy/simulation.py", line 773, in storeData
self.sciPhase[sci][i] = self.sciCams[sci].residual
AttributeError: 'PSF' object has no attribute 'residual'
Using a clean install of Ubuntu 18.04 LTS found the following issues with the instructions
If using a correlating wfs, then on init the a reference image should be generated for each of the wavefront sensors, rather than reading in from file.
Hello,
I am following the on-line tutorial creating a SCAO conf file to simulate the CANARY instrument and, possibly, I found a bug.
If I set in the conf file
saveLgsPsf: False
everything seems to work fine. On the other hand setting the entry to "True" I get these messages and an error:
soapy conf/CANARY_SCAO.yaml
Pixel Scale: 30.48 pxls/m
subScreenSize: 154 simulation pixels
1 of 1: Loaded configuration file successfully!
Starting Sim: 2017-04-18-16-07-56
Pixel Scale: 30.48 pxls/m
subScreenSize: 154 simulation pixels
Creating mask...
Turbulence summary @ 500 nm:
| r0 = 0.14 m (0.74" seeing)
| Vbar_5/3 = 11.90 m/s
| tau0 = 3.69 ms
Generating Phase Screens
Generate Phase Screen 0 with r0: 0.24, size: 2048
Generate Phase Screen 1 with r0: 0.32, size: 2048
Generate Phase Screen 2 with r0: 0.41, size: 2048
Generate Phase Screen 3 with r0: 0.62, size: 2048
Generate Phase Screen 4 with r0: 0.62, size: 2048
Initialising WFSs....
AOFFT.py -> init: No pyfftw available. Defaulting to scipy.fftpack
WFS 0: 72 measurements
Initialising 2 DMs...
DM 0: 2 active actuators
DM 1: 60 active actuators
62 total DM Actuators
Initialising Reconstructor...
Initialising 1 Science Cams...
AOFFT.py -> init: No pyfftw available. Defaulting to scipy.fftpack
Initialise Data Storage...
Traceback (most recent call last):
File "/Users/covino/owncloud/Pacchetti/anaconda3/bin/soapy", line 4, in
import('pkg_resources').run_script('soapy==0.13.1', 'soapy')
File "/Users/covino/owncloud/Pacchetti/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/pkg_resources/init.py", line 744, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/Users/covino/owncloud/Pacchetti/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg/pkg_resources/init.py", line 1499, in run_script
exec(code, namespace, namespace)
File "/Users/covino/owncloud/Pacchetti/anaconda3/lib/python3.5/site-packages/soapy-0.13.1-py3.5.egg/EGG-INFO/scripts/soapy", line 92, in
runCmdSim(sim, interactive=args.interactive)
File "/Users/covino/owncloud/Pacchetti/anaconda3/lib/python3.5/site-packages/soapy-0.13.1-py3.5.egg/EGG-INFO/scripts/soapy", line 35, in runCmdSim
sim.aoinit()
File "/Users/covino/owncloud/Pacchetti/anaconda3/lib/python3.5/site-packages/soapy-0.13.1-py3.5.egg/soapy/simulation.py", line 264, in aoinit
self.initSaveData()
File "/Users/covino/owncloud/Pacchetti/anaconda3/lib/python3.5/site-packages/soapy-0.13.1-py3.5.egg/soapy/simulation.py", line 650, in initSaveData
if self.config.wfss[lgs].lgsUplink:
AttributeError: 'WfsConfig' object has no attribute 'lgsUplink'
Thanks a lot for your attention, and I hope not to bore you too much.
Stefano
Currently, knowing which configuration parameters are required can be a bit messy. Currently, the configuration parameters that are needed for a whole group of components are listed in the confparse.py
module, but there is no distinction within this. For instance, a tip-tilt mirror does not require a number of actuators, but clearly the simulation should fail if a stack array DM is configured without this parameter.
Where and in what format the list of required parameters is put may need some further thought...
Wind directions of 90 and 270 are flipped. This is an easy fix. See ~ln.520 within atmosphere.py. When using e.g. 91 and 271, wind direction is correct (the problem is when using exactly 90 and 270).
The names should also be aligned: pyaos -> soapy.
This would reduce the need for users to edit source code.
The saved data format keeps a copy of the config in a .py file rather than a .yaml file
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.