refactored
This commit is contained in:
+3
-2
@@ -34,8 +34,7 @@ def deep_merge(d, u, only_existing=True):
|
|||||||
d[k] = u[k]
|
d[k] = u[k]
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
if __name__ == '__main__':
|
|
||||||
files = [
|
files = [
|
||||||
"results/WVWZZZE1ZMP010760/2024/10/18/vehicle_WVWZZZE1ZMP010760_2024-10-15T12-05-23.json",
|
"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",
|
"results/WVWZZZE1ZMP010760/2024/10/19/vehicle_WVWZZZE1ZMP010760_2024-10-19T00-00-34.json",
|
||||||
@@ -72,3 +71,5 @@ if __name__ == '__main__':
|
|||||||
# Check integrity
|
# Check integrity
|
||||||
assert src == merged_list
|
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
|
return v_list
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
if __name__ == '__main__':
|
|
||||||
end_points = []
|
end_points = []
|
||||||
for k in settings.eps_defs.keys():
|
for k in settings.eps_defs.keys():
|
||||||
end_points.append(Endpoint(k, settings.eps_defs[k]))
|
end_points.append(Endpoint(k, settings.eps_defs[k]))
|
||||||
@@ -326,3 +325,6 @@ if __name__ == '__main__':
|
|||||||
plot.grid()
|
plot.grid()
|
||||||
|
|
||||||
plot.show()
|
plot.show()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ def model_bat_dcr(temperature: float, soc: float, p: Params):
|
|||||||
return rb * np.exp(p.alpha*(t2 - tb2) + p.beta*(_t - tb))
|
return rb * np.exp(p.alpha*(t2 - tb2) + p.beta*(_t - tb))
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
temps = [0, 5, 10, 20, 25, 40]
|
temps = [0, 5, 10, 20, 25, 40]
|
||||||
pl = 10000
|
pl = 10000
|
||||||
il = 100
|
il = 100
|
||||||
@@ -72,3 +73,6 @@ for sp, name, title in zip([0, 1], ["P_loss [kW]", "P_batt [kW]"], titles):
|
|||||||
plot.ylabel(name)
|
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
|
return res
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
if __name__ == '__main__':
|
|
||||||
|
|
||||||
result = jay_diff_add({}, {'a': 'hamburger', 'b': 'fries', 'c': {'e': 'coke', 'f': 'coffee'}})
|
result = jay_diff_add({}, {'a': 'hamburger', 'b': 'fries', 'c': {'e': 'coke', 'f': 'coffee'}})
|
||||||
assert result == {'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})
|
result = jay_merge_full(old, {'update':update, 'add':add, 'delete':delete})
|
||||||
assert result == old
|
assert result == old
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|||||||
+4
-2
@@ -54,7 +54,6 @@ car_list = [
|
|||||||
def rho(temperature_degc: float, p_pa: float =g_p0):
|
def rho(temperature_degc: float, p_pa: float =g_p0):
|
||||||
return p_pa/(g_RS*(temperature_degc + 273.15))
|
return p_pa/(g_RS*(temperature_degc + 273.15))
|
||||||
|
|
||||||
|
|
||||||
# Force : N = kg·m·s2
|
# Force : N = kg·m·s2
|
||||||
def fd(rho: float, velocity_kmh: float, c_val: float, area: float):
|
def fd(rho: float, velocity_kmh: float, c_val: float, area: float):
|
||||||
vel = velocity_kmh / 3.6
|
vel = velocity_kmh / 3.6
|
||||||
@@ -62,7 +61,7 @@ def fd(rho: float, velocity_kmh: float, c_val: float, area: float):
|
|||||||
res = 0.5*rho*vel*vel*cwa
|
res = 0.5*rho*vel*vel*cwa
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
# Fd vs. velocity, param: temperature
|
# Fd vs. velocity, param: temperature
|
||||||
temps_list = [-20, -10, 0, 10, 20, 30]
|
temps_list = [-20, -10, 0, 10, 20, 30]
|
||||||
vel_list = [20, 40, 60, 80, 100, 120, 130, 140, 160]
|
vel_list = [20, 40, 60, 80, 100, 120, 130, 140, 160]
|
||||||
@@ -122,3 +121,6 @@ plot.title("Windwiderstand vs Geschwindigkeit")
|
|||||||
plot.legend(car_list_leg)
|
plot.legend(car_list_leg)
|
||||||
plot.grid()
|
plot.grid()
|
||||||
plot.show()
|
plot.show()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|||||||
+4
-4
@@ -23,7 +23,6 @@ domains = [
|
|||||||
"measurements"
|
"measurements"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class WeCollector:
|
class WeCollector:
|
||||||
def __init__(self, user):
|
def __init__(self, user):
|
||||||
# Init collecting records
|
# Init collecting records
|
||||||
@@ -92,7 +91,6 @@ class WeCollector:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Exception: {e}")
|
print(f"Exception: {e}")
|
||||||
|
|
||||||
|
|
||||||
def request_loop(wc: WeCollector):
|
def request_loop(wc: WeCollector):
|
||||||
_date_last = None
|
_date_last = None
|
||||||
_file_timestamp = None
|
_file_timestamp = None
|
||||||
@@ -122,8 +120,7 @@ def request_loop(wc: WeCollector):
|
|||||||
time_to_wait = 0
|
time_to_wait = 0
|
||||||
time.sleep(time_to_wait)
|
time.sleep(time_to_wait)
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
if __name__ == '__main__':
|
|
||||||
parser = argparse.ArgumentParser(prog="We Collect", description="Collects vehicle data")
|
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("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)
|
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 with Exception {e}")
|
||||||
|
|
||||||
print(f"Terminated Normally")
|
print(f"Terminated Normally")
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user