1- ''' Features that aberrate and modify pupil functions
1+ ''' Features that aberrate and modify pupil functions.
22
33Classes
44-------
@@ -54,7 +54,6 @@ def _process_and_get(self, image_list, **kwargs):
5454 for image in image_list :
5555 x = np .arange (image .shape [0 ]) - image .shape [0 ] / 2
5656 y = np .arange (image .shape [1 ]) - image .shape [1 ] / 2
57-
5857 X , Y = np .meshgrid (x , y )
5958 rho = np .sqrt (X ** 2 + Y ** 2 )
6059 rho /= np .max (rho [image != 0 ])
@@ -69,7 +68,6 @@ def _process_and_get(self, image_list, **kwargs):
6968# AMPLITUDE ABERRATIONS
7069
7170
72-
7371class GaussianApodization (Aberration ):
7472 ''' Introduces pupil apodization.
7573
@@ -81,15 +79,28 @@ class GaussianApodization(Aberration):
8179 sigma : float
8280 The standard deviation of the apodization. The edge of the pupil
8381 is at one deviation from the center.
82+ offset : (float, float)
83+ Offsets the center of the gaussian.
8484
8585 '''
8686
87- def __init__ (self , sigma , ** kwargs ):
88- super ().__init__ (sigma = sigma , ** kwargs )
87+ def __init__ (self , sigma = 1 , offset = (0 , 0 ), ** kwargs ):
88+ super ().__init__ (sigma = sigma , offset = offset , ** kwargs )
89+
90+
91+ def get (self , pupil , offset , sigma , rho , ** kwargs ):
92+ if offset != (0 , 0 ):
93+ x = np .arange (pupil .shape [0 ]) - pupil .shape [0 ] / 2 - offset [0 ]
94+ y = np .arange (pupil .shape [1 ]) - pupil .shape [1 ] / 2 - offset [1 ]
95+ X , Y = np .meshgrid (x , y )
96+ rho = np .sqrt (X ** 2 + Y ** 2 )
97+ rho /= np .max (rho [pupil != 0 ])
98+ rho [rho > 1 ] = np .inf
8999
90100
91- def get (self , pupil , sigma , rho , ** kwargs ):
92- return pupil * np .exp (- (rho / sigma )** 2 )
101+ pupil = pupil * np .exp (- (rho / sigma )** 2 )
102+ return pupil
103+
93104
94105
95106
@@ -100,7 +111,7 @@ def get(self, pupil, sigma, rho, **kwargs):
100111class Zernike (Aberration ):
101112 ''' Introduces a Zernike phase aberration.
102113
103- Calculates the Zernike polynomial deined by the numbers `n` and `m` at
114+ Calculates the Zernike polynomial defined by the numbers `n` and `m` at
104115 each pixel in the pupil, multiplies it by `coefficient`, and adds the
105116 result to the phase of the pupil.
106117
0 commit comments