Compare commits

...

3 Commits

Author SHA1 Message Date
simon 574ae675b7
fix smoothing last 7 axis with incomplete data 2022-10-23 16:56:22 +07:00
simon 19c5b92db0
close monthly plts 2022-10-23 16:56:00 +07:00
simon 17eed21eb3
fix inaccurate sensor startup sleep 2022-10-23 16:35:01 +07:00
3 changed files with 9 additions and 2 deletions

View File

@ -32,7 +32,9 @@ class SDS:
def startup(self):
"""activate and set mode"""
self.pm.active = 1
sleep(0.5)
while self.pm.active.get("value") != 1:
sleep(0.5)
self.pm.mode = simple_sds011.MODE_PASSIVE
print("warm up sensor")
sleep(20)

View File

@ -197,6 +197,7 @@ class MonthGenerator():
plt.tight_layout()
plt.savefig(file_name, dpi=300)
plt.figure()
plt.close()
@staticmethod
def get_aqi(val):

View File

@ -160,7 +160,11 @@ class LastSevenDays:
mean['avg'][0] = (mean['avg'].iloc[6] + mean['aqi'][0]) / 2
mean['avg'][-1] = (mean['avg'].iloc[-6] + mean['aqi'][-1]) / 2
# smooth
mean['avg'].interpolate(method='polynomial', order=3, inplace=True)
try:
mean['avg'].interpolate(method='polynomial', order=3, inplace=True)
except ValueError:
mean['avg'].interpolate(method='polynomial', order=1, inplace=True)
mean.reset_index(level=0, inplace=True)
mean['timestamp'] = mean['timestamp'].dt.strftime('%Y-%m-%d %H:%M')
mean['aqi'] = mean['aqi'].round()