Skip to content

Periodogram

light_curve.Periodogram

Bases: _FeatureEvaluator

Peaks of Lomb–Scargle periodogram and periodogram as a meta-feature

Periodogram \(P(\omega)\) is an estimate of spectral density of unevenly time series. peaks argument corresponds to a number of the most significant spectral density peaks to return. For each peak its period and "signal to noise" ratio is returned:

\[ \mathrm{signal~to~noise~of~peak} \equiv \frac{P(\omega_\mathrm{peak}) - \langle P(\omega) \rangle}{\sigma\_{P(\omega)}}. \]

[Periodogram] can accept other features for feature extraction from periodogram as it was time series without observation errors (unity weights are used if required). You can even pass one [Periodogram] to another one if you are crazy enough.

Additionally, [Periodogram] supports phase features: features extracted from the light curve phase-folded at the best period. The phase runs from 0 to 1, with phase 0 at the magnitude minimum. Phase feature names are prefixed with period_folded_.

  • Depends on: time, magnitude
  • Minimum number of observations: as required by sub-features, but at least two
  • Number of features: \(2 \times \mathrm{peaks}\) plus spectrum sub-features plus phase sub-features

Parameters:

Name Type Description Default
peaks int or None

Number of peaks to find

1
resolution float or None

Resolution of frequency grid

10
max_freq_factor float or None

Mulitplier for Nyquist frequency

1
nyquist str or float or None

Type of Nyquist frequency. Could be one of:

  • 'average': "Average" Nyquist frequency
  • 'median': Nyquist frequency is defined by median time interval between observations
  • float: Nyquist frequency is defined by given quantile of time intervals between observations
'average'
freqs array - like or None

Explicit and fixed frequency grid (angular frequency, radians/time unit). If given, resolution, max_freq_factor and nyquist are ignored. For fast=True the only supported type of the grid is np.linspace(0.0, max_freq, 2**k+1), where k is an integer. For fast=False any grid is accepted, but linear grids apply some computational optimisations.

None
fast bool or None

Use "Fast" (approximate and FFT-based) or direct periodogram algorithm

True
features iterable or None

Features extracted from the periodogram power spectrum, treating it as a time-series (frequency as time, power as magnitude). None means no additional spectrum features.

None
phase_features iterable or None

Features to extract from the light curve phase-folded at the best period. Phase runs from 0 to 1 with phase 0 at the magnitude minimum. Feature names are prefixed with period_folded_. None means no phase features.

None
normalization str

Normalization of the periodogram power. Affects power(), freq_power(), and feature extraction via __call__(). Let P be the raw power and n the number of observations. Must be one of:

  • 'psd': Raw power P, unnormalized. Consistent with scipy.signal.lombscargle(normalize=False) on variance-normalized data, but differs from astropy's 'psd' convention
  • 'standard': P_std = P * 2 / (n - 1), values in [0, 1]. Matches astropy's 'standard' normalization
  • 'model': P_std / (1 - P_std), values in [0, inf). Matches astropy's 'model' normalization
  • 'log': -ln(1 - P_std), values in [0, inf). Matches astropy's 'log' normalization
'psd'
transform None

Not supported for Periodogram. Peaks are not transformed, but you may apply transformation for the underlying features via their constructors

None
bands list of str or None

Passband names for multiband mode. If provided, a multiband periodogram is evaluated across all passbands simultaneously using a joint frequency grid.

required
multiband_normalization str

How per-band power spectra are combined into the joint spectrum. Only used when bands is given. Must be one of:

  • 'chi2' (default): each band is weighted by sum((m - m_mean)^2 / sigma^2). sigma is optional; unity weights are used when absent, which differs from 'count' normalization and may not be meaningful.
  • 'count': weight each passband by observation count, ignoring sigma
'chi2'

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

freq_power(t, m, sigma=None, band=None, *, cast=False)

Get periodogram as a pair of frequencies and power values.

In single-band mode (bands not set at construction) only t and m are accepted.

In multiband mode (bands set at construction) band is required. sigma is optional but recommended: it is used to weight each band by its chi-squared statistic when multiband_normalization='chi2' (the default); unity weights are assumed when omitted.

Parameters

t : np.ndarray of np.float32 or np.float64 Time array

m : np.ndarray of np.float32 or np.float64 Magnitude (flux) array

sigma : np.ndarray of np.float32 or np.float64, optional Photometric uncertainties. Used only for chi2-based band combination: each band is weighted by sum((m - m_mean)^2 / sigma^2). Unity weights are assumed when omitted, which changes the band weights but does not affect the per-observation Lomb-Scargle power computation. Ignored in single-band mode.

band : array-like of str, required in multiband mode Passband label for each observation. Must be one of the bands given at construction.

cast : bool, optional Cast inputs to np.ndarray objects of the same dtype

Returns

freq : np.ndarray of np.float32 or np.float64 Frequency grid

power : np.ndarray of np.float32 or np.float64 Periodogram power (combined across bands in multiband mode)

power(t, m, *, cast=False)

Get periodogram power

Parameters

t : np.ndarray of np.float32 or np.float64 Time array

m : np.ndarray of np.float32 or np.float64 Magnitude (flux) array

cast : bool, optional Cast inputs to np.ndarray objects of the same dtype

Returns

power : np.ndarray of np.float32 or np.float64 Periodogram power

Examples:

>>> import numpy as np
>>> from light_curve import Periodogram
>>> periodogram = Periodogram(peaks=2, resolution=20.0, max_freq_factor=2.0,
...                           nyquist='average', fast=True)
>>> t = np.linspace(0, 10, 101)
>>> m = np.sin(2*np.pi * t / 0.7) + 0.5 * np.cos(2*np.pi * t / 3.3)
>>> peaks = periodogram(t, m, sorted=True)[::2]
>>> frequency, power = periodogram.freq_power(t, m)