Aperture photometry with an estimated background (source code)

= Aperture photometry with an estimated background
{title2=$\operatorname{Var}\widehat S=S+n(b+d)t+nMr^2+n^2\sigma_{\widehat B}^2$}

For total source electrons $S$, $n$ aperture pixels, sky-plus-dark rate $b+d$, time $t$, $M$ reads with rms $r$, and an independent mean-background estimate of <variance> $\sigma_{\widehat B}^2$ per pixel, the aperture <variance> is $S+n(b+d)t+nMr^2+n^2\sigma_{\widehat B}^2$ before additional <calibration> terms. The last factor is $n^2$ because one uncertain background mean is subtracted from all aperture pixels. Pixel correlations require <covariance> terms.