-
Notifications
You must be signed in to change notification settings - Fork 0
/
datenauswerter.py
61 lines (46 loc) · 1.79 KB
/
datenauswerter.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
55
56
57
58
59
60
61
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import io
from PIL import Image
def chart_for_timelapse(df, max_i, x_lim, y_lim, x_title, y_title, cols):
fontdict_x = {'fontsize': 17,
'fontweight' : 'normal',
'verticalalignment': 'top',
'horizontalalignment': 'center'}
fontdict_y = {'fontsize': 17,
'fontweight' : 'normal',
'verticalalignment': 'baseline',
'horizontalalignment': 'center'}
fig, plot = plt.subplots()
plot.set_xlim(x_lim[0], x_lim[1])
plot.set_ylim(y_lim[0], y_lim[1])
plot.plot(df.loc[:max_i, cols], linewidth=3)
plot.set_xlabel(x_title, fontdict = fontdict_x)
plot.set_ylabel(y_title, fontdict = fontdict_y)
#plt.savefig('chart.png')
buf = io.BytesIO()
plt.savefig(buf, format='png', transparent=True)
buf.seek(0)
img = Image.open(buf)
plot.clear()
plt.close(fig)
return img
# Messung = pd.read_csv('m2.csv', sep=';', index_col='Zeit')
# chart_for_timelapse(Messung,
# cols=['Cap_Dirt', 'Cap_Leaf'],
# max_i=10000,
# x_lim=[0, 10000],
# y_lim=[0, 400],
# x_title='Zeit',
# y_title='Analogwert')
# Path = input("Enter path to file: ")
# Messung = pd.read_csv(Path, sep=';', index_col='Zeit')
# Messung.index = Messung.index / 3600 / 24
# cap_dirt = Messung[['Cap_Dirt']]
# cap_leaf = Messung[['Cap_Leaf']]
# both = cap_dirt.join((cap_leaf), how='inner')
# plotting = both.plot(linewidth=1)
# plt.show(plotting)
# Rol = both.rolling(min_periods = 10, window = 60, center = False).mean().plot(linewidth=1)
# plt.show(Rol)