# MIT Quick-Look Pipeline (QLP): TESS full-frame-image light curves

## Facts

- Provider: MIT / Space Telescope Science Institute (MAST)
- License: CC-BY-4.0
- Records: One FITS file per (sector, TIC). Rows per file are cadences: about 1.2-1.3k in sectors 1-26 (30 min), 3.3-3.7k in sectors 27-55 (10 min), 8.6-11.8k in sectors 56-96
- Stored at: Amazon S3, s3://stpubdata/mast/hlsp/qlp (us-east-1)
- Access: public, readable without an account
- Category: Astronomy & Space
- Source: https://registry.opendata.aws/mast-qlp/
- Page: https://scigantic.com/archive/9a95cca0-9d2a-55f3-a502-d83acfba72ac
- Keywords: Astronomy & Space, AWS Open Data

## About

Light curves for stars brighter than TESS magnitude 13.5, derived from TESS Full Frame Images by the MIT Quick-Look Pipeline and hosted by MAST as a high-level science product (CC BY 4.0). Mount root is mast/hlsp/qlp/: one directory per sector (s0001 to s0098), each holding one FITS light curve per star at / / / / /hlsp_qlp_tess_ffi_s - _tess_v01_llc.fits, plus target_lists/ (TIC_ID,RA,DEC per sector) and download_scripts/. About 96.9 million FITS files, about 39 TB. Cadence is 30 min in sectors 1-26, 10 min in 27-55 and 200 s from sector 56. Flux column is KSPSAP_FLUX in sectors 1-55 and DET_FLUX from sector 56.

## Load the data

```python
# Task: load WASP-18 (TIC 100100827) QLP light curves from sectors 2 (30 min) and 69 (200 s) with numpy only
# (no astropy in the notebook images), keep QUALITY==0 cadences, fold on the 0.9414526 d period, print the transit depth.
import os, numpy as np
ROOT = os.path.expanduser("~/archive")
def path(sector, tic):
    t = f"{tic:016d}"; v = "v02" if 74 <= sector <= 79 else "v01"
    return f"{ROOT}/s{sector:04d}/{t[:4]}/{t[4:8]}/{t[8:12]}/{t[12:]}/hlsp_qlp_tess_ffi_s{sector:04d}-{t}_tess_{v}_llc.fits"
def read_lc(p):  # primary HDU is empty, the LIGHTCURVE bintable is the 2nd HDU; every column is big-endian
    raw = open(p, "rb").read(); off = 0; hdrs = []
    for _ in range(2):
        h = {}
        while True:
            blk = raw[off:off + 2880].decode("ascii"); off += 2880
            for i in range(0, 2880, 80):
                c = blk[i:i + 80]
                if c.startswith("END"): break
                if c[8:10] == "= ": h[c[:8].strip()] = c[10:].split("/")[0].strip().strip("'").strip()
            else: continue
            break
        hdrs.append(h)
    h = hdrs[1]; code = {"D": ">f8", "J": ">i4", "E": ">f4"}
    dt = np.dtype([(h[f"TTYPE{i}"], code[h[f"TFORM{i}"]]) for i in range(1, int(h["TFIELDS"]) + 1)])
    return hdrs[0], np.frombuffer(raw, dt, count=int(h["NAXIS2"]), offset=off)
for sec in (2, 69):
    h0, d = read_lc(path(sec, 100100827))
    col = "KSPSAP_FLUX" if "KSPSAP_FLUX" in d.dtype.names else "DET_FLUX"   # renamed from sector 56 on
    ok = (d["QUALITY"] == 0) & np.isfinite(d[col])
    ph = ((d["TIME"][ok] / 0.9414526) % 1.0); b = np.floor(ph * 50).astype(int)
    med = np.array([np.median(d[col][ok][b == k]) for k in range(50)])
    print(f"S{sec}: SECTOR={h0['SECTOR']} CAM={h0['CAMERA']} CCD={h0['CCD']} rows={len(d)} q0={ok.sum()} flux={col} depth_ppt={1e3*(1-med.min()):.1f}")
```

Written for a Scigantic notebook, where /mnt/archive (SCIGANTIC_MOUNT_PATH) is the mounted dataset.

## Data structure

| Field | Type |
| --- | --- |
| `TIME` | float64 big-endian, BTJD = BJD-2457000 days (TDB, barycentric). Sector 1 starts at 1325.33; sector 69 at about 3184… |
| `CADENCENO` | int32, FFI cadence counter from mission start (4697 in sector 1, about 1.19 million by sector 98). Not unique to a… |
| `SAP_FLUX` | float32, simple aperture photometry from the best aperture, normalised to median 1.0 (measured median 1.0 in every… |
| `KSPSAP_FLUX` | float32, SAP flux detrended with a Kepler-spline fit, median 1.0. Sectors 1-55 ONLY. Finite on flagged cadences too… |
| `KSPSAP_FLUX_ERR` | float32, 1 sigma on KSPSAP_FLUX. Sectors 1-55 only. In the sector 1 sample file it is a single constant 0.001948 for… |
| `KSPSAP_FLUX_SML / KSPSAP_FLUX_LAG` | float32, detrended flux from a smaller / larger aperture (SMALLAP, LARGEAP header keywords). Sectors 1-55. Renamed… |
| `DET_FLUX, DET_FLUX_ERR, SYS_RM_FLUX` | float32. Sectors 56-98 only (14 columns instead of 13). DET_FLUX replaces KSPSAP_FLUX (header DETMET='QSP')… |
| `QUALITY` | int32 bit field, 0 = good. Observed values: 32, 128, 2048, 4096 (sectors 1-55: bit 13, the QLP low-precision flag; the… |
| `ORBITID` | int32, TESS orbit counter (9,10 in sector 1; 119,120 in sector 56; 4 orbit ids in sectors 97-98). 0 appears on some… |
| `SAP_X, SAP_Y` | float32, pixels, flux-weighted centroid in CCD column / row coordinates (sector 1 sample 46.09, 1426.93). NaN on a few… |
| `SAP_BKG, SAP_BKG_ERR` | float32, background flux in the aperture in electron units (NOT normalised and can be negative: sector 1 sample -9357… |

Files:

```text
Mount root is mast/hlsp/qlp/. One directory per TESS sector, s0001 to s0098, plus download_scripts/ and target_lists/ and two documentation files at the root. Inside a sector the tree is NOT camera/CCD: it is the 16-digit zero-padded TIC id cut into four 4-digit directories, then one file per directory.

/ (mast/hlsp/qlp/)
  hlsp_qlp_tess_ffi_all_tess_v1_readme.txt        2.5 KB, release notes
  hlsp_qlp_tess_ffi_all_tess_v1_data-prod-desc.pdf   80 KB, column and flag tables
  s0001/ ... s0098/
    <TIC[0:4]>/<TIC[4:8]>/<TIC[8:12]>/<TIC[12:16]>/
      hlsp_qlp_tess_ffi_s<SSSS>-<TIC16>_tess_<vNN>_llc.fits
      hlsp_qlp_tess_ffi_s<SSSS>-<TIC16>_tess_<vNN>_llc.txt   (sectors 1-26 only)
  target_lists/s0001.csv ... s0098.csv     '#TIC_ID,RA,DEC', one row per light curve in that sector
  download_scripts/hlsp_qlp_tess_ffi_sSSSS_tess_vNN_llc-fits.sh   (98 files), ...-llc-txt.sh (26 files, sectors 1-26)

TIC 8195168 = 0000 0000 0819 5168, so sector 1 holds s0001/0000/0000/0819/5168/. The first level under a sector is always 0000; in sector 60 the second level runs 0000-0020 (TIC below 2.1 billion) plus 0100 (TIC ids of about 1e10, e.g. 10000024550). A leaf directory holds exactly one TIC, so every leaf has 1 fits (and 1 txt in sectors 1-26). The same TIC lives at the same relative path in every sector, only the s<SSSS> prefix changes. Version token is v01 everywhere except sectors 74-79, which are v02. Camera and CCD are only in the FITS primary header (CAMERA, CCD), not in any path or file name.
```

Example file: `s0001/0000/0000/0819/5168/hlsp_qlp_tess_ffi_s0001-0000000008195168_tess_v01_llc.fits  (80,640 bytes): TIC 8195168, sector 1, camera 1 CCD 1, 1,282 rows at 30 min cadence, 13 columns.`

## Open it

- In a hosted notebook with the data mounted: https://scigantic.com/archive/9a95cca0-9d2a-55f3-a502-d83acfba72ac
- Full record as JSON (schema card included): https://api.scigantic.com/api/archives/9a95cca0-9d2a-55f3-a502-d83acfba72ac
- Over MCP: `get_schema_card` with id `9a95cca0-9d2a-55f3-a502-d83acfba72ac` at https://api.scigantic.com/mcp

## Related topics

- [Astronomy & Space datasets](https://scigantic.com/topics/astronomy-and-space)
