← 返回 Skills 市场
wu-uk

transit-least-squares

作者 wu-uk · GitHub ↗ · v0.1.0 · MIT-0
cross-platform ✓ 安全检测通过
72
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install exoplanet-detection-period-transit-least-squares
功能描述
Transit Least Squares (TLS) algorithm for detecting exoplanet transits in light curves. Use when searching for transiting exoplanets specifically, as TLS is...
使用说明 (SKILL.md)

Transit Least Squares (TLS)

Transit Least Squares is a specialized algorithm optimized for detecting exoplanet transits in light curves. It's more sensitive than Lomb-Scargle for transit-shaped signals because it fits actual transit models.

Overview

TLS searches for periodic transit-like dips in brightness by fitting transit models at different periods, durations, and epochs. It's the preferred method for exoplanet transit detection.

Installation

pip install transitleastsquares

Basic Usage

CRITICAL: Always include flux_err (flux uncertainties) for best results!

import transitleastsquares as tls
import lightkurve as lk
import numpy as np

# Example 1: Using Lightkurve (recommended)
lc = lk.LightCurve(time=time, flux=flux, flux_err=error)
lc_clean = lc.remove_outliers(sigma=3)
lc_flat = lc_clean.flatten()

# Create TLS object - MUST include flux_err!
pg_tls = tls.transitleastsquares(
    lc_flat.time.value,      # Time array
    lc_flat.flux.value,      # Flux array
    lc_flat.flux_err.value   # Flux uncertainties (REQUIRED!)
)

# Search for transits (uses default period range if not specified)
out_tls = pg_tls.power(
    show_progress_bar=False,  # Set True for progress tracking
    verbose=False
)

# Extract results
best_period = out_tls.period
period_uncertainty = out_tls.period_uncertainty
t0 = out_tls.T0                    # Transit epoch
depth = out_tls.depth               # Transit depth
snr = out_tls.snr                   # Signal-to-noise ratio
sde = out_tls.SDE                   # Signal Detection Efficiency

print(f"Best period: {best_period:.5f} ± {period_uncertainty:.5f} days")
print(f"Transit epoch (T0): {t0:.5f}")
print(f"Depth: {depth:.5f}")
print(f"SNR: {snr:.2f}")
print(f"SDE: {sde:.2f}")

Example 2: With explicit period range

# Search specific period range
out_tls = pg_tls.power(
    period_min=2.0,      # Minimum period (days)
    period_max=7.0,      # Maximum period (days)
    show_progress_bar=True,
    verbose=True
)

Period Refinement Strategy

Best Practice: Broad search first, then refine for precision.

Example workflow:

  1. Initial search finds candidate at ~3.2 days
  2. Refine by searching narrower range (e.g., 3.0-3.4 days)
  3. Narrower range → finer grid → better precision

Why? Initial searches use coarse grids (fast). Refinement uses dense grid in small range (precise).

# After initial search finds a candidate, narrow the search:
results_refined = pg_tls.power(
    period_min=X,  # e.g., 90% of candidate
    period_max=Y   # e.g., 110% of candidate
)

Typical refinement window: ±2% to ±10% around candidate period.

Advanced Options

For very precise measurements, you can adjust:

  • oversampling_factor: Finer period grid (default: 1, higher = slower but more precise)
  • duration_grid_step: Transit duration sampling (default: 1.1)
  • T0_fit_margin: Mid-transit time fitting margin (default: 5)

Advanced Parameters

  • oversampling_factor: Higher values give finer period resolution (slower)
  • duration_grid_step: Step size for transit duration grid (1.01 = 1% steps)
  • T0_fit_margin: Margin for fitting transit epoch (0 = no margin, faster)

Phase-Folding

Once you have a period, TLS automatically computes phase-folded data:

# Phase-folded data is automatically computed
folded_phase = out_tls.folded_phase      # Phase (0-1)
folded_y = out_tls.folded_y              # Flux values
model_phase = out_tls.model_folded_phase # Model phase
model_flux = out_tls.model_folded_model # Model flux

# Plot phase-folded light curve
import matplotlib.pyplot as plt
plt.plot(folded_phase, folded_y, '.', label='Data')
plt.plot(model_phase, model_flux, '-', label='Model')
plt.xlabel('Phase')
plt.ylabel('Flux')
plt.legend()
plt.show()

Transit Masking

After finding a transit, mask it to search for additional planets:

from transitleastsquares import transit_mask

# Create transit mask
mask = transit_mask(time, period, duration, t0)
lc_masked = lc[~mask]  # Remove transit points

# Search for second planet
pg_tls2 = tls.transitleastsquares(
    lc_masked.time,
    lc_masked.flux,
    lc_masked.flux_err
)
out_tls2 = pg_tls2.power(period_min=2, period_max=7)

Interpreting Results

Signal Detection Efficiency (SDE)

SDE is TLS's measure of signal strength:

  • SDE > 6: Strong candidate
  • SDE > 9: Very strong candidate
  • SDE \x3C 6: Weak signal, may be false positive

Signal-to-Noise Ratio (SNR)

  • SNR > 7: Generally considered reliable
  • SNR \x3C 7: May need additional validation

Common Warnings

TLS may warn: "X of Y transits without data. The true period may be twice the given period."

This suggests:

  • Data gaps may cause period aliasing
  • Check if period * 2 also shows a signal
  • The true period might be longer

Model Light Curve

TLS provides the best-fit transit model:

# Model over full time range
model_time = out_tls.model_lightcurve_time
model_flux = out_tls.model_lightcurve_model

# Plot with data
import matplotlib.pyplot as plt
plt.plot(time, flux, '.', label='Data')
plt.plot(model_time, model_flux, '-', label='Model')
plt.xlabel('Time [days]')
plt.ylabel('Flux')
plt.legend()
plt.show()

Workflow Considerations

When designing a transit detection pipeline, consider:

  1. Data quality: Filter by quality flags before analysis
  2. Preprocessing order: Remove outliers → flatten/detrend → search for transits
  3. Initial search: Use broad period range to find candidates
  4. Refinement: Narrow search around candidates for better precision
  5. Validation: Check SDE, SNR, and visual inspection of phase-folded data

Typical Parameter Ranges

  • Outlier removal: sigma=3-5 (lower = more aggressive)
  • Period search: Match expected orbital periods for your target
  • Refinement window: ±2-10% around candidate period
  • SDE threshold: >6 for candidates, >9 for strong detections

Multiple Planet Search Strategy

  1. Initial broad search: Use TLS with default or wide period range
  2. Identify candidate: Find period with highest SDE
  3. Refine period: Narrow search around candidate period (±5%)
  4. Mask transits: Remove data points during transits
  5. Search for additional planets: Repeat TLS on masked data

Dependencies

pip install transitleastsquares lightkurve numpy matplotlib

References

When to Use TLS vs. Lomb-Scargle

  • Use TLS: When specifically searching for exoplanet transits
  • Use Lomb-Scargle: For general periodic signals (rotation, pulsation, eclipsing binaries)

TLS is optimized for transit-shaped signals and is typically more sensitive for exoplanet detection.

Common Issues

"flux_err is required"

Always pass flux uncertainties to TLS! Without them, TLS cannot properly weight data points.

Period is 2x or 0.5x expected

Check for period aliasing - the true period might be double or half of what TLS reports. Also check the SDE for both periods.

Low SDE (\x3C6)

  • Signal may be too weak
  • Try different preprocessing (less aggressive flattening)
  • Check if there's a data gap during transits
安全使用建议
This skill is an instructional guide for the transitleastsquares Python package and appears coherent. Before using: (1) confirm you have a Python environment and pip (the SKILL.md assumes them but the skill metadata does not declare them); (2) install packages (transitleastsquares, lightkurve, numpy, matplotlib) in a virtualenv to avoid affecting system Python; (3) review the transitleastsquares package on PyPI/GitHub to confirm it is the expected project and check licensing; (4) be aware pip install downloads packages from the network—if you have strict offline or supply-chain policies, obtain packages from vetted mirrors; (5) the examples assume you supply time/flux/flux_err arrays—do not feed sensitive data you do not intend to analyze. There are no credentials or surprising behaviors identified.
能力评估
Purpose & Capability
The name/description (TLS for exoplanet transit detection) matches the instructions (examples using the transitleastsquares package and lightkurve). Minor mismatch: the metadata declares no required binaries, but the SKILL.md assumes Python and pip and depends on additional Python packages (lightkurve, matplotlib, numpy) that are not declared.
Instruction Scope
The runtime instructions stay on-topic: they show how to install and use transitleastsquares, how to refine periods, mask transits, and interpret outputs. The instructions do not request or reference unrelated files, credentials, or external endpoints.
Install Mechanism
There is no install spec (instruction-only), which is low risk. The doc instructs users to run `pip install transitleastsquares` — this is normal but the skill does not declare that it requires pip/Python or list other Python deps. Installing from PyPI at runtime involves network downloads; verify package provenance before installing.
Credentials
The skill requests no environment variables, credentials, or config paths. All recommended operations are local data analysis using provided light curve arrays; requested access is proportionate to the stated purpose.
Persistence & Privilege
The skill is not always-enabled and does not request elevated or persistent privileges. It's instruction-only and will not modify other skills or system settings by itself.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install exoplanet-detection-period-transit-least-squares
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /exoplanet-detection-period-transit-least-squares 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v0.1.0
Bulk publish from all-task-skills-dedup
元数据
Slug exoplanet-detection-period-transit-least-squares
版本 0.1.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

transit-least-squares 是什么?

Transit Least Squares (TLS) algorithm for detecting exoplanet transits in light curves. Use when searching for transiting exoplanets specifically, as TLS is... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 72 次。

如何安装 transit-least-squares?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install exoplanet-detection-period-transit-least-squares」即可一键安装,无需额外配置。

transit-least-squares 是免费的吗?

是的,transit-least-squares 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

transit-least-squares 支持哪些平台?

transit-least-squares 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 transit-least-squares?

由 wu-uk(@wu-uk)开发并维护,当前版本 v0.1.0。

💬 留言讨论