From 5135dde56417255b172ef44fe720c7b6e0e62c4f Mon Sep 17 00:00:00 2001 From: peterdudfield Date: Wed, 24 Apr 2024 11:46:06 +0100 Subject: [PATCH 01/11] rework sie forecast, to add DA forecast --- requirements.txt | 2 +- src/pvsite_forecast.py | 35 +++++++++++++++++++++++++++-------- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/requirements.txt b/requirements.txt index fa2cc4e..7327cb1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ altair==4.2.2 nowcasting_datamodel==1.5.39 -pvsite-datamodel==1.0.19 +pvsite-datamodel==1.0.20 numpy==1.24.1 pandas==1.5.3 plotly==5.10.0 diff --git a/src/pvsite_forecast.py b/src/pvsite_forecast.py index ee7416d..49b649c 100644 --- a/src/pvsite_forecast.py +++ b/src/pvsite_forecast.py @@ -31,20 +31,37 @@ def pvsite_forecast_page(): site_selection = st.sidebar.selectbox("Select sites by site_uuid", site_uuids,) starttime = st.sidebar.date_input("Start Date", min_value=datetime.today() - timedelta(days=365), max_value=datetime.today()) - created = st.sidebar.text_input("Created Before", pd.Timestamp.now().ceil('15min')) - if created == "": - created = datetime.now() + forecast_type = st.sidebar.selectbox("Select Forecast Type", ["Latest", "Forecast_horizon", "DA"], 0) + + if forecast_type == "Latest": + created = st.sidebar.text_input("Created Before", pd.Timestamp.now().ceil('15min')) + + if created == "": + created = datetime.now() + else: + created = datetime.fromisoformat(created) + st.write("Forecast for", site_selection, "starting on", starttime, "created by", created) + else: + created = None + + if forecast_type == "Forecast_horizon": + forecast_horizon = st.sidebar.selectbox("Select Forecast Horizon", range(0,2880,15), 5) else: - created = datetime.fromisoformat(created) - st.write("Forecast for", site_selection, "starting on", starttime, "created by", created) + forecast_horizon = None - forecast_horizon = st.sidebar.selectbox("Select Forecast Horizon", range(0,2880,15), None) + if forecast_type == "DA": + day_ahead_hours = 9 + day_ahead_timezone_delta_hours = 5.5 + st.write(f"Forecast for {day_ahead_hours} oclock the day before " + f"with {day_ahead_timezone_delta_hours} hour timezone delta") + else: + day_ahead_hours = None + day_ahead_timezone_delta_hours = None # an option to resample to the data resample = st.sidebar.selectbox("Resample data", [None, "15T", "30T"], None) - # get forecast values for selected sites and plot with connection.get_session() as session: forecasts = get_latest_forecast_values_by_site( @@ -52,7 +69,9 @@ def pvsite_forecast_page(): site_uuids=[site_selection], start_utc=starttime, created_by=created, - forecast_horizon_minutes=forecast_horizon + forecast_horizon_minutes=forecast_horizon, + day_ahead_hours=day_ahead_hours, + day_ahead_timezone_delta_hours=day_ahead_timezone_delta_hours ) forecasts = forecasts.values() From 111d09b39fb5c147a63284cb2e066d8347d4042c Mon Sep 17 00:00:00 2001 From: peterdudfield Date: Wed, 24 Apr 2024 11:52:19 +0100 Subject: [PATCH 02/11] pvsite-datamodel==1.0.21 --- requirements.txt | 2 +- src/pvsite_forecast.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 7327cb1..881b24b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ altair==4.2.2 nowcasting_datamodel==1.5.39 -pvsite-datamodel==1.0.20 +pvsite-datamodel==1.0.21 numpy==1.24.1 pandas==1.5.3 plotly==5.10.0 diff --git a/src/pvsite_forecast.py b/src/pvsite_forecast.py index 49b649c..a82b356 100644 --- a/src/pvsite_forecast.py +++ b/src/pvsite_forecast.py @@ -51,6 +51,7 @@ def pvsite_forecast_page(): forecast_horizon = None if forecast_type == "DA": + # TODO make these more flexible day_ahead_hours = 9 day_ahead_timezone_delta_hours = 5.5 st.write(f"Forecast for {day_ahead_hours} oclock the day before " From b8ec31c6a93375318482e897904d071720783437 Mon Sep 17 00:00:00 2001 From: peterdudfield Date: Wed, 24 Apr 2024 11:54:52 +0100 Subject: [PATCH 03/11] adjust default values --- src/pvsite_forecast.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pvsite_forecast.py b/src/pvsite_forecast.py index a82b356..e4d13ab 100644 --- a/src/pvsite_forecast.py +++ b/src/pvsite_forecast.py @@ -46,7 +46,7 @@ def pvsite_forecast_page(): created = None if forecast_type == "Forecast_horizon": - forecast_horizon = st.sidebar.selectbox("Select Forecast Horizon", range(0,2880,15), 5) + forecast_horizon = st.sidebar.selectbox("Select Forecast Horizon", range(0,2880,15), 6) else: forecast_horizon = None From fb13987af3f4980b465d10f0dbb50ade91e5ae92 Mon Sep 17 00:00:00 2001 From: peterdudfield Date: Wed, 24 Apr 2024 11:56:12 +0100 Subject: [PATCH 04/11] adjust axis --- src/pvsite_forecast.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pvsite_forecast.py b/src/pvsite_forecast.py index e4d13ab..034137a 100644 --- a/src/pvsite_forecast.py +++ b/src/pvsite_forecast.py @@ -113,7 +113,7 @@ def pvsite_forecast_page(): fig = go.Figure( layout=go.Layout( title=go.layout.Title(text="Latest Forecast for Selected Site"), - xaxis=go.layout.XAxis(title=go.layout.xaxis.Title(text="Date")), + xaxis=go.layout.XAxis(title=go.layout.xaxis.Title(text="Time [UTC]")), yaxis=go.layout.YAxis(title=go.layout.yaxis.Title(text="KW")), legend=go.layout.Legend(title=go.layout.legend.Title(text="Chart Legend")), ) From e90b8f149023f01402a0cfa26275cd764e7c6632 Mon Sep 17 00:00:00 2001 From: peterdudfield Date: Wed, 24 Apr 2024 12:01:50 +0100 Subject: [PATCH 05/11] use github remove-python3.9 specific bit --- .github/workflows/pytest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index b29efc9..e6fa630 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -6,7 +6,7 @@ on: - cron: "0 12 * * 1" jobs: call-run-python-tests: - uses: openclimatefix/.github/.github/workflows/python-test.yml@main + uses: openclimatefix/.github/.github/workflows/python-test.yml@remove-python3.9-specifc with: # default python versions to use python-version: "['3.11']" From 7ad1f7e035634dfb198070a5c3009d977fda1547 Mon Sep 17 00:00:00 2001 From: peterdudfield Date: Wed, 24 Apr 2024 12:20:29 +0100 Subject: [PATCH 06/11] trigger --- .github/workflows/pytest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index e6fa630..efb6dea 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -9,7 +9,7 @@ jobs: uses: openclimatefix/.github/.github/workflows/python-test.yml@remove-python3.9-specifc with: # default python versions to use - python-version: "['3.11']" + python-version: "['3.11']" # pytest-cov looks at this folder pytest_cov_dir: "src" # brew_install: "proj geos librttopo" From ae6c1126f97ecc1a80d2a45ce6ec79a2e75e8f00 Mon Sep 17 00:00:00 2001 From: peterdudfield Date: Wed, 24 Apr 2024 12:23:37 +0100 Subject: [PATCH 07/11] trigger --- .github/workflows/pytest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index efb6dea..e6fa630 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -9,7 +9,7 @@ jobs: uses: openclimatefix/.github/.github/workflows/python-test.yml@remove-python3.9-specifc with: # default python versions to use - python-version: "['3.11']" + python-version: "['3.11']" # pytest-cov looks at this folder pytest_cov_dir: "src" # brew_install: "proj geos librttopo" From 8023870060392539f3f00f2641773ce18504c663 Mon Sep 17 00:00:00 2001 From: peterdudfield Date: Wed, 24 Apr 2024 12:28:34 +0100 Subject: [PATCH 08/11] trigger --- .github/workflows/pytest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index e6fa630..efb6dea 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -9,7 +9,7 @@ jobs: uses: openclimatefix/.github/.github/workflows/python-test.yml@remove-python3.9-specifc with: # default python versions to use - python-version: "['3.11']" + python-version: "['3.11']" # pytest-cov looks at this folder pytest_cov_dir: "src" # brew_install: "proj geos librttopo" From 4c9da473556e1438a24b98eec92fccd0e543236e Mon Sep 17 00:00:00 2001 From: peterdudfield Date: Wed, 24 Apr 2024 12:33:40 +0100 Subject: [PATCH 09/11] trigger --- .github/workflows/pytest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index efb6dea..e6fa630 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -9,7 +9,7 @@ jobs: uses: openclimatefix/.github/.github/workflows/python-test.yml@remove-python3.9-specifc with: # default python versions to use - python-version: "['3.11']" + python-version: "['3.11']" # pytest-cov looks at this folder pytest_cov_dir: "src" # brew_install: "proj geos librttopo" From 02ac0c5a1cd3ce2f964b1990cce14a9b15808151 Mon Sep 17 00:00:00 2001 From: peterdudfield Date: Wed, 24 Apr 2024 12:40:08 +0100 Subject: [PATCH 10/11] move back to main --- .github/workflows/pytest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index e6fa630..b29efc9 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -6,7 +6,7 @@ on: - cron: "0 12 * * 1" jobs: call-run-python-tests: - uses: openclimatefix/.github/.github/workflows/python-test.yml@remove-python3.9-specifc + uses: openclimatefix/.github/.github/workflows/python-test.yml@main with: # default python versions to use python-version: "['3.11']" From 1dc880e6dd167cc31827c12398a6e84d973c0494 Mon Sep 17 00:00:00 2001 From: peterdudfield Date: Wed, 24 Apr 2024 12:41:20 +0100 Subject: [PATCH 11/11] use v1.8.4 --- .github/workflows/pytest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index b29efc9..b4100e7 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -6,7 +6,7 @@ on: - cron: "0 12 * * 1" jobs: call-run-python-tests: - uses: openclimatefix/.github/.github/workflows/python-test.yml@main + uses: openclimatefix/.github/.github/workflows/python-test.yml@v1.8.4 with: # default python versions to use python-version: "['3.11']"