refactored
This commit is contained in:
+3
-2
@@ -34,8 +34,7 @@ def deep_merge(d, u, only_existing=True):
|
||||
d[k] = u[k]
|
||||
return d
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
def main() -> None:
|
||||
files = [
|
||||
"results/WVWZZZE1ZMP010760/2024/10/18/vehicle_WVWZZZE1ZMP010760_2024-10-15T12-05-23.json",
|
||||
"results/WVWZZZE1ZMP010760/2024/10/19/vehicle_WVWZZZE1ZMP010760_2024-10-19T00-00-34.json",
|
||||
@@ -72,3 +71,5 @@ if __name__ == '__main__':
|
||||
# Check integrity
|
||||
assert src == merged_list
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
+4
-2
@@ -235,8 +235,7 @@ def make_values(_ts_list, _ep: Endpoint, ic=0):
|
||||
|
||||
return v_list
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
def main() -> None:
|
||||
end_points = []
|
||||
for k in settings.eps_defs.keys():
|
||||
end_points.append(Endpoint(k, settings.eps_defs[k]))
|
||||
@@ -326,3 +325,6 @@ if __name__ == '__main__':
|
||||
plot.grid()
|
||||
|
||||
plot.show()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
+25
-21
@@ -29,32 +29,33 @@ def model_bat_dcr(temperature: float, soc: float, p: Params):
|
||||
return rb * np.exp(p.alpha*(t2 - tb2) + p.beta*(_t - tb))
|
||||
|
||||
|
||||
temps = [0, 5, 10, 20, 25, 40]
|
||||
pl = 10000
|
||||
il = 100
|
||||
ul = 100
|
||||
rl = ul/il
|
||||
p_ = np.linspace(0, 20000, 100)
|
||||
i_ = p_/ul
|
||||
def main() -> None:
|
||||
temps = [0, 5, 10, 20, 25, 40]
|
||||
pl = 10000
|
||||
il = 100
|
||||
ul = 100
|
||||
rl = ul/il
|
||||
p_ = np.linspace(0, 20000, 100)
|
||||
i_ = p_/ul
|
||||
|
||||
bat_params = Params(alpha=0.0007545, beta=-0.07033)
|
||||
rt_ = []
|
||||
for t in temps:
|
||||
bat_params = Params(alpha=0.0007545, beta=-0.07033)
|
||||
rt_ = []
|
||||
for t in temps:
|
||||
rt_.append(model_bat_dcr(t, 100, bat_params))
|
||||
|
||||
plot.figure()
|
||||
plot.plot(temps, rt_)
|
||||
r, t = bas(100)
|
||||
plot.title(f"DCR vs temperature (Base DCR={r}@{t}°C)")
|
||||
plot.xlabel("Temperature [°C]")
|
||||
plot.ylabel("R [Ohm]")
|
||||
plot.grid()
|
||||
plot.figure()
|
||||
plot.plot(temps, rt_)
|
||||
r, t = bas(100)
|
||||
plot.title(f"DCR vs temperature (Base DCR={r}@{t}°C)")
|
||||
plot.xlabel("Temperature [°C]")
|
||||
plot.ylabel("R [Ohm]")
|
||||
plot.grid()
|
||||
|
||||
titles = [
|
||||
titles = [
|
||||
"Battery power loss vs internal battery resistance (DCR)",
|
||||
"Batter power consumption vs internal battery resistance (DCR)"
|
||||
]
|
||||
for sp, name, title in zip([0, 1], ["P_loss [kW]", "P_batt [kW]"], titles):
|
||||
]
|
||||
for sp, name, title in zip([0, 1], ["P_loss [kW]", "P_batt [kW]"], titles):
|
||||
plot.figure()
|
||||
legs = []
|
||||
plot.grid()
|
||||
@@ -71,4 +72,7 @@ for sp, name, title in zip([0, 1], ["P_loss [kW]", "P_batt [kW]"], titles):
|
||||
plot.legend(legs)
|
||||
plot.ylabel(name)
|
||||
|
||||
plot.show()
|
||||
plot.show()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
+3
-3
@@ -120,9 +120,7 @@ def jay_merge_full(_old, _diff):
|
||||
|
||||
return res
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
def main() -> None:
|
||||
result = jay_diff_add({}, {'a': 'hamburger', 'b': 'fries', 'c': {'e': 'coke', 'f': 'coffee'}})
|
||||
assert result == {'a':'hamburger', 'b':'fries', 'c': {'e': 'coke', 'f': 'coffee'}}
|
||||
|
||||
@@ -566,3 +564,5 @@ if __name__ == '__main__':
|
||||
result = jay_merge_full(old, {'update':update, 'add':add, 'delete':delete})
|
||||
assert result == old
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
+39
-37
@@ -54,7 +54,6 @@ car_list = [
|
||||
def rho(temperature_degc: float, p_pa: float =g_p0):
|
||||
return p_pa/(g_RS*(temperature_degc + 273.15))
|
||||
|
||||
|
||||
# Force : N = kg·m·s2
|
||||
def fd(rho: float, velocity_kmh: float, c_val: float, area: float):
|
||||
vel = velocity_kmh / 3.6
|
||||
@@ -62,15 +61,15 @@ def fd(rho: float, velocity_kmh: float, c_val: float, area: float):
|
||||
res = 0.5*rho*vel*vel*cwa
|
||||
return res
|
||||
|
||||
def main() -> None:
|
||||
# Fd vs. velocity, param: temperature
|
||||
temps_list = [-20, -10, 0, 10, 20, 30]
|
||||
vel_list = [20, 40, 60, 80, 100, 120, 130, 140, 160]
|
||||
reference = fd(rho(20), 100, c_val_id3, area_id3)
|
||||
temps_list_leg = [f"{t}°C" for t in temps_list]
|
||||
|
||||
# Fd vs. velocity, param: temperature
|
||||
temps_list = [-20, -10, 0, 10, 20, 30]
|
||||
vel_list = [20, 40, 60, 80, 100, 120, 130, 140, 160]
|
||||
reference = fd(rho(20), 100, c_val_id3, area_id3)
|
||||
temps_list_leg = [f"{t}°C" for t in temps_list]
|
||||
|
||||
plot.figure()
|
||||
for temp_degc in temps_list:
|
||||
plot.figure()
|
||||
for temp_degc in temps_list:
|
||||
rho_t = rho(temp_degc)
|
||||
y_fd = []
|
||||
for vel_kmh in vel_list:
|
||||
@@ -79,22 +78,22 @@ for temp_degc in temps_list:
|
||||
|
||||
plot.plot(vel_list, y_fd)
|
||||
|
||||
plot.title("Windwiderstand vs Geschwindigkeit")
|
||||
plot.ylabel("Windwiderstand [%]")
|
||||
plot.xlabel("Geschwindigkeit [km/h]")
|
||||
plot.legend(temps_list_leg)
|
||||
plot.grid()
|
||||
plot.title("Windwiderstand vs Geschwindigkeit")
|
||||
plot.ylabel("Windwiderstand [%]")
|
||||
plot.xlabel("Geschwindigkeit [km/h]")
|
||||
plot.legend(temps_list_leg)
|
||||
plot.grid()
|
||||
|
||||
# Fd vs. velocity, param: car
|
||||
temp = 20
|
||||
vel_list = [20, 40, 60, 80, 100, 120, 130, 140, 160]
|
||||
car_list_leg = [f"{t['car']}" for t in car_list]
|
||||
# Fd vs. velocity, param: car
|
||||
temp = 20
|
||||
vel_list = [20, 40, 60, 80, 100, 120, 130, 140, 160]
|
||||
car_list_leg = [f"{t['car']}" for t in car_list]
|
||||
|
||||
rho_t = rho(temp)
|
||||
reference = fd(rho_t, 100, c_val_id3, area_id3)
|
||||
rho_t = rho(temp)
|
||||
reference = fd(rho_t, 100, c_val_id3, area_id3)
|
||||
|
||||
plot.figure()
|
||||
for car in car_list:
|
||||
plot.figure()
|
||||
for car in car_list:
|
||||
y_fd = []
|
||||
for vel_kmh in vel_list:
|
||||
fd_t = (fd(rho_t, vel_kmh, car['cw'], car['area'])/reference - 1) * 100
|
||||
@@ -102,23 +101,26 @@ for car in car_list:
|
||||
|
||||
plot.plot(vel_list, y_fd)
|
||||
|
||||
plot.ylabel("Windwiderstand ID.3 [%]")
|
||||
plot.xlabel("Geschwindigkeit [km/h]")
|
||||
plot.title("Windwiderstand vs Geschwindigkeit")
|
||||
plot.legend(car_list_leg)
|
||||
plot.grid()
|
||||
plot.ylabel("Windwiderstand ID.3 [%]")
|
||||
plot.xlabel("Geschwindigkeit [km/h]")
|
||||
plot.title("Windwiderstand vs Geschwindigkeit")
|
||||
plot.legend(car_list_leg)
|
||||
plot.grid()
|
||||
|
||||
plot.figure()
|
||||
y_fd = []
|
||||
for vel_kmh in vel_list:
|
||||
plot.figure()
|
||||
y_fd = []
|
||||
for vel_kmh in vel_list:
|
||||
fd_t = fd(rho_t, vel_kmh, c_val_id3, area_id3)
|
||||
y_fd.append(fd_t)
|
||||
|
||||
plot.plot(vel_list, y_fd)
|
||||
plot.plot(vel_list, y_fd)
|
||||
|
||||
plot.ylabel("Windwiderstand [N]")
|
||||
plot.xlabel("Geschwindigkeit [km/h]")
|
||||
plot.title("Windwiderstand vs Geschwindigkeit")
|
||||
plot.legend(car_list_leg)
|
||||
plot.grid()
|
||||
plot.show()
|
||||
plot.ylabel("Windwiderstand [N]")
|
||||
plot.xlabel("Geschwindigkeit [km/h]")
|
||||
plot.title("Windwiderstand vs Geschwindigkeit")
|
||||
plot.legend(car_list_leg)
|
||||
plot.grid()
|
||||
plot.show()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
+4
-4
@@ -23,7 +23,6 @@ domains = [
|
||||
"measurements"
|
||||
]
|
||||
|
||||
|
||||
class WeCollector:
|
||||
def __init__(self, user):
|
||||
# Init collecting records
|
||||
@@ -92,7 +91,6 @@ class WeCollector:
|
||||
except Exception as e:
|
||||
print(f"Exception: {e}")
|
||||
|
||||
|
||||
def request_loop(wc: WeCollector):
|
||||
_date_last = None
|
||||
_file_timestamp = None
|
||||
@@ -122,8 +120,7 @@ def request_loop(wc: WeCollector):
|
||||
time_to_wait = 0
|
||||
time.sleep(time_to_wait)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(prog="We Collect", description="Collects vehicle data")
|
||||
parser.add_argument("username", help="Username to collect data for (must exist in credentials.py)")
|
||||
parser.add_argument("--loop", help="Execute once or create event loop", type=bool, default=False)
|
||||
@@ -142,3 +139,6 @@ if __name__ == '__main__':
|
||||
print(f"Terminated with Exception {e}")
|
||||
|
||||
print(f"Terminated Normally")
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user