brandondube / prysm

physical optics: integrated modeling, phase retrieval, segmented systems, polynomials and fitting, sequential raytracing...
https://prysm.readthedocs.io/en/stable/
MIT License
257 stars 44 forks source link
4d diffraction forbes-polynomial gpu-computing modeling mtf mtf-mapper optics phase-retrieval phasecam propagation psf python q-polynomial raytracing trioptics wavefront wavefront-sensing zernike zygo

Prysm

CircleCI Documentation Status Coverage Status DOI

Prysm is a python 3.6+ library for numerical optics. Its features are a superset of those in both POPPY and PROPER, not limited to physical optics, thin lens, thin film, and detector modeling. There is also a submodule that can replace the software that comes with an interferometer for data analysis.

Prysm is believed to be by significant margin the fastest package in the world at what it does. On CPU, end-to-end calculation is more than 100x as fast as the above for like-for-like calculations. On GPU, prysm is more than 1,000x faster than its competition. The lowfssim model can run at over 2kHz in real-time and is all prysm under the hood.

Prysm can be used for everything from forward modeling of optical systems from camera lenses to coronographs to reverse modeling and phase retrieval. Due to its composable structure, it plays well with others and can be substituted in or out of other code easily. Of special note is prysm's interchangeable backend system, which allows the user to freely exchange numpy for cupy, enabling use of a GPU for all computations, or other similar exchanges, such as pytorch for algorithmic differentiation.

Installation

prysm is on pypi:

pip install prysm

prysm requires only numpy, and scipy.

Optional Dependencies

Prysm uses numpy for array operations or any compatible library. To use GPUs, you may install cupy and use it as the backend at runtime. Plotting uses matplotlib. Images are read and written with imageio. Some MTF utilities utilize pandas and seaborn. Reading of Zygo datx files requires h5py.

Features

Propagation

Polynomials

All of these polynomials provide highly optimized GPU-compatible implementations, as well as derivatives.

Pupil Masks

Segmented systems

Image Simulation

Metrics

Detectors

Thin Films

Refractive Index

Thin Lenses

Tilted Planes and other surfaces

Deformable Mirrors

Interferometry

Tutorials, How-Tos

See the documentation on each

Contributing

If you find an issue with prysm, please open an issue or pull request. Prysm has some usage of f-strings, so any code contributed is only expected to work on python 3.6+, and is licensed under the MIT license.

Issue tracking, roadmaps, and project planning are done on Zenhub. Contact Brandon for an invite if you would like to participate; all are welcome.

Heritage