Skip to content

Commit

Permalink
Merge pull request #141 from openclimatefix/issue/da-read
Browse files Browse the repository at this point in the history
Issue/da read
  • Loading branch information
peterdudfield authored Apr 24, 2024
2 parents d4b94f2 + 1dc880e commit 0515200
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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']"
Expand Down
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.39
pvsite-datamodel==1.0.19
pvsite-datamodel==1.0.21
numpy==1.24.1
pandas==1.5.3
plotly==5.10.0
Expand Down
38 changes: 29 additions & 9 deletions src/pvsite_forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,48 @@ 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 = datetime.fromisoformat(created)
st.write("Forecast for", site_selection, "starting on", starttime, "created by", created)
created = None

forecast_horizon = st.sidebar.selectbox("Select Forecast Horizon", range(0,2880,15), None)
if forecast_type == "Forecast_horizon":
forecast_horizon = st.sidebar.selectbox("Select Forecast Horizon", range(0,2880,15), 6)
else:
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 "
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(
session=session,
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()
Expand Down Expand Up @@ -93,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")),
)
Expand Down

0 comments on commit 0515200

Please sign in to comment.