Ejemplo n.º 1
1
def compute_Power():

    from astroML.time_series import generate_power_law
    from astroML.fourier import PSD_continuous

    from astroML.plotting import setup_text_plots
    setup_text_plots(fontsize=8, usetex=False)

    N = 1024
    dt = 0.01
    factor = 100

    t = dt * np.arange(N)
    random_state = np.random.RandomState(1)

    fig = plt.figure(figsize=(5, 3.75))
    fig.subplots_adjust(wspace=0.05)

    for i, beta in enumerate([1.0, 2.0]):
    # Generate the light curve and compute the PSD
        x = factor * generate_power_law(N, dt, beta, random_state=random_state)
        f, PSD = PSD_continuous(t, x)

    # First axes: plot the time series
        ax1 = fig.add_subplot(221 + i)
        ax1.plot(t, x, '-k')

        ax1.text(0.95, 0.05, r"$P(f) \propto f^{-%i}$" % beta,
             ha='right', va='bottom', transform=ax1.transAxes)

        ax1.set_xlim(0, 10.24)
        ax1.set_ylim(-1.5, 1.5)

        ax1.set_xlabel(r'$t$')

    # Second axes: plot the PSD
        ax2 = fig.add_subplot(223 + i, xscale='log', yscale='log')
        ax2.plot(f, PSD, '-k')
        ax2.plot(f[1:], (factor * dt) ** 2 * (2 * np.pi * f[1:]) ** -beta, '--k')

        ax2.set_xlim(1E-1, 60)
        ax2.set_ylim(1E-6, 1E1)

        ax2.set_xlabel(r'$f$')

        if i == 1:
            ax1.yaxis.set_major_formatter(plt.NullFormatter())
            ax2.yaxis.set_major_formatter(plt.NullFormatter())
        else:
            ax1.set_ylabel(r'${\rm counts}$')
            ax2.set_ylabel(r'$PSD(f)$')

    plt.show()
Ejemplo n.º 2
0
def test_generate_args(N, generate_complex):
    dt = 0.1
    beta = 2
    x = generate_power_law(N, dt, beta, generate_complex)

    assert_(bool(generate_complex) == np.iscomplexobj(x))
    assert_(len(x) == N)
Ejemplo n.º 3
0
def test_generate_args(N, generate_complex):
    dt = 0.1
    beta = 2
    x = generate_power_law(N, dt, beta, generate_complex)

    assert_(bool(generate_complex) == np.iscomplexobj(x))
    assert_(len(x) == N)
Ejemplo n.º 4
0
from astroML.plotting import setup_text_plots
setup_text_plots(fontsize=8, usetex=True)

N = 1024
dt = 0.01
factor = 100

t = dt * np.arange(N)
random_state = np.random.RandomState(1)

fig = plt.figure(figsize=(5, 3.75))
fig.subplots_adjust(wspace=0.05)

for i, beta in enumerate([1.0, 2.0]):
    # Generate the light curve and compute the PSD
    x = factor * generate_power_law(N, dt, beta, random_state=random_state)
    f, PSD = PSD_continuous(t, x)

    # First axes: plot the time series
    ax1 = fig.add_subplot(221 + i)
    ax1.plot(t, x, '-k')

    ax1.text(0.95, 0.05, r"$P(f) \propto f^{-%i}$" % beta,
             ha='right', va='bottom', transform=ax1.transAxes)

    ax1.set_xlim(0, 10.24)
    ax1.set_ylim(-1.5, 1.5)

    ax1.set_xlabel(r'$t$')

    # Second axes: plot the PSD
Ejemplo n.º 5
0
from astroML.plotting import setup_text_plots
setup_text_plots(fontsize=8, usetex=True)

N = 1024
dt = 0.01
factor = 100

t = dt * np.arange(N)
random_state = np.random.RandomState(1)

fig = plt.figure(figsize=(5, 3.75))
fig.subplots_adjust(wspace=0.05)

for i, beta in enumerate([1.0, 2.0]):
    # Generate the light curve and compute the PSD
    x = factor * generate_power_law(N, dt, beta, random_state=random_state)
    f, PSD = PSD_continuous(t, x)

    # First axes: plot the time series
    ax1 = fig.add_subplot(221 + i)
    ax1.plot(t, x, '-k')

    ax1.text(0.95,
             0.05,
             r"$P(f) \propto f^{-%i}$" % beta,
             ha='right',
             va='bottom',
             transform=ax1.transAxes)

    ax1.set_xlim(0, 10.24)
    ax1.set_ylim(-1.5, 1.5)
Ejemplo n.º 6
0
def check_generate_args(N, dt, beta, generate_complex):
    x = generate_power_law(N, dt, beta, generate_complex)

    assert_(bool(generate_complex) == np.iscomplexobj(x))
    assert_(len(x) == N)
Ejemplo n.º 7
0
def check_generate_args(N, dt, beta, generate_complex):
    x = generate_power_law(N, dt, beta, generate_complex)

    assert_(bool(generate_complex) == np.iscomplexobj(x))
    assert_(len(x) == N)