- plot charging energy
- plot power consumption (still buggy)
This commit is contained in:
+39
-12
@@ -7,7 +7,7 @@ import dateutil.parser as dup
|
|||||||
from jay_diff import jay_merge_full
|
from jay_diff import jay_merge_full
|
||||||
from matplotlib import pyplot as plot
|
from matplotlib import pyplot as plot
|
||||||
import eval_records_settings as settings
|
import eval_records_settings as settings
|
||||||
|
from record.types.charging import ChargingState
|
||||||
|
|
||||||
def has_diff_entries(diff):
|
def has_diff_entries(diff):
|
||||||
handled = False
|
handled = False
|
||||||
@@ -267,35 +267,62 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
# calc speed
|
# calc speed
|
||||||
speed = [0]
|
speed = [0]
|
||||||
|
dt = settings.t_interval_s
|
||||||
for i in range(1, len(time_h)):
|
for i in range(1, len(time_h)):
|
||||||
dt = float(time_h[i] - time_h[i - 1])
|
|
||||||
dv = v_odo[i] - v_odo[i-1]
|
dv = v_odo[i] - v_odo[i-1]
|
||||||
speed.append(dv/dt*60*60)
|
speed.append(dv/dt*60*60)
|
||||||
|
|
||||||
# Convert x-axis
|
# Convert x-axis
|
||||||
dt_h = (np.array(time_h) - time_h[0]) / 3600 / 24 + settings.sel_days[0]
|
dt_h = (np.array(time_h) - time_h[0]) / 3600 / 24 + settings.sel_days[0]
|
||||||
|
|
||||||
|
v_energy = []
|
||||||
|
v_consumption = []
|
||||||
|
energy = 0
|
||||||
|
consumption = 0
|
||||||
|
chg_state_last = 0
|
||||||
|
odo_last = v_odo[0]
|
||||||
|
odo_diff_last = 0
|
||||||
|
# Calc charging energy
|
||||||
|
for chgpwr, chgstate, odo in zip(v_chgpwr, v_chg_state, v_odo):
|
||||||
|
energy += chgpwr/3600*dt
|
||||||
|
if chg_state_last != chgstate:
|
||||||
|
chg_state_last = chgstate
|
||||||
|
if ChargingState[chgstate] == ChargingState.charging:
|
||||||
|
odo_diff = odo - odo_last
|
||||||
|
odo_last = odo
|
||||||
|
if odo_diff_last > 0:
|
||||||
|
consumption = 100 * energy / odo_diff_last
|
||||||
|
odo_diff_last = odo_diff
|
||||||
|
energy = 0
|
||||||
|
|
||||||
|
v_consumption.append(consumption)
|
||||||
|
v_energy.append(energy)
|
||||||
|
|
||||||
# plot data
|
# plot data
|
||||||
plot.subplot(5, 1, 1)
|
NUM_PLOTS = 6
|
||||||
|
plot.subplot(NUM_PLOTS, 1, 1)
|
||||||
plot.plot(dt_h, np.array(v_odo) - v_odo[0])
|
plot.plot(dt_h, np.array(v_odo) - v_odo[0])
|
||||||
plot.title("Kilometerstand")
|
plot.ylabel("Kilometerstand")
|
||||||
plot.grid()
|
plot.grid()
|
||||||
plot.subplot(5, 1, 2)
|
plot.subplot(NUM_PLOTS, 1, 2)
|
||||||
plot.plot(dt_h, speed)
|
plot.plot(dt_h, speed)
|
||||||
plot.title("Speed")
|
plot.ylabel("Speed")
|
||||||
plot.grid()
|
plot.grid()
|
||||||
plot.subplot(5, 1, 3)
|
plot.subplot(NUM_PLOTS, 1, 3)
|
||||||
plot.plot(dt_h, v_soc, dt_h, v_chgpwr)
|
plot.plot(dt_h, v_soc, dt_h, v_chgpwr)
|
||||||
plot.title("Akkustand")
|
plot.ylabel("Akkustand")
|
||||||
plot.grid()
|
plot.grid()
|
||||||
plot.subplot(5, 1, 4)
|
plot.subplot(NUM_PLOTS, 1, 4)
|
||||||
plot.plot(dt_h, v_range)
|
plot.plot(dt_h, v_range)
|
||||||
plot.title("Range")
|
plot.ylabel("Range")
|
||||||
plot.grid()
|
plot.grid()
|
||||||
plot.subplot(5, 1, 5)
|
plot.subplot(NUM_PLOTS, 1, 5)
|
||||||
plot.plot(dt_h, v_chg_state)
|
plot.plot(dt_h, v_chg_state)
|
||||||
plot.title("Charge state")
|
plot.ylabel("Charge state")
|
||||||
|
plot.grid()
|
||||||
|
plot.subplot(NUM_PLOTS, 1, 6)
|
||||||
|
plot.plot(dt_h, v_energy, dt_h, v_consumption)
|
||||||
|
plot.ylabel("Charge energy")
|
||||||
plot.grid()
|
plot.grid()
|
||||||
|
|
||||||
plot.show()
|
plot.show()
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ class ChargingState(enum.Enum):
|
|||||||
chargePurposeReachedAndNotConservationCharging = 2
|
chargePurposeReachedAndNotConservationCharging = 2
|
||||||
chargePurposeReachedAndConservation = 3
|
chargePurposeReachedAndConservation = 3
|
||||||
error = 4
|
error = 4
|
||||||
|
conservation = 5
|
||||||
|
readyForCharging = 6
|
||||||
|
|
||||||
|
|
||||||
print(ChargingState["charging"].value)
|
print(ChargingState["charging"].value)
|
||||||
|
|||||||
Reference in New Issue
Block a user