01 — Science/Live
From raw light to a real magnitude.
This is a Python pipeline that measures how bright a supernova is from telescope images. It calibrates the camera against known reference stars, then reports the supernova's brightness in standard astronomical magnitudes, with uncertainties. I hand-coded it line by line with Astropy and NumPy.
Step 01 · Input
Two filters, one truth.
The pipeline loads two stacked FITS frames, one green and one red, and registers them to a shared world-coordinate system so every pixel maps to the same patch of sky.
Step 02 · Photometry
Measure the light.
It runs aperture photometry on each calibration star, summing the flux inside a fixed-radius aperture and then subtracting the sky measured in a surrounding annulus.
Step 03 · Calibration
Instrumental to standard.
It then fits least-squares color transforms (Tgr, Cgr and Tg, Cg) that map the instrumental magnitudes onto published standards, correcting for the camera's own color response.
Step 04 · Result
The supernova, measured.
Applying the transforms yields the supernova's standard g and r magnitudes, with propagated uncertainties from the fit residuals.
How it works
Four stages, from photons to a calibrated number.
Register two filters
The pipeline opens two stacked FITS images, a green (g) and a red (r) exposure, and reads each header's World Coordinate System. Every reference star's sky coordinates (RA/Dec) are converted to pixel positions with all_world2pix, so both frames and the star catalog line up on the same grid.
Aperture photometry + sky subtraction
For each calibration star it sums the counts inside a fixed-radius aperture, then estimates the background from a surrounding annulus and subtracts the average sky per pixel. That yields a clean instrumental flux, which becomes an instrumental magnitude via −2.5·log₁₀(flux).
Least-squares color transform
Cameras don't see color the way the standard system does. The code fits two linear transforms by ordinary least squares (solving the normal equations directly with NumPy): one mapping instrumental g−r to standard g−r (slope Tgr, intercept Cgr), and one for the g zero-point (Tg, Cg).
Solve the supernova + propagate error
It runs the same aperture measurement on the supernova, applies the fitted transforms to recover its standard g and r magnitudes, and propagates uncertainty from the fit residuals (root-mean-square of the scatter about each line) into a final error on g, r, and g−r.
The result is a magnitude you could publish: not just "this pixel is bright," but a color-calibrated brightness on the standard scale, with an honest error bar derived from the calibration fit itself.