Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions src/pvsite_forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,16 @@ def pvsite_forecast_page():
"Select site by", ("site_uuid", "client_site_name")
)

if query_method == "site_uuid":
site_selection_uuid = st.sidebar.selectbox(
"Select sites by site_uuid",
site_uuids,
)
if query_method == "site_uuid":
site_selection_uuid = st.sidebar.selectbox(
"Select sites by site_uuid",
site_uuids,
)

else:
client_site_name = st.sidebar.selectbox(
"Select sites by client_site_name",
sorted([sites.client_location_name for sites in sites]),

resample = st.sidebar.selectbox("Resample data", [None, "15min", "30min"], None)
,
)
site_selection_uuid = [
sites.location_uuid
Expand Down Expand Up @@ -331,7 +331,13 @@ class Models:
df_forecast.set_index("forecast_datetime", inplace=True)
df_generation.set_index("generation_datetime", inplace=True)

if resample is not None:
# … your df_generation setup above …

# if the user hasn’t chosen a resample interval, prompt them
if resample is None:
st.caption("Please resample to '15min' to get MAE")
else:
# actually do the resampling and merge
df_forecast = df_forecast.resample(resample).mean()
df_generation = df_generation.resample(resample).mean()

Expand All @@ -340,10 +346,11 @@ class Models:
df_generation, left_index=True, right_index=True, how="outer"
)

# select variables
# now you can reassign xx/yy or whatever follows…
xx = df_all.index
yy = df_all["generation_power_kw"]


fig = go.Figure(
layout=go.Layout(
title=go.layout.Title(text="Latest Forecast for Selected Site"),
Expand Down Expand Up @@ -694,4 +701,4 @@ def convert_df(df: pd.DataFrame):
mime="text/csv",
)
else:
st.info("No valid data available for error metrics visualization. Please check if your selected time range contains both forecast and generation data.")
st.info("No valid data available for error metrics visualization. Please check if your selected time range contains both forecast and generation data.")
Loading