1#!/usr/bin/env python
2
3from numpy import genfromtxt
4import matplotlib.pyplot as plt
5
6def read_data():
7
8    measurement_data = genfromtxt('measurement_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, x_range, mean, std
22
23def update_plot(fig, axes, p1, p2, p3, p4):
24    #print("update_plot() called")
25
26    location, output, x_range, mean, std = 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    p2.set_data(x_range,mean)
35    p3.set_data(x_range,mean+2*std)
36    p4.set_data(x_range,mean-2*std)
37    axes.relim()
38    axes.autoscale_view(True,True,True)
39    fig.canvas.draw()
40    #plt.draw()
41
42
43
44
45def main():
46    print("main function started")
47    plt.ion()
48    fig = plt.figure()
49    axes = fig.add_subplot(111)
50    p1, = plt.plot([],[],'r+')
51    p2, = plt.plot([],[], '-b')
52    p3, = plt.plot([],[], ':b')
53    p4, = plt.plot([],[], ':b')
54    while True:
55        try:
56            update_plot(fig, axes, p1, p2, p3, p4)
57        except:
58            pass
59        plt.pause(1.0)
60
61if __name__ == "__main__":
62    main()
63