-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e99057b
commit 5bfce99
Showing
3 changed files
with
52 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,34 @@ | ||
from aotools import functions | ||
from aotools.functions import ell_zernike | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
if __name__ == '__main__': | ||
a = 1 | ||
b = 0.8 | ||
|
||
rmax = 7 | ||
npix = 256 | ||
l = 35 | ||
def test_ZernikeEllipticalaperture(): | ||
# Define parameters for the ZernikeEllipticalaperture instance | ||
nterms = 6 # Number of Zernike terms | ||
npix = 256 # Number of pixels in each dimension | ||
a = 1.0 # Semi-major axis of the elliptical aperture | ||
b = 0.5 # Semi-minor axis of the elliptical aperture | ||
|
||
ell_zern = functions.ZernikeEllipticalaperture(rmax, npix, a, b, l) | ||
zernike_instance = ell_zernike.ZernikeEllipticalaperture(nterms, npix, a, b) | ||
|
||
Ell = ell_zern.CalculateEllipticalZernike() | ||
plt.imshow(Ell[2]) | ||
plt.show() | ||
assert zernike_instance.ell_aperture_mask.shape == (npix, npix), "Aperture mask shape is incorrect" | ||
|
||
phi = ell_zern.EllZernikeMap() | ||
plt.imshow(phi) | ||
plt.show() | ||
assert np.all(np.isin(zernike_instance.ell_aperture_mask, [0, 1])), "Aperture mask should contain only 0s and 1s" | ||
|
||
assert zernike_instance.E.shape == (nterms, npix, npix), "Zernike modes shape is incorrect" | ||
|
||
assert np.any(zernike_instance.E[0][zernike_instance.GenerateEllipticalAperture() == 1]) != 0, "First Zernike mode should have non-zero values in the aperture" | ||
|
||
expected_number_of_modes = nterms | ||
assert zernike_instance.E.shape[0] == expected_number_of_modes, f"Expected {expected_number_of_modes} Zernike modes, got {zernike_instance.E.shape[0]}" | ||
|
||
phi = zernike_instance.EllZernikeMap() | ||
assert phi.shape == (npix, npix), "Output shape is incorrect when no coefficients are provided." | ||
|
||
coeff = np.random.random(nterms) | ||
phi_with_coeff = zernike_instance.EllZernikeMap(coeff) | ||
assert phi_with_coeff.shape == (npix, npix), "Output shape is incorrect with provided coefficients." | ||
|
||
|
||
test_ZernikeEllipticalaperture() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters