Feature extractor from noisy time series
Project description
light-curve
processing toolbox for Python
This package provides a collection of light curve feature extractions classes.
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 the Rust toolchain to install the package, please get the toolchain using your OS package manager of rustup
script.
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("{} = {:.2f}".format(name, value) 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)
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 Distributions
Hashes for light_curve-0.5.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 499db9a5d831ed3828519811db1dc59033ab96db31e633e9ea84452ab7aea836 |
|
MD5 | ea714d7594450e735ea30b44946f5af5 |
|
BLAKE2b-256 | ca622bf07417a115509aa40cfcf941bad9e76724dafc7112db41ef2380459473 |
Hashes for light_curve-0.5.2-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42ce81d9c4424ae0088740292196c4802ed9444d31b75448c129672a75779f41 |
|
MD5 | 0e0fc2a4951a3eced85992a31ab24e1d |
|
BLAKE2b-256 | be06139023cf48735fd527dbdc552f0f0537006f7c64e15fbe42446cf920bdb1 |
Hashes for light_curve-0.5.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7030864c6701821db0f8579350ac21b95ce84bb652124fc28cd557e3dd3ddadd |
|
MD5 | 33c68d8358eb92c07250e9d52c57d543 |
|
BLAKE2b-256 | 1af642e5d64afe114d7d11d8f3da7b13c89c85e23f2417d980ffd2593d7db81c |
Hashes for light_curve-0.5.2-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cf3738b3e3d425d9d8f3c5b35fc2ce28b6eda2fb7102cf6df4ebe335d987b03 |
|
MD5 | f9320d4586933d008b23913faf708c5e |
|
BLAKE2b-256 | 214752dd6fe6e3fda4b89831809006cd7be9c5a08b5df56c7d82f43ee037e212 |
Hashes for light_curve-0.5.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60bf514957a885f6ca761002769792d349a0fb21d18f3f9caf258cc32677cc21 |
|
MD5 | bb8ff48dc5c8582807c7d1584941dc51 |
|
BLAKE2b-256 | 27a543f2621cdcd2059c2628e306cffdb88ba54bb9975435f613ea540d83ceb0 |
Hashes for light_curve-0.5.2-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ddc44611ffb75d9465fee9cc4225b5356664e2c3de2decdceac5a8404b5d3aee |
|
MD5 | 931d2ca42e7d8809993c5e93067ba7bd |
|
BLAKE2b-256 | 9f26c61021bc32393169c1c010dc719ebb434e3d1eec2d6f5c9a5830a0e46c22 |
Hashes for light_curve-0.5.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35007636bfe664c62a0b362f8c819ea2aea561aca7300628233bdcbe65f55e23 |
|
MD5 | f9bd6ec04966d034edd282118f9ef643 |
|
BLAKE2b-256 | 610fcfe50fab95f4b5b4710fdc03b012522656c864033ec1ae59ad964b300b9a |
Hashes for light_curve-0.5.2-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62ea8a56b827af668ab217caa87cc0c94b89af584158f1292cc0cd085755db79 |
|
MD5 | 5ef4fec29df0a5329fc98fdaec0a1065 |
|
BLAKE2b-256 | 31e823637f52420ef397628f3c0f08dbbca3b348d708f02f4610262b90ee7d66 |
Hashes for light_curve-0.5.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d985bb56be4ca8188fd379db88872f9138becc972956b3db818259555fcabb3c |
|
MD5 | e32cc8974d435431861480fdf2f43bb0 |
|
BLAKE2b-256 | 4fc7ec4134fb0028553e15c3a0b2b6841bdf4cbc29c9c32905ac937b4b563f05 |
Hashes for light_curve-0.5.2-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e326c53119a7275e9f774bd1af06cce9b68423e5b0d70d9fc9934c5203faa484 |
|
MD5 | 1083b7191bf2f9b23f5c60917ada7952 |
|
BLAKE2b-256 | 5954b267e77438cbeb222377cd31972e8f20fe06dbebb08aecd7ef83598af153 |
Hashes for light_curve-0.5.2-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5c84400f9f430d4372540e82926b609b15bd5136fe51545541886f9839d912d |
|
MD5 | 8e742e2f800e7e5a61465c74a5f651c2 |
|
BLAKE2b-256 | 4511eed86142c99de786d55fff73d9b18ce43d930d63c41b0e1ed2de3e9b6df6 |
Hashes for light_curve-0.5.2-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c41a2f62d0bbc2fff026fbe5a189a4728e9132293860bf36af4757953f4fd924 |
|
MD5 | 4bf39245668485f91faf776fb992f209 |
|
BLAKE2b-256 | 111070562f239d2b2518a86eb56e56b8e4e844d47e9637d396ffa0861afc662b |
Hashes for light_curve-0.5.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1c37a3c7b4307a9f28608c12977333195e29abb74aa4cd7afd9414a3f77160b |
|
MD5 | f55a08b0db15fb8d7f979821aac4482e |
|
BLAKE2b-256 | ec721e2776c81af36519e82251050fd241022c76d4f895c101dcc47ac0d3eea2 |
Hashes for light_curve-0.5.2-cp36-cp36m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35604bc222465263e5c14a009e146490835cb5d825ee7714e2f039ac85bc14c0 |
|
MD5 | ad77a082e39192a8e525c7eef0456fe2 |
|
BLAKE2b-256 | 4ef499d6a7213d5d3ce01e8aa5c321c90c70fcb28c543fee45a0a67546d82803 |
Hashes for light_curve-0.5.2-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f564d8c663c5bcf406285ffc15633470df5cf5c2122f0c03142e51f31f18dd6f |
|
MD5 | db8c25506b4206d39b03954b9ca8ef68 |
|
BLAKE2b-256 | fd4ed1e92c09cd5ffe1960242c263dc0620419ea76d0e5fabe5377d4ee2cc387 |
Hashes for light_curve-0.5.2-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62f23bae91c8e681a2f3db08774c04e768bba6dd894f4f9226865aeca81cf032 |
|
MD5 | 4d261dfa72527bc04e63b3b20886c423 |
|
BLAKE2b-256 | e73daa3f90170d8da7f3861891c7f46c67b975ca998a5b17f4dfc7c1de176a1c |