gammapy.time.robust_periodogram(time, flux, flux_err=None, periods=None, loss='linear', scale=1)[source]

Compute a light curve’s period.

A single harmonic model is fitted to the light curve. The periodogram returns the power for each period. The maximum power indicates the period of the light curve, assuming an underlying periodic process.

The fitting can be done by ordinary least square regression (Lomb-Scargle periodogram) or robust regression. For robust regression, the scipy object least_squares is called. For an introduction to robust regression techniques and loss functions, see [1] and [2].

The significance of a periodogram peak can be evaluated in terms of a false alarm probability. It can be computed with the false_alarm_probability-method of astropy, assuming Gaussian white noise light curves. For an introduction to the false alarm probability of periodogram peaks, see Lomb-Scargle Periodograms.

The periodogram is biased by measurement errors, high order modes and sampling of the light curve. To evaluate the impact of the sampling, compute the spectral window function with the astropy.stats.LombScargle-class.

The function returns a dictionary with the following content:

  • periods (numpy.ndarray) – Period grid in units of t
  • power (numpy.ndarray) – Periodogram peaks at periods of pgrid
  • best_period (float) – Period of the highest periodogram peak
time : numpy.ndarray

Time array of the light curve

flux : numpy.ndarray

Flux array of the light curve

flux_err : numpy.ndarray

Flux error array of the light curve. Default is 1.

periods : numpy.ndarray

Period grid on which the periodogram is performed. If not given, a linear grid will be computed limited by the length of the light curve and the Nyquist frequency.

loss : {‘linear’, ‘soft_l1’, ‘huber’, ‘cauchy’, ‘arctan’}

Loss function for the robust regression. Default is ‘linear’, resulting in the Lomb-Scargle periodogram.

scale : float (optional, default=1)

Loss scale parameter to define margin between inlier and outlier residuals. If not given, will be set to 1.

results : OrderedDict

Results dictionary (see description above).


[1]Nikolay Mayorov (2015), “Robust nonlinear regression in scipy”, see here
[2]Thieler et at. (2016), “RobPer: An R Package to Calculate Periodograms for Light Curves Based on Robust Regression”, see here