Skip to content

Commit 261546c

Browse files
committed
Update bench.py photutils compatibility.
1 parent cc50e17 commit 261546c

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

bench.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,9 @@
110110
if HAVE_PHOTUTILS:
111111
t0 = time.time()
112112
for _ in range(0, nloop):
113-
try:
114-
bkg = photutils.background.Background(
115-
data, (64, 64)
116-
) # estimate background
117-
except AttributeError:
118-
bkg = photutils.background.Background2D(
119-
data, (64, 64)
120-
) # estimate background
113+
from photutils import background
114+
115+
bkg = background.Background2D(data, (64, 64)) # estimate background
121116
t1 = time.time()
122117
t_pu = (t1 - t0) * 1.0e3 / nloop
123118
line += " {0:7.2f} ms | {1:6.2f} |".format(t_pu, t_pu / t_sep)
@@ -163,6 +158,8 @@
163158
line += " {0:7.2f} us/aper |".format(t_sep)
164159

165160
if HAVE_PHOTUTILS:
161+
from photutils import aperture
162+
166163
apertures = photutils.aperture.CircularAperture(np.column_stack((x, y)), r)
167164
t0 = time.time()
168165
for _ in range(0, nloop):
@@ -196,6 +193,8 @@
196193
line += " {0:7.2f} us/aper |".format(t_sep)
197194

198195
if HAVE_PHOTUTILS:
196+
from photutils import aperture
197+
199198
apertures = photutils.aperture.EllipticalAperture(
200199
np.column_stack((x, y)), a * r, b * r, theta
201200
)

0 commit comments

Comments
 (0)