Implementation of the extended Nijboer-Zernike (ENZ) theory for Python.
This toolbox can be used to compute the point-spread function (PSF) using the scalar ENZ theory, see [ENZ], [J2002], [B2008], and [H2010]. It also contains code to fit the phase and the generalised pupil function using real- and complex-valued Zernike polynomials, see [A2015].
- real- and complex-valued Zernike polynomials
- complex point-spread function computation
- multi-threaded computation of the V_n^m terms (Eq.(2.48) in [B2008])
- routines to fit and evaluate the phase and the generalised pupil function
- load/save functions for each object
- numerous examples & documentation
- ENZPL algorithm example for phase retrieval
- Python 3
- pthreads (tested on Linux and Mac OS X Yosemite)
- Numpy
- h5py
- [optional] matplotlib
- [optional] PyQt5
- [optional] CVXOPT
Make sure you have installed the packages in Requirements.
$ git clone https://github.com/jacopoantonello/enzpy.git
$ cd enzpy
$ sudo python setup.py installThe easiest way to use this toolbox is to install Anaconda for Python 3, which includes all the necessary packages in Requirements, except for PyQt5 and CVXOPT. Once you have installed Anaconda, create an environment:
$ conda create -n py3 python=3 anaconda
$ source activate py3and install enzpy:
$ git clone https://github.com/jacopoantonello/enzpy.git
$ cd enzpy
$ python setup.py installPyQt5 is necessary to run the examples with a graphical interface:
alpha_abs.py and alpha_abs_qt.py.
After installing enzpy, you can run the examples located in examples/ (some screenshots are here):
through_focus_intensity.pyis taken from [ENZ], and computes the intensity as a function of the radial coordinate and the defocus parameter.psf_plot.pyplots a diffraction-limited PSF at different defocus planes.phase_plot.pyplots the first 10 real-valued Zernike polynomials.fit_phase.pyestimates a vector of real-valued Zernike coefficients from a phase grid by taking inner products numerically.fit_gpfestimates a vector of real-valued Zernike coefficients from a phase grid by taking inner products numerically. The coefficients can be used to approximate the generalised pupil function.beta_abs.pyandbeta_abs_qt.pyplot the point-spread function that corresponds to a given complex-valued Zernike analysis of the generalised pupil function. The coefficients can be adjusted using the command line (beta_abs.py) or a Qt widget (beta_abs_qt.py).alpha_abs.pyandalpha_abs_qt.pyplot the point-spread function that corresponds to a given real-valued Zernike analysis of the phase aberration function. The coefficients can be adjusted using the command line (alpha_abs.py) or a Qt widget (alpha_abs_qt.py).enzpl/runcontains an example of the ENZPL algorithm, which uses PhaseLift (see [C2013]) and the ENZ theory to correct a random aberration.
Alternatively, you can execute the consistency tests:
$ cd tests
$ nosetests -v -x --pdb *.py
[W1] http://www.antonello.org
[ENZ] (1, 2) http://www.nijboerzernike.nl/
[J2002] A. J. E. M. Janssen, "Extended Nijboer–Zernike approach for the computation of optical point-spread functions," J. Opt. Soc. Am. A 19, 849–857 (2002). url.
[B2008] (1, 2) J. Braat, S. van Haver, A. Janssen, P. Dirksen, Chapter 6 Assessment of optical systems by means of point-spread functions, In: E. Wolf, Editor(s), Progress in Optics, Elsevier, 2008, Volume 51, Pages 349-468, ISSN 0079-6638, ISBN 9780444532114. url.
[H2010] S. van Haver, The Extended Nijboer-Zernike Diffraction Theory and its Applications (Ph.D. thesis, Delft University of Technology, The Netherlands, 2010). url.
[A2015] Jacopo Antonello and Michel Verhaegen, "Modal-based phase retrieval for adaptive optics," J. Opt. Soc. Am. A 32, 1160-1170 (2015). url.
[C2013] E. J. Candès, Y. C. Eldar, T. Strohmer, and V. Voroninski, "Phase retrieval via matrix completion," SIAM J. Imaging Sci. 6, 199–225 (2013). url.