In [13]:
import numpy as np
import matplotlib.pyplot as plt

A = 10
nu = 2
phi = 0.5*np.pi

xi = np.linspace(0, 10, 1000)
yi = A*np.sin(2.0*np.pi*nu*xi + phi)

plt.figure()
plt.plot(xi, yi)

from scipy.interpolate import interp1d

f = interp1d(xi, yi)

N = 5000
T = 1.0/500.0

x = np.linspace(0, N*T, N)
y = f(x)

from scipy.fftpack import fft

yf = fft(y)
xf = np.linspace(0.0, 1.0/(2.0*T), N/2)

plt.figure()
plt.plot(xf, 2.0/N * np.abs(yf[0:N/2]))
plt.grid()
plt.xlim([0, 5])

from scipy.signal import lombscargle

normval = x.shape[0]

freqs = np.linspace(1e-6, 20, 1000)
pgram = lombscargle(x, y, freqs)

plt.figure()
plt.plot(freqs, np.sqrt(4*(pgram/normval)))


Out[13]:
[<matplotlib.lines.Line2D at 0x10d8a3350>]

In [ ]: