diff --git a/src/pvsite_forecast.py b/src/pvsite_forecast.py index d4d6ad6..7f8edbd 100644 --- a/src/pvsite_forecast.py +++ b/src/pvsite_forecast.py @@ -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 @@ -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() @@ -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"), @@ -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.") \ No newline at end of file + st.info("No valid data available for error metrics visualization. Please check if your selected time range contains both forecast and generation data.")