### D Calculation of the errors

The errors are calculated in one of four ways, as discussed in the section on command P. The first method assumes true photon statistics and the error is calculated from the following definitions:

Number of pixels in object aperture $={a}_{o}$
Number of pixels in sky aperture $={a}_{s}$
Sum of data in object aperture $={D}_{o}$
Sum of data in sky aperture $={D}_{s}$
Offset in one pixel $=BIASLE$
Number of photons per data unit $=PADU$

The contribution of the sky in the object aperture can now be calculated:

Number of photons in object aperture $={P}_{o}=PADU\ast \left({D}_{o}-{a}_{o}\ast BIASLE\right)$
Number of photons in sky aperture $={P}_{s}=PADU\ast \left({D}_{s}-{a}_{s}\ast BIASLE\right)$
Number of photons in object aperture due to sky $={P}_{so}=PADU\ast \left({D}_{s}-{a}_{s}\ast BIASLE\right)\ast \left({a}_{o}/{a}_{s}\right)$

The signal due to the object is the difference of the total number of photons in the object aperture minus the number due to the sky:

Object signal $={S}_{o}={P}_{o}-{P}_{so}=PADU\ast \left({D}_{o}-{D}_{s}\ast \left({a}_{o}/{a}_{s}\right)\right)$

The error on the object signal is the quadratic sum of the errors on the individual measurements. Using $\epsilon$ to signify the error:

$\epsilon {\left({S}_{o}\right)}^{2}\sim \epsilon {\left({D}_{o}\right)}^{2}+\epsilon {\left({D}_{s}\right)}^{2}\ast {\left({a}_{o}/{a}_{s}\right)}^{2}$

Assuming the errors are solely from photon statistics then the error on the signal is:

$\epsilon {\left({S}_{o}\right)}^{2}=\epsilon {\left({P}_{o}\right)}^{2}+\epsilon {\left({P}_{s}\right)}^{2}\ast {\left({a}_{o}/{a}_{s}\right)}^{2}$

The error from photon counting is the square root of the number of photons:

$\epsilon \left({P}_{o}\right)=\sqrt{{P}_{o}}$ and $\epsilon \left({P}_{s}\right)=\sqrt{{P}_{s}}$

Therefore:

 $\underline{\epsilon {\left({S}_{o}\right)}^{2}={P}_{o}+{P}_{s}\ast \left({a}_{o}^{2}/{a}_{s}^{2}\right)=PADU\ast \left({D}_{o}+{D}_{s}\ast \left({a}_{o}^{2}/{a}_{s}^{2}\right)-BIASLE\ast {a}_{o}\left(1+{a}_{o}/{a}_{s}\right)\right)}$ (1)

The second method of calculating the errors assumes that the variance in the sky aperture corresponds to the photon noise. This allows the photon errors to be calculated without knowing BIASLE. One additional definition has to be given:

Standard deviation in sky aperture per pixel in data units $={\sigma }_{s}$

If the photon error $\sqrt{{P}_{s}}$ is equated to the standard deviation $PADU\ast {\sigma }_{s}$ then the total number of photons in the sky aperture is given by:

${P}_{s}={a}_{s}\ast PAD{U}^{2}\ast {\sigma }_{s}^{2}$

The offset in the sky aperture can now be calculated:

$BIASLE=\left({D}_{s}/{a}_{s}\right)-\left(PADU\ast {\sigma }_{s}^{2}\right)$

Substituting this into the calculation of the error gives:

$\epsilon {\left({S}_{o}\right)}^{2}=PADU\ast \left({D}_{o}-{D}_{s}\ast \left({a}_{o}/{a}_{s}\right)+PADU\ast {\sigma }_{s}^{2}\ast {a}_{o}\ast \left(1+{a}_{o}/{a}_{s}\right)\right)$

or

 $\underset{\right)}{\epsilon {\left({S}_{o}\right)}^{2}={S}_{o}+PAD{U}^{2}\ast {\sigma }_{s}^{2}\ast {a}_{o}\ast \left(1+{a}_{o}/{a}_{s}\right)}$ (2)

The third method of calculating the errors sums the data variances from the variance component of an NDF. Two additional definitions have to be given:

Sum of variance in object aperture $={V}_{o}$
Sum of variance in sky aperture $={V}_{s}$

The error is then calculated from:

 $\underline{\epsilon {\left({S}_{o}\right)}^{2}=PAD{U}^{2}\ast \left({V}_{o}+{V}_{s}\ast {\left({a}_{o}/{a}_{s}\right)}^{2}\right)}$ (3)

The magnitude error is calculated from differentiating the magnitude equation:

$m=-2.5{log}_{10}{S}_{o}$

thus:

$\underline{dm=\frac{-2.5}{ln10}\ast \frac{\epsilon \left({S}_{o}\right)}{{S}_{o}}}$

The fourth method is like method two, but the sky variations are interpreted by a gaussian error source, so PADU and BIASLE are not required. With guassian errors the source signal is effectively zero (since it has the same noise per pixel as the sky), so

 $\underset{\right)}{\epsilon \left({S}_{o}\right)=PADU\ast {\sigma }_{s}\ast \sqrt{\left(}{a}_{o}}$ (4)

and

 $\underline{{S}_{o}=PADU\ast \left({D}_{o}-{D}_{s}\ast \left({a}_{o}/{a}_{s}\right)\right)}$ (5)

so the PADUs cancel out in the $dm$ calculation.