Skip to content

Commit

Permalink
Merge pull request #148 from ysBach/main
Browse files Browse the repository at this point in the history
Update ``bench.py``
  • Loading branch information
PJ-Watson authored Nov 26, 2024
2 parents 1557cf4 + e3a884e commit 0534ae5
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,19 @@
line = "| {0:4d}^2 image background |".format(data.shape[0])

t0 = time.time()
for _ in xrange(0, nloop):
for _ in range(0, nloop):
bkg = sep.Background(data)
t1 = time.time()
t_sep = (t1-t0) * 1.e3 / nloop
line += " {0:7.2f} ms |".format(t_sep)

if HAVE_PHOTUTILS:
t0 = time.time()
for _ in xrange(0, nloop):
for _ in range(0, nloop):
try:
bkg = photutils.Background(data, (64, 64)) # estimate background
except AttributeError:
bkg = photutils.Background2D(data, (64, 64)) # estimate background
bkg = photutils.background.Background2D(data, (64, 64)) # estimate background
t1 = time.time()
t_pu = (t1-t0) * 1.e3 / nloop
line += " {0:7.2f} ms | {1:6.2f} |".format(t_pu, t_pu/t_sep)
Expand Down Expand Up @@ -135,17 +135,17 @@
line = "| circles r={0:2d} {1:8s} |".format(int(r), label)

t0 = time.time()
for _ in xrange(0, nloop):
for _ in range(0, nloop):
flux, fluxerr, flag = sep.sum_circle(data, x, y, r, subpix=subpix)
t1 = time.time()
t_sep = (t1-t0) * 1.e6 / naper / nloop
line += " {0:7.2f} us/aper |".format(t_sep)

if HAVE_PHOTUTILS:
apertures = photutils.CircularAperture((x, y), r)
apertures = photutils.aperture.CircularAperture(np.array((x, y)).T, r)
t0 = time.time()
for _ in xrange(0, nloop):
res = photutils.aperture_photometry(
for _ in range(0, nloop):
res = photutils.aperture.aperture_photometry(
data, apertures, method=method, subpixels=subpix)
t1 = time.time()
t_pu = (t1-t0) * 1.e6 / naper / nloop
Expand All @@ -165,18 +165,18 @@
line = "| ellipses r={0:2d} {1:8s} |".format(int(r), label)

t0 = time.time()
for _ in xrange(0, nloop):
for _ in range(0, nloop):
flux, fluxerr, flag = sep.sum_ellipse(data, x, y, a, b, theta, r,
subpix=subpix)
t1 = time.time()
t_sep = (t1-t0) * 1.e6 / naper / nloop
line += " {0:7.2f} us/aper |".format(t_sep)

if HAVE_PHOTUTILS:
apertures = photutils.EllipticalAperture((x, y), a*r, b*r, theta)
apertures = photutils.aperture.EllipticalAperture(np.array((x, y)).T, a*r, b*r, theta)
t0 = time.time()
for _ in xrange(0, nloop):
res = photutils.aperture_photometry(
for _ in range(0, nloop):
res = photutils.aperture.aperture_photometry(
data, apertures, method=method, subpixels=subpix)
t1 = time.time()
t_pu = (t1-t0) * 1.e6 / naper / nloop
Expand Down

0 comments on commit 0534ae5

Please sign in to comment.