1#!/usr/bin/env python
2
3import matplotlib.pyplot as plt
4from numpy import genfromtxt
5
6def read_data():
7
8    measurement_data = genfromtxt('tm_data.csv', delimiter=',') # read GP data from csv
9    measurement_data = measurement_data[1:,:] # strip first line to remove header text
10
11    location = measurement_data[:,0]
12    output = measurement_data[:,1]
13
14    gp_data = genfromtxt('gp_data.csv', delimiter=',')
15    gp_data = gp_data[1:,:]
16
17    x_range = gp_data[:,0]
18    mean = gp_data[:,1]
19    std = gp_data[:,2]
20
21    return location, output
22
23def update_plot(fig, axes, p1):
24    #print("update_plot() called")
25
26    location, output = read_data()
27    #plt.clf()
28    #plt.plot(location, output, 'r+')
29    #plt.plot(x_range, mean, '-b')
30    #plt.plot(x_range, mean+2*std, ':b')
31    #plt.plot(x_range, mean-2*std, ':b')
32
33    p1.set_data(location,output)
34
35    axes.relim()
36    axes.autoscale_view(True,True,True)
37    fig.canvas.draw()
38    #plt.draw()
39
40
41
42
43def main():
44    print("main function started")
45    plt.ion()
46    fig = plt.figure()
47    axes = fig.add_subplot(111)
48    p1, = plt.plot([],[],'r+')
49
50    while True:
51        try:
52            update_plot(fig, axes, p1)
53        except:
54            pass
55        plt.pause(1.0)
56
57if __name__ == "__main__":
58    main()
59