Skip to content

Commit

Permalink
Update bench.py photutils compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
PJ-Watson committed Feb 3, 2025
1 parent cc50e17 commit 261546c
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,9 @@
if HAVE_PHOTUTILS:
t0 = time.time()
for _ in range(0, nloop):
try:
bkg = photutils.background.Background(
data, (64, 64)
) # estimate background
except AttributeError:
bkg = photutils.background.Background2D(
data, (64, 64)
) # estimate background
from photutils import background

bkg = background.Background2D(data, (64, 64)) # estimate background
t1 = time.time()
t_pu = (t1 - t0) * 1.0e3 / nloop
line += " {0:7.2f} ms | {1:6.2f} |".format(t_pu, t_pu / t_sep)
Expand Down Expand Up @@ -163,6 +158,8 @@
line += " {0:7.2f} us/aper |".format(t_sep)

if HAVE_PHOTUTILS:
from photutils import aperture

apertures = photutils.aperture.CircularAperture(np.column_stack((x, y)), r)
t0 = time.time()
for _ in range(0, nloop):
Expand Down Expand Up @@ -196,6 +193,8 @@
line += " {0:7.2f} us/aper |".format(t_sep)

if HAVE_PHOTUTILS:
from photutils import aperture

apertures = photutils.aperture.EllipticalAperture(
np.column_stack((x, y)), a * r, b * r, theta
)
Expand Down

0 comments on commit 261546c

Please # to comment.