---
title: "Extract TESS brightness from twelve pixels"
description: "Re-run aperture photometry on frozen measured TIC 25155310 Sector 1 pixels, keeping quality flags, background and failure examples."
canonical_url: "https://sandboxphysics.com/stories/stellar-photometry/tess-pixels/"
language: "en"
page_type: "story"
alternate_languages:
  zh-CN: "https://sandboxphysics.com/zh/stories/stellar-photometry/tess-pixels/"
last_modified: "2026-10-28"
---

[Measure starlight in a crowded sky](https://sandboxphysics.com/stories/stellar-photometry/)

AC02 · L3

# Extract TESS brightness from twelve pixels

Sandbox Physics · 2026-10-28

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.

## Before you begin

Read the two measurement chapters and know how to run a Python script. Offline extraction uses only the standard library. Rebuilding the subset from FITS additionally requires Astropy.

## 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 $2457000$ 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 $\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.

$$
F_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\;[\mathrm e^{-}\,\mathrm s^{-1}]$ Measured TESS pixel sums

Cyan: correct aperture sum · Amber: background subtracted twice · Gray: flagged frame $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](https://sandboxphysics.com/labs/crowded-star-photometry/)

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.

[Previous: One pixel can contain light from two stars](https://sandboxphysics.com/stories/stellar-photometry/separating-stars/) [Next: Read the residuals in deblending and difference images](https://sandboxphysics.com/stories/stellar-photometry/reading-crowded-images/)

[Download the complete reproducible exercise](https://sandboxphysics.com/tutorials/stellar-photometry/materials.zip) · [Run instructions](https://sandboxphysics.com/tutorials/stellar-photometry/README.md)

[Measured input and provenance](https://sandboxphysics.com/tutorials/stellar-photometry/tess-tic25155310-sector1.json) · [Python extractor](https://sandboxphysics.com/tutorials/stellar-photometry/extract-lightcurve.py) · [File checksums](https://sandboxphysics.com/tutorials/stellar-photometry/manifest.json)

## Sources and calculation scope

1. [MAST, Read and Display A TESS Target Pixel File](https://spacetelescope.github.io/mast_notebooks/notebooks/TESS/beginner_how_to_use_tp/beginner_how_to_use_tp.html)

   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)](https://archive.stsci.edu/files/live/sites/mast/files/home/missions-and-data/active-missions/tess/_documents/EXP-TESS-ARC-ICD-TM-0014-Rev-F.pdf)

   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](https://photutils.readthedocs.io/en/3.1.1/user_guide/aperture.html)

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