Beispiel #1
0
#id, period = 11375941, 58.4
id, period = 18525697, 17.05

data = fetch_LINEAR_sample()
t, y, dy = data[id].T

#omega, power = search_frequencies(t, y, dy)
#period = omega[np.argmax(power)]
#print period
#exit()

omega = np.linspace(period, period + 0.1, 1000)
ax = plt.subplot(211)
for n_terms in [1, 2, 3]:
    P1 = multiterm_periodogram(t, y, dy, omega, n_terms=n_terms)
    plt.plot(omega, P1, lw=1, label='m = %i' % n_terms)
plt.legend(loc=2)
plt.xlim(period, period + 0.1)
plt.ylim(0, 1.0)
plt.ylabel('$1 - \chi^2(\omega) / \chi^2_{ref}$')

plt.subplot(212, sharex=ax)
for generalized in [True, False]:
    if generalized:
        label = 'generalized LS'
    else:
        label = 'standard LS'
    P2 = lomb_scargle(t, y, dy, omega, generalized=generalized)
    plt.plot(omega, P2, lw=1, label=label)
plt.legend(loc=2)
Beispiel #2
0
t, y, dy = data[14752041].T
omega0 = 17.217

# focus only on the region with the peak
omega1 = np.linspace(17.213, 17.220, 100)
omega2 = 0.5 * omega1

#------------------------------------------------------------
# Compute the delta BIC
terms = np.arange(1, 21)
BIC_max = np.zeros((2, len(terms)))

for i, omega in enumerate([omega1, omega2]):
    for j in range(len(terms)):
        P = multiterm_periodogram(t, y, dy, omega, terms[j])
        BIC = lomb_scargle_BIC(P, y, dy, n_harmonics=terms[j])
        BIC_max[i, j] = BIC.max()

#----------------------------------------------------------------------
# Plot the results
fig = plt.figure(figsize=(5, 3.75))

ax = [
    fig.add_axes((0.15, 0.53, 0.8, 0.37)),
    fig.add_axes((0.15, 0.1, 0.8, 0.37))
]
ax_inset = [
    fig.add_axes((0.15 + 7 * 0.04, 0.55, 0.79 - 7 * 0.04, 0.17)),
    fig.add_axes((0.15 + 7 * 0.04, 0.12, 0.79 - 7 * 0.04, 0.17))
]
Beispiel #3
0
t -= 0.4 * np.pi / omega0

width = 0.03
omega = np.linspace(omega0 - width, omega0 + width, 1000)

#------------------------------------------------------------
# Compute periodograms and best-fit solutions
#  factor gives the factor that we're dividing the fundamental frequency by
factors = [1, 2]
nterms = [1, 6]

# Compute PSDs for factors & nterms
PSDs = dict()
for f in factors:
    for n in nterms:
        PSDs[(f, n)] = multiterm_periodogram(t, y, dy, omega / f, n)

# Compute the best-fit omega from the 6-term fit
omega_best = dict()
for f in factors:
    omegaf = omega / f
    PSDf = PSDs[(f, 6)]
    omega_best[f] = omegaf[np.argmax(PSDf)]

# Compute the best-fit solution based on the fundamental frequency
best_fit = dict()
for f in factors:
    for n in nterms:
        mtf = MultiTermFit(omega_best[f], n)
        mtf.fit(t, y, dy)
        phase_best, y_best = mtf.predict(1000, adjust_offset=False)
Beispiel #4
0
import numpy as np
from astroML.datasets import fetch_LINEAR_sample
from astroML.time_series import multiterm_periodogram, MultiTermFit

from bombscargle.bombscargle import (MultiTermFit, MultiTermFitMCMC,
                                     MultiTermMixtureFitFull,
                                     MultiTermMixtureFit)

import matplotlib.pyplot as plt


data = fetch_LINEAR_sample()
t, y, dy = data[1004849].T

omega = np.linspace(13.4, 14, 10000)
PSD = multiterm_periodogram(t, y, dy, omega, 6)
#plt.plot(omega, PSD)
#plt.show()
#exit()
omega_best = omega[np.argmax(PSD)]
print omega_best

models = [MultiTermFit(omega_best, 6),
          MultiTermFitMCMC(omega_best, 6),
          MultiTermMixtureFitFull(omega_best, 6)
]

for model in models:
    model = model.fit(t, y, dy)
    print model.w_
    phase_fit, y_fit, phased_t = model.predict(1000, return_phased_times=True)
Beispiel #5
0
t, y, dy = data[14752041].T
omega0 = 17.217

# focus only on the region with the peak
omega1 = np.linspace(17.213, 17.220, 100)
omega2 = 0.5 * omega1

#------------------------------------------------------------
# Compute the delta BIC
terms = np.arange(1, 21)
BIC_max = np.zeros((2, len(terms)))

for i, omega in enumerate([omega1, omega2]):
    for j in range(len(terms)):
        P = multiterm_periodogram(t, y, dy, omega, terms[j])
        BIC = lomb_scargle_BIC(P, y, dy, n_harmonics=terms[j])
        BIC_max[i, j] = BIC.max()

#----------------------------------------------------------------------
# Plot the results
fig = plt.figure()

ax = [fig.add_axes((0.15, 0.53, 0.8, 0.37)),
      fig.add_axes((0.15, 0.1, 0.8, 0.37))]
ax_inset = [fig.add_axes((0.15 + 7 * 0.04, 0.55, 0.79 - 7 * 0.04, 0.17)),
            fig.add_axes((0.15 + 7 * 0.04, 0.12, 0.79 - 7 * 0.04, 0.17))]
ylims = [(22750, 22850),
         (26675, 26775)]
omega0 = [17.22, 8.61]
Beispiel #6
0
import numpy as np
from astroML.datasets import fetch_LINEAR_sample
from astroML.time_series import multiterm_periodogram, MultiTermFit

from bombscargle.bombscargle import (MultiTermFit, MultiTermFitMCMC,
                                     MultiTermMixtureFitFull,
                                     MultiTermMixtureFit)

import matplotlib.pyplot as plt

data = fetch_LINEAR_sample()
t, y, dy = data[1004849].T

omega = np.linspace(13.4, 14, 10000)
PSD = multiterm_periodogram(t, y, dy, omega, 6)
#plt.plot(omega, PSD)
#plt.show()
#exit()
omega_best = omega[np.argmax(PSD)]
print omega_best

models = [
    MultiTermFit(omega_best, 6),
    MultiTermFitMCMC(omega_best, 6),
    MultiTermMixtureFitFull(omega_best, 6)
]

for model in models:
    model = model.fit(t, y, dy)
    print model.w_
    phase_fit, y_fit, phased_t = model.predict(1000, return_phased_times=True)