astropy/photutils — pull request #138 by astrofrog (2014-08-19 13:33:27+00:00)
Title: Allow user to use aperture classes for the photometry

As discussed, this re-instates the use of aperture classes by the user (see also discussion in https://github.com/bsipocz/photutils/pull/1)

Here's an example usage:

```python
from astropy import units as u
from astropy.coordinates import SkyCoord
from astropy.io import fits

from photutils import aperture_photometry, SkyCircularAperture

hdu = fits.open('2MASS_k.fits.gz')[0]
gc = SkyCoord(0. * u.deg, 0 * u.deg, frame='galactic')

aperture = SkyCircularAperture(gc, r=5. * u.arcsec)
table = aperture_photometry(hdu, aperture)[0]
```

Just a couple of ideas for improving the suggestion in this PR:

* API-wise, I think the ``Sky...`` classes should also take a ``frame`` argument to specify what frame the e.g. position angle would be taken in (when relevant)

* We could allow pixel coordinates to be passed to ``Sky...`` (which would make ``frame`` default to ``pixel``) and we could then rename ``SkyCircularAperture`` to ``CircularAperture`` and ``CircularAperture`` to ``PixelCircularAperture``. The user then has a single point of entry (``CircularAperture``) and we preserve the simple ``PixelCircularAperture`` class as it currently is.

So example usage:

```python
gc = SkyCoord(0. * u.deg, 0 * u.deg, frame='galactic')
aperture = CircularAperture(gc, r=5. * u.arcsec)
table = aperture_photometry(hdu, aperture)[0]

pos = ([10,20,30] * u.pixel, [50, 60, 70] * u.pixel)
aperture = CircularAperture(pos, r=5)
table = aperture_photometry(hdu, aperture)[0]
```

I only implemented the ``SkyCircularAperture`` class for now, and will implement other ones and update the docs.

cc @cdeil @bsipocz