There is one issue left. As you suggested I decided to store the data in a more space and time saving format. The time is now in unix format. I did not find a way to transform it back to a human readable format in the graph.
Attached you will find a sample of the input data and the actual script. For testing I reduced the measuring interval to 1 min.
Code: Select all
1574010839.0, 20.9, 46.7, C
1574010899.0, 20.9, 46.7, C
1574010959.0, 20.9, 46.8, C
1574011019.0, 20.9, 46.8, C
1574011079.0, 20.9, 46.8, C
1574011139.0, 20.9, 46.7, C
1574011199.0, 20.9, 46.8, C
1574011259.0, 20.9, 46.8, C
1574011319.0, 20.9, 46.9, C
1574011379.0, 20.9, 46.9, C
1574011439.0, 21.0, 47.0, C
1574011499.0, 20.9, 46.9, C
1574011559.0, 21.0, 46.9, C
1574011619.0, 21.0, 47.0, C
1574011679.0, 21.0, 46.9, C
1574011739.0, 21.0, 46.9, C
1574011799.0, 21.0, 46.9, C
1574011859.0, 21.0, 46.9, C
1574011919.0, 20.9, 46.9, C
1574011979.0, 20.9, 46.9, C
1574012039.0, 21.0, 46.9, C
1574012099.0, 21.0, 46.9, C
1574012159.0, 21.0, 46.9, C
1574012219.0, 21.0, 46.9, C
1574012279.0, 21.0, 46.9, C
1574012339.0, 21.0, 46.9, C
1574012399.0, 21.0, 46.8, C
1574012459.0, 21.1, 46.9, C
1574012519.0, 21.0, 46.8, C
1574012579.0, 21.1, 46.9, C
1574012639.0, 21.1, 46.8, C
1574012699.0, 21.1, 46.8, C
1574012759.0, 21.1, 46.8, C
Code: Select all
import matplotlib.pyplot as plt
import numpy as np
# Zum Glätten der Kurve
# =====================
import sys
sys.path.append('C:\Daten\Programmdaten\EventGhost\Code')
import savitzky_golay as sg
# Ein- und Ausgabepfade:
# ======================
GeraetePfad = 'C:/Daten/Programmdaten/EventGhost/Geraete/' # input
Geraet = 'Sonoff-33'
Modul = 'AM2301'
WebPfad = 'C:/Daten/Programmdaten/EventGhost/web/' # output
# Daten aus Datei einlesen:
# =========================
Data = np.loadtxt(GeraetePfad + Geraet +'_' + Modul + '.txt', delimiter = ',', usecols = (0,1,2))
x = Data[:,0]
y1 = Data[:,1]
y2 = Data[:,2]
# Kurve glätten:
# ==============
y1 = sg.savitzky_golay(y1, window_size=27, order=3)
y2 = sg.savitzky_golay(y2, window_size=27, order=3)
# Kurven plotten:
# ===============
Bild = plt.figure(num=1, figsize=(16,9))
ax1 = Bild.add_subplot(1, 1, 1, label='erster Subplot')
ax1.plot(x, y1, label='Temperatur', color='tab:red', linestyle='solid', linewidth=5)
ax2 = ax1.twinx()
ax2.plot(x, y2, label='Luftfeuchte', color='tab:blue', linestyle='solid', linewidth=5)
# Decorations
# ax1 (left Y axis)
ax1.spines['bottom'].set_color('white')
ax1.spines['top'].set_color('white')
ax1.spines['right'].set_color('white')
ax1.spines['left'].set_color('white')
ax1.set_xlabel('Zeit', fontsize=20)
ax1.tick_params(axis='x', rotation=45, labelsize=20)
ax1.set_ylabel('Temperatur [C]', color='tab:red', fontsize=20)
ax1.tick_params(axis='y', rotation=0, labelcolor='tab:red', labelsize=20 )
ax1.grid(alpha=.4)
# ax2 (right Y axis)
ax2.spines['bottom'].set_color('white')
ax2.spines['top'].set_color('white')
ax2.spines['right'].set_color('white')
ax2.spines['left'].set_color('white')
ax2.set_ylabel("Luftfeuchte [%]", color='tab:blue', fontsize=20)
ax2.tick_params(axis='y', labelcolor='tab:blue', labelsize=20)
ax2.set_xticklabels(x[::60], rotation=90, fontdict={'fontsize':10})
ax2.set_title("Temperatur und Luftfeuchte Dachboden (33)", fontsize=22, color='white')
Bild.tight_layout()
plt.savefig(WebPfad + Geraet +'_' + Modul, transparent = True)
ax2.remove()
ax1.remove()