# Methodology sources for the TESS detrending pilot

Research notes prepared on 1 December 2026. These notes distinguish documented data/API behavior from proposed study decisions. They contain no experimental results.

## Define the experiment's scope

Use one published photometric product as the starting point for all cleaning methods. SPOC light-curve FITS files provide SAP aperture flux and PDCSAP flux after systematics processing, with flux uncertainties in electrons per second and missing values represented by NaNs. Thus a light-curve injection experiment measures the additional processing applied to that product. Its scope begins after the mission's image calibration and aperture extraction. [NASA data-products documentation](https://heasarc.gsfc.nasa.gov/docs/tess/data_products.html), [NASA introductory tutorial](https://heasarc.gsfc.nasa.gov/docs/tess/TESS-Intro.html)

SAP and PDCSAP have different systematic corrections. PDCSAP also incorporates crowding and aperture-flux-loss corrections. NASA's crowding tutorial explains that contaminating neighboring light reduces apparent transit depths and can bias inferred planet radii. Record the product and relevant crowding metadata. A comparison of injected SAP versus already-computed PDCSAP would not rerun PDC on the modified measurements. [NASA crowding tutorial](https://heasarc.gsfc.nasa.gov/docs/tess/UnderstandingCrowdingv2.html)

For a first study, report injected fractional depth, period, duration, and epoch directly. Any conversion to planet radius requires additional stellar and dilution assumptions. If using trapezoids, state ingress fraction and total duration. If using a physical limb-darkened model, state its parameters and exposure integration. Label simplified profiles in the methods and figures.

## Keep time and masks reproducible

TESS time is BTJD, meaning BJD minus 2457000 in the TDB time scale. Keep period and duration in days and preserve the reference time when subtracting an offset. The Lightkurve implementation accepts cadences through `(quality & bitmask) == 0`. TESS quality flags include attitude changes, safe/coarse/Earth pointing, desaturation, cosmic rays, manual exclusions, outliers, stray light, and calibration or planet-search exclusions. Its named masks contain different flag combinations and should be recorded numerically with the installed package version. [Lightkurve quality and time implementation](https://lightkurve.github.io/lightkurve/_modules/lightkurve/utils.html)

Proposed design decisions follow.

- Derive the finite-time, finite-positive-flux, finite-positive-uncertainty, and mission-quality mask once from each unmodified input. Save excluded counts by reason. Apply that shared cadence set to every injection and method.
- Keep gaps as gaps. Separate detrending segments at declared gaps, define edge handling, and record any additional method-specific discarded cadences.
- Freeze target selection before injection results. Select variability strata using an explicitly named pre-injection statistic. Raw SAP scatter combines stellar variability with instrument effects, so describe it as observed variability unless those effects are separated.
- Shared, pre-injection masks support clean comparisons. Method-dependent clipping can itself become an experimental factor, with its lost in-transit samples counted.

## Inject before cleaning

For each fixed seed, create one synthetic signal on the observed timestamps, combine it with the chosen input flux, then rerun every detrending method. Use the same signal and phase for each paired comparison. Apply an uncertainty convention consistently and document whether added signal changes the reported uncertainty. A multiplicative injection has the form `flux_injected = flux_original * transit_model`.

The Wotan paper benchmarks detrending through transit recovery and shows that performance depends on the stellar sample and estimator. Its documentation distinguishes time-based windows from cadence-based median filters and exposes gap/edge behavior. Record a window's physical duration and actual cadence equivalent. [Hippke et al. 2019](https://arxiv.org/abs/1906.00966), [Wotan usage documentation](https://wotan.readthedocs.io/en/latest/Usage.html)

The injected ephemeris belongs exclusively to evaluation. Any masking used during a blind search should be derived by a predeclared algorithm from the data available to that search. Supplying exact injected transit times to detrending would evaluate an oracle-assisted procedure. Such a procedure can be a separately labelled reference condition.

## Run a genuinely blind period search

Astropy BLS searches trial periods and durations while fitting transit phase and depth. `autoperiod` constructs a grid uniform in frequency with spacing `frequency_factor * min(duration) / time_span**2`. A smaller factor refines the grid. `minimum_n_transit` sets a default maximum search period through the time span. Actual observed transit counts require a separate check. The `oversample` argument governs phase resolution. Specify all bounds, durations, objective, and grid settings explicitly and keep them fixed across methods. [Astropy BLS API](https://docs.astropy.org/en/stable/api/astropy.timeseries.BoxLeastSquares.html)

Recommended evaluation criteria follow.

- Search a broad, fixed interval containing the injection grid, including regions between injected periods. Supplying only injected periods makes the task easier.
- Record the strongest candidate's period, epoch, duration, depth, depth uncertainty, and search statistic.
- Require period agreement and epoch agreement modulo the injected period. Also check accumulated timing drift across the observing baseline against the transit duration. A fixed percentage period tolerance alone can accept a candidate that loses phase coherence.
- Count actual sampled transit events and in-transit exposure coverage. Distinguish insufficient coverage from a well-covered search failure.
- Report half-period and double-period aliases separately. Estimate depth attenuation at the known ephemeris for all injections as an additional measurement, including missed signals, to avoid selecting only favorable recoveries.

## Calibrate detection claims separately from recovery

The following are statistical design recommendations. A high BLS peak is a candidate-ranking statistic. Its empirical false-positive behavior depends on the search extent, observing window, correlated noise, and cleaning method.

Run each original light curve without injection. These controls reveal pre-existing periodic variability, transits, and instrumental peaks. With only a few input stars, this baseline cannot establish a precise low false-positive rate.

A larger experiment can predefine a red-noise-preserving surrogate scheme, create separate calibration and held-out evaluation sets, and apply the identical detrending-plus-search pipeline to each surrogate. Calibrate thresholds on the maximum search statistic. Evaluate false positives on the held-out set, with binomial uncertainty and explicit surrogate assumptions. Simple independent point shuffling destroys time correlations and changes the noise problem.

Until such calibration is supported, describe the result as ephemeris recovery under a stated statistic threshold and publish the control results. Paired recovery differences and depth attenuation remain informative pilot outcomes.

## Retain an audit trail

Save product identifiers, download URLs, FITS checksums, metadata, quality mask, selected timestamps, random seeds, injection parameters, method settings, software versions, search grids, outcomes, and timing measurements. Preserve all exclusions and failed runs. Show denominators in every completeness cell.

Many injections share the same star and noise realization. Report per-star results and paired method differences. Any pooled uncertainty should respect this dependence, for example through a declared bootstrap clustered by star. A handful of stars supports a sample-specific pilot, with sample expansion needed to characterize broader stellar populations.
