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
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:This assumes that you have previously obtained the total error and stored it in an array (which you pass through the
errorparameter). Give the docs a read, it will help you understand a few things.I opened an issue at
photutilsa 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.