Example #1
0
def test_overwrite():
    """ Tests if data is overwritten as pointed out in issue
    https://github.com/aewallin/allantools/issues/76
    """
    x1 = at.noise.white(num_points=1024)
    x2 = at.noise.pink(num_points=1024)
    ds1 = at.Dataset(x1)
    ds2 = at.Dataset(x2)
    r1 = ds1.compute('oadev')
    r2 = ds2.compute('oadev')
    # If both are identical, something is wrong...
    assert (not numpy.allclose(r1['stat'], r2['stat']))
Example #2
0
def test_plot():
    ds = at.Dataset(data=at.noise.white(1000), rate=1.234)
    ds.compute("adev")
    p = at.Plot(no_display=True)
    p.plot(ds, errorbars=True)
Example #3
0
        y = data[2048 - n_pts:2048 + n_pts]
        # Fit the absorption peak with a parabola y = ax^2+bx+c
        z = np.polyfit(x, y, 2)
        a = z[0]
        b = z[1]
        c = z[2]
        # Find the position of the peak minimum by derivating the parabola
        peak_pos = factor * -b / (2 * a)

        frequency = np.roll(frequency, -1)
        frequency[-1] = peak_pos

        # Plot
        li.set_ydata(frequency)
        ax.relim()
        ax.autoscale_view(True, True, True)
        fig.canvas.draw()
        print time.time() - t0, peak_pos
        plt.pause(0.001)
    except KeyboardInterrupt:
        break

a = allantools.Dataset(data=frequency)
a.compute("adev")

# Plot it using the Plot class
b = allantools.Plot()
b.plot(a, errorbars=True, grid=True)
# You can override defaults before "show" if needed
b.ax.set_xlabel("Tau (s)")
b.show()
Example #4
0
import allantools
import numpy as np

# Compute a deviation using the Dataset class
a = allantools.Dataset(data=np.random.rand(1000))
a.compute("mdev")

# Plot it using the Plot class
b = allantools.Plot()
b.plot(a, errorbars=True, grid=True)
# You can override defaults before "show" if needed
b.ax.set_xlabel("Tau (s)")
b.show()
Example #5
0
    proper_file_type = None
    for filetype in POSSIBLE_FILE_TYPES:
        if filetype in args.input_file:
            proper_file_type = filetype
            print("Input file type: {}".format(filetype))
    if not proper_file_type:
        raise ValueError("Invalid file type. Expected one of {}".format(POSSIBLE_FILE_TYPES))

    if args.allan_deviation:
        if proper_file_type != 'clockstats':
            raise ValueError("Invalid file type for producing AllanDeviation. Expected clockstats")

        print("Plotting Allan deviation")
        clock_times = np.loadtxt(args.input_file, usecols=3)
        rate = 1   # 1 Hz, if NTP is set up with PPS flag4 = 1
        at_dataset = allantools.Dataset(data=clock_times, rate=rate, data_type="phase", taus="octave")

        # Other possible computations are adev, mdev, tdev, hdev, ohdev, totdev,
        # mtotdev, ttotdev, htotdev, theo1, mtie, tierms, gradev
        at_dataset.compute("oadev")
        at_plotter = allantools.Plot()
        at_plotter.plot(at_dataset)
        at_plotter.show()

    # TODO: Code reuse for most of the following:
    if args.offset:
        if proper_file_type != 'loopstats':
            raise ValueError("Invalid file type for producing offset plot. Expected loopstats")

        print("Plotting loopstats offset")
        offsets = np.loadtxt(args.input_file, usecols=2)