Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdudfield committed Feb 15, 2024
1 parent 7fe1749 commit 4982480
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions india_forecast_app/model.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""
Model classes (currently just allows for loading a dummy model)
"""

import datetime as dt
import math
import random
Expand Down Expand Up @@ -52,7 +51,9 @@ def _generate_dummy_forecast(self, timestamp: dt.datetime):
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()
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")
Expand Down Expand Up @@ -94,14 +95,12 @@ def _basicSolarYieldFunc(timeUnix: int, scaleFactor: int = 4000) -> float:
# Remove negative values
basefunc = max(0, basefunc)
# Steepen the curve. The divisor is based on the max value
basefunc = basefunc**4 / 1.01**4
basefunc = basefunc ** 4 / 1.01 ** 4

# Instead of completely random noise, apply based on the following process:
# * A base noise function which is the product of long and short sines
# * The resultant function modulates with very small amplitude around 1
noise = (math.sin(math.pi * time.hour) / 20) * (
math.sin(math.pi * time.hour / 3)
) + 1
noise = (math.sin(math.pi * time.hour) / 20) * (math.sin(math.pi * time.hour / 3)) + 1
noise = noise * random.random() / 20 + 0.97

# Create the output value from the base function, noise, and scale factor
Expand Down

0 comments on commit 4982480

Please sign in to comment.