Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Zs = numpy.empty((maxJ, N, N))
for j in xrange(1, maxJ+1):
Zs[j-1] = zernike_noll(j, N)
if norm=="p2v":
for z in xrange(len(Zs)):
Zs[z] /= (Zs[z].max()-Zs[z].min())
elif norm=="rms":
for z in xrange(len(Zs)):
# Norm by RMS. Remember only to include circle elements in mean
Zs[z] /= numpy.sqrt(
numpy.sum(Zs[z]**2)/numpy.sum(circle(N/2., N)))
return Zs
R = numpy.sqrt(X**2 + Y**2)
theta = numpy.arctan2(Y, X)
if m==0:
Z = numpy.sqrt(n+1)*zernikeRadialFunc(n, 0, R)
else:
if m > 0: # j is even
Z = numpy.sqrt(2*(n+1)) * zernikeRadialFunc(n, m, R) * numpy.cos(m*theta)
else: #i is odd
m = abs(m)
Z = numpy.sqrt(2*(n+1)) * zernikeRadialFunc(n, m, R) * numpy.sin(m * theta)
# clip
Z = Z*numpy.less_equal(R, 1.0)
return Z*circle(N/2., N)