def dataWindow(x, f, max_period):
'''
Computes a data window of the dataset. That is, a periodogram with
the all of the RV values and variances set to 1.
Parameters
----------
x : list
The times at which the data points were gathered.
f : float
The number of samples to take over the interval.
max_period : float
The maximum of the interval of periods to check.
Returns
-------
periods : array_like[len(f)]
Equally spaced array of possible period values.
powers : array_like[len(f)]
The calculated Power values over the range of periods,
these form the normalized Lomb-Scargle Periodogram.
'''
from scipy.signal import lombscargle
# Sort the time data chronologically.
x = np.sort(np.array(x))
delta_x = np.inf
# Iteratively lower the measure delta_x
for i in range(0, len(x)-2):
if x[i+1]-x[i] < delta_x and x[i+1]-x[i] != 0:
delta_x = x[i+1]-x[i]
periods = np.linspace(delta_x, max_period, num = f)
ang_freqs = 2 * pi / periods
powers = lombscargle(x, np.ones(len(x)), ang_freqs)
powers *= 2 / len(x)
return periods, powers
评论列表
文章目录