Start with the same product
The source product is tess2018206045859-s0001-0000000025155310-0120-s_tp.fits, the target used by the official MAST pixel-file tutorial. The downloaded header records data release 42 and pipeline spoc-5.0.10-20200904, with camera four and CCD one. The header supplies the processing version independently of the filename.
The subset retains every four-hundredth source row and the first example of every nonzero quality pattern. Selection uses row numbers and flags, never measured brightness. Each frame contains eleven-by-eleven pixel arrays, uncertainties, background estimates, time and position corrections. Sparse sampling makes this a measurement exercise, unsuitable for a complete transit search.
The frozen input is tess-tic25155310-sector1.json. The extractor checks its SHA-256, and provenance preserves the source FITS checksum. If a future download differs, inspect the release before replacing the input.
Reading: MAST, Read and Display A TESS Target Pixel File · TESS Science Data Products Description, Revision F (2020)
Read the columns before subtracting anything
TIME is a barycentrically corrected Julian date with subtracted, in days. It is not elapsed seconds from the start of this sample.
FLUX contains calibrated, cosmic-ray-processed and already background-subtracted pixel rates in electrons per second. FLUX_BKG preserves the background estimate removed by SPOC, and FLUX_BKG_ERR its uncertainty. FLUX_ERR supplies the pixel flux uncertainty. Subtracting FLUX_BKG from FLUX again removes the background twice.
QUALITY is a bit field, not a continuous score. This exercise accepts only quality-zero frames with finite time and required aperture values for normalization. It retains every row in the CSV. Consult Table 32 of the product description when deciding which flags suit a different science case.
Reading: TESS Science Data Products Description, Revision F (2020)
Recover the twelve-pixel aperture
The APERTURE image assigns integer flags to pixels. Test to identify the pixels used for photometry in this product. The bitwise AND checks the relevant bit even when other flags are also set. Selecting only integer values equal to two would fail.
Twelve pixels meet that condition here. The extractor sums their measured values using the original mask. It does not replace the stamp by a smooth star or apply a new contamination or aperture-loss correction. The result is the light received within that aperture.
Square the supplied errors, add them and take the square root to obtain the aperture uncertainty under independent pixels. A full variability error model would also need additional systematics and interpixel covariance.
Reading: MAST, Read and Display A TESS Target Pixel File · Photutils 3.1.1, Aperture photometry
Run the calculation and inspect its products
Download and unzip the exercise linked below, then run these commands inside its folder. The default output directory is reproduced; --out selects another directory. Python checks the input checksum and writes a CSV and summary JSON without third-party packages.
Of fifty-seven rows, forty-six satisfy the acceptance rule and eleven are flagged or incomplete. The median accepted aperture flux is 8444.270568847656 electrons per second. relative_flux divides each finite aperture flux by that median. A flagged row can still have a relative value, but its accepted field makes clear that it did not enter the normalization.
The spoc_background_e_per_s column preserves the summed background estimate separately. wrong_double_subtracted_e_per_s intentionally displays the incorrect calculation. The correct result remains flux_e_per_s. Missing inputs remain empty, preserving the distinction from a measured zero.
python3 extract-lightcurve.py
python3 extract-lightcurve.py --out /tmp/tess-photometry-checkUse the failures to test your interpretation
Choose a row with accepted equal to zero. Inspect its quality and finite values in the input. Determine whether the failure comes from a flag or missing data before choosing a treatment. Deleting every unusual point until the curve looks smooth can remove the phenomenon being sought.
Compare the correct flux with the deliberately double-subtracted column. A varying background can make the wrong operation create or exaggerate apparent variability, as well as shift the mean. The comparison uses the stored measured background estimate.
To rebuild the input, download the named FITS file through the MAST tutorial and run freeze-tess.py. Raw extraction additionally requires Astropy; the original used version 6.0.1. The generator retains original floating-point values, writes nonfinite values as JSON null and preserves source row indices. Each output can therefore be traced back to its input frame.
python3 freeze-tess.py /path/to/tess2018206045859-s0001-0000000025155310-0120-s_tp.fitsRead the next light curve in the same order
Record target, sector, processing version and units. Establish the background convention, mask definition, quality rule, missing-data treatment and propagated uncertainty. Only then interpret the normalized curve.
A transit analysis would next need the complete time series, neighboring-source and centroid checks, and a treatment of instrumental trends. The sparse output here measures aperture fluxes and preserves the information needed to inspect them.