Tools for working with exoplanet data
Project description
ExoTools
Python tools for working with exoplanet data from various sources including NASA's Exoplanet Archive, TESS, and Gaia.
Installation
Install exotools with pip:
pip install exotools
Getting Started
Basic Usage with Default Storage
The simplest way to get started is using the default in-memory storage. Data will be cached in memory, and lost at the termination of the program.
from exotools import PlanetarySystemsDataset
# Create dataset with default in-memory storage
dataset = PlanetarySystemsDataset()
# Download a small sample of known exoplanets
exo_db = dataset.download_known_exoplanets(limit=10)
# Access the data
print(f"Downloaded {len(exo_db)} exoplanet records")
print("First few host star names:", exo_db.view["hostname"][:5])
# Convert to pandas for analysis
df = exo_db.to_pandas()
print(df.head())
Using Persistent Storage
For larger datasets or persistent storage, use one of the available storage backends:
from exotools import PlanetarySystemsDataset
from exotools.io import Hdf5Storage
# Create HDF5 storage backend
storage = Hdf5Storage("exoplanet_data.h5")
dataset = PlanetarySystemsDataset(storage=storage)
# Download and store data persistently
exo_db = dataset.download_known_exoplanets(limit=100)
# Later, load the same data from storage
exo_db = dataset.load_known_exoplanets_dataset()
Storage Options
ExoTools supports multiple storage backends to fit different use cases:
Memory Storage (Default)
Fast but temporary storage - data is lost when the program ends:
from exotools import PlanetarySystemsDataset
# Uses MemoryStorage by default
dataset = PlanetarySystemsDataset()
Feather Storage (Recommended for Local Use)
Recommended for local development and analysis - fastest read access for the "download once, reuse multiple times" workflow:
from exotools.io import FeatherStorage
from exotools import PlanetarySystemsDataset
storage = FeatherStorage("data_directory")
dataset = PlanetarySystemsDataset(storage=storage)
HDF5 Storage (Recommended for Portability)
Recommended for managing multiple datasets in a single file or when transferring between machines (e.g., in HPC environments):
from exotools.io import Hdf5Storage
from exotools import PlanetarySystemsDataset
storage = Hdf5Storage("my_data.h5")
dataset = PlanetarySystemsDataset(storage=storage)
ECSV Storage (Maximum Compatibility)
Human-readable CSV format with metadata - slower but offers maximum portability and inspection capabilities:
from exotools.io import EcsvStorage
from exotools import PlanetarySystemsDataset
storage = EcsvStorage("data_directory")
dataset = PlanetarySystemsDataset(storage=storage)
Available Datasets
Known Exoplanets
Access confirmed exoplanets from NASA's Exoplanet Archive:
from exotools import PlanetarySystemsDataset
from exotools.io import Hdf5Storage
storage = Hdf5Storage("exoplanet_data.h5")
dataset = PlanetarySystemsDataset(storage=storage)
# Download confirmed exoplanets
exo_db = dataset.download_known_exoplanets(store=True)
# Load from storage
exo_db = dataset.load_known_exoplanets_dataset()
# Access specific data
tess_planets = exo_db.get_tess_planets()
print(f"Found {len(tess_planets)} planets discovered by TESS")
Known Exoplanets with Gaia Data
Cross-match with Gaia DR3 stellar parameters:
# Download with Gaia stellar data
exo_db = dataset.download_known_exoplanets(with_gaia_star_data=True)
# Load Gaia data separately
gaia_db = dataset.load_gaia_dataset_of_known_exoplanets()
# Get stellar distances from Gaia
distances = gaia_db.view["distance_gspphot"]
print(f"Stellar distances: {distances[:5]}")
Candidate Exoplanets (TOIs)
Work with TESS Objects of Interest:
from exotools import CandidateExoplanetsDataset
dataset = CandidateExoplanetsDataset(storage=storage)
# Download candidate exoplanets
candidates_db = dataset.download_candidate_exoplanets(store=True)
# Load from storage
candidates_db = dataset.load_candidate_exoplanets_dataset()
print(f"Found {len(candidates_db)} candidate exoplanets")
Gaia Stellar Parameters
Access Gaia DR3 stellar parameters for specific stars:
from exotools import GaiaParametersDataset
# Optional: authenticate for higher query limits
GaiaParametersDataset.authenticate("your_username", "your_password")
dataset = GaiaParametersDataset(storage=storage)
# Download Gaia data for specific Gaia source IDs
gaia_ids = [1234567890123456789, 2345678901234567890]
gaia_db = dataset.download_gaia_parameters(gaia_ids)
# Load from storage
gaia_db = dataset.load_gaia_parameters_dataset()
# Access stellar parameters
print(f"Downloaded {len(gaia_db)} stellar records")
print("Stellar masses:", gaia_db.view["mass_flame"][:5])
print("Stellar distances:", gaia_db.view["distance_gspphot"][:5])
print("Effective temperatures:", gaia_db.view["teff_gspphot"][:5])
# Access computed properties
print("Habitable zone inner edges:", gaia_db.view["hz_inner"][:5])
print("Habitable zone outer edges:", gaia_db.view["hz_outer"][:5])
TESS Catalog Data
Access TESS Input Catalog (requires MAST authentication):
from exotools import TicCatalogDataset
# Authenticate with MAST (required for TIC queries)
TicCatalogDataset.authenticate_casjobs(user_wsid=12345678, password="your_password")
dataset = TicCatalogDataset(storage=storage)
# Search for targets by stellar mass
tic_db = dataset.download_tic_targets(
star_mass_range=(0.8, 1.2), # Solar masses
limit=50,
store=True
)
# Download specific TIC targets by ID
tic_ids = [1234567, 2345678, 3456789]
tic_db = dataset.download_tic_targets_by_ids(tic_ids)
TESS Observation Metadata
Get observation metadata for lightcurve downloads:
from exotools import TicObservationsDataset
# Optional: authenticate for faster downloads
TicObservationsDataset.authenticate_mast("your_mast_token")
dataset = TicObservationsDataset(storage=storage)
# Get observation metadata for specific TIC IDs
tic_ids = exo_db.view["tic_id"][:10] # First 10 TIC IDs
obs_db = dataset.download_observation_metadata(tic_ids)
print(f"Found {len(obs_db)} TESS observations")
Lightcurve Data
Download TESS lightcurve FITS files:
from exotools import LightcurveDataset
from pathlib import Path
# Lightcurves are stored as FITS files in the filesystem
lc_dataset = LightcurveDataset(
lc_storage_path=Path("lightcurves"),
verbose=True
)
# Download lightcurves for the observations
lc_db = lc_dataset.download_lightcurves_from_tic_db(obs_db)
print(f"Downloaded {len(lc_db)} lightcurves")
# Load previously downloaded lightcurves
lc_db = lc_dataset.load_lightcurve_dataset()
# Work with individual lightcurves and time conversions
for lc_plus in lc_db.lightcurves[:3]: # First 3 lightcurves
print(f"Original time system: {lc_plus.time_system}")
# Convert time formats in place (new API)
lc_plus.to_jd_time() # Convert to Julian Date
print(f"After JD conversion: {lc_plus.time_system}")
lc_plus.to_btjd_time() # Convert to Barycentric TESS Julian Date
print(f"After BTJD conversion: {lc_plus.time_system}")
lc_plus.to_bjd_time() # Convert to Barycentric Julian Date
print(f"After BJD conversion: {lc_plus.time_system}")
Object-Oriented Star System Interface
Access exoplanet data through an intuitive object-oriented interface:
from exotools import PlanetarySystemsDataset
dataset = PlanetarySystemsDataset(storage=storage)
# Download data with Gaia cross-matching (required for star systems)
exo_db = dataset.download_known_exoplanets(with_gaia_star_data=True)
# Load star system representation
star_systems = dataset.load_star_system_dataset()
# Access star systems by name
kepler_system = star_systems.get_star_system_from_star_name("Kepler-90")
# Access star properties with uncertainties
star = kepler_system.star
print(f"Star: {star.name}")
print(f" Radius: {star.radius.central} ± {star.radius.upper - star.radius.central}")
print(f" Mass: {star.mass.central} ± {star.mass.upper - star.mass.central}")
# Access planets in the system
for planet in kepler_system.planets:
print(f"Planet: {planet.name}")
print(f" Radius: {planet.radius.central}")
print(f" Mass: {planet.mass.central}")
print(f" Orbital Period: {planet.orbital_period.central}")
Advanced Usage
Working with Multiple Datasets
from exotools import (
PlanetarySystemsDataset,
CandidateExoplanetsDataset,
TicObservationsDataset,
LightcurveDataset
)
from exotools.io import Hdf5Storage
from pathlib import Path
# Shared storage for metadata
storage = Hdf5Storage("exoplanet_data.h5")
# Download known exoplanets
known_dataset = PlanetarySystemsDataset(storage=storage)
exo_db = known_dataset.download_known_exoplanets(limit=50)
# Download candidates
candidate_dataset = CandidateExoplanetsDataset(storage=storage)
candidates_db = candidate_dataset.download_candidate_exoplanets(limit=50)
# Get TESS observations for known exoplanets
obs_dataset = TicObservationsDataset(storage=storage)
obs_db = obs_dataset.download_observation_metadata(exo_db.view["tic_id"][:10])
# Download lightcurves
lc_dataset = LightcurveDataset(Path("lightcurves"))
lc_db = lc_dataset.download_lightcurves_from_tic_db(obs_db)
Custom Storage Configuration
from exotools.io import Hdf5Storage, FeatherStorage
from exotools import PlanetarySystemsDataset
# Configure HDF5 storage with custom path
hdf5_storage = Hdf5Storage("custom/path/exodata.h5")
# Configure Feather storage with custom directory
feather_storage = FeatherStorage("custom/data/directory")
# Use different storage for different datasets
exo_dataset = PlanetarySystemsDataset(storage=hdf5_storage)
candidate_dataset = CandidateExoplanetsDataset(storage=feather_storage)
License
MIT License
Citation
If you use exotools in your research, please cite it as follows:
@misc{cardin2025exotools,
author = {Christian Cardin},
title = {ExoTools: Astronomical data access and analysis toolkit},
year = {2025},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/sechlol/exotools}},
note = {Version 0.1.2},
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file exotools-0.4.2.tar.gz.
File metadata
- Download URL: exotools-0.4.2.tar.gz
- Upload date:
- Size: 533.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0bb6b7baa36aa2aeeba7dd899e91b7cea80c9b0542539e1ecb985200bb1b0557
|
|
| MD5 |
61c68943633c81cf117bce95bdcdc110
|
|
| BLAKE2b-256 |
6374fbe32c466e3fb141780cc7984ef21bccd91e84bd16f0a32552140c6ec7dd
|
Provenance
The following attestation bundles were made for exotools-0.4.2.tar.gz:
Publisher:
publish-to-pypi.yml on sechlol/exotools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
exotools-0.4.2.tar.gz -
Subject digest:
0bb6b7baa36aa2aeeba7dd899e91b7cea80c9b0542539e1ecb985200bb1b0557 - Sigstore transparency entry: 1154646841
- Sigstore integration time:
-
Permalink:
sechlol/exotools@607aa238cc950a47a4a518e321d1c4deb549237c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/sechlol
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@607aa238cc950a47a4a518e321d1c4deb549237c -
Trigger Event:
push
-
Statement type:
File details
Details for the file exotools-0.4.2-py3-none-any.whl.
File metadata
- Download URL: exotools-0.4.2-py3-none-any.whl
- Upload date:
- Size: 72.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da05763a7eb9cde2f327077b3bdc0fc804d9f2d87d3d0d230673b79cde54f2e8
|
|
| MD5 |
03d55da1ac51619b96587056b05abc68
|
|
| BLAKE2b-256 |
1049967fdefacfaebe69e8fc5290a265caf46cad2f3edf65ba599bd4bf81bc17
|
Provenance
The following attestation bundles were made for exotools-0.4.2-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on sechlol/exotools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
exotools-0.4.2-py3-none-any.whl -
Subject digest:
da05763a7eb9cde2f327077b3bdc0fc804d9f2d87d3d0d230673b79cde54f2e8 - Sigstore transparency entry: 1154646845
- Sigstore integration time:
-
Permalink:
sechlol/exotools@607aa238cc950a47a4a518e321d1c4deb549237c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/sechlol
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@607aa238cc950a47a4a518e321d1c4deb549237c -
Trigger Event:
push
-
Statement type: