Skip to content

Commit

Permalink
make forecast work for large sites
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdudfield committed Oct 3, 2024
1 parent 9b061ba commit 02668f4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions quartz_solar_forecast/forecast.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from datetime import datetime, timedelta
import logging

import pandas as pd

from quartz_solar_forecast.data import get_nwp, make_pv_data
from quartz_solar_forecast.forecasts import forecast_v1_tilt_orientation, TryolabsSolarPowerPredictor
from quartz_solar_forecast.pydantic_models import PVSite

log = logging.getLogger(__name__)

def predict_ocf(
site: PVSite, model=None, ts: datetime | str = None, nwp_source: str = "icon"
Expand All @@ -25,13 +27,27 @@ def predict_ocf(
if isinstance(ts, str):
ts = datetime.fromisoformat(ts)

if site.capacity_kwp > 4:
log.warning("Your site capacity is greater than 4kWp, "
"however the model is trained on sites with capacity <= 4kWp."
"We therefore will run the model with a capacity of 4 kWp, "
"and we'll scale the results afterwards.")
capacity_kwp_original = site.capacity_kwp
site.capacity_kwp = 4
else:
capacity_kwp_original = site.capacity_kwp

# make pv and nwp data from nwp_source
nwp_xr = get_nwp(site=site, ts=ts, nwp_source=nwp_source)
pv_xr = make_pv_data(site=site, ts=ts)

# load and run models
pred_df = forecast_v1_tilt_orientation(nwp_source, nwp_xr, pv_xr, ts, model=model)

# scale the results if the capacity is different
if capacity_kwp_original != site.capacity_kwp:
pred_df["power_kw"] = pred_df["power_kw"] * capacity_kwp_original / site.capacity_kwp

return pred_df


Expand Down

0 comments on commit 02668f4

Please sign in to comment.