The algorithm for calculating the optimum extraction radius is equivalent for the circular and elliptical regions.
SNRMAX=0
TOTAL_SRC_COUNTS = counts in the input image within the source region
corrected for the encircled energy fraction of the
source region
Loop TEST_RADIUS = 1 to 300 arcseconds
EEF = calculate encircled energy fraction for this TEST_RADIUS
using the PSF relevant for this Epic camera at the
position of the source box for a photon energy of 1.5 keV
SRC_COUNTS = TOTAL_SRC_COUNTS * EEF
BGD_COUNTS = background counts per arcsec^2 * PI * TEST_RADIUS**2
S/N ratio = SRC_COUNTS / sqrt(SRC_COUNTS + BGD_COUNTS)
if (S/N ratio > SNRMAX) {
SNRMAX = S/N ratio
}
EndLoop