1

I am performing aperture photometry using photutils. I've followed the tutorials in the photutils page, calaculated the background from a circular annulus around the source and subtracted it. Now I have to calculate the error on the photometry, but the aperture_photometry task doesn't give the apertures errors nor the background error unless I give it an input error. What input error should I give the task? To obtain the aperture photometry I've used the following code:

    import numpy as np
    import matplotlib.pyplot as plt
    from astropy.io import fits
    from matplotlib.colors import LogNorm
    from astropy.stats import sigma_clipped_stats
    from photutils import aperture_photometry
    from photutils import CircularAnnulus
    from photutils import CircularAperture

    image = fits.open('cut_F555_03.fits')
    hdu_list = image
    image_data = hdu_list[0].data

    import pandas as pd
    sources = pd.read_csv('daofind.tab', delimiter = '\s+', header = 0)


    loc = np.array([sources['xcentroid'], sources['ycentroid']])

    positions = np.transpose(loc)

    apertures = CircularAperture(positions, r = 8.12)
    rawflux = aperture_photometry(image_data, apertures)

    annulus_apertures = CircularAnnulus(positions, r_in = 8.12, r_out = 18.12)

    annulus_masks = annulus_apertures.to_mask(method = 'center')

    bkg_median = []
    for mask in annulus_masks:
        annulus_data = mask.multiply(image_data)
        annulus_data_1d = annulus_data[mask.data > 0]
        _, median_sigclip, _ = sigma_clipped_stats(annulus_data_1d)
        bkg_median.append(median_sigclip)
   bkg_median = np.array(bkg_median)

   rawflux['annulus_median'] = bkg_median / annulus_apertures.area

   rawflux['aper_bkg'] = bkg_median * apertures.area

   rawflux['final_phot'] = rawflux['aperture_sum'] - rawflux['aper_bkg']

Any idea on how to obtain the errors would be really appreciated. Best wishes. Sara

1 Answers1

0

Welcome to SO Sara!

This is a good question, and one I found myself asking a few years ago when I worked with photutils. There is a section on Error estimation in the docs which states that:

If and only if the error keyword is input to aperture_photometry(), the returned table will include a 'aperture_sum_err' column in addition to 'aperture_sum'. 'aperture_sum_err' provides the propagated uncertainty associated with 'aperture_sum'.

This assumes that you have previously obtained the total error and stored it in an array (which you pass through the error parameter). Give the docs a read, it will help you understand a few things.

I opened an issue at photutils a little over two years ago regarding this topic. A user suggested a script to obtain aperture photometry errors in the same way that IRAF does. Unfortunately I apparently did not follow through with testing the provided script so I guess it's now up to you.

Unfortunately Nº 2. IRAF is on its deathbed and most of the resources one could use to learn about how it performed some tasks (e.g., aperture photometry) are now gone. There is a Facebook group for (professional) astronomers that you might find helpful for this sort of questions.

Gabriel
  • 40,504
  • 73
  • 230
  • 404
  • Hi Gabriel! Thank you so much for your answer. I've already read the photutils documentation about aperture photometry, and I found the section about the errors estimation. What I don't understand is how to find the error array to put as input for aperture_photometry(), because the document doesn't specify it. Do you have any idea of how to find it? – Sara Federle Feb 23 '20 at 15:14
  • @SaraFederle May I ask if you ever found an answer to this question? – Paul Jan 03 '21 at 18:53