Skip to main content

🪐 Exo Gargantua: TESS Exoplanet ML Vetting & Detection Pipeline

PyPI version Python Tests License: MIT Python Version Status

An end-to-end Machine Learning and Bayesian astrophysical framework for automated detection, pixel-level Difference Image Analysis (DIA) vetting, and MCMC parameter estimation of transiting exoplanets from TESS observations.


Exoplanet Vetting Summary

📖 Table of Contents


🔭 Executive Overview

Exo Gargantua is a publishable, research-grade pipeline engineered to process millions of TESS cadences. It transitions exoplanet discovery from brittle heuristics into a unified statistical and Machine Learning engine.

Starting from raw SPOC (Science Processing Operations Center) calibrated Target Pixel Files (TPFs) and Light Curves downloaded programmatically from the Mikulski Archive for Space Telescopes (MAST), the pipeline performs:

  1. Multi-Sector Ingestion & Stitching with crowding metric (CROWDSAP) corrections.
  2. Continuum-Referenced Transit-Masked Detrending to preserve true transit depths.
  3. Decimated Box Least Squares (BLS) periodic transit searches with bootstrap False Alarm Probability (FAP) estimation.
  4. Dynamic Stellar Limb-Darkening Estimation via ldtk and the TESS Input Catalog (TIC v8.2).
  5. Pixel-Level Difference Image Analysis (DIA) to detect background blended contaminants down to sub-pixel accuracy.
  6. Supervised ML Vetting via a calibrated Random Forest classifier trained on spatial and photometric false-positive models.
  7. Bayesian MCMC Posterior Sampling using emcee and batman with full Monte Carlo physical parameter propagation (Rp, a, Teq, Seff).

🚀 Key Features & Major Upgrades (v2.0)

Capability Pipeline v1 (Baseline) Pipeline v2 (Current)
Vetting Paradigm Hard heuristic thresholds Supervised Random Forest Classifier + Physical DIA Vetoes
Centroid Analysis Simple flux-weighted 1st moments True Difference Image Analysis (DIA) Out-of-Transit vs In-Transit
Limb Darkening Static quadratic constants (u1=0.3, u2=0.1) Dynamic q1, q2 profiles computed via ldtk from TIC (Teff, log(g), [Fe/H])
Validation Suite Manual targets / Error-prone harness Full Synthetic Transit Injection-Recovery & Multi-Modal Dataset Generator
Packaging & CI Script collection (requirements.txt) Modern pyproject.toml PEP 518/621 standard + GitHub Actions CI
Reporting & Telemetry Basic terminal printouts Structured JSON Reports, Corner Plots, and 4-Panel Publication Figures

🏗️ Astrophysical & ML Architecture

flowchart TD
    A[MAST API / SPOC Lightcurves & TPFs] --> B[Phase 1: Ingestion, Stitching & Crowding Correction]
    B --> C[Phase 2: Continuum-Referenced Transit-Masked Detrending]
    C --> D[Phase 3: Fast Decimated BLS Search & Bootstrap FAP]
    
    D --> E[Phase 3b: Physical Vetting Engine]
    E --> F[Odd/Even Transit Depth Delta Check]
    E --> G[Rolling-Mean Red Noise Secondary Eclipse Test]
    E --> H[Difference Image Analysis DIA Centroid Shift]
    
    F --> I[Feature Extraction Vector]
    G --> I
    H --> I
    D --> I
    
    I --> J[Phase 3c: Calibrated ML Vetter Random Forest]
    J -->|Disposition & Planet Probability| K{Pass Physical & ML Vetting?}
    
    K -->|Yes / Validated Candidate| L[Phase 4: Dynamic Limb Darkening LDTk + MCMC emcee]
    K -->|No / Blended False Positive| L
    
    L --> M[Phase 4b: Monte Carlo Physical Parameter Derivation]
    M --> N[Phase 4c: Publication Figures & JSON Summary Report]

🔬 Vetting Engine & Difference Image Analysis (DIA)

The vetting suite isolates genuine planetary transits from astrophysical false positives (Eclipsing Binaries, Grazing Binaries, and Background Eclipsing Binaries):

1. Difference Image Analysis (DIA) Centroid Vetting

To verify that the transit signal originates from the target star rather than a nearby background star within the large TESS pixel aperture (~21 arcsec / pixel):

  • Construct the reference out-of-transit average frame I_out and in-transit average frame I_in.
  • Compute the differential flux image:
    ΔI = I_out - I_in
    
  • Calculate the flux-weighted centroid of the differential dip (x_res, y_res) and the reference star (x_ref, y_ref).
  • Calculate the Euclidean centroid shift:
    Δr = √((x_res - x_ref)² + (y_res - y_ref)²)
    
  • Veto Threshold: A shift Δr ≥ 0.333 pixels (~7 arcsec) triggers an immediate FAILED_CENTROID_DIA flag.

2. Odd/Even Depth Consistency

Calculates the absolute depth difference Δδ = |δ_odd - δ_even|. Large differences (Δδ > 0.005) indicate alternating primary and secondary eclipses characteristic of eclipsing binary systems.

3. Integrated Red-Noise Secondary Eclipse Check

Computes the rolling-mean standard deviation in out-of-transit chunks matched to the transit duration, scoring secondary eclipse significance:

σ_sec = δ_sec / σ_rolling

Any secondary eclipse with |σ_sec| > 3.0σ flags the candidate as an occulting stellar companion.


🤖 Machine Learning Vetting Architecture

Rather than relying purely on heuristic threshold cuts, exoplanet_pipeline/ml_vetting.py implements a calibrated Random Forest Classifier trained on multi-modal feature vectors:

Feature Vector = [ BLS_Power, Odd_Even_Depth_Diff, Secondary_Eclipse_Sigma, Centroid_Shift, SNR, Centroid_Failed_Flag ]
Feature Importances in Trained Model:
  centroid_shift           : 29.65%
  depth_diff               : 27.82%
  centroid_fail (DIA Veto) : 22.54%
  secondary_eclipse_sigma  : 17.76%
  snr                      :  1.31%
  bls_power                :  0.92%

Spatial Veto & Consistency Guarantee

Because 1D transit injection cannot synthesize 2D pixel-level centroid shifts into Target Pixel Files, the training pipeline couples synthetic transit datasets with multi-modal physical false-positive generators (Background Eclipsing Binaries with centroid offsets 0.35 to 3.0 pixels, and EBs with high secondary eclipses).

Furthermore, MLVetter.predict() enforces hard physical gating: a candidate failing the spatial DIA test (Δr ≥ 0.333 pixels) has its planet probability suppressed to < 0.5%, preventing high 1D SNR from overriding spatial contamination.


🧪 Synthetic Injection-Recovery Framework

The pipeline includes exoplanet_pipeline/validate_injection.py to evaluate pipeline recovery completeness across the parameter space (Period: 1–15 days, Rp/Rs: 0.01–0.15):

  • Ingests real quiet TESS light curves.
  • Injects non-linear Mandel & Agol (2002) transit models using batman.
  • Runs blind detrending and BLS detection to evaluate recovery fraction and signal preservation.

📊 Benchmark Results: TIC 25155310 (WASP-126b)

The complete end-to-end pipeline was executed on benchmark target TIC 25155310 (WASP-126b).

MCMC Corner Plot

Extracted Parameters (output/TIC_25155310_summary.json)

Parameter Pipeline Value Uncertainty (-1σ / +1σ) Physical Unit
Orbital Period (P) 3.288790 ± 0.000001 days
Transit Epoch (t0) 1327.519196 -0.000448 / +0.000387 BTJD
Radius Ratio (Rp / Rs) 0.063223 -0.000394 / +0.000926 —
Semi-Major Axis (a / Rs) 8.007972 -0.511112 / +0.147525 —
Orbital Inclination (i) 88.52 -1.65 / +0.99 degrees
Planetary Radius (Rp) 8.77 ± 0.44 R_Earth (0.78 R_Jup)
Semi-Major Axis (a) 0.0449 ± 0.0007 AU
Equilibrium Temperature (Teq) 1359 ± 42 K
Centroid Shift (DIA) 0.4965 — pixels (passed: false)
ML Vetting Disposition FALSE_POSITIVE prob: 0.00% Flagged: FAILED_CENTROID_DIA

💻 Installation & Environment Setup

Prerequisites

  • Python >= 3.9, <= 3.11
  • Git

Quick Install via PyPI

pip install exo-gargantua

Development Installation from Source

# 1. Clone the repository
git clone https://github.com/bytes06runner/exo_gargantua.git
cd exo_gargantua

# 2. Create and activate a virtual environment
python3 -m venv exo-env
source exo-env/bin/activate

# 3. Install in editable mode with development & testing dependencies
pip install -e ".[dev]"

🛠️ Command-Line Interface (CLI) Usage

1. Run the Full End-to-End Pipeline

Process a TESS target through ingestion, detrending, BLS search, vetting, DIA, and MCMC parameter estimation:

python run_pipeline.py "TIC 25155310" --report

Options:

  • --report: Generates summary JSON in output/ and publication 4-panel diagnostic plots.
  • --no-mcmc: Skips MCMC posterior estimation for fast screening.
  • --no-centroid: Skips Target Pixel File (TPF) downloads.

2. Generate Synthetic Injection-Recovery Datasets

python exoplanet_pipeline/validate_injection.py

3. Train the ML Vetting Model

python exoplanet_pipeline/ml_vetting.py

4. Run Astrophysical Ground-Truth Validation Harness

python run_pipeline.py --validate

🧪 Testing & Continuous Integration (CI)

The repository includes a comprehensive pytest test suite configured with GitHub Actions CI on Ubuntu runners with Python 3.10 and 3.11:

# Execute local unit tests
pytest tests/ -v

Test Coverage Includes:

  • Kepler's Third Law astronomical scaling and error boundaries (tests/test_math.py).
  • Rolling-mean red-noise boxcar standard deviations (tests/test_math.py).
  • Odd/Even transit depth deltas (tests/test_math.py).
  • ML Vetter model training, prediction, and spatial DIA centroid veto consistency (tests/test_ml_vetting.py).

👤 Authors & Citation

Srijeet Prasad Banerjee (@bytes06runner)
Contact: cybrobasics@gmail.com

License

This project is open-source and licensed under the MIT License.

Metadata

Release files for exo-gargantua 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for exo-gargantua 0.1.1
File Size Uploaded
exo_gargantua-0.1.1.tar.gz 40.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for exo-gargantua 0.1.1
File Interpreter ABI Platform
exo_gargantua-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 84.4 kB

Release files / exo_gargantua-0.1.1.tar.gz

Download URL exo_gargantua-0.1.1.tar.gz
Size 40.2 kB
Tags Source
SHA-256 checksum
How to use checksums
17158365a9a360984c990de2f48b0d9ede868e513bc0c23552ad4fd87f3c342b
BLAKE2b-256 checksum
How to use checksums
9d011cfdf027660601ccb9df1359cc59bf961d8bbfa83964a8c8688f1e80dcdc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.7

Release files / exo_gargantua-0.1.1-py3-none-any.whl

Download URL exo_gargantua-0.1.1-py3-none-any.whl
Size 44.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1003c29cf68b37a090df710a79f7c6b6549c8adc30bdc93cccc589e78a0d68e7
BLAKE2b-256 checksum
How to use checksums
4daa77e00a197cdedf049270f3eab8482052984701290d89fb4e5ffa4f28f301
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.7

Release history Release notifications | RSS feed

3.0.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page