ConniKLu commited on
Commit
727307d
·
verified ·
1 Parent(s): 895dc27

Upload app.py

Browse files

fixed bug concerning price duration curve

Files changed (1) hide show
  1. app.py +17 -21
app.py CHANGED
@@ -923,17 +923,10 @@ def plot_electricity_prices(m, dt, col, df, df_residual_load_duration):
923
  df_price['t'] = df_price['t'].str.strip("'")
924
  df_price['t'] = pd.to_datetime(df_price['t'], format='%Y-%m-%d %H:%M %z')
925
 
926
- # # Line plot for electricity prices
927
- # fig_price = px.line(df_price, y='dual', x='t',
928
- # title=df.loc['plot_label_electricity_prices', st.session_state.lang],
929
- # # range_y=[0, 250],
930
- # labels={'dual': '', 't': ''}
931
- # )
932
- # with col:
933
- # st.plotly_chart(fig_price)
934
 
935
  # Create the price duration curve
936
- df_sorted_price = df_price["dual"].repeat(dt).sort_values(ascending=False).reset_index(drop=True) / int(dt)
 
937
  df_residual_load_sorted = df_residual_load_duration.sort_values(by='Residual_Load', ascending=False).reset_index(drop=True)
938
  df_axis2 = df_residual_load_sorted['Residual_Load']
939
 
@@ -991,7 +984,7 @@ def plot_electricity_prices(m, dt, col, df, df_residual_load_duration):
991
  text=df.loc['plot_label_price_duration_curve', st.session_state.lang],
992
  font=dict(color='blue')
993
  ),
994
- range=[-(100 / (ax2_max / (ax2_max - ax2_min)) - 100), 100],
995
  tickfont=dict(color='blue')
996
  ),
997
  yaxis2=dict(
@@ -1019,17 +1012,20 @@ def plot_electricity_prices(m, dt, col, df, df_residual_load_duration):
1019
  with col:
1020
  st.plotly_chart(fig_duration)
1021
 
1022
- # Set y-axis range conditionally
1023
- range_y = [0, 250] if st.session_state.level == "graduate" else None
1024
- # Line plot for electricity prices
1025
- fig_price = px.line(df_price, y='dual', x='t',
1026
- title=df.loc['plot_label_electricity_prices', st.session_state.lang],
1027
- labels={'dual': '', 't': ''}
1028
- )
1029
-
1030
- # Apply axis range if needed
1031
- if range_y is not None:
1032
- fig_price.update_yaxes(range=range_y)
 
 
 
1033
 
1034
  with col:
1035
  st.plotly_chart(fig_price)
 
923
  df_price['t'] = df_price['t'].str.strip("'")
924
  df_price['t'] = pd.to_datetime(df_price['t'], format='%Y-%m-%d %H:%M %z')
925
 
 
 
 
 
 
 
 
 
926
 
927
  # Create the price duration curve
928
+ # df_sorted_price = df_price["dual"].repeat(dt).sort_values(ascending=False).reset_index(drop=True) / int(dt)
929
+ df_sorted_price = df_price["dual"].repeat(dt).sort_values(ascending=False).reset_index(drop=True)
930
  df_residual_load_sorted = df_residual_load_duration.sort_values(by='Residual_Load', ascending=False).reset_index(drop=True)
931
  df_axis2 = df_residual_load_sorted['Residual_Load']
932
 
 
984
  text=df.loc['plot_label_price_duration_curve', st.session_state.lang],
985
  font=dict(color='blue')
986
  ),
987
+ range=[-(100 / (ax2_max / (ax2_max - ax2_min)) - 100), 300],
988
  tickfont=dict(color='blue')
989
  ),
990
  yaxis2=dict(
 
1012
  with col:
1013
  st.plotly_chart(fig_duration)
1014
 
1015
+ if st.session_state.level == "undergraduate":
1016
+ # Line plot for electricity prices
1017
+ fig_price = px.line(df_price, y='dual', x='t',
1018
+ title=df.loc['plot_label_electricity_prices', st.session_state.lang],
1019
+ range_y = [0, 300],
1020
+ labels={'dual': '', 't': ''}
1021
+ )
1022
+ else:
1023
+ # Line plot for electricity prices
1024
+ fig_price = px.line(df_price, y='dual', x='t',
1025
+ title=df.loc['plot_label_electricity_prices', st.session_state.lang],
1026
+ # range_y = [0, 250],
1027
+ labels={'dual': '', 't': ''}
1028
+ )
1029
 
1030
  with col:
1031
  st.plotly_chart(fig_price)