From 3c5626d8e98dab6aa61e65757637f32f3820a948 Mon Sep 17 00:00:00 2001 From: Peter Dudfield <34686298+peterdudfield@users.noreply.github.com> Date: Thu, 21 Mar 2024 07:26:40 +0000 Subject: [PATCH] bug in forecast.run_forecast: 'nwp_source' was not respected (#85) (#88) * 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 Co-authored-by: Jakob Elias Gebler --- quartz_solar_forecast/forecast.py | 4 ++-- tests/test_forecast.py | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/quartz_solar_forecast/forecast.py b/quartz_solar_forecast/forecast.py index 9e32c0e7..5a6e1fd6 100644 --- a/quartz_solar_forecast/forecast.py +++ b/quartz_solar_forecast/forecast.py @@ -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 diff --git a/tests/test_forecast.py b/tests/test_forecast.py index 4d0d1e06..1316c284 100644 --- a/tests/test_forecast.py +++ b/tests/test_forecast.py @@ -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()}")