Examples

Plotting

We have recipes for all our aperture types, so you can easily create overlays on your images.

using Photometry
using Plots

plot(CircularAperture(2, 3, 4), c=1, xlims=(0, 9), ylims=(0, 9))
plot!(CircularAnnulus(5, 5, 2.1, 3), c=2)
plot!(EllipticalAperture(0, 0, 10, 1, 32), c=3)
plot!(EllipticalAnnulus(5, 5, 4, 10, 1, 32), c=4)

Simple Stars

Here is an example where we will find aperture fluxes for stars from M67. The dataset is provided as part of the astropy/photutils-datasets repository.

Let's start by downloading and showing our image

using Photometry
using Plots
using FITSIO

hdu = FITS(download("https://github.com/astropy/photutils-datasets/raw/master/data/M6707HH.fits"))
image = read(hdu[1])'
chunk = @view image[71:150, 81:155]

heatmap(chunk, aspect_ratio=1, c=:inferno,
    xlims=(1, size(chunk, 2)), ylims=(1, size(chunk, 1)))

Now let's add some apertures!

positions = [
    [47.5, 67.5],
    [29.5, 62.5],
    [23.5, 48.5],
    [17.5, 29.5],
    [13.5, 10.5],
    [65.5, 14.0]
]

radii = [3, 3, 2.7, 2, 2.7, 3]

aps = CircularAperture.(positions, radii)
6-element Array{CircularAperture{Float64},1}:
 CircularAperture(47.5, 67.5, r=3.0)
 CircularAperture(29.5, 62.5, r=3.0)
 CircularAperture(23.5, 48.5, r=2.7)
 CircularAperture(17.5, 29.5, r=2.0)
 CircularAperture(13.5, 10.5, r=2.7)
 CircularAperture(65.5, 14.0, r=3.0)

now let's plot them up

heatmap(chunk, aspect_ratio=1, c=:inferno,
    xlims=(1, size(chunk, 2)), ylims=(1, size(chunk, 1)))
plot!.(aps, c=:white)

and finally let's get our output table for the photometry

table = aperture_photometry(aps, chunk)

6 rows × 4 columns

xcenterycenteraperture_sumaperture_sum_err
Float64Float64Float64Float64
147.567.52.48267e50.0
229.562.52.25989e50.0
323.548.51.49979e50.0
417.529.572189.40.0
513.510.5148774.00.0
665.514.02.02803e50.0