When a raw image is read into BANZAI, an uncertainty value is assigned to each pixel. By default, this is simply the read noise divided by the gain: RDN / g . Initially, the uncertainty is the same value for every pixel.
When adding or subtracting two pixels (e.g. in bias subtraction), the uncertainty of each is added in quadrature and stored. When multiplying or dividing pixels (e.g. in flat field division) the relative uncertainties are added in quadrature and stored.
Each stage of reduction contributes some amount to a final uncertainty array, which is written as a separate HDU (Header Data Unit) in the final BANZAI data product.
When stacking reduced calibrations (bias, dark, flat), BANZAI uses the uncertainties of the reduced calibration frames that go into each stack to contribute to a final uncertainty array for the master calibration.
BANZAI uses a sigma-clipped mean to stack calibration frames. For each pixel in the master calibration image, the uncertainties of every contributing pixel are added in quadrature and then divided by the number of pixels being stacked. This is the uncertainty array used when reducing science frames with these master calibrations.
When reducing science frames with master calibrations, the master calibrations’ uncertainty array contributes to the science frame’s final uncertainty array. For example, when dividing a science image by a master flat, BANZAI updates the science frames’ uncertainty array by adding the science frame’s and master flat’s relative pixel uncertainties in quadrature. As an image makes its way through the pipeline, the uncertainty is updated and stored every time pixel-level operations occur.
In the reduced data products, the uncertainty array is stored in a FITS HDU named ‘ERR’. This is a standard image HDU, much like the BPM and SCI HDUs. When working with astropy, this HDU has a data attribute where the pixel uncertainties can be accessed.