[eval_records]

- plot data
This commit is contained in:
2024-10-23 20:23:49 +02:00
parent 433a29971f
commit 87fc8d6119
+30 -17
View File
@@ -2,13 +2,15 @@ import json
import os import os
from datetime import datetime from datetime import datetime
from jay_diff import jay_merge_full from jay_diff import jay_merge_full
from matplotlib import pyplot as plot
BASE = "/media/jens/cifs/jens@moon/projects/we_collect/results" BASE = "/media/jens/cifs/jens@moon/projects/we_collect/results"
VIN = 'WVWZZZE1ZMP010760' VIN = 'WVWZZZE1ZMP010760'
USER = 'alex' USER = 'alex'
YEAR = 2024 YEAR = 2024
MONTH = 10 MONTH = 10
DAY = ['20', '21', '22'] DAY = ['15', '16', '17', '18', '19', '20', '21', '22', '23']
def has_diff_entries(diff): def has_diff_entries(diff):
@@ -35,12 +37,17 @@ class Endpoint:
self._ts_format = _ts_format self._ts_format = _ts_format
self._ts_path_keys = self.to_keys(_ts_path) self._ts_path_keys = self.to_keys(_ts_path)
def __str__(self):
return f"{self._ep_path}:{len(self._values)}: {self._values}"
def timestamps_str(self): def timestamps_str(self):
return f"{self._ep_path}:{len(self._timestamps)}: {self._timestamps}" return f"{self._ep_path}:{len(self._timestamps)}: {self._timestamps}"
@property
def timestamps(self):
return self._timestamps
@property
def values(self):
return self._values
@property @property
def path(self): def path(self):
return self._ep_path return self._ep_path
@@ -82,12 +89,11 @@ class Endpoint:
return Endpoint.deref_multi(data[keys[0]], keys[1:]) if keys else data return Endpoint.deref_multi(data[keys[0]], keys[1:]) if keys else data
end_points = [ end_points = {
Endpoint('data/measurements/odometerStatus/value/odometer', 'info/timestamp'), 'odo': Endpoint('data/measurements/odometerStatus/value/odometer', 'info/timestamp'),
Endpoint('data/measurements/fuelLevelStatus/value/currentSOC_pct', 'info/timestamp'), 'soc': Endpoint('data/measurements/fuelLevelStatus/value/currentSOC_pct', 'info/timestamp'),
Endpoint('data/vehicleLights/lightsStatus/value/lights', 'info/timestamp'), 'engine': Endpoint('data/fuelStatus/rangeStatus/value/primaryEngine', 'info/timestamp')
Endpoint('data/fuelStatus/rangeStatus/value/primaryEngine', 'info/timestamp') }
]
def convert(timestamp_str: str, pattern: str = "%Y-%m-%dT%H:%M:%S.%f%z"): def convert(timestamp_str: str, pattern: str = "%Y-%m-%dT%H:%M:%S.%f%z"):
@@ -158,14 +164,21 @@ for day in day_list:
vehicle_data = jay_merge_full(last, vehicle_diff) vehicle_data = jay_merge_full(last, vehicle_diff)
last = vehicle_data last = vehicle_data
try: try:
for end_point in end_points: for k in end_points.keys():
end_point.assign({'info': record['info'], 'data': vehicle_data}) end_points[k].assign({'info': record['info'], 'data': vehicle_data})
except KeyError: except KeyError:
pass pass
for end_point in end_points: for k in end_points.keys():
end_point.remove_dups() end_points[k].remove_dups()
print(end_point)
print(end_point.timestamps_str())
d = convert('2024-10-17T18:37:17.067Z') plot.subplot(2, 1, 1)
plot.plot(end_points['odo'].timestamps, end_points['odo'].values)
plot.title("Kilometerstand")
plot.grid()
plot.subplot(2, 1, 2)
plot.plot(end_points['odo'].timestamps, end_points['soc'].values)
plot.title("Akku in %")
plot.grid()
plot.show()