Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update imports, fixing #67 #78

Merged
merged 26 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions aotools/functions/zernike.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import numpy
from . import circle

# xrange just "range" in python3.
# This code means fastest implementation used in 2 and 3
try:
xrange
except NameError:
xrange = range

def phaseFromZernikes(zCoeffs, size, norm="noll"):
"""
Expand All @@ -22,7 +16,7 @@ def phaseFromZernikes(zCoeffs, size, norm="noll"):
"""
Zs = zernikeArray(len(zCoeffs), size, norm=norm)
phase = numpy.zeros((size, size))
for z in xrange(len(zCoeffs)):
for z in range(len(zCoeffs)):
phase += Zs[z] * zCoeffs[z]

return phase
Expand Down Expand Up @@ -90,7 +84,7 @@ def zernikeRadialFunc(n, m, r):

R = numpy.zeros(r.shape)
# Can cast the below to "int", n,m are always *both* either even or odd
for i in xrange(0, int((n - m) / 2) + 1):
for i in range(0, int((n - m) / 2) + 1):

R += numpy.array(r**(n - 2 * i) * (((-1)**(i)) *
numpy.math.factorial(n - i)) /
Expand Down Expand Up @@ -143,7 +137,7 @@ def zernikeArray(J, N, norm="noll"):
try:
nJ = len(J)
Zs = numpy.empty((nJ, N, N))
for i in xrange(nJ):
for i in range(nJ):
Zs[i] = zernike_noll(J[i], N)

# Else, cast to int and create up to that number
Expand All @@ -154,16 +148,16 @@ def zernikeArray(J, N, norm="noll"):

Zs = numpy.empty((maxJ, N, N))

for j in xrange(1, maxJ+1):
for j in range(1, maxJ+1):
Zs[j-1] = zernike_noll(j, N)


if norm=="p2v":
for z in xrange(len(Zs)):
for z in range(len(Zs)):
Zs[z] /= (Zs[z].max()-Zs[z].min())

elif norm=="rms":
for z in xrange(len(Zs)):
for z in range(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)))
Expand Down
11 changes: 1 addition & 10 deletions aotools/turbulence/infinitephasescreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,9 @@
An implementation of the "infinite phase screen", as deduced by Francois Assemat and Richard W. Wilson, 2006.
"""

from scipy.special import gamma, kv
from scipy import linalg
from scipy.interpolate import interp2d
import numpy
from numpy import pi

# Numba compiles python code to machine code for faster execution
try:
import numba
except:
numba = None

import numba

from . import phasescreen, turb

Expand Down
11 changes: 3 additions & 8 deletions aotools/turbulence/phasescreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
import time
import random

# Fastest range in both python2 and python3
try:
xrange
except NameError:
xrange = range

def ft_sh_phase_screen(r0, N, delta, L0, l0, FFT=None, seed=None):

Expand Down Expand Up @@ -57,7 +52,7 @@ def ft_sh_phase_screen(r0, N, delta, L0, l0, FFT=None, seed=None):
phs_lo = numpy.zeros(phs_hi.shape)

# loop over frequency grids with spacing 1/(3^p*L)
for p in xrange(1,4):
for p in range(1,4):
# setup the PSD
del_f = 1 / (3**p*D) #frequency grid spacing [1/m]
fx = numpy.arange(-1,2) * del_f
Expand All @@ -81,8 +76,8 @@ def ft_sh_phase_screen(r0, N, delta, L0, l0, FFT=None, seed=None):
* numpy.sqrt(PSD_phi)*del_f )
SH = numpy.zeros((N,N),dtype="complex")
# loop over frequencies on this grid
for i in xrange(0, 3):
for j in xrange(0, 3):
for i in range(0, 3):
for j in range(0, 3):

SH += cn[i,j] * numpy.exp(1j*2*numpy.pi*(fx[i,j]*x+fy[i,j]*y))

Expand Down
6 changes: 0 additions & 6 deletions aotools/wfs/wfslib.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@

import numpy

# Best range for python2 and 3
try:
range = xrange
except:
pass


def findActiveSubaps(subaps, mask, threshold, returnFill=False):
"""
Expand Down
Loading