ZernikePy


NameZernikePy JSON
Version 0.0.2 PyPI version JSON
download
home_page
SummaryA minimalistic Python package to generate individual or a series of Zernike polynomials of arbitrary orders with visualization.
upload_time2024-02-27 13:47:48
maintainer
docs_urlNone
author
requires_python>=3.8
license
keywords zernike psf optics polynomials basis
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            _ZernikePy_ is a minimalistic Python library to compute and visualize Zernike polynomials of any given orders.
A typical usage is to generate basis functions for phase modulation in optics.

# Installation
```
pip install ZernikePy
```

# Requirements
```
numpy
scipy
matplotlib
```

# How to use
After installation, first import the main function from the library
```
from zernikepy import zernike_polynomials
```

## Examples
Generate a (256, 256)-sized Zernike polynomial of order 4 (defocusing):
```python
p = zernike_polymonials(mode=4, size=256)
```
or
```python
p = zernike_polymonials(mode='defocusing', size=256)
```
Generate the first 55 modes and display them:
```python
ps = zernike_polymonials(mode=55, select='all', show=True)
```
Generate the following selected modes defocusing, vertical coma, oblique astigmatism and
display them:
```python
ps = zernike_polynomials(mode=10, select=[4, 'vertical coma', 'oblique astigmatism'], show=True)
```
Note that regardless of the order of the elements in the list `select`, the output stores the polynomials in ascending 
order in the last dimension. Hence, in the output `ps[:, :, 0]` is oblique astigmatism, `ps[:, :, 1]` is defocusing and 
`ps[:, :, 2]` is vertical coma.

## Detailed explanation
The main function `zernike_polynomials(mode, size, select, show)`
takes four variables:
- `mode`: which (or up to which) order of the polynomial. It follows the [OSA standard indexing](https://en.wikipedia.org/wiki/Zernike_polynomials#OSA/ANSI_standard_indices) convention 
and should be a nonnegative integer. It is also possible to pass a string of the corresponding name for the first 15 modes. Default is `'defocus'`.
- `size`: numerical size of the square Cartesian mesh. It should be a postive integer. Default is `128`.
- `select`: in the case of passing more than one polynomial, i.e. some selected modes up to the given `mode`,
give a list of integers or strings or a mixture of both. A special case is `select='all'` where all the polynomials up to
the given `mode` is passed. Default is `None` in which case only a single polynomial of the given `mode` is passed.
- `show`: boolen variable to determine whether to display the polynomials. Default is `False`.

The output is a Numpy array, either 2D for a single mode, or 3D for multiple modes.

### Name of the first 15 modes

| Mode / OSA index |              Name              |
|------------------|:------------------------------:|
| 0                |             piston             |
| 1                |         vertical tilt          |
| 2                |        horizontal tilt         |
| 3                |      oblique astigmatism       |
| 4                |            defocus             |
| 5                |      vertical astigmatism      |
| 6                |        vertical trefoil        |
| 7                |         vertical coma          |
| 8                |        horizontal coma         |
| 9                |        oblique trefoil         |
| 10               |       oblique quadrafoil       |
| 11               | oblique secondary astigmatism  |
| 12               |       primary spherical        |
| 13               | vertical secondary astigmatism |
| 14               |      vertical quadrafoil       |


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "ZernikePy",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "Yan Liu <yanyan@ik.me>",
    "keywords": "zernike,psf,optics,polynomials,basis",
    "author": "",
    "author_email": "Yan Liu <yanyan@ik.me>",
    "download_url": "https://files.pythonhosted.org/packages/50/d6/88a2071ac83452fe0ade027b5becd8c29eae2007fc4a9a7dc3f2c2d6e3a3/ZernikePy-0.0.2.tar.gz",
    "platform": null,
    "description": "_ZernikePy_ is a minimalistic Python library to compute and visualize Zernike polynomials of any given orders.\nA typical usage is to generate basis functions for phase modulation in optics.\n\n# Installation\n```\npip install ZernikePy\n```\n\n# Requirements\n```\nnumpy\nscipy\nmatplotlib\n```\n\n# How to use\nAfter installation, first import the main function from the library\n```\nfrom zernikepy import zernike_polynomials\n```\n\n## Examples\nGenerate a (256, 256)-sized Zernike polynomial of order 4 (defocusing):\n```python\np = zernike_polymonials(mode=4, size=256)\n```\nor\n```python\np = zernike_polymonials(mode='defocusing', size=256)\n```\nGenerate the first 55 modes and display them:\n```python\nps = zernike_polymonials(mode=55, select='all', show=True)\n```\nGenerate the following selected modes defocusing, vertical coma, oblique astigmatism and\ndisplay them:\n```python\nps = zernike_polynomials(mode=10, select=[4, 'vertical coma', 'oblique astigmatism'], show=True)\n```\nNote that regardless of the order of the elements in the list `select`, the output stores the polynomials in ascending \norder in the last dimension. Hence, in the output `ps[:, :, 0]` is oblique astigmatism, `ps[:, :, 1]` is defocusing and \n`ps[:, :, 2]` is vertical coma.\n\n## Detailed explanation\nThe main function `zernike_polynomials(mode, size, select, show)`\ntakes four variables:\n- `mode`: which (or up to which) order of the polynomial. It follows the [OSA standard indexing](https://en.wikipedia.org/wiki/Zernike_polynomials#OSA/ANSI_standard_indices) convention \nand should be a nonnegative integer. It is also possible to pass a string of the corresponding name for the first 15 modes. Default is `'defocus'`.\n- `size`: numerical size of the square Cartesian mesh. It should be a postive integer. Default is `128`.\n- `select`: in the case of passing more than one polynomial, i.e. some selected modes up to the given `mode`,\ngive a list of integers or strings or a mixture of both. A special case is `select='all'` where all the polynomials up to\nthe given `mode` is passed. Default is `None` in which case only a single polynomial of the given `mode` is passed.\n- `show`: boolen variable to determine whether to display the polynomials. Default is `False`.\n\nThe output is a Numpy array, either 2D for a single mode, or 3D for multiple modes.\n\n### Name of the first 15 modes\n\n| Mode / OSA index |              Name              |\n|------------------|:------------------------------:|\n| 0                |             piston             |\n| 1                |         vertical tilt          |\n| 2                |        horizontal tilt         |\n| 3                |      oblique astigmatism       |\n| 4                |            defocus             |\n| 5                |      vertical astigmatism      |\n| 6                |        vertical trefoil        |\n| 7                |         vertical coma          |\n| 8                |        horizontal coma         |\n| 9                |        oblique trefoil         |\n| 10               |       oblique quadrafoil       |\n| 11               | oblique secondary astigmatism  |\n| 12               |       primary spherical        |\n| 13               | vertical secondary astigmatism |\n| 14               |      vertical quadrafoil       |\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A minimalistic Python package to generate individual or a series of Zernike polynomials of arbitrary orders with visualization.",
    "version": "0.0.2",
    "project_urls": {
        "Homepage": "https://github.com/yanyan-liu/ZernikePy",
        "Issues": "https://github.com/yanyan-liu/ZernikePy/issues",
        "Repository": "https://github.com/yanyan-liu/ZernikePy"
    },
    "split_keywords": [
        "zernike",
        "psf",
        "optics",
        "polynomials",
        "basis"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "545c298d05bdb9ad6f5a7833da3344179904f75d9b30ead451cbbf063ed16c9d",
                "md5": "9d429441d65661b533729a4335465ed5",
                "sha256": "f1f188a9a0046d2d7c59fbd9db98ab45580bbc4503ff1a131261289bcc5d5d4f"
            },
            "downloads": -1,
            "filename": "ZernikePy-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9d429441d65661b533729a4335465ed5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 6952,
            "upload_time": "2024-02-27T13:47:46",
            "upload_time_iso_8601": "2024-02-27T13:47:46.594347Z",
            "url": "https://files.pythonhosted.org/packages/54/5c/298d05bdb9ad6f5a7833da3344179904f75d9b30ead451cbbf063ed16c9d/ZernikePy-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "50d688a2071ac83452fe0ade027b5becd8c29eae2007fc4a9a7dc3f2c2d6e3a3",
                "md5": "6d6d6adfbc764e407fa32c111726bacb",
                "sha256": "840d8a02446643f4bab17290b68738f25cd168175a9ac8a5c4d061d84a851e4a"
            },
            "downloads": -1,
            "filename": "ZernikePy-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "6d6d6adfbc764e407fa32c111726bacb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 6234,
            "upload_time": "2024-02-27T13:47:48",
            "upload_time_iso_8601": "2024-02-27T13:47:48.487003Z",
            "url": "https://files.pythonhosted.org/packages/50/d6/88a2071ac83452fe0ade027b5becd8c29eae2007fc4a9a7dc3f2c2d6e3a3/ZernikePy-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-27 13:47:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "yanyan-liu",
    "github_project": "ZernikePy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "zernikepy"
}
        
Elapsed time: 0.19416s