In [1]:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import seaborn; seaborn.set()
In [2]:
from multiband_LS.data import fetch_light_curves
In [3]:
rrlyrae = fetch_light_curves(partial=True)
In [4]:
ids = list(rrlyrae.ids)
lcid = ids[1]
In [5]:
t, y, dy, filts = rrlyrae.get_lightcurve(lcid)
In [6]:
for filt in 'ugriz':
mask = (filts == filt)
plt.errorbar(t[mask] % rrlyrae.get_metadata(lcid)['P'], y[mask], dy[mask], fmt='o')
In [7]:
from multiband_LS import LombScargleMultiband, SuperSmoother
In [10]:
class SuperSmoother1Band(SuperSmoother):
"""Convenience class to fit a single band of data with supersmoother"""
def __init__(self, optimizer=None, band='g'):
self.band = band
SuperSmoother.__init__(self, optimizer)
def _fit(self, t, y, dy, filts):
mask = (filts == self.band)
self.t, self.y, self.dy = t[mask], y[mask], dy[mask]
self.filts = None
return SuperSmoother._fit(self, self.t, self.y, self.dy, self.filts)
In [17]:
def do_plot(i=0):
lcid = ids[i]
t, y, dy, filts = rrlyrae.get_lightcurve(lcid)
periods = np.linspace(0.2, 1.2, 10000)
fig = plt.figure(figsize=(12, 4))
gs = plt.GridSpec(2, 2)
ax = [fig.add_subplot(gs[:, 0]),
fig.add_subplot(gs[0, 1]),
fig.add_subplot(gs[1, 1])]
for filt in 'ugriz':
mask = (filts == filt)
ax[0].errorbar(t[mask] % rrlyrae.get_metadata(lcid)['P'], y[mask], dy[mask], fmt='o')
#model = SuperSmoother()
#mask = (filts == 'g')
#model.fit(t[mask], y[mask], dy[mask])
model = SuperSmoother1Band(band='g')
model.fit(t, y, dy, filts)
ax[1].plot(periods, model.score(periods), lw=1)
ax[1].set_ylim(0, 1)
print("total observations: {0}".format(len(t)))
print("g-band observations: {0}".format(mask.sum()))
model = LombScargleMultiband(Nterms_base=1, Nterms_band=0)
model.fit(t, y, dy, filts)
ax[2].plot(periods, model.score(periods), lw=1)
ax[2].set_ylim(0, 1)
#P_best, scores = model.find_best_periods(5, True)
#ax[2].plot(P_best, scores, '.k')
print(rrlyrae.get_metadata(lcid)['P'])
In [18]:
do_plot(2)
In [16]:
do_plot(2)
In [ ]: