File: test_periodogram.py

package info (click to toggle)
astroml 1.0.2-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 932 kB
  • sloc: python: 5,731; makefile: 3
file content (25 lines) | stat: -rw-r--r-- 552 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import numpy as np
from numpy.testing import assert_almost_equal
from astroML.time_series import search_frequencies


# TODO: add tests of lomb_scargle inputs & significance

# TODO: add tests of bootstrap


def test_search_frequencies():
    rng = np.random.RandomState(0)

    t = np.arange(0, 1E1, 0.01)
    f = 1
    w = 2 * np.pi * np.array(f)
    y = np.sin(w * t)

    dy = 0.01
    y += dy * rng.randn(len(y))

    omegas, power = search_frequencies(t, y, dy)
    omax = omegas[power == max(power)]

    assert_almost_equal(w, omax, decimal=3)