SPHEREx time-domain analysis package for querying and analyzing spectral image data
Project description
SPXQuery - SPHEREx Time-Domain Analysis Package
SPXQuery is a Python package designed to automate SPHEREx spectral image data query, download, and time-domain analysis for astronomical sources.
Example Output
Automated spectral and temporal analysis of the Cloverleaf quasar (z=2.56) showing SPHEREx's multi-wavelength time-domain capabilities.
Features
- Automated data pipeline: Query → Download → Photometry → Visualization
- Image cutout support: Download only regions of interest (99% storage reduction)
- Parallel processing: Fast downloads and photometry extraction
- Resumable execution: Automatic state persistence for interrupted runs
- Quality control: Built-in filtering with visual inspection of rejected data
- Publication-ready plots: Combined spectral and time-series visualization
Installation
Requirements
- Python 3.11 or later (supports Python 3.11-3.13)
Install from PyPI (Recommended)
pip install spxquery
Verify installation:
python -c "import spxquery; print(spxquery.__version__)"
Installation from Source
For the latest development version:
git clone https://github.com/WenkeRen/spxquery.git
cd spxquery
pip install .
For Developers (Optional)
If you want to contribute to SPXQuery or manage dependencies with Poetry:
# Install Poetry
curl -sSL https://install.python-poetry.org | python3 -
# Install with Poetry
poetry install
For detailed installation instructions and troubleshooting, see INSTALL.md.
Quick Start
One-Line Pipeline
from spxquery.core.pipeline import run_pipeline
# Run complete pipeline for Cloverleaf quasar (z=2.56)
run_pipeline(
ra=213.9427080,
dec=11.4953890,
output_dir="output",
source_name="cloverleaf",
aperture_diameter=2.0,
cutout_size="60px"
)
Basic Usage
Configure and Run
from spxquery import Source, QueryConfig, SPXQueryPipeline
# Configure your analysis for Cloverleaf quasar
source = Source(ra=213.9427080, dec=11.4953890, name="cloverleaf")
config = QueryConfig(
source=source,
output_dir="output",
aperture_diameter=2.0,
cutout_size="60px"
)
# Run the pipeline
pipeline = SPXQueryPipeline(config)
pipeline.run_full_pipeline()
Step-by-Step Execution
pipeline.run_query() # Query IRSA archive
pipeline.run_download() # Download FITS files
pipeline.run_processing() # Extract photometry
pipeline.run_visualization() # Create plots
Resume After Interruption
# Automatically resume from saved state
pipeline = SPXQueryPipeline(config)
pipeline.resume()
For detailed examples including quality control settings, band selection, and advanced features, see example/quickstart_demo.ipynb.
Output Files
The pipeline creates an organized output directory:
output_dir/
├── data/ # Downloaded FITS files (by band)
├── results/
│ ├── lightcurve.csv # Photometry time-series (all measurements)
│ ├── combined_plot.png # Spectral + temporal visualization
│ ├── query_summary.json # Query metadata
└── {source_name}.json # Pipeline state (for resume)
The lightcurve.csv contains all photometry measurements with columns including MJD, flux, wavelength, band, quality flags, and SNR.
SPHEREx Bands
| Band | Wavelength Range | Resolving Power |
|---|---|---|
| D1 | 0.75-1.09 μm | R=39 |
| D2 | 1.10-1.62 μm | R=41 |
| D3 | 1.63-2.41 μm | R=41 |
| D4 | 2.42-3.82 μm | R=35 |
| D5 | 3.83-4.41 μm | R=112 |
| D6 | 4.42-5.00 μm | R=128 |
Documentation
- Installation Guide: Detailed installation instructions and troubleshooting
- Quick Start Notebook: Interactive tutorial with examples
- API Reference: Source code with docstrings
Key Features Explained
Image Cutouts: Download 200×200 pixel cutouts (~0.7 MB) instead of full 2040×2040 images (~70 MB) for 99% storage reduction. Specify cutout_size="200px" or use angular units like "3arcmin".
Quality Control: All measurements are saved to CSV. Visualization applies configurable filters (sigma_threshold, bad_flags) to show good measurements (filled circles) and rejected data (gray crosses) for inspection.
Resume Capability: Pipeline automatically saves state after each stage. Use pipeline.resume() to continue from interruptions without re-downloading data.
Known Issues
Overly Conservative Source Masking: The pipeline uses official SPHEREx image masks to avoid bad pixels during background subtraction. However, the official pipeline tends to provide overly large source masks. If your target is located in an extended nebula or near bright stars, the photometry extraction may fail because no clean pixels are available for background estimation. In such cases, consider using a different background estimation method or manually adjusting the mask parameters.
License
This package is provided as-is for SPHEREx data analysis.
Acknowledgments
Based on SPHEREx data from NASA/IPAC Infrared Science Archive (IRSA).
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 spxquery-0.2.0.tar.gz.
File metadata
- Download URL: spxquery-0.2.0.tar.gz
- Upload date:
- Size: 46.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.14.0 Darwin/25.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
559572cbe7d021f6ce12152734ef5478d5eed0e64c8e1949b1ff06e54a6d2fbe
|
|
| MD5 |
92a7553fddc4e354c33d1f6eb2be8d62
|
|
| BLAKE2b-256 |
a61d109d35e0c96b47f4020f1c1c2e079b834edf8d0d57c0c720301e17fdee31
|
File details
Details for the file spxquery-0.2.0-py3-none-any.whl.
File metadata
- Download URL: spxquery-0.2.0-py3-none-any.whl
- Upload date:
- Size: 51.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.14.0 Darwin/25.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
071c2ac2a488e1806559760c2c0a3c2cbdf40d02d8ca565669c639f1930db295
|
|
| MD5 |
8d17afda29fc3f1f5ad024fd4a3ab93b
|
|
| BLAKE2b-256 |
5b9fc883eb61d79d91b018fe7fddf57cd3f7b1a604e5a5c22f03466f7c660e27
|