# 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 sys
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import allantools as at
from allantools import noise
from  scipy.signal import welch
#!/usr/bin/python

sys.path.append("..")

matplotlib.use('Agg') # automated tests run without a display


def test_psd2allan_figure():
    f= np.arange(1e4+1) # generate f-vector 0...10^4 Hz in 1 Hz steps -> Nyquist freq is 5 kHz
    S_y0=1e-24 # some arbitrarily chosen noise level
    S_y_WFM= S_y0*np.ones(np.size(f)) # generate white frequency noise S_y(f)
    S_y_WPM= S_y_WFM*f**2 # white phase noise S_y(f)

    plt.rc('text', usetex=True)

    plt.close('all')
    plt.figure(1)
    plt.loglog(f[f>0],S_y_WFM[f>0])
    plt.loglog(f[f>0],S_y_WPM[f>0])


# 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: tests/functional_tests/test_psd2allan.py
import sys
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import allantools as at
from allantools import noise
from  scipy.signal import welch

#!/usr/bin/python

sys.path.append("..")

matplotlib.use('Agg') # automated tests run without a display


def test_psd2allan_figure():
    f= np.arange(1e4+1) # generate f-vector 0...10^4 Hz in 1 Hz steps -> Nyquist freq is 5 kHz
    S_y0=1e-24 # some arbitrarily chosen noise level
    S_y_WFM= S_y0*np.ones(np.size(f)) # generate white frequency noise S_y(f)
    S_y_WPM= S_y_WFM*f**2 # white phase noise S_y(f)

    plt.rc('text', usetex=True)

    plt.close('all')
    plt.figure(1)
    plt.loglog(f[f>0],S_y_WFM[f>0])
    plt.loglog(f[f>0],S_y_WPM[f>0])


    y_WFM_ind= noise.white(num_points= int(2e4), b0=S_y0, fs=2e4)