import csv
import matplotlib.pyplot as plt
from scipy import signal
import numpy as np

with open('sense_hat_data_2019_01_04_00_00.csv') as f:
    datas = csv.reader(f)
    header = next(datas)
    temp = []
    time = []
    for row in datas:
        time.append(float(row[0]))
        temp.append(float(row[2]))

print(temp)

temp_decimate = signal.decimate(temp, 10, 3, zero_phase=True)
print(temp_decimate)
temp_mean = np.mean(temp)
print(temp_mean)

temp_filtered = signal.savgol_filter(temp, 53, 3)

plt.plot(time,temp)
plt.plot(time,temp_filtered)
plt.show()