hswfs is a Python package which provides a minimalistic simulation of a Hartmann-Shack Wavefront Sensor. A HSWFS is a popular and conceptually simple type of wavefront sensor that can be used to measure the abberations of a wavefront. It is commonly used in the adaptive optics systems of larger telescopes, which correct the image for the perturbations introduced by the turbulent movement of the air in the Earth's atmosphere.
Among other things, hswfs includes the following features:
- Generate random wavefront sensor data.
- Fit the wavefront using Zernike polynomials of arbitrary order (hswfs uses sympy to compute expressions of arbitrary Zernike polynomials and their derivatives in both polar and Cartesian coordinates).
- Compute the point spread function (PSF) from a wavefront.
To get started, clone this repository and install hswfs as a Python package:
git clone git@github.com:timothygebhard/hswfs.git
cd hswfs
pip install .
Here is an example result, showing a virtual wavefront sensor with the shifts measured in each subaperture, and the respective reconstructed wavefront and point spread function:
This example was created by the hswfs_example.py
script in the demo
directory.
This script should provide a good starting point to familiarize yourself with the functionality of hswfs.
The documentation for hswfs is available on ReadTheDocs.
hswfs comes with a series of unit tests, which can be run as follows:
pytest tests
Contributions to hswfs are always very welcome! Whether you have found a bug, or want to enhance hswfs's functionality, please feel free to open an issue here on GitHub, or send a pull request.
hswfs is provided under the permissive MIT License, which gives you a lot of freedom to use it for your own work.
Please note, however, that hswfs is provided as is, without any guarantees regarding completeness or correctness. If you break your telescope or AO system, that's on you! 😉