Skip to main content

GTLS: GPU Transit Least Squares

PyPI License: MIT

GTLS is a CUDA implementation of the Transit Least Squares (TLS) algorithm for detecting periodic exoplanet transits in light curves. It keeps the TLS interface and transit model, and evaluates all trial periods, durations and epochs in parallel on an NVIDIA GPU, which makes it several times faster than CPU TLS.

GTLS periodogram and phase-folded transit

Features

  • Drop-in replacement for the transitleastsquares search API
  • Limb-darkened transit templates (default, grazing and box-shaped)
  • Batches trial periods automatically to fit the free GPU memory
  • Refines the strongest peaks and their period aliases (P/2, 2P, 2P/3, 3P/2) with a finer epoch search, and fits the best period at every cadence
  • Supports multi-GPU machines: pick a device with GPUDeviceID or split one search across several with GPUDeviceIDs

Requirements

  • An NVIDIA GPU with CUDA
  • Python >= 3.8
  • CuPy matching your CUDA version

Installation

CuPy wheels depend on the local CUDA version, so CuPy is not a hard dependency. Install CuPy following the official guide, then install GTLS:

pip install gputls

Or let pip pick a CuPy build for you:

pip install "gputls[cuda12]"   # CUDA 12.x
pip install "gputls[cuda11]"   # CUDA 11.x

To install from source:

git clone https://github.com/Farthing-0/GTLS.git
cd GTLS
pip install .

Quick start

from gputls import gtls

# time in days, flux normalized to 1, optional flux uncertainties dy
model = gtls(time, flux, dy)
result = model.power()

print(result.period, result.T0, result.duration, result.depth, result.SDE)

power() accepts the same keyword arguments as TLS. Commonly used ones:

Argument Default Description
period_min, period_max 0, inf Limits of the automatic period grid (days)
periods [] Custom array of trial periods; overrides the automatic grid
R_star, M_star 1.0, 1.0 Stellar radius and mass (solar units) used for the period grid
R_star_min, R_star_max 0.13, 3.5 Stellar radius limits (solar units) of the plausible transit durations
M_star_min, M_star_max 0.1, 1.0 Stellar mass limits (solar units) of the plausible transit durations. Paired with the radius limits as in TLS 2: (R_star_min, high mass) for the shortest and (R_star_max, low mass) for the longest duration
oversampling_factor 3 Period grid oversampling
duration_grid_step 1.1 Multiplicative step of the duration grid
transit_depth_min 1e-5 Minimum depth of a trial transit
transit_template "default" "default", "grazing" or "box"
T0_fit_margin 0.125 Epoch step of the coarse search as a fraction of the duration (0 to 0.125; 0 tests every cadence)
T0_refine_margin 0.01 Epoch step when the strongest peaks are re-searched, as a fraction of the duration (0 to 0.125; 0 tests every cadence). 0.01 is the T0 resolution of TLS
GPUDeviceID 0 CUDA device to run on
GPUDeviceIDs None List of CUDA devices to split the search across (e.g. [0, 1]); overrides GPUDeviceID. Results are identical to a single-GPU run
bar_location 0 Position of the progress bar, useful when running several searches in parallel
fast False Return only (periods, power), skipping the refinement and transit statistics

Results

power() returns a gtlsResult object with the following attributes:

Attribute Description
period Best period (days)
T0 Mid-transit time of the first transit (days)
duration Transit duration (days)
depth Fractional transit depth (1 - in-transit flux). Note: TLS reports the in-transit flux level instead
SDE Signal Detection Efficiency of the best period
snr, snrPink Signal-to-noise ratio with white and pink (correlated) noise
snrFit, snrFitPink Signal-to-noise ratio from the fitted transit depth
transitTimes Mid-transit times within the light curve
periods, power Periodogram: trial periods and SDE power
chi2 Minimum chi² of each period after refinement
raw_chi2, raw_power Minimum chi² and power of the coarse search, before refinement
possiblePeriods, possiblePeriodsIndices Periods that were refined, and their indices in periods
rawDuration, rawDurations, durationPoints Best duration as a fraction of the period, the duration grid, and the best duration in data points

Examples

The examples/ folder contains Jupyter notebooks comparing GTLS with TLS:

The notebooks also need matplotlib, astropy, transitleastsquares, lightkurve and wotan.

Testing

The test suite runs end-to-end searches on the GPU: injection-recovery on a synthetic light curve, the fast mode, a real Kepler light curve stored in tests/data/, release of GPU memory after a search, and (on machines with at least two GPUs) bitwise agreement between single- and multi-GPU searches. It needs astropy in addition to the runtime dependencies.

One-click build, install and test (inside an environment where CuPy is installed):

./run_tests.sh            # GPU 0
./run_tests.sh 1          # GPU 1
PYTHON=/path/to/python ./run_tests.sh

The script reinstalls only gputls itself (--no-deps) and then runs tests/test_gtls.py. The tests can also be run with pytest tests; select the GPU with the GTLS_GPU_DEVICE environment variable.

Comparison with TLS 1.x and TLS 2.x

tests/tls_compare/ benchmarks GTLS against the last TLS 1.x release (1.32) and TLS 2.x (2.0.4). All engines search the same mock Kepler and TESS-SPOC pipeline products, which are read and detrended with lightkurve. The benchmark reports runtimes, recovery of the injected transits and cross-engine agreement. Both TLS versions are installed automatically into isolated directories. The benchmark needs lightkurve (pip install "gputls[test]"):

python tests/compare_tls.py                  # standard suite: report.md + report.json
python tests/compare_tls.py --suite full --plot
python tests/compare_tls.py --suite long --timeout 3600 --repeat-limit 60   # whole Kepler mission, short cadence
pytest tests/test_tls_compare.py             # injection recovery and agreement checks

Project structure

GTLS/
├── src/gputls/          # Python package
│   ├── main.py          # gtls class (public API)
│   ├── core.py          # GPU search driver
│   ├── kernels.cu       # CUDA kernels, compiled at runtime by CuPy
│   ├── grid.py          # period and duration grids
│   ├── transit.py       # transit templates (batman)
│   ├── stats.py         # periodogram and SNR statistics
│   ├── validate.py      # input and argument validation
│   ├── constants.py     # default parameters
│   └── ...
├── tests/               # GPU test suite, TLS comparison framework (tls_compare/) and test data
├── examples/            # Jupyter notebooks
├── docs/images/         # Figures used in the documentation
├── run_tests.sh         # One-click build and test
└── pyproject.toml

Acknowledgements and license

GTLS is adapted from TLS by Michael Hippke and René Heller. If you use GTLS, please also cite the TLS paper: Hippke, M. & Heller, R. (2019), Optimized transit detection algorithm to search for periodic transits of small planets, A&A 623, A39.

Both TLS and GTLS are released under the MIT License.

Metadata

Release files for gputls 2.1.0

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

Source distribution (sdist)

Source distribution for gputls 2.1.0
File Size Uploaded Provenance Actions
gputls-2.1.0.tar.gz 39.3 kB Without provenance Details for gputls-2.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gputls 2.1.0
File Interpreter ABI Platform Actions
gputls-2.1.0-py3-none-any.whl Python 3 none any Details for gputls-2.1.0-py3-none-any.whl

Total release size: 73.7 kB

Release files / gputls-2.1.0.tar.gz

Download URL gputls-2.1.0.tar.gz
Size 39.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a980f35264be45552ceb4024fd42972689f2a1ef97560e72026d0f3c017e8ca5
BLAKE2b-256 checksum
How to use checksums
5f8a8455ea64916b9498e8058613d77fd9e0006a47de831e6c7f3013d30e61e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / gputls-2.1.0-py3-none-any.whl

Download URL gputls-2.1.0-py3-none-any.whl
Size 34.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5121e345c92a50ca4d58324e62b7fe0e6754f14d26db206a9fe45544d1281f3e
BLAKE2b-256 checksum
How to use checksums
b04df92962460c89587054bb4a60162d9bfe63b295ddd65ddf321caa49ae8e63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for gputls 2.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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