Zernike
Python code to handle complex- and real-valued Zernike polynomials. This module was part of enzpy but will be further developed here instead.
Installation
You can install zernike using pip
pip install --user zernike
Example: plot the Zernike pyramid
python -m zernike.pyramid
Example: plot the first 9 Zernike polynomials
import numpy as np
import matplotlib.pyplot as plt
from zernike import RZern
cart = RZern(6)
L, K = 200, 250
ddx = np.linspace(-1.0, 1.0, K)
ddy = np.linspace(-1.0, 1.0, L)
xv, yv = np.meshgrid(ddx, ddy)
cart.make_cart_grid(xv, yv)
c = np.zeros(cart.nk)
plt.figure(1)
for i in range(1, 10):
plt.subplot(3, 3, i)
c *= 0.0
c[i] = 1.0
Phi = cart.eval_grid(c, matrix=True)
plt.imshow(Phi, origin='lower', extent=(-1, 1, -1, 1))
plt.axis('off')
plt.show()
Example: fit Zernike polynomials in Cartesian coordinates
import numpy as np
import matplotlib.pyplot as plt
from zernike import RZern
cart = RZern(6)
L, K = 200, 250
ddx = np.linspace(-1.0, 1.0, K)
ddy = np.linspace(-1.0, 1.0, L)
xv, yv = np.meshgrid(ddx, ddy)
cart.make_cart_grid(xv, yv)
c0 = np.random.normal(size=cart.nk)
Phi = cart.eval_grid(c0, matrix=True)
c1 = cart.fit_cart_grid(Phi)[0]
plt.figure(1)
plt.subplot(1, 2, 1)
plt.imshow(Phi, origin='lower', extent=(-1, 1, -1, 1))
plt.axis('off')
plt.subplot(1, 2, 2)
plt.plot(range(1, cart.nk + 1), c0, marker='.')
plt.plot(range(1, cart.nk + 1), c1, marker='.')
plt.show()
Example: fit Zernike polynomials in polar coordinates
import numpy as np
from zernike import RZern, FitZern
pol = RZern(6)
L, K = 200, 250
ip = FitZern(pol, L, K)
pol.make_pol_grid(ip.rho_j, ip.theta_i)
c_true = np.random.normal(size=pol.nk)
Phi = pol.eval_grid(c_true)
c_hat = ip.fit(Phi)
R = np.zeros((pol.nk, 3))
R[:, 0] = c_true
R[:, 1] = c_hat
R[:, 2] = np.abs(c_true - c_hat)
print(R)
np.linalg.norm(c_true - c_hat)/np.linalg.norm(c_true)
Installation from the GitHub repository
- You should first install the following requirements:
- Anaconda for Python 3. This includes Python as well as some necessary scientific libraries.
- Git. This is necessary for the automatic version numbering of this package. Also, make sure you choose Git from the command line and also 3rd-party software in Adjusting your PATH environment.
- Clone this repository using Git. From any folder in File Explorer,
right-click and hit Git Bash here. Paste
git clone https://github.com/jacopoantonello/zernikeand hit enter. Do not use GitHub's Download ZIP button above, as the installation script will not work in that case. - Finally, double-click on
install.bat.
Tests
python -m zernike.test
Metadata
Release files for zernike 0.0.33
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| zernike-0.0.33.tar.gz | 21.9 kB | Without provenance | Details for zernike-0.0.33.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| zernike-0.0.33-py3-none-any.whl | Python 3 | none | any | Details for zernike-0.0.33-py3-none-any.whl |
Total release size: 43.5 kB
Release files / zernike-0.0.33.tar.gz
| Download URL | zernike-0.0.33.tar.gz |
|---|---|
| Size | 21.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1cb57e77e503952932e157ab91253a8154d66d0f539d19fa0ad7860cfee92043
|
|
BLAKE2b-256 checksum How to use checksums |
99f6823901c7ee83d6a7575552b6665367fccd7b7b7834336f6f0eb864633a17
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Release files / zernike-0.0.33-py3-none-any.whl
| Download URL | zernike-0.0.33-py3-none-any.whl |
|---|---|
| Size | 21.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bc94aa305c56894193ad7d2d1f527368e70748c4eb002c13b86fae9b2f2b04ef
|
|
BLAKE2b-256 checksum How to use checksums |
636072eb20d553404675d5cb4a91dbd173c727ba5631da650393957acd6cc622
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Security for zernike 0.0.33
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.