- #1
lee403
- 16
- 1
I have this really noisy data and I'm wanting to plot Temperature v. Time. I used this function to calculate a moving average. Here's some sample code.
The moving average function seems to work fine at removing some of the random noise, but now I want to find the point in the array tmp1MA that corresponds to a given time1 value. For example, I would like be able to find the averaged temperature at time 500.
Python:
BA1='ANP-Heat-BA1.csv'
#Time Trial 1
time1=pd.read_csv(BA1,skiprows=0)
time1=time1['Time(s)']
#Temperature
tmp1=pd.read_csv(BA1,skiprows=0)
tmp1=tmp1['Temp']
def movingaverage (values, window):
weights = np.repeat(1.0, window)/window
sma = np.convolve(values, weights, 'valid')
return sma
tmp1MA=movingaverage(tmp1, 10)
p.plot(time1[len(time1)-len(tmp1MA):],tmp1MA)
The moving average function seems to work fine at removing some of the random noise, but now I want to find the point in the array tmp1MA that corresponds to a given time1 value. For example, I would like be able to find the averaged temperature at time 500.