Skip to main content
Sandbox Physics
Measure starlight in a crowded sky

AC02 · L3

Extract TESS brightness from twelve pixels

With the Sandbox Physics source and Python 3, you can repeat aperture photometry on a fixed set of measured TESS pixels. The fifty-seven-frame sample is from TIC 25155310 in Sector 1. The output keeps every frame and explicitly marks those used for normalization.

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 24570002457000 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 mask  &  2≠0\mathrm{mask}\;\&\;2\ne0 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.

Fj=∑i∈AFLUXji,σj=∑i∈AFLUX_ERRji 2F_j=\sum_{i\in\mathcal A}\mathrm{FLUX}_{ji},\qquad\sigma_j=\sqrt{\sum_{i\in\mathcal A}\mathrm{FLUX\_ERR}_{ji}^{\,2}}
The indices identify frame and aperture pixel. Both flux and uncertainty are rates in electrons per second.

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-check
F  [e− s−1]F\;[\mathrm e^{-}\,\mathrm s^{-1}]Measured TESS pixel sums
60007000800090001325.31353.1
Cyan: correct aperture sum · Amber: background subtracted twice · Gray: flagged framet  [BJDTDB−2457000  day]t\;[\mathrm{BJD}_{\mathrm{TDB}}-2457000\;\mathrm{day}]
Sparse measured samples from the frozen TIC 25155310 Sector 1 product. Points are not joined across missing or skipped cadences; no transit model is fitted.

Use 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.fits

Read 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.

Try the prediction

Compare a controlled background mistake

  1. Choose Subtract too much sky and observe the direction of the aperture error.
  2. Check whether the difference between the correct and double-subtracted CSV columns equals the saved background.
  3. Distinguish simulated counts per exposure from TESS rates per second.

Sources and calculation scope

  1. MAST, Read and Display A TESS Target Pixel File

    Target TIC 25155310, Sector 1, FITS columns and aperture bit 2. The frozen tutorial subset is extracted from this named product.

  2. TESS Science Data Products Description, Revision F (2020)

    Section 4.2.2, Table 8: FLUX is already background-subtracted; FLUX_BKG and FLUX_BKG_ERR preserve the removed estimate. Table 32 describes quality flags.

  3. Photutils 3.1.1, Aperture photometry

    Fractional aperture weighting, background subtraction and error propagation. The browser uses its own documented midpoint area quadrature.

FeedbackSomething broken, confusing, or missing on this page?Tell us
What kind of feedback?

Sent with this page’s address, its Lab ID, the site language and your device type. Please leave out personal details. Feedback is kept for up to 12 months.Privacy policy