Skip to main content

Feature extractor from noisy time series

Project description

light-curve processing toolbox for Python

The Python wrapper for Rust light-curve-feature and light-curve-dmdt packages which gives a collection of high-performant time-series feature extractors.

PyPI version testing publishing pre-commit.ci status

Installation

python3 -mpip install light-curve

Minimum supported Python version is 3.6. The package is tested on Linux (x86-64, aarch64, ppc64) and macOS (x86-64). Pre-built wheels for these platforms are available on pypi.org, other systems are required to have GNU scientific library (GSL) v2.1+ and the Rust toolchain v1.56+ to build and install the package. You can use rustup script to get the most recent Rust toolchain.

Also could find light-curve-python package which is just an "alias" to the main light-curve package.

Feature evaluators

Most of the classes implement various feature evaluators useful for light-curve based astrophysical source classification and characterisation.

import light_curve as lc
import numpy as np

# Time values can be non-evenly separated but must be an ascending array
n = 101
t = np.linspace(0.0, 1.0, n)
perfect_m = 1e3 * t + 1e2
err = np.sqrt(perfect_m)
m = perfect_m + np.random.normal(0, err)

# Half-amplitude of magnitude
amplitude = lc.Amplitude()
# Fraction of points beyond standard deviations from mean
beyond_std = lc.BeyondNStd(nstd=1)
# Slope, its error and reduced chi^2 of linear fit
linear_fit = lc.LinearFit()
# Feature extractor, it will evaluate all features in more efficient way
extractor = lc.Extractor(amplitude, beyond_std, linear_fit)

# Array with all 5 extracted features
result = extractor(t, m, err, sorted=True, check=False)

print('\n'.join(f"{name} = {value:.2f}" for name, value in zip(extractor.names, result)))

# Run in parallel for multiple light curves:
results = amplitude.many(
    [(t[:i], m[:i], err[:i]) for i in range(n // 2, n)],
    n_jobs=-1,
    sorted=True,
    check=False,
)
print("Amplitude of amplitude is {:.2f}".format(np.ptp(results)))

If you confident in your inputs you could use sorted = True (t is in ascending order) and check = False (no NaNs in inputs, no infs in t or m) for better performance. Note that if your inputs are not valid and are not validated by sorted=None and check=True (default values) then all kind of bad things could happen.

Print feature classes list

import light_curve as lc

print([x for x in dir(lc) if hasattr(getattr(lc, x), "names")])

Read feature docs

import light_curve as lc

help(lc.BazinFit)

Experimental extractors

From the technical point of view the package consists of two parts: a wrapper for light-curve-feature Rust crate (light_curve_ext sub-package) and pure Python sub-package light_curve_py. We use the Python implementation of feature extractors to test Rust implementation and to implement new experimental extractors. Please note, that the Python implementation is much slower for the most of the extractors and doesn't provide the same functionality as the Rust implementation. However, the Python implementation provides some new feature extractors you can find useful.

You can manually use extractors from both implementations:

import numpy as np
from numpy.testing import assert_allclose
from light_curve.light_curve_ext import LinearTrend as RustLinearTrend
from light_curve.light_curve_py import LinearTrend as PythonLinearTrend

rust_fe = RustLinearTrend()
py_fe = PythonLinearTrend()

n = 100
t = np.sort(np.random.normal(size=n))
m = 3.14 * t - 2.16 + np.random.normal(size=n)

assert_allclose(rust_fe(t, m), py_fe(t, m),
                err_msg="Python and Rust implementations must provide the same result")

This should print a warning about experimental status of the Python class

dm-dt map

Class DmDt provides dm–dt mapper (based on Mahabal et al. 2011, Soraisam et al. 2020). It is a Python wrapper for light-curve-dmdt Rust crate.

import numpy as np
from light_curve import DmDt
from numpy.testing import assert_array_equal

dmdt = DmDt.from_borders(min_lgdt=0, max_lgdt=np.log10(3), max_abs_dm=3, lgdt_size=2, dm_size=4, norm=[])

t = np.array([0, 1, 2], dtype=np.float32)
m = np.array([0, 1, 2], dtype=np.float32)

desired = np.array(
    [
        [0, 0, 2, 0],
        [0, 0, 0, 1],
    ]
)
actual = dmdt.points(t, m)

assert_array_equal(actual, desired)

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.5.4.tar.gz (56.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.5.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (24.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

light_curve-0.5.4-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (2.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ppc64le

light_curve-0.5.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

light_curve-0.5.4-cp310-cp310-macosx_10_7_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.10macOS 10.7+ x86-64

light_curve-0.5.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (24.0 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

light_curve-0.5.4-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (2.9 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ppc64le

light_curve-0.5.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.6 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

light_curve-0.5.4-cp39-cp39-macosx_10_7_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.9macOS 10.7+ x86-64

light_curve-0.5.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (24.0 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

light_curve-0.5.4-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (2.9 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ ppc64le

light_curve-0.5.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.6 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ ARM64

light_curve-0.5.4-cp38-cp38-macosx_10_7_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.8macOS 10.7+ x86-64

light_curve-0.5.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (24.0 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

light_curve-0.5.4-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (2.9 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ ppc64le

light_curve-0.5.4-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.6 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ ARM64

light_curve-0.5.4-cp37-cp37m-macosx_10_7_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.7mmacOS 10.7+ x86-64

light_curve-0.5.4-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (24.0 MB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.17+ x86-64

light_curve-0.5.4-cp36-cp36m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (2.9 MB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.17+ ppc64le

light_curve-0.5.4-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.6 MB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.17+ ARM64

light_curve-0.5.4-cp36-cp36m-macosx_10_7_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.6mmacOS 10.7+ x86-64

File details

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

File metadata

  • Download URL: light_curve-0.5.4.tar.gz
  • Upload date:
  • Size: 56.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.12.5

File hashes

Hashes for light_curve-0.5.4.tar.gz
Algorithm Hash digest
SHA256 820d4215abd4f2edf099ff09333b51577e3810d7a75415c113bee7bae36a2912
MD5 e074bd795b9423ad9b37b7fc7ed050b0
BLAKE2b-256 eada943152a9596d7bb80d0aa21372974c0b73431042e7b17fac38afb94f6587

See more details on using hashes here.

File details

Details for the file light_curve-0.5.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for light_curve-0.5.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e9f178ed457a4fecb906d7ee36322a775d388966577ce43d6479676766d7e240
MD5 2037c8b15ce120f6257c17c2df76502a
BLAKE2b-256 609ff493598e8bed15349f56bb08010a664a2c17a07dc8e90a5c7684391fec9b

See more details on using hashes here.

File details

Details for the file light_curve-0.5.4-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for light_curve-0.5.4-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 836bdaec61249ae3cd82b6959aee6713e5f8382cf9fcdbfc99b30eb25203031e
MD5 75b8ad2e70147125ed083dbd18b1bcb5
BLAKE2b-256 d66f3b564f530cc2f85beb254c4dba0bc49a50532108575c3fc3f26aaf0e1cc5

See more details on using hashes here.

File details

Details for the file light_curve-0.5.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for light_curve-0.5.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8dfb6ec0c270808dbc2ef4ed61b51e78ac40a98c07353c7bbd6342b0c0aa4ad6
MD5 c69c875175ce6b6a31365299f3106d50
BLAKE2b-256 8c1cbf5288f8c15a4a7d19e2d557f30943071221de6935ff157f96ebafef45af

See more details on using hashes here.

File details

Details for the file light_curve-0.5.4-cp310-cp310-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for light_curve-0.5.4-cp310-cp310-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 7f4b839e4939dc92277a67cd734cb7ad97c0ba1833067694d00e929b697c80fc
MD5 4fbaebe091d29478b1670374e1a8c98e
BLAKE2b-256 376e2e530ba906d13775f65203f7435584797700da53cb809db98e414864f1e6

See more details on using hashes here.

File details

Details for the file light_curve-0.5.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for light_curve-0.5.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5e3e1fd76ffc81b1da85fea3e3588c1ee56f392a34fca3a9b4614e77e1a8ba59
MD5 d2c22b610a7e16fa6fe4f6aa1d8223ed
BLAKE2b-256 fd4ee3dc04db98f10bd31330d428ba5a21e7678b585495309992cf8c0a9fc273

See more details on using hashes here.

File details

Details for the file light_curve-0.5.4-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for light_curve-0.5.4-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 3b39ccbe5d62dad2cbdf08bec535372707f04fe18c882379ef7a2754b3daf1a7
MD5 3e3a1c5527c2c2b2cc53b31354fe5f22
BLAKE2b-256 be0c741f6e2c078ca15be1caaf07380458d96671f3baae3fe8c4337ae498bca1

See more details on using hashes here.

File details

Details for the file light_curve-0.5.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for light_curve-0.5.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4c471849354b7453ae45bbeefaa9e1d1fee3c2648645cf52429c3a112180d5c9
MD5 d81982c2f48c317ed4851e914cf5335c
BLAKE2b-256 748a4ca4444fcc11c687ad437aeac63d64edb683b90ebecf9a64cc1438b5d0de

See more details on using hashes here.

File details

Details for the file light_curve-0.5.4-cp39-cp39-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for light_curve-0.5.4-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 c6a9cfbe5297a21db67ea78f8eaad7d56078c53f8c5ab8c77136f5dc1a70bf60
MD5 811e8f903e20dbbc45cd590da222a8ec
BLAKE2b-256 26085c414ab440391e65278ff50fefbaaacd8b337d21c959c9128ca856c02423

See more details on using hashes here.

File details

Details for the file light_curve-0.5.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for light_curve-0.5.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a4f4b43deca3171efa98c07b6092c3cd9ae09918cc20078af90a7f1808251a46
MD5 e8f4ee5064effb6a503895b62dedf5b0
BLAKE2b-256 066b4efce36a0f7a7e003dd74c7244c5eba831e4534268cdd25b0f252f821b3f

See more details on using hashes here.

File details

Details for the file light_curve-0.5.4-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for light_curve-0.5.4-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 54899e908b206d52c13edb5b4e5262c5214c9056a1d7e5770da0f2da257af95f
MD5 c8007064298e91951b5502d8f5302c26
BLAKE2b-256 772776c4f07c7a7cfa5568237792aab7e3d72be3662a7cab9db391cddd3d9dd6

See more details on using hashes here.

File details

Details for the file light_curve-0.5.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for light_curve-0.5.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 552b212fe65196b3f9542e50998845793723de49274b5d0ca094a7775d3f8e48
MD5 6531aa9c8140a2cd76143d7afd67d9dc
BLAKE2b-256 20d4d8a2bf7b2d17da5635d386aff9137c6c16da3b6b4fadabd6a4b915a8ffc9

See more details on using hashes here.

File details

Details for the file light_curve-0.5.4-cp38-cp38-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for light_curve-0.5.4-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 f992528b08773fe95a40a2a135c115d5e1cf789a66bc1e4be146eaf0a6472576
MD5 1455c3ed760ff0759b847963b3093b54
BLAKE2b-256 a56bf497b0145a273176fb012d8e5cb1abdacb48e8014a9a9b0146eafd52a7dd

See more details on using hashes here.

File details

Details for the file light_curve-0.5.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for light_curve-0.5.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8b020e9dff783ec48fec454175fa35b4bddbdbe62675a9c6340aed6f010339da
MD5 ddf5f557e82707e0a576a629575965c5
BLAKE2b-256 058838e5579113478809476be38e7e03b16180447940ebbd799edb3e2ec90e79

See more details on using hashes here.

File details

Details for the file light_curve-0.5.4-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for light_curve-0.5.4-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 e048bd55c1a9446c31c037c936edf2f968053ffd04e104308cf0308c164d560e
MD5 f4b1aaa19d3a3fc3fd4e15dfb6bfa73c
BLAKE2b-256 0ee1154487354a86cd042fb3634525d8c030338b584d7ea3e573825568a2a4d2

See more details on using hashes here.

File details

Details for the file light_curve-0.5.4-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for light_curve-0.5.4-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8257bd7afb3c70853c7d024435dbcc1bc5c655aea71ae8966034cbd765c4daab
MD5 a79f63ede0a2e8139c65bf097bbc1161
BLAKE2b-256 131c8855dcb7ef2bc46c0339109629bfbf15c7f1f6d471bff5bb963ec9d755b4

See more details on using hashes here.

File details

Details for the file light_curve-0.5.4-cp37-cp37m-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for light_curve-0.5.4-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 247eac92e955452db49685c6099ac2f890ae61583f4e7438a43875611ae7c2d5
MD5 114f622c15148df793c2f36fb04aa52c
BLAKE2b-256 26c5ad012a4f929352e4deb0a914acb089c258d4f0d51461ba9137a413b0a5ef

See more details on using hashes here.

File details

Details for the file light_curve-0.5.4-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for light_curve-0.5.4-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8521909f5914606fe70ecc1aedf875cf57b43385a87eb9eb0b030773ab997ac3
MD5 7bcc5d704cef570d1ecf4453ae18c5a1
BLAKE2b-256 5a8ed70f05248e6ca6cdb35952dfda2636b6267c96c6d34e596a7df6d0a70630

See more details on using hashes here.

File details

Details for the file light_curve-0.5.4-cp36-cp36m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for light_curve-0.5.4-cp36-cp36m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 730f85f80fee40c0e9a2c452431fdad82974210e8714c43d279197d75bfd5a72
MD5 7ccab016bfa05e7eea408688422812cd
BLAKE2b-256 a69b4417651041287dc05a3edc18f41b3be71a226ed599055b3e706a6b82f7f8

See more details on using hashes here.

File details

Details for the file light_curve-0.5.4-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for light_curve-0.5.4-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 98118942bfeccaf8a2f6b3c3be5b4674d9cfc4cf06a01638c478f9717bc392d8
MD5 d2993a532c97640ebb4b968cb3be2b2d
BLAKE2b-256 2c08796369e4d27e9ccdeb4c6b7d6f0db3976e185a834d4482bada764ff3d471

See more details on using hashes here.

File details

Details for the file light_curve-0.5.4-cp36-cp36m-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for light_curve-0.5.4-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 ac92d5527cbae15beb9c4d44772874276da7714d74e57046dfc68d42f27c9d5c
MD5 1ad48ff6ddcca8e298ca6cec4ff559eb
BLAKE2b-256 a9bd57971253b96db5730c57613b73159b5c9cf9c4d8cf08ea1fd0b35cba6c1d

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