-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathUtility36.py
54 lines (49 loc) · 1.44 KB
/
Utility36.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# -*- coding: utf-8 -*-
"""
@copyright, Peter Kner, University of Georgia, 2019
"""
import numpy as np
import Zernike36 as Z
def discArray(shape=(128,128),radius=64,origin=None,dtype=np.float64):
nx = shape[0]
ny = shape[1]
ox = nx/2
oy = ny/2
x = np.linspace(-ox,ox-1,nx)
y = np.linspace(-oy,oy-1,ny)
X,Y = np.meshgrid(x,y)
rho = np.sqrt(X**2 + Y**2)
disc = (rho<radius).astype(dtype)
if not origin==None:
s0 = origin[0]-int(nx/2)
s1 = origin[1]-int(ny/2)
disc = np.roll(np.roll(disc,s0,0),s1,1)
return disc
def radialArray(shape=(128,128), func=None, origin=None, dtype=np.float64):
nx = shape[0]
ny = shape[1]
ox = nx/2
oy = ny/2
x = np.linspace(-ox,nx-ox,nx)
y = np.linspace(-oy,ny-oy,ny)
X,Y = np.meshgrid(x,y)
rho = np.sqrt(X**2 + Y**2)
rarr = func(rho)
if not origin==None:
s0 = origin[0]-nx/2
s1 = origin[1]-ny/2
rarr = np.roll(np.roll(rarr,s0,0),s1,1)
return rarr
def shift(arr,shifts=None):
if shifts == None:
shifts = np.array(arr.shape)/2
if len(arr.shape)==len(shifts):
for m,p in enumerate(shifts):
arr = np.roll(arr,p,m)
return arr
def buildphiZ(phi,shape,radius):
nx = shape[0]
pupil = np.zeros(shape)
for m,amp in enumerate(phi):
pupil = pupil + amp*Z.Zm(m,radius,None,nx)
return pupil