[AstroPy] Aperture photometry

Erik Tollerud erik.tollerud at gmail.com
Thu Apr 14 21:37:42 EDT 2011

Hello all,

In case one of these options doesn't suit your needs, I'm attaching a
rather basic script I used for some simple aperture photometry in
uncrowded fields.  If uses some basic robust statistics to identify
sources, so you don't give it specific coordinates.  it "just works"
for me, although you may have to tweak some parameters, as I only
tuned it to work for one particular telescope/CCD combination.  It's
pretty fast, though, if simple (and hence, we'll say "no warranty" :).

The command-line usage is also somewhat particular to my setup, so you
may have to modify it for whatever your filename scheme/filters are.

Note that this is the basis for a module I intended to polish and
eventually add to astropysics.phot
(http://packages.python.org/Astropysics/coremods/phot.html), although
the timescale for that is rather nebulous right now.

On Thu, Apr 14, 2011 at 2:50 PM, Sergio Pascual <sergiopr at fis.ucm.es> wrote:
> 2011/4/14 Rene Breton <superluminique at gmail.com>:
>> The plan is to deliver comparable functionality as the IDL astrolib routine.
>> This means been able to perform the aperture photometry from an image array,
>> given a list of coordinates, apertures, etc. The actual function arguments
>> might be different to make it more modern and the algorithms might be
>> improved, if possible.
>> The aper.pro (http://idlastro.gsfc.nasa.gov/ftp/pro/idlphot/aper.pro)
>> routine deals specifically with circular aperture photometry (polygonal
>> could eventually be added if someone wants to extend the circular aperture
>> one). According to the documentation there are two methods to deal with
>> subpixels, a polygonal approximation and an exact calculation. Here is the
>> quote:
>> ; /EXACT -  By default, APER counts subpixels, but uses a polygon
>> ; approximation for the intersection of a circular aperture with
>> ; a square pixel (and normalizes the total area of the sum of the
>> ; pixels to exactly match the circular area).   If the /EXACT
>> ; keyword, then the intersection of the circular aperture with a
>> ; square pixel is computed exactly.    The /EXACT keyword is much
>> ; slower and is only needed when small (~2 pixels) apertures are
>> ; used with very undersampled data.
>> So my idea is also to provide different algorithms. The first is the crude
>> aperture, with no subpixel. The second will be the polygonal approximation,
>> which is fine in most situations, and last will be the exact. I'm still at
>> the stage of taking apart the code and reorganizing it so I can't tell much
>> more about the algorithm.
> I have implemented a exact elliptical aperture (with axis not rotated)
> and yes, it's very slow. I use a modified mid-point algorithm to trace
> the quadrants of the ellipse (and compute the subpixel contribution),
> but I think I should try a polygonal approximation and compare
> performances.
> Regards, Sergio
>> Rene
>> On 11-04-14 05:23 PM, Sergio Pascual wrote:
>>> It would be great to have routines directly comparable with those from
>>> Iraf or IDL. What kind of apertures does Astrolib support? How it
>>> handles subpixel fractions?
>>> I think there's a lack of information about the algorithms used to
>>> effectively compute the subpixel fraction in the apertures.
>>> Regards, Sergio
>>> 2011/4/14 Rene Breton<superluminique at gmail.com>:
>>>> Hi Sergio,
>>>> I'm currently working on porting the IDL astrolib aperture photometry
>>>> routines to python (which you can find in pyastrolib). I'm not done with
>>>> them yet. Hopefully it should be done soon as I have some data reduction
>>>> to
>>>> perform. I can let you know if you're interested.
>>>> If you want something more basic for now, have a look at the attached
>>>> python
>>>> script. It does the aperture photometry but doesn't handle subpixel
>>>> contributions. If the radius of your aperture isn't too small it
>>>> shouldn't
>>>> be too far off a more careful reduction. I haven't made the script to
>>>> handle
>>>> multiple source positions/apertures but this could easily be fixed.
>>>> Cheers,
>>>> Rene
>>>> On 11-04-14 01:18 PM, Sergio Pascual wrote:
>>>>> Hi
>>>>> Let's say I have an image as a  numpy array and I want to obtain the
>>>>> summed values of the array inside an ellipse inside the image. In
>>>>> other words, I wanto to make aperture photometry. Do you know of any
>>>>> python astronomy package that implements this. It's a fairly basic
>>>>> think, but I haven't found anything.
>>>>> Regards
> --
> Sergio Pascual                        http://guaix.fis.ucm.es/~spr
> gpg fingerprint: 5203 B42D 86A0 5649 410A F4AC A35F D465 F263 BCCC
> Departamento de Astrofísica -- Universidad Complutense de Madrid (Spain)
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy

Erik Tollerud
-------------- next part --------------
A non-text attachment was scrubbed...
Name: aperphot.py
Type: application/octet-stream
Size: 16191 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/astropy/attachments/20110414/95ecf185/attachment.obj>

More information about the AstroPy mailing list