Diego Marroquin commited on
Commit ·
a2df43f
1
Parent(s): 5b21d40
previous version with only nucmonitor
Browse files
app.py
CHANGED
|
@@ -577,99 +577,99 @@ def run_app():
|
|
| 577 |
|
| 578 |
st.write(df_photo_date_2)
|
| 579 |
|
| 580 |
-
# Create a Table that displays the forecast of each dataframe total for two months before date and two months after
|
| 581 |
-
# Create a Table that displays the forecast of each dataframe for the Winter months (Nov, Dec, Jan, Feb, Mar)
|
| 582 |
-
|
| 583 |
-
# Filter dates for two months before and after the current date
|
| 584 |
-
# Define date ranges
|
| 585 |
-
two_months_before = (current_date - pd.DateOffset(months=2)).strftime('%Y-%m-%d')
|
| 586 |
-
one_month_before = (current_date - pd.DateOffset(months=1)).strftime('%Y-%m-%d')
|
| 587 |
-
one_month_after = (current_date + pd.DateOffset(months=1)).strftime('%Y-%m-%d')
|
| 588 |
-
two_months_after = (current_date + pd.DateOffset(months=2)).strftime('%Y-%m-%d')
|
| 589 |
-
|
| 590 |
-
# Filter DataFrames based on date ranges
|
| 591 |
-
df_nucmonitor_filtered = df_nucmonitor_2[
|
| 592 |
-
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
]
|
| 598 |
-
|
| 599 |
-
df_photo_date_filtered = df_photo_date_2[
|
| 600 |
-
|
| 601 |
-
|
| 602 |
-
|
| 603 |
-
|
| 604 |
-
|
| 605 |
-
]
|
| 606 |
-
|
| 607 |
-
# Display the filtered DataFrames
|
| 608 |
-
st.write(f"Forecast update {current_date_str}")
|
| 609 |
-
st.write(df_nucmonitor_filtered)
|
| 610 |
-
st.write(f"Forecast update {past_date_str}")
|
| 611 |
-
st.write(df_photo_date_filtered)
|
| 612 |
-
current_forecast_update = df_nucmonitor_filtered.tolist()
|
| 613 |
-
past_forecast_update = df_photo_date_filtered.tolist()
|
| 614 |
-
delta = [current - past for current, past in zip(current_forecast_update, past_forecast_update)]
|
| 615 |
-
|
| 616 |
-
# Create a DataFrame for display
|
| 617 |
-
data = {
|
| 618 |
-
|
| 619 |
-
|
| 620 |
-
|
| 621 |
-
|
| 622 |
-
}
|
| 623 |
-
|
| 624 |
-
df_display = pd.DataFrame(data)
|
| 625 |
-
|
| 626 |
-
# Display the DataFrame as a horizontal table
|
| 627 |
-
st.write("Table 1. Average expected availability on the French nuclear fleet (MW) - M-1, M, M+1, M+2, M+3")
|
| 628 |
-
st.table(df_display)
|
| 629 |
-
|
| 630 |
-
|
| 631 |
-
# Line charts of the forecasts (need to combine them so they appear in the same chart)
|
| 632 |
-
st.write("Current forecast")
|
| 633 |
-
st.line_chart(df_nucmonitor_2)
|
| 634 |
-
|
| 635 |
-
st.write("Previous forecast")
|
| 636 |
-
st.line_chart(df_photo_date_2)
|
| 637 |
-
# Create a new dataframe out of df_nucmonitor_2 call real_forecast that contains df_nucmonitor_2 up until current_date
|
| 638 |
-
|
| 639 |
-
# Slice the DataFrame to include data up until current_date
|
| 640 |
-
real_forecast = df_nucmonitor_2.loc[df_nucmonitor_2.index <= current_date_str]
|
| 641 |
-
|
| 642 |
-
# Optionally, if you want to reset the index
|
| 643 |
-
# real_forecast = real_forecast.reset_index()
|
| 644 |
-
print(real_forecast)
|
| 645 |
-
st.write("Real forecast")
|
| 646 |
-
st.line_chart(real_forecast)
|
| 647 |
|
| 648 |
-
# Combine dataframes
|
| 649 |
-
combined_df = pd.concat([df_nucmonitor_2, df_photo_date_2, real_forecast], axis=1)
|
| 650 |
-
combined_df.columns = [f'Forecast {current_date_str}', f'Forecast {past_date_str}', 'Real Forecast']
|
| 651 |
|
| 652 |
-
print(combined_df)
|
| 653 |
-
st.write(f"Graph 1. {start_date} to {end_date}")
|
| 654 |
-
st.line_chart(combined_df)
|
| 655 |
|
| 656 |
-
# Set Nucmonitor as a dotted line until the current date
|
| 657 |
|
| 658 |
-
fig, ax = plt.subplots(figsize=(10, 6))
|
| 659 |
|
| 660 |
-
plt.plot(combined_df.index, combined_df[f'Forecast {current_date_str}'], 'r--', label=f'Forecast {current_date_str}')
|
| 661 |
-
plt.plot(combined_df.index, combined_df[f'Forecast {past_date_str}'], 'b-', label=f'Forecast {past_date_str}')
|
| 662 |
|
| 663 |
-
plt.axvline(current_date_str, color='k', linestyle='--', linewidth=1, label='Current Date')
|
| 664 |
|
| 665 |
-
# Set the x-axis to show only the first day of every month
|
| 666 |
-
ax.xaxis.set_major_locator(MonthLocator(bymonthday=1))
|
| 667 |
|
| 668 |
-
plt.legend()
|
| 669 |
|
| 670 |
-
plt.xticks(rotation=45)
|
| 671 |
|
| 672 |
-
st.pyplot(fig)
|
| 673 |
|
| 674 |
# For Historical Winter Availability, can just get the max and min of each month, store as list in a column, and try to graph that
|
| 675 |
|
|
|
|
| 577 |
|
| 578 |
st.write(df_photo_date_2)
|
| 579 |
|
| 580 |
+
# # Create a Table that displays the forecast of each dataframe total for two months before date and two months after
|
| 581 |
+
# # Create a Table that displays the forecast of each dataframe for the Winter months (Nov, Dec, Jan, Feb, Mar)
|
| 582 |
+
|
| 583 |
+
# # Filter dates for two months before and after the current date
|
| 584 |
+
# # Define date ranges
|
| 585 |
+
# two_months_before = (current_date - pd.DateOffset(months=2)).strftime('%Y-%m-%d')
|
| 586 |
+
# one_month_before = (current_date - pd.DateOffset(months=1)).strftime('%Y-%m-%d')
|
| 587 |
+
# one_month_after = (current_date + pd.DateOffset(months=1)).strftime('%Y-%m-%d')
|
| 588 |
+
# two_months_after = (current_date + pd.DateOffset(months=2)).strftime('%Y-%m-%d')
|
| 589 |
+
|
| 590 |
+
# # Filter DataFrames based on date ranges
|
| 591 |
+
# df_nucmonitor_filtered = df_nucmonitor_2[
|
| 592 |
+
# (df_nucmonitor_2.index == two_months_before) |
|
| 593 |
+
# (df_nucmonitor_2.index == one_month_before) |
|
| 594 |
+
# (df_nucmonitor_2.index == current_date_str) |
|
| 595 |
+
# (df_nucmonitor_2.index == one_month_after) |
|
| 596 |
+
# (df_nucmonitor_2.index == two_months_after)
|
| 597 |
+
# ]
|
| 598 |
+
|
| 599 |
+
# df_photo_date_filtered = df_photo_date_2[
|
| 600 |
+
# (df_photo_date_2.index == two_months_before) |
|
| 601 |
+
# (df_photo_date_2.index == one_month_before) |
|
| 602 |
+
# (df_photo_date_2.index == current_date_str) |
|
| 603 |
+
# (df_photo_date_2.index == one_month_after) |
|
| 604 |
+
# (df_photo_date_2.index == two_months_after)
|
| 605 |
+
# ]
|
| 606 |
+
|
| 607 |
+
# # Display the filtered DataFrames
|
| 608 |
+
# st.write(f"Forecast update {current_date_str}")
|
| 609 |
+
# st.write(df_nucmonitor_filtered)
|
| 610 |
+
# st.write(f"Forecast update {past_date_str}")
|
| 611 |
+
# st.write(df_photo_date_filtered)
|
| 612 |
+
# current_forecast_update = df_nucmonitor_filtered.tolist()
|
| 613 |
+
# past_forecast_update = df_photo_date_filtered.tolist()
|
| 614 |
+
# delta = [current - past for current, past in zip(current_forecast_update, past_forecast_update)]
|
| 615 |
+
|
| 616 |
+
# # Create a DataFrame for display
|
| 617 |
+
# data = {
|
| 618 |
+
# 'Dates': [two_months_before, one_month_before, current_date_str, one_month_after, two_months_after],
|
| 619 |
+
# f"Forecast update {current_date_str}": current_forecast_update,
|
| 620 |
+
# f"Forecast update {past_date_str}": past_forecast_update,
|
| 621 |
+
# 'Delta': delta
|
| 622 |
+
# }
|
| 623 |
+
|
| 624 |
+
# df_display = pd.DataFrame(data)
|
| 625 |
+
|
| 626 |
+
# # Display the DataFrame as a horizontal table
|
| 627 |
+
# st.write("Table 1. Average expected availability on the French nuclear fleet (MW) - M-1, M, M+1, M+2, M+3")
|
| 628 |
+
# st.table(df_display)
|
| 629 |
+
|
| 630 |
+
|
| 631 |
+
# # Line charts of the forecasts (need to combine them so they appear in the same chart)
|
| 632 |
+
# st.write("Current forecast")
|
| 633 |
+
# st.line_chart(df_nucmonitor_2)
|
| 634 |
+
|
| 635 |
+
# st.write("Previous forecast")
|
| 636 |
+
# st.line_chart(df_photo_date_2)
|
| 637 |
+
# # Create a new dataframe out of df_nucmonitor_2 call real_forecast that contains df_nucmonitor_2 up until current_date
|
| 638 |
+
|
| 639 |
+
# # Slice the DataFrame to include data up until current_date
|
| 640 |
+
# real_forecast = df_nucmonitor_2.loc[df_nucmonitor_2.index <= current_date_str]
|
| 641 |
+
|
| 642 |
+
# # Optionally, if you want to reset the index
|
| 643 |
+
# # real_forecast = real_forecast.reset_index()
|
| 644 |
+
# print(real_forecast)
|
| 645 |
+
# st.write("Real forecast")
|
| 646 |
+
# st.line_chart(real_forecast)
|
| 647 |
|
| 648 |
+
# # Combine dataframes
|
| 649 |
+
# combined_df = pd.concat([df_nucmonitor_2, df_photo_date_2, real_forecast], axis=1)
|
| 650 |
+
# combined_df.columns = [f'Forecast {current_date_str}', f'Forecast {past_date_str}', 'Real Forecast']
|
| 651 |
|
| 652 |
+
# print(combined_df)
|
| 653 |
+
# st.write(f"Graph 1. {start_date} to {end_date}")
|
| 654 |
+
# st.line_chart(combined_df)
|
| 655 |
|
| 656 |
+
# # Set Nucmonitor as a dotted line until the current date
|
| 657 |
|
| 658 |
+
# fig, ax = plt.subplots(figsize=(10, 6))
|
| 659 |
|
| 660 |
+
# plt.plot(combined_df.index, combined_df[f'Forecast {current_date_str}'], 'r--', label=f'Forecast {current_date_str}')
|
| 661 |
+
# plt.plot(combined_df.index, combined_df[f'Forecast {past_date_str}'], 'b-', label=f'Forecast {past_date_str}')
|
| 662 |
|
| 663 |
+
# plt.axvline(current_date_str, color='k', linestyle='--', linewidth=1, label='Current Date')
|
| 664 |
|
| 665 |
+
# # Set the x-axis to show only the first day of every month
|
| 666 |
+
# ax.xaxis.set_major_locator(MonthLocator(bymonthday=1))
|
| 667 |
|
| 668 |
+
# plt.legend()
|
| 669 |
|
| 670 |
+
# plt.xticks(rotation=45)
|
| 671 |
|
| 672 |
+
# st.pyplot(fig)
|
| 673 |
|
| 674 |
# For Historical Winter Availability, can just get the max and min of each month, store as list in a column, and try to graph that
|
| 675 |
|