In [1]:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import seaborn; seaborn.set()
from multiband_LS import LombScargle, SuperSmoother
In [2]:
def plot_width(period_true=0.5, T=1000, N=60, dy=0.01):
rng = np.random.RandomState(0)
omega_true = 2 * np.pi / period_true
width_guess = 2 * np.pi / T
t = T * rng.rand(N)
y = np.sin(omega_true * t) + dy * rng.randn(N)
offset = np.linspace(-4, 4, 100)
sample_offset = 0.25 * (np.random.rand() + np.arange(-10, 10))
samples = omega_true + sample_offset * width_guess
omega_test = omega_true + width_guess * offset
score = LombScargle().fit(t, y, dy).score(2 * np.pi / omega_test)
sample_score = LombScargle().fit(t, y, dy).score(2 * np.pi / samples)
plt.plot(offset, score)
plt.plot(sample_offset, sample_score, 'ok')
In [3]:
from IPython.html.widgets import interact
In [4]:
interact(plot_width, period_true=(0.01, 1.0), T=(1, 2000), N=(10, 100), dy=(0.01, 1.0));
In [5]:
from multiband_LS import LombScargleAstroML
In [13]:
P = 0.6
N = 30
rng = np.random.RandomState(42)
t = rng.randint(0, 100, N) + 0.1 * rng.randn(N)
dy = 0.5
y = dy * np.sin(2 * np.pi * t / P)
model = LombScargle().fit(t, y, dy)
periods = np.linspace(0.2, 1.2, 5000)
scores = model.score(periods)
best_periods, best_scores = model.optimizer.find_best_periods(model, 5, return_scores=True)
plt.plot(periods, scores);
plt.plot(best_periods, best_scores, 'ok')
plt.ylim(0, 1.1);
In [6]: