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 lc
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 = lc.Extractor(lc.Amplitude(), lc.BeyondNStd(nstd=1), lc.LinearFit())
result = extractor(t, m, err)
print('\n'.join(f"{name} = {value:.4f}" for name, value in zip(extractor.names, result)))

# dm-dt map — 2D histogram of Δmag vs log-Δt for CNN classifiers
dmdt = lc.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.12.5.tar.gz (449.1 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.12.5-cp310-abi3-win_amd64.whl (6.3 MB view details)

Uploaded CPython 3.10+Windows x86-64

light_curve-0.12.5-cp310-abi3-musllinux_1_2_x86_64.whl (31.8 MB view details)

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

light_curve-0.12.5-cp310-abi3-musllinux_1_2_aarch64.whl (8.0 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

light_curve-0.12.5-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (45.8 MB view details)

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

light_curve-0.12.5-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl (6.1 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

light_curve-0.12.5-cp310-abi3-macosx_15_0_x86_64.whl (7.6 MB view details)

Uploaded CPython 3.10+macOS 15.0+ x86-64

light_curve-0.12.5-cp310-abi3-macosx_14_0_arm64.whl (6.4 MB view details)

Uploaded CPython 3.10+macOS 14.0+ ARM64

File details

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

File metadata

  • Download URL: light_curve-0.12.5.tar.gz
  • Upload date:
  • Size: 449.1 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.12.5.tar.gz
Algorithm Hash digest
SHA256 8bbece679e6e8c1fe41aa07d71461aab75eb18d50aeef80446b5ac9ec680cf72
MD5 701864dd084d46c768b774210bcdb447
BLAKE2b-256 603297df1cdc352cad8d603ab81da41e8fa22c81a41031a92dde939c09651fa7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_curve-0.12.5-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 bbbe4b95b45e8d78de23225b55b1b6244503b5ddf3c6eb4f5664f8650c46e416
MD5 e2005068b008fd18d8dfe7b1f1b19d45
BLAKE2b-256 f58a7af7b5db45a6de3e452d5ea359ae41f0ccea72d4992fe594ab4d14ec55ac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_curve-0.12.5-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 f71e55f2ccf1e7430e69bde52a5dd471d67d5d69e32e29f8084e32d4db7225f0
MD5 1a702a0e55654e515d7afa3b6a39722d
BLAKE2b-256 f48611b2c7b6d0fd40755f978427d8d7318ae726cf4612f81f8e5375fea5b546

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_curve-0.12.5-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 d363bd5494bb89d1e00b31dcb6d26b41d3828d1929fcb07e2719640e7206df86
MD5 48607d628f119b6ac8f67f8215ca2e95
BLAKE2b-256 95a054c5426b5c22bf8cfc9891d7ea76532afde3645f3a9d1eb0b2afdde23a07

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_curve-0.12.5-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 7ce44f8ccbf564101cf06b367e3d9bdbafda9a425e4c131c882da8f11c01591e
MD5 35cd0952bd871a276991bccdf3529384
BLAKE2b-256 35afe3f12f11a5af2876b8e82c5391b5ef41ef73faf7566e563ca593bae91542

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_curve-0.12.5-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 9b74a14c66d3eefe6f08ac007738a4e7034574a87351ec5057322af9df9bc477
MD5 f17273068481bc312010f79eeece5776
BLAKE2b-256 ba31c83e094bf0bbcda593655ba2ee7c31891d151ce619d2101d8dcc1e88aae7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_curve-0.12.5-cp310-abi3-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 377e57c7b182ccc3d5ceecfd499e1fc6efdb0a2b664dce3b3af92a397df37805
MD5 30b599b684a50f1640a055661b44d69c
BLAKE2b-256 90160f251eca907fde328045f76849ebf77f962e08bb07d41a5e5b3970089c0f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_curve-0.12.5-cp310-abi3-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 5482dcd619375590e099c6fd4aa664eb453bd44653dc50802cffc612179157f4
MD5 9836a8154d786c76fcecf79b1f11460f
BLAKE2b-256 34028c99545d706ee1e173fa9b9658072b4412cf82c4fe6f6737c7c5c2869350

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