Skip to content

Commit

Permalink
Bugfix on plot generation
Browse files Browse the repository at this point in the history
Out of range index caused prediction to fail under certain circumstances.
  • Loading branch information
salewis38 authored Oct 2, 2023
1 parent 57da7ab commit d740821
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions palm_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ def compute_tgt_soc(self, gen_fcast, weight: int, commit: bool) -> str:
# the battery charge based on forecast generation and historical usage. Capture values
# for maximum charge and also the minimum charge value at any time before the maximum.

day = 0
diff = 0
day: int = 0
diff: int = 0
while day < 2: # Repeat for tomorrow and next day
batt_charge[0] = max_charge = min_charge = reserve_energy
est_gen = 0
Expand Down Expand Up @@ -504,9 +504,9 @@ def compute_tgt_soc(self, gen_fcast, weight: int, commit: bool) -> str:
while i < 48:
if day == 1 and i == 0:
diff = plot_y2[48] - plot_y1[49]
if plot_y1[day*48 + i + 1] + diff > 100: # Correct for SoC > 100%
if day == 1 and plot_y1[day*48 + i + 1] + diff > 100: # Correct for SoC > 100%
diff = 100 - plot_y1[day*48 + i]
plot_y2.append(plot_y1[day*48 + i + 1] + diff)
plot_y2.append(max(0, min(100, plot_y1[day*48 + i + 1] + diff)))
i += 1
day += 1

Expand Down

0 comments on commit d740821

Please sign in to comment.