From 60cca393ba7294625217b9a8499ebb3d06938cdd Mon Sep 17 00:00:00 2001 From: peterdudfield Date: Thu, 15 Feb 2024 21:05:15 +0000 Subject: [PATCH] smooth out wind forecast --- india_forecast_app/model.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/india_forecast_app/model.py b/india_forecast_app/model.py index f4d0898..6970ae3 100644 --- a/india_forecast_app/model.py +++ b/india_forecast_app/model.py @@ -5,6 +5,7 @@ import datetime as dt import math import random +import pandas as pd class DummyModel: @@ -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() + + # turn back to list of dicts + values = values_df.to_dict(orient="records") + return values @@ -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())