A fast template periodogram

This proceedings contribution presents a novel, non-linear extension to the Lomb-Scargle periodogram that allows periodograms to be generated for arbitrary signal shapes. Such periodograms are already known as “template periodograms” or “periodic matched filters,” but current implementations are computationally inefficient. The “fast template periodogram” presented here improves existing techniques by a factor of ∼a few for small test cases (O(10) observations), and over three orders of magnitude for lightcurves containingO(104) observations. The fast template periodogram scales asymptotically as O(HNf log HNf +HNf ), where H denotes the number of harmonics required to adequately approximate the template and Nf is the number of trial frequencies. Existing implementations scale as O(NobsNf ), where Nobs is the number of observations in the lightcurve. An open source Python implementation is available on GitHub.


Introduction
Template fitting, or periodic matched filtering, is a powerful technique for identifying, classifying, and characterizing periodic variability in noisy time series data.However, template fitting requires several orders of magnitude more computational resources than running a Lomb Scargle periodogram ( [1][2][3][4]) on the same lightcurve, and the computational requirements scale as N obs N f , where N obs is the number of observations in the lightcurve and N f is the number of trial frequencies.
For example, [5] used template fitting to model RR Lyrae in the Pan-STARRS DR1 ( [6]) and found that, for a given completeness, template fitting produced purer samples of RR Lyrae than Lomb-Scargle or multi-term extensions ( [7]).However, [5] found that the computational resources needed to produce template fits (approximately 30 minutes per source per CPU) limited the number of lightcurves for which a full template fit could be performed to O(10 3 ) out of O(10 6 ) Pan-STARRS DR1 lightcurves.
Pan-STARRS lightcurves typically have less than 35 observations in 5 photometric filters (∼ 7 per filter), but many photometric surveys have orders of magnitude more observations -CoRoT ( [8]), SuperWASP ( [9]), HATNet ( [10]), and Kepler ( [11]), for example, have O(10 4 − 10 5 ) observations per lightcurve.Since template fitting scales as O(N 2 obs ), 1 running template periodograms on these surveys currently requires a prohibitively large amount of computational resources.However, if template periodograms were computationally efficient enough to run on entire surveys with O(10 3 − 10 5 ) observations per lightcurve, they would have the potential to be a powerful tool for automated classification.For example, by selecting a group of templates that capture the variety of periodic signals present in astrophysical data, a template periodogram could provide simultaneous detection and (pre-)classification of all lightcurves with higher signal to noise ratio than multi-harmonic periodograms, which are also designed to detect non-sinusoidal signals.
The advantage of templates is that there are only three free parameters (amplitude, phase, and a constant offset), compared to the multi-harmonic periodogram, which has 2H + 1 free parameters, where H is the number of harmonics.Using a collection of templates encodes "domain knowledge" (see, e.g., [13]) into the periodogram, which helps to reduce the parameter space to a set of physically plausible lightcurve shapes.

Extending Lomb-Scargle to arbitrary shapes
The Lomb-Scargle periodogram ( [1][2][3][4]) is also known as least squares spectral analysis.The formulation of the periodogram given in [1] and [2] fits a linear model to time series data D = {t n , y n , σ n |n < N} at a number of trial frequencies ω.The Lomb-Scargle periodogram, is similar to a Fourier intensity for unevenly spaced data.As shown in [2], the periodogram can be derived by minimizing the squared residuals and setting where χ 2 (ω) is the minimum (weighted) sum of squared residuals for a model fit at frequency ω, and χ 2 0 is the weighted sum of squared residuals for a constant fit.There are many extensions to the Lomb-Scargle periodogram that are useful for time domain astronomy.[14] used weighted squared residuals and added a constant offset to ŷ, [7,15] further extended the Lomb-Scargle periodogram for models with more than one harmonic, and recently [12] provided a formalism for applying periodograms to multi-band time series.The multiharmonic periodogram is designed to find non-sinusoidal periodic signals in irregularly spaced time series data.However, as shown in [12], increased flexibility comes at a cost -the noise level of the periodogram relative to the maximum peak height tends to increase as the number of free parameters in the model ŷ increases, and in some cases the best frequency can tend to a harmonic or a subharmonic of the true frequency.
If the signal shape of interest is known a priori and can be expressed as a truncated Fourier series with H harmonics,

Conclusion
Finding non-sinusoidal signals in irregularly spaced astrophysical data is a challenging problem that requires balancing model flexibility against the need to use as few model parameters as possible to minimize the relative noise of the periodogram.Template periodograms, or periodic matched filters, allow for the detection of periodic signals with fixed, arbitrary non-sinusoidal shapes without the increase of periodogram noise inherent in the multiharmonic periodogram presented in [7,15].However, template periodogram implementations to date ( [5,17]) have relied on non-linear optimization at each trial frequency to obtain the optimal amplitude, phase, and offset of the template.Thus, applying template periodograms to large photometric surveys like Pan-STARRS ( [6]) requires prohibitive amounts of computational resources and scale as O(N f N obs ∼ N 2 obs ).However, template periodograms can be made orders of magnitude more computationally efficient.By using the algorithmic shortcuts described here, template periodograms could potentially prove computationally feasible on large photometric surveys with many ( 10 2 ) observations per lightcurve, like CoRoT ( [8]), HATNet ( [10]), and others.An open source implementation of the fast template periodogram is available on GitHub, and improvements to the existing implementation should continue to improve computational efficiency.

Figure 1 .
Figure 1.Timing (left) and accuracy (right) comparisons between the gatspy ([17]) template fitting algorithm and the fast template periodogram.The fast template periodogram improves computational efficiency by a factor of ∼a few for small test cases and this improvement factor grows linearly in O(N f ∼ N obs ).Though the fast template periodogram has O(N f log N f ) asymptotic scaling for a given value of H, the root-finding utilities (which scale as O(N f )) dominate the computational time for all test cases shown here.In most cases, the fast template periodogram finds better template fits than gatspy (points that fall below the dashed line on the right-most figure).