示例#1
0
def try_sawtooth(period, noise=0.0, reps=1):
    eps = 3 # why is sawtooth so flaky?
    npass = 0
    s = sequences.sawtooth(1.0, period, CYCLES, period / 3)
    for _ in range(reps):
        ns = sequences.add_noise(sequences.mix(s, 0, noise), noise)
        ns = ns - ns.mean()
        p = fit_period(ns)
        if period - eps <= p and p <= period + eps:
            npass += 1
        else:
            print "saw {0} got {1}".format(period, p)
    print "try_sawtooth noise {0} period {1} -> {2}%".format(
        noise, period, (100 * npass) / reps)
    return npass
示例#2
0
def try_sawtooth(period, noise=0.0, reps=1):
    eps = 3  # why is sawtooth so flaky?
    npass = 0
    s = sequences.sawtooth(1.0, period, CYCLES, period // 3)
    for _ in range(reps):
        ns = sequences.add_noise(sequences.mix(s, 0, noise), noise)
        ns = ns - ns.mean()
        p = fit_period(ns)
        if period - eps <= p and p <= period + eps:
            npass += 1
        else:
            print("saw {0} got {1}".format(period, p))
    print("try_sawtooth noise {0} period {1} -> {2}%".format(
        noise, period, (100 * npass) / reps))
    return npass
示例#3
0
def test_sawtooth():
    for period in PERIODS:
        s = sequences.sawtooth(period / 5, period, CYCLES, period / 3)
        p = periodogram_peaks(s, thresh=1.0)
        assert len(p) == 1 and p[0][2] <= period and p[0][3] >= period
示例#4
0
def test_sawtooth():
    for period in PERIODS:
        s = sequences.sawtooth(period // 5, period, CYCLES, period // 3)
        p = periodogram_peaks(s, thresh=1.0)
        assert len(p) == 1 and p[0][2] <= period and p[0][3] >= period