-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCSV2JPG_enviroment.py
55 lines (39 loc) · 1.16 KB
/
CSV2JPG_enviroment.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import time
import os
from os.path import exists
from datetime import datetime
import pandas as pd
import matplotlib.pyplot as plt
plt.style.use('dark_background')
shareDir = "/home/pi/EnviromentShare/"
if not exists(shareDir):
os.mkdir(shareDir)
imgname = shareDir + "daily_data.jpg"
while True:
filename = shareDir + datetime.now().strftime("%y_%m_%d_") + "data.csv"
if not exists(filename):
print( "Sleeping")
else:
with open(filename, 'r') as file:
df = pd.read_csv(file)
df['RT'] = df['Temperature'].rolling(10).mean()
df['RH'] = df['Humidity'].rolling(10).mean()
df['RP'] = df['Pressure'].rolling(10).mean()
plt.subplot(3, 1, 1)
a = plt.gca()
xax = a.axes.get_xaxis()
xax = xax.set_visible(False)
plt.plot(df['Time'], df['RT'])
plt.subplot(3, 1, 2)
a = plt.gca()
xax = a.axes.get_xaxis()
xax = xax.set_visible(False)
plt.plot(df['Time'], df['RH'])
plt.subplot(3, 1, 3)
a = plt.gca()
xax = a.axes.get_xaxis()
xax = xax.set_visible(False)
plt.plot(df['Time'], df['RP'])
plt.savefig(imgname)
plt.clf()
time.sleep(60)