Code Monkey home page Code Monkey logo

soapy's Introduction

AOtools

Useful tools for Adaptive Optics analysis for the Python Programming Language. If using this code for a publication please cite the aotools paper (M. J. Townson, O. J. D. Farley, G. Orban de Xivry, J. Osborn, and A. P. Reeves, "AOtools: a Python package for adaptive optics modelling and analysis," Opt. Express 27, 31316-31329 (2019))

image

image

image

image

Documentation Status

Required libraries

python
SciPy
NumPy
matplotlib
numba

Installation

As everything is just pure python, you don't really need to "install" at all. To be able to use the tools from anywhere on your system, add the aotools directory to your PYTHONTPATH. Alternatively you can use one of the methods below.

Anaconda

AOtools can be installed in an anaconda environment using:

conda install -c aotools aotools

Pip

AOtools can be installed using pip:

pip install aotools

(which may require admin or root privileges)

From Source

Alternatively, to install the tools to your system python distribution from source, run:

python setup.py install

(which may require admin or root privileges) from the aotools directory.

Documentation

Full documentation is hosted by Read the Docs

Issues and Contributions

Have you found a problem with an AO Tool? Is there something you use often that you think should be included? Please have a quick look at the source code and see if you can fix the problem or make an addition. AOtools is a collaboration between many AO scientists across the world to try and make a well tested and reliable library of AO based functions. There isn't neccessarily a central "developer" to make significant changes, therefore if you think you can help then please get involved, make an issue, clone the code or make a pull request! Feel free to make an issue for discussion.

Usage Stats

Pip

image

Anaconda

image

soapy's People

Contributors

andrewpaulreeves avatar aureliemagniez avatar jwoillez avatar matthewtownson avatar ojdf avatar rahulbhadani avatar robjharris37 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

soapy's Issues

cannot import name phasescreen

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

Dependancies

Soapy doesn't list aotools as a dependency, despite now requiring it.

SCI type: singleModeFibre do not work

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!

Can not open soapy GUI

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']
    

Issues in base.py

/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).

Add latency to the control loop

@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/

"No atmosphere" Science Camera PSF does not look like Airy pattern

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?
psfairywrong

Simulation stalls when initialising WFS objects in Debian

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.

Configuration parameters for different objects

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...

Better configuration format

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!

python multi-processing

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.

Abstract Centroider choice

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.

Scipy Update breaking array operations

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).

Installation procedure on ubuntu out of date

Using a clean install of Ubuntu 18.04 LTS found the following issues with the instructions

  • Uses apt not apt-get
  • No installation instructions for Python 3
  • Repo to clone refers to soapy/soapy
  • Pyfftw not listed in dependencies for apt-get instructions

Wrong screen rotation

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).

Problem with saveLgsPsf: True

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

Unit testing

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!)

Strange GUI behaviour on mac osx

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!

Numba ``linterp`` function harms AO performance

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.

Version 1 development status

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.

  • Configuration in YAML
  • Configuration parameters defined per object type (issue #55)
  • Full unit test suite
  • Standardising all class/module/function names
  • Ensure all interfaces between modules are standard (i.e. checking WFS output measurements in the same way)
  • Use aotools (issue #59)

Comprehensive *Physics* tests

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

  • Check phase screens match Noll Zernilke spectrum

Science Detector

  • Check science Strehl ratio's match Marachel approx.

Parameter Names

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

`saveSciRes: True` does not work anymore

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'

Correlating Centroider blank reference image

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

Move long exposure calculations to science camera class

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?

GUI not launching

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

Migrate to using 'aotools' repository

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

  • copying across a snapshot of the aotools libraries
  • setting up a git "submodule"

Not sure which to go with

Unit test tracking

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.

  • Simulation
  • atmosphere
  • WFS
  • DM
  • RECON
  • SCI
  • AOTools
  • centroiders

Problems on Mac OSX in starting soapy with GUI

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

Saved data format

The saved data format keeps a copy of the config in a .py file rather than a .yaml file

LGS launchPosition needs to be numpy.array

/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.

Numba "Failed at nopython" Error

@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....

Generating reference images

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.

DM actuators

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.