# 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
    (t2, ad, ade, adn) = allantools.mdev(
        y, data_type='freq', rate=rate, taus=taus)
    plt.loglog(t2, ad, style, label=label)


def plotallan_phase(plt, y, rate, taus, style, label="", alpha=1.0):
    (t2, ad, ade, adn) = allantools.mdev(
        y, data_type='phase', rate=rate, taus=taus)
    plt.loglog(t2, ad, style, label=label, alpha=alpha)


def plotline(plt, alpha, taus, style, label=""):
    """ plot a line with the slope alpha """
    y = [pow(tt, alpha) for tt in taus]
    plt.loglog(taus, y, style, label=label)


if __name__ == "__main__":
    print("allatools tests with various noise types")
    # we test ADEV etc. by calculations on synthetic data
    # 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")

# 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

    (t2, ad, ade, adn) = allantools.mdev(
        y, data_type='freq', rate=rate, taus=taus)
    plt.loglog(t2, ad, style, label=label)


def plotallan_phase(plt, y, rate, taus, style, label="", alpha=1.0):
    (t2, ad, ade, adn) = allantools.mdev(
        y, data_type='phase', rate=rate, taus=taus)
    plt.loglog(t2, ad, style, label=label, alpha=alpha)


def plotline(plt, alpha, taus, style, label=""):
    """ plot a line with the slope alpha """
    y = [pow(tt, alpha) for tt in taus]
    plt.loglog(taus, y, style, label=label)


if __name__ == "__main__":
    print("allatools tests with various noise types")
    # we test ADEV etc. by calculations on synthetic data
    # 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)