Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
finesse
pykat
Commits
fc4b9be4
Commit
fc4b9be4
authored
Dec 01, 2014
by
Daniel Brown
Browse files
forgot zernike file...
parent
e3599504
Changes
1
Hide whitespace changes
Inline
Side-by-side
pykat/utilities/zernike.py
0 → 100644
View file @
fc4b9be4
import
numpy
as
np
from
scipy.misc
import
factorial
as
fac
def
zernike_R
(
m
,
n
,
rho
):
if
((
n
-
m
)
%
2
):
return
rho
*
0.0
nnm
=
(
n
-
m
)
/
2.0
npm
=
(
n
+
m
)
/
2.0
R
=
0
return
sum
(
rho
**
(
n
-
2.0
*
k
)
*
(
-
1.0
)
**
k
*
fac
(
n
-
k
)
/
(
fac
(
k
)
*
fac
(
npm
-
k
)
*
fac
(
nnm
-
k
))
for
k
in
xrange
(
int
(
nnm
)
+
1
))
def
zernike
(
m
,
n
,
rho
,
phi
):
"""
Computes the zernike polynomial in radial coordinates:
Z_{n}^{m}(rho, phi) = R_{n}^{m}(rho) cos(m * phi) (even)
R_{n}^{m}(rho) sin(m * phi) (odd)
Must satisfy n >= m.
"""
if
(
n
<
0
):
raise
ValueError
(
"n must be larger than 0"
)
if
(
abs
(
m
)
>
n
):
raise
ValueError
(
"Must use m <= n"
)
if
m
>
0
:
return
zernike_R
(
m
,
n
,
rho
)
*
np
.
cos
(
m
*
phi
)
elif
m
<
0
:
return
zernike_R
(
-
m
,
n
,
rho
)
*
np
.
sin
(
-
m
*
phi
)
else
:
return
zernike_R
(
0
,
n
,
rho
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment