Skip to main content

Feature extractor from noisy time series

Project description

light-curve processing toolbox for Python

A Python wrapper for the light-curve-feature and light-curve-dmdt Rust crates, providing high-performance time-series feature extraction for astrophysics.

PyPI version Conda Version testing pre-commit.ci status

Full documentation: light-curve.snad.space

Quick start

pip install 'light-curve[full]'
import light_curve as licu
import numpy as np

rng = np.random.default_rng(0)
t = np.sort(rng.uniform(0, 100, 100))
m = 15.0 + 0.01 * t + rng.normal(0, 0.1, 100)
err = np.full(100, 0.1)

# Statistical and variability feature extraction
extractor = licu.Extractor(licu.Amplitude(), licu.BeyondNStd(nstd=1), licu.LinearFit())
result = extractor(t, m, err)
print('\n'.join(f"{name} = {value:.4f}" for name, value in zip(extractor.names, result)))

# Multi-band: per-band features and cross-band color in one Extractor
band = np.tile(["g", "r"], 50)  # 50 interleaved g/r observations
ext_mb = licu.Extractor(licu.WeightedMean(bands=["g", "r"]), licu.ColorOfMedian(["g", "r"]))
result_mb = ext_mb(t, m, err, band=band)
print(dict(zip(ext_mb.names, result_mb)))

# dm-dt map — 2D histogram of Δmag vs log-Δt for CNN classifiers
dmdt = licu.DmDt.from_borders(min_lgdt=0, max_lgdt=2, max_abs_dm=1.0, lgdt_size=16, dm_size=16, norm=[])
matrix = dmdt.points(t, m)
print(f"dm-dt map shape: {matrix.shape}")  # (16, 16)

Embed the light curve with a pretrained Astromer2 transformer (model downloads on first use):

from light_curve.embed import Astromer2
import numpy as np

rng = np.random.default_rng(0)
t = np.sort(rng.uniform(0, 100, 100))
m = 15.0 + 0.01 * t + rng.normal(0, 0.1, 100)

model = Astromer2.from_hf(output="mean")  # cached after first download
embedding = model(t, m).squeeze()  # shape (256,)
print(f"Embedding shape: {embedding.shape}")

The package provides:

  • 40+ feature extractors — amplitude, period, variability indices, parametric fits, and more. See the Features docs for a full list.
  • ML embeddings — embed light curves with pretrained ONNX models (Astromer2, ATCAT). See the Embeddings docs.
  • dm-dt maps — 2D histograms of Δm vs log-Δt for CNN input. See the dm-dt docs.

Installation

pip install 'light-curve[full]'
# or
conda install -c conda-forge light-curve-python

The full extra installs optional Python dependencies required by some features (iminuit, scipy).

Binary wheels are available for Linux (x86-64, aarch64), macOS, and Windows. For the full platform support table and build-from-source instructions, see the Installation docs.

Developer guide

Prepare environment

Install a recent Rust toolchain and Python 3.10+. Use rustup to install Rust and keep it updated with rustup update.

Clone the repository, then create and activate a virtual environment:

git clone https://github.com/light-curve/light-curve-python.git
cd light-curve-python/light-curve
python3 -m venv venv
source venv/bin/activate

Install the package in editable mode:

python -mpip install maturin
maturin develop --group dev

Run this command on initial setup. On subsequent runs, activate the environment with source venv/bin/activate and rebuild Rust code with maturin develop. Python-only changes require no rebuild.

Install pre-commit hooks:

pre-commit install

Run tests

python -mpytest

Benchmarks are disabled by default; enable them with --benchmark-enable.

Citation

If you found this project useful for your research, please cite Malanchev et al., 2021:

@ARTICLE{2021MNRAS.502.5147M,
       author = {{Malanchev}, K.~L. and {Pruzhinskaya}, M.~V. and {Korolev}, V.~S. and {Aleo}, P.~D. and {Kornilov}, M.~V. and {Ishida}, E.~E.~O. and {Krushinsky}, V.~V. and {Mondon}, F. and {Sreejith}, S. and {Volnova}, A.~A. and {Belinski}, A.~A. and {Dodin}, A.~V. and {Tatarnikov}, A.~M. and {Zheltoukhov}, S.~G. and {(The SNAD Team)}},
        title = "{Anomaly detection in the Zwicky Transient Facility DR3}",
      journal = {\mnras},
     keywords = {methods: data analysis, astronomical data bases: miscellaneous, stars: variables: general, Astrophysics - Instrumentation and Methods for Astrophysics, Astrophysics - Solar and Stellar Astrophysics},
         year = 2021,
        month = apr,
       volume = {502},
       number = {4},
        pages = {5147-5175},
          doi = {10.1093/mnras/stab316},
archivePrefix = {arXiv},
       eprint = {2012.01419},
 primaryClass = {astro-ph.IM},
       adsurl = {https://ui.adsabs.harvard.edu/abs/2021MNRAS.502.5147M},
      adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

light_curve-0.13.0.tar.gz (486.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

light_curve-0.13.0-cp310-abi3-win_amd64.whl (6.9 MB view details)

Uploaded CPython 3.10+Windows x86-64

light_curve-0.13.0-cp310-abi3-musllinux_1_2_x86_64.whl (32.4 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ x86-64

light_curve-0.13.0-cp310-abi3-musllinux_1_2_aarch64.whl (8.5 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

light_curve-0.13.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (46.4 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

light_curve-0.13.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl (6.6 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

light_curve-0.13.0-cp310-abi3-macosx_15_0_x86_64.whl (8.1 MB view details)

Uploaded CPython 3.10+macOS 15.0+ x86-64

light_curve-0.13.0-cp310-abi3-macosx_14_0_arm64.whl (6.9 MB view details)

Uploaded CPython 3.10+macOS 14.0+ ARM64

File details

Details for the file light_curve-0.13.0.tar.gz.

File metadata

  • Download URL: light_curve-0.13.0.tar.gz
  • Upload date:
  • Size: 486.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for light_curve-0.13.0.tar.gz
Algorithm Hash digest
SHA256 789e6cdbde3a5bc338348a2d8270a22a716424028d433b8a6d36ef4f4aa7d1dd
MD5 b730d51e4e0b6d2ba3994801ac861c5b
BLAKE2b-256 ef15898b7bd31ad1c4948b76582632dcadbd4f9eff038dc99a637b138abca713

See more details on using hashes here.

File details

Details for the file light_curve-0.13.0-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for light_curve-0.13.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 b718d15535def74ceb789cb42917752bd46294e3000dbf5ed2123587b9133eff
MD5 3319612f9f32d947c4ce794dbd57325c
BLAKE2b-256 05c77e3d37e0eef696f857803cd1d1932fbe18ac1ff8e3d30702d7fa7b1ab1a0

See more details on using hashes here.

File details

Details for the file light_curve-0.13.0-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for light_curve-0.13.0-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 f52790daa204de382ba0cbbcad6c64f246dffab9159e41e1081e968e5333a66c
MD5 0c35eb43136af8549e4e352153b71673
BLAKE2b-256 1cd8e260acd9f364cf1257a92e11066883c013da068de5617a8a1499ae9883b7

See more details on using hashes here.

File details

Details for the file light_curve-0.13.0-cp310-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for light_curve-0.13.0-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 47bed190bb1f7160622f0b04c80462b1116fd72fa8d2b38baf1dc81f03a3cc9f
MD5 fa257d3e1a644b39c222c8c017610de9
BLAKE2b-256 af0006a3505aa65033d437b04c820a6d69dbac275070489831fded88de19f0f7

See more details on using hashes here.

File details

Details for the file light_curve-0.13.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for light_curve-0.13.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 d357e5ac80138e5e4980c49f4f3293c42d85f2c73b5ac5aeffe5ea7c8867b034
MD5 fec17bfdf0fb16438d45e3613f806fdc
BLAKE2b-256 9adcbedac5fcbbbec69d1da0c1e786b5388d9ef6f38423e536b15e78a086b490

See more details on using hashes here.

File details

Details for the file light_curve-0.13.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl.

File metadata

File hashes

Hashes for light_curve-0.13.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 30b165241ddf622871c146b5f74016c3b4ca98f051e1345b8fb75e5cb07d18d2
MD5 e3648bc2948b46443747f09bd044fdfa
BLAKE2b-256 52d8096a4caa2d718d3c509e13242865cfb3d81877e7e970d32e0eef8b5ed0e3

See more details on using hashes here.

File details

Details for the file light_curve-0.13.0-cp310-abi3-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for light_curve-0.13.0-cp310-abi3-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 d1176dc06a87467938613aae36f106adcdfea0c78b6c006ddf68d1359d4a29f4
MD5 3685ac976d814790eb3c6d88b317770b
BLAKE2b-256 75b334c53fe44f89aa3382c3062cd2216789faf2af98c1947a19f9af9b623901

See more details on using hashes here.

File details

Details for the file light_curve-0.13.0-cp310-abi3-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for light_curve-0.13.0-cp310-abi3-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 a4fb02000fe20428d84e24c61531c307f62b711b6b9167267ee76e0545e55f1b
MD5 e4f985c2ccd9e6f35b41605216b8f625
BLAKE2b-256 b4e858ae0faee79742fefea1e005192e4df1e52a788d0e9e12167f35cfdfec03

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page