Skip to content

Meta — Extractor, Bins and Bootstrap

light_curve.Extractor

Combine multiple feature extractors into a single callable.

Pass any number of feature objects; the result behaves like a single feature whose output is the concatenation of all individual outputs. Use :meth:__call__ for a single light curve or :meth:many for batch processing. Especially efficient for cheap features because it avoids repeated passes over the data and reduces Python–Rust call overhead.

Parameters:

Name Type Description Default
*features feature objects

Any mix of Rust-backed or pure-Python feature instances.

required

Attributes:

Name Type Description
names list of str

Concatenated feature names from all sub-features.

descriptions list of str

Concatenated descriptions from all sub-features.

Examples:

>>> import numpy as np
>>> from light_curve import Extractor, Amplitude, StandardDeviation
>>> ext = Extractor(Amplitude(), StandardDeviation())
>>> t = np.array([0.0, 1.0, 2.0, 3.0, 4.0])
>>> m = np.array([15.1, 14.9, 15.2, 15.0, 14.8])
>>> ext(t, m)
array([...])

light_curve.Bins

Bases: _FeatureEvaluator

Sampled time series meta-feature

Binning time series to bins with width \(\mathrm{window}\) with respect to some \(\mathrm{offset}\). \(j-th\) bin interval is \([j \cdot \mathrm{window} + \mathrm{offset}; (j + 1) \cdot \mathrm{window} + \mathrm{offset})\). Binned time series is defined by

\[ t_j^* = (j + \frac12) \cdot \mathrm{window} + \mathrm{offset}, \]
\[ m_j^* = \frac{\sum{m_i / \delta_i^2}}{\sum{\delta_i^{-2}}}, \]
\[ \delta_j^* = \frac{N_j}{\sum{\delta_i^{-2}}}, \]

where \(N_j\) is a number of sampling observations and all sums are over observations inside considering bin. Bins takes any other feature evaluators to extract features from sample time series

  • Depends on: time, magnitude, magnitude error
  • Minimum number of observations: as required by sub-features, but at least 1
  • Number of features: as provided by sub-features

Parameters:

Name Type Description Default
features iterable

Features to extract from binned time-series

required
window positive float

Width of binning interval in units of time

required
offset float

Zero time moment

required
transform None

Not supported, apply transformations to individual features

None
bands list of str or None

Passband names for multiband mode. If given, each single-band feature in features is evaluated independently per passband; multiband features (e.g. color features) are passed through unchanged.

required

Attributes:

Name Type Description
names list of str

Feature names

descriptions list of str

Feature descriptions

bands numpy.ndarray of str or None

Passband names for multiband mode, or None for single-band mode

Methods:

Name Description
__call__

Extract features and return them as a numpy array

many

Extract features from multiple light curves in parallel


light_curve.Bootstrap

Bases: _FeatureEvaluator

Bootstrap uncertainty meta-feature

Estimates the uncertainty of feature values by bagging: it draws n_bootstrap resamples of the light curve, sampling observations with replacement and keeping the original length, and evaluates the wrapped features on each resample. For every wrapped feature value it returns the value on the original light curve, followed by a summary of that value's spread over the resamples — either the sample standard deviation, or the levels given by quantiles.

In single-band mode all n_bootstrap resamples are always evaluated, so the uncertainty is always defined. In multiband mode the 'rejection' strategy may collect too few valid resamples, in which case the feature fails and fill_value applies as it does to any other feature.

Features that cannot be evaluated on a resample are rejected with ValueError:

  • features requiring sorting — bagging duplicates observations, which divides by a zero time interval for features that also read time and, even where time is not read, biases statistics built from consecutive differences, since duplicated points sort adjacent and contribute spurious zero-difference terms,
  • features requiring variability — a resample may be constant.

  • Depends on: as required by sub-features

  • Minimum number of observations: as required by sub-features, but at least 1
  • Number of features: (1 + n_uncertainty) per sub-feature value, where n_uncertainty is 1 for the standard deviation, or the number of quantile levels

Parameters:

Name Type Description Default
features iterable

Features to estimate the bootstrap uncertainty of. Features requiring sorting or variability are rejected: bagging duplicates observations, and a resample may turn out constant

required
n_bootstrap int

Number of resamples to draw, at least 2

100
seed int

Seed of the random number generator drawing the resamples, which makes the output reproducible

0
quantiles sequence of float or None

Quantile levels in [0, 1] to summarise the spread of each feature over the resamples, e.g. [0.16, 0.84] for a 1-sigma-like interval. If None, the sample standard deviation is used instead

None
transform None

Not supported, apply transformations to individual features

None
bands list of str or None

Passband names for multiband mode. If given, each single-band feature in features is evaluated independently per passband; multiband features (e.g. color features) are passed through unchanged

required
band_strategy str

How the multiband light curve is resampled, ignored unless bands is given. The two strategies answer different questions and can give noticeably different uncertainties on unevenly sampled data:

  • 'stratified': resample each passband on its own, drawing exactly as many observations as that passband started with. This conditions on the per-band sample sizes, so the uncertainty leaves out the variance coming from how observations happened to be split between bands. Every resample keeps every passband at its original length, so none can fall below what the wrapped features need and none is ever rejected. Use it when the per-band cadence is a fixed property of the survey rather than a random outcome,
  • 'rejection': the classical i.i.d. bootstrap — resample all observations jointly, ignoring which band they came from. Per-band counts then vary between resamples, so the uncertainty also covers the allocation of observations across bands, but a resample can leave a passband with too few points for the wrapped features. Those resamples are thrown away and redrawn, within the budget set by max_attempts_factor. Use it when you want the uncertainty of the light curve as a whole; be wary of it when some band has few observations, as most resamples may be rejected
'stratified'
max_attempts_factor int

Bounds the redrawing budget of the 'rejection' strategy at n_bootstrap * max_attempts_factor total draws. Ignored by 'stratified'

100

Attributes:

Name Type Description
names list of str

Feature names

descriptions list of str

Feature descriptions

bands numpy.ndarray of str or None

Passband names for multiband mode, or None for single-band mode

Methods:

Name Description
__call__

Extract features and return them as a numpy array

many

Extract features from multiple light curves in parallel