Skip to content

Commit

Permalink
add options of forecast page
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdudfield committed Mar 12, 2024
1 parent 32715b0 commit 822835a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
altair==4.2.2
nowcasting_datamodel==1.5.32
pvsite-datamodel==1.0.7
pvsite-datamodel==1.0.14
numpy==1.24.1
pandas==1.5.3
plotly==5.10.0
Expand Down
13 changes: 12 additions & 1 deletion src/pvsite_forecast.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import pandas as pd

Check warning on line 2 in src/pvsite_forecast.py

View check run for this annotation

Codecov / codecov/patch

src/pvsite_forecast.py#L2

Added line #L2 was not covered by tests
import streamlit as st
from datetime import datetime, timedelta, time, timezone
from pvsite_datamodel.connection import DatabaseConnection
Expand Down Expand Up @@ -30,14 +31,24 @@ 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=3), max_value=datetime.today())
st.write("Forecast for", site_selection, "starting on", starttime)
created = st.sidebar.text_input("Created Before", pd.Timestamp.now().ceil('15min'))

Check warning on line 34 in src/pvsite_forecast.py

View check run for this annotation

Codecov / codecov/patch

src/pvsite_forecast.py#L34

Added line #L34 was not covered by tests

if created == "":
created = datetime.now()

Check warning on line 37 in src/pvsite_forecast.py

View check run for this annotation

Codecov / codecov/patch

src/pvsite_forecast.py#L36-L37

Added lines #L36 - L37 were not covered by tests
else:
created = datetime.fromisoformat(created)
st.write("Forecast for", site_selection, "starting on", starttime, "created by", created)

Check warning on line 40 in src/pvsite_forecast.py

View check run for this annotation

Codecov / codecov/patch

src/pvsite_forecast.py#L39-L40

Added lines #L39 - L40 were not covered by tests

forecast_horizon = st.sidebar.selectbox("Select Forecast Horizon", range(0,2880,15), None)

Check warning on line 42 in src/pvsite_forecast.py

View check run for this annotation

Codecov / codecov/patch

src/pvsite_forecast.py#L42

Added line #L42 was not covered by tests

# get forecast values for selected sites and plot
with connection.get_session() as session:
forecasts = get_latest_forecast_values_by_site(
session=session,
site_uuids=[site_selection],
start_utc=starttime,
created_by=created,
forecast_horizon_minutes=forecast_horizon
)

forecasts = forecasts.values()
Expand Down

0 comments on commit 822835a

Please sign in to comment.