Scheduler
reward.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 import matplotlib.pyplot as plt
3 import sys
4 import numpy
5 from math import floor
6 
7 def movingAverage(x, N):
8  cumsum = numpy.cumsum(numpy.insert(x, 0, 0))
9  return (cumsum[N:] - cumsum[:-N])/N
10 
11 filename = "reports/configuration.confrewardRecordReport.txt"
12 if (len(sys.argv) > 1):
13  filename = sys.argv[1]
14 
15 with open(filename) as f:
16  print f.readline()
17  time = []
18  temp = []
19  avg = []
20  for line in f:
21  entry = line.split(":")
22  time.append(float(entry[0]))
23  temp.append(float(entry[1]))
24 
25 windowSize = 100
26 avg = [0] * (windowSize - 1)
27 avg = avg + list( movingAverage(temp, windowSize))
28 
29 ratio = 0.999
30 avg = avg[int(floor(len(avg )*ratio)): len(avg )-1]
31 time = time[int(floor(len(time)*ratio)): len(time)-1]
32 temp = temp[int(floor(len(temp)*ratio)): len(temp)-1]
33 
34 
35 
36 
37 plt.plot(time, temp, 'r-')
38 plt.plot(time, avg, 'ro')
39 plt.show()
def movingAverage(x, N)
Definition: reward.py:7