In [1]:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
# use seaborn's default plotting styles for matplotlib
import seaborn; seaborn.set()
The astroML project includes a data fetcher for light curves from the LINEAR survey. We'll use one of the light curves as an example.
In [2]:
from astroML.datasets import fetch_LINEAR_sample
data = fetch_LINEAR_sample()
In [3]:
lcid = 10022663
t, y, dy = data[lcid].T
In [4]:
fig, ax = plt.subplots()
ax.errorbar(t, y, dy, fmt='o');
ax.invert_yaxis()
ax.set_xlabel('MJD')
ax.set_ylabel('magnitude')
ax.set_title('LINEAR object {0}'.format(lcid));
In [5]:
# imports are from up one directory
import sys; import os; sys.path.append(os.path.abspath('..'))
from multiband_LS import SuperSmoother
In [6]:
model = SuperSmoother().fit(t, y, dy)
model.optimizer.period_range = (0.6, 0.65)
print("best period: {0:.4f}".format(model.best_period))
In [7]:
period = np.linspace(model.best_period - 0.005,
model.best_period + 0.005, 500)
P = model.periodogram(period)
plt.plot(period, P)
plt.xlabel('period (days)'); plt.ylabel('Lomb-Scargle Power');
In [8]:
t_fit = np.linspace(0, model.best_period, 500)
plt.errorbar(t % model.best_period, y, dy, fmt='o')
y_fit = model.predict(t_fit)
plt.plot(t_fit, y_fit, '-k')
plt.gca().invert_yaxis()
That's our result.