Skip to content

Commit

Permalink
Adjust truck battery size, with uncertainty
Browse files Browse the repository at this point in the history
  • Loading branch information
romainsacchi authored and romainsacchi committed Aug 21, 2024
1 parent 21613be commit 3bf0cb0
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions premise/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,26 +630,28 @@ def adjust_battery_size(self, ds):
# detect size in name
size = [s for s in self.battery_size["truck"] if s in ds["name"]][0]

if self.year < min(self.battery_size["truck"][size].keys()):
print(self.battery_size["truck"][size])

if self.year <= min(self.battery_size["truck"][size].keys()):
mean_battery_size = self.battery_size["truck"][size][
min(self.battery_size["truck"][size]["mean"].keys())
]
min(self.battery_size["truck"][size].keys())
]["mean"]
min_battery_size = self.battery_size["truck"][size][
min(self.battery_size["truck"][size]["min"].keys())
]
min(self.battery_size["truck"][size].keys())
]["min"]
max_battery_size = self.battery_size["truck"][size][
min(self.battery_size["truck"][size]["max"].keys())
]
elif self.year > max(self.battery_size["truck"][size].keys()):
min(self.battery_size["truck"][size].keys())
]["max"]
elif self.year >= max(self.battery_size["truck"][size].keys()):
mean_battery_size = self.battery_size["truck"][size][
max(self.battery_size["truck"][size]["mean"].keys())
]
max(self.battery_size["truck"][size].keys())
]["mean"]
min_battery_size = self.battery_size["truck"][size][
max(self.battery_size["truck"][size]["min"].keys())
]
max(self.battery_size["truck"][size].keys())
]["min"]
max_battery_size = self.battery_size["truck"][size][
max(self.battery_size["truck"][size]["max"].keys())
]
max(self.battery_size["truck"][size].keys())
]["max"]
else:
mean_battery_size = np.interp(
self.year,
Expand All @@ -674,7 +676,7 @@ def adjust_battery_size(self, ds):
exc["minimum"] = min_battery_size
exc["maximum"] = max_battery_size

ds["comment"] += f" Battery size adjusted to {battery_size} kWh."
ds["comment"] += f" Battery size adjusted to {mean_battery_size} kWh."

def write_log(self, dataset, status="created"):
"""
Expand Down

0 comments on commit 3bf0cb0

Please sign in to comment.