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 (AstraCLR, Astromer2, ATAT, 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.1.tar.gz (498.5 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.1-cp310-abi3-win_amd64.whl (6.9 MB view details)

Uploaded CPython 3.10+Windows x86-64

light_curve-0.13.1-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.1-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.1-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.1-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.1-cp310-abi3-macosx_15_0_x86_64.whl (8.2 MB view details)

Uploaded CPython 3.10+macOS 15.0+ x86-64

light_curve-0.13.1-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.1.tar.gz.

File metadata

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

File hashes

Hashes for light_curve-0.13.1.tar.gz
Algorithm Hash digest
SHA256 6fd0d870fa046304d0c76e20fd02a4896e45306dd3681690b5974909f516c8ba
MD5 3f45f3555e7abea3fb58cb3ef5068e8d
BLAKE2b-256 b02072d914b5ef75a299c68e8b4b296c3342a4caf32a3b3cdfdc7eab4f3ca429

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_curve-0.13.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9ecae8f34b0e76d7edbc41152eee133e90246340f522e154af8572fbd72ce4b7
MD5 7af92810259333ec4a378400b4b2e584
BLAKE2b-256 e70dd5188dcaf979409ed404c53b9e99b58b1b185e7f8556523a59788b77a40a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_curve-0.13.1-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 ca485de3ac785615b4622febeb91cd84c2affbaceb3272b3227628db7c59739f
MD5 419b215ebb91b3615b962380a8ea6037
BLAKE2b-256 5f1c6f3900cfefe1fbb5b251b56a9b78b9feccb24a7416140b1cf2280a3e63cf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_curve-0.13.1-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 d771bd51b30e841e9491f8cde42d88beccecdb5d8bf709a590b7c37fe7b0b869
MD5 cca2e467bfa9d4c8b9655fa349b824e8
BLAKE2b-256 d866459ae7c1d8831b88842afd3eb74739d9be22a52be488d680b3850a0805d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_curve-0.13.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 2c4a49753d4cd01ada7eb9175b9d961498915b2bb3328068320817789db203c2
MD5 f4bc6222e94cffb5498969fcc55fcee0
BLAKE2b-256 ad16766abe312cff42012bdc6f69406da8fe7f70d9b7077134ef949cb8253ad9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_curve-0.13.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 3c0311f7697446170c640451c1e8a9ab471975d5b60061afd356e30b36cba2c8
MD5 75e63c7bef52825b401deab65b1228d1
BLAKE2b-256 855f29346cb944a9066c30a49e54e12979b42efe8902eb44eac650847192362e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_curve-0.13.1-cp310-abi3-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 53c40e7f29d3beac7bc798ab2c313014e193065f4db76c20a0fb2f534f7c25fb
MD5 25766394a69b24c0eac9ff193a89fb83
BLAKE2b-256 7348c70bc8917766d27843f57dbbbf267a1e9b4ff59f6f80e5ad83b4f4c04c2d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_curve-0.13.1-cp310-abi3-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 76074ef46ebd026c42fbaf07047ec6f12930c4ccf01759890612b07ff616a09d
MD5 e01c2d82e5e8979492e2fb035c92d2d4
BLAKE2b-256 3cd15aac15374c49e9a62b303f84adb6fd0585f473498dc39d5ce6a2b8234d1b

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