# Path: allantools/noise.py
# def numpy_psd(x, f_sample=1.0):
# def scipy_psd(x, f_sample=1.0, nr_segments=4):
# def white(num_points=1024, b0=1.0, fs=1.0):
# def brown(num_points=1024, b_minus2=1.0, fs=1.0):
# def violet(num_points=1024, b2=1, fs=1):
# def pink(num_points=1024, depth=80):
# def iterpink(depth=20):


import numpy
import matplotlib.pyplot as plt
import allantools
from allantools import noise
    # with known slopes of ADEV

    t = [tt for tt in numpy.logspace(0, 3, 50)]  # tau values from 1 to 1000
    plt.subplot(111, xscale="log", yscale="log")
    N = 100000

    # Colors: http://en.wikipedia.org/wiki/Colors_of_noise

    # Brownian a.k.a random walk  frequency => sqrt(tau) ADEV
    print("Random Walk frequency noise - should have sqrt(tau) ADEV")
    freq_rw = noise.brown(N)
    phase_rw_rw = numpy.cumsum(noise.brown(N))  # integrate to get  phase
    plotallan(plt, freq_rw, 1, t, 'm.')
    plotallan_phase(plt, phase_rw_rw, 1, t, 'mo',
                    label='random walk frequency')
    plotline(plt, +0.5, t, 'm', label="f^(+1/2)")

    # pink frequency noise => constant ADEV
    print("Pink frequency noise - should have constant ADEV")
    freq_pink = noise.pink(N)
    phase_p = numpy.cumsum(noise.pink(N))  # integrate to get phase, color??
    plotallan_phase(plt, phase_p, 1, t, 'co',
                    label="pink/flicker frequency noise")
    plotallan(plt, freq_pink, 1, t, 'c.')
    plotline(plt, 0, t, 'c', label="f^0")

    # white frequency modulation => 1/sqrt(tau) ADEV
    print("White frequency noise - should have 1/sqrt(tau) ADEV")
    freq_white = noise.white(N)
    # integrate to get Brownian, or random walk phase

# Path: allantools/noise.py
# def numpy_psd(x, f_sample=1.0):
# def scipy_psd(x, f_sample=1.0, nr_segments=4):
# def white(num_points=1024, b0=1.0, fs=1.0):
# def brown(num_points=1024, b_minus2=1.0, fs=1.0):
# def violet(num_points=1024, b2=1, fs=1):
# def pink(num_points=1024, depth=80):
# def iterpink(depth=20):


# Path: examples/noise-color-demo.py
import numpy
import matplotlib.pyplot as plt
import allantools
from allantools import noise

    # with known slopes of ADEV

    t = [tt for tt in numpy.logspace(0, 3, 50)]  # tau values from 1 to 1000
    plt.subplot(111, xscale="log", yscale="log")
    N = 100000

    # Colors: http://en.wikipedia.org/wiki/Colors_of_noise

    # Brownian a.k.a random walk  frequency => sqrt(tau) ADEV
    print("Random Walk frequency noise - should have sqrt(tau) ADEV")
    freq_rw = noise.brown(N)
    phase_rw_rw = numpy.cumsum(noise.brown(N))  # integrate to get  phase
    plotallan(plt, freq_rw, 1, t, 'm.')
    plotallan_phase(plt, phase_rw_rw, 1, t, 'mo',
                    label='random walk frequency')
    plotline(plt, +0.5, t, 'm', label="f^(+1/2)")

    # pink frequency noise => constant ADEV
    print("Pink frequency noise - should have constant ADEV")
    freq_pink = noise.pink(N)
    phase_p = numpy.cumsum(noise.pink(N))  # integrate to get phase, color??
    plotallan_phase(plt, phase_p, 1, t, 'co',
                    label="pink/flicker frequency noise")
    plotallan(plt, freq_pink, 1, t, 'c.')
    plotline(plt, 0, t, 'c', label="f^0")

    # white frequency modulation => 1/sqrt(tau) ADEV
    print("White frequency noise - should have 1/sqrt(tau) ADEV")
    freq_white = noise.white(N)
    # integrate to get Brownian, or random walk phase

    phase_rw = noise.brown(N)