Skip to content

Commit

Permalink
bug in forecast.run_forecast: 'nwp_source' was not respected (#85) (#88)
Browse files Browse the repository at this point in the history
* bug in forecast.run_forecast: 'nwp_source' was not respected when loading the nwp data

* adjustment of the test for run_forecast. Test for ICON and GFS NWP.

---------

Co-authored-by: Jakob Gebler <[email protected]>
Co-authored-by: Jakob Elias Gebler <[email protected]>
  • Loading branch information
3 people authored Mar 21, 2024
1 parent ad91007 commit 3c5626d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions quartz_solar_forecast/forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def run_forecast(site: PVSite, ts: datetime | str = None, nwp_source: str = "ico
if isinstance(ts, str):
ts = datetime.fromisoformat(ts)

# make pv and nwp data from GFS
nwp_xr = get_nwp(site=site, ts=ts)
# 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
Expand Down
13 changes: 9 additions & 4 deletions tests/test_forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ def test_run_forecast():
# make input data
site = PVSite(latitude=51.75, longitude=-1.25, capacity_kwp=1.25)

# run model
predications_df = run_forecast(site=site, ts='2023-10-30')
# run model with icon and gfs nwp
predications_df_gfs = run_forecast(site=site, ts='2023-10-30', nwp_source="gfs")
predications_df_icon = run_forecast(site=site, ts='2023-10-30', nwp_source="icon")

print(predications_df)
print(f"Max: {predications_df['power_wh'].max()}")
print("\nPrediction based on GFS NWP\n")
print(predications_df_gfs)
print(f"Max: {predications_df_gfs['power_wh'].max()}")

print("\nPrediction based on ICON NWP\n")
print(predications_df_icon)
print(f"Max: {predications_df_icon['power_wh'].max()}")

0 comments on commit 3c5626d

Please sign in to comment.