Skip to content

Commit

Permalink
smooth out wind forecast
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdudfield committed Feb 15, 2024
1 parent 1943299 commit 60cca39
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion india_forecast_app/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import datetime as dt
import math
import random
import pandas as pd


class DummyModel:

Check failure on line 11 in india_forecast_app/model.py

View workflow job for this annotation

GitHub Actions / lint_and_test / Lint the code and run the tests

Ruff (I001)

india_forecast_app/model.py:5:1: I001 Import block is un-sorted or un-formatted
Expand Down Expand Up @@ -46,6 +47,16 @@ def _generate_dummy_forecast(self, timestamp: dt.datetime):
}
)

if self.asset_type == "wind":
# change to dataframe
values_df = pd.DataFrame(values)

# smooth the wind forecast
values_df["forecast_power_kw"] = values_df["forecast_power_kw"].rolling(6, min_periods=1).mean()

Check failure on line 55 in india_forecast_app/model.py

View workflow job for this annotation

GitHub Actions / lint_and_test / Lint the code and run the tests

Ruff (E501)

india_forecast_app/model.py:55:101: E501 Line too long (108 > 100)

# turn back to list of dicts
values = values_df.to_dict(orient="records")

return values


Expand Down Expand Up @@ -99,7 +110,7 @@ def _basicSolarYieldFunc(timeUnix: int, scaleFactor: int = 10000) -> float:
return output


def _basicWindYieldFunc(timeUnix: int, scaleFactor: int = 10000) -> float:
def _basicWindYieldFunc(timeUnix: int, scaleFactor: int = 3000) -> float:
"""Gets a fake wind yield for the input time."""
output = min(scaleFactor, scaleFactor * random.random())

Expand Down

0 comments on commit 60cca39

Please sign in to comment.