grafici giornaliero + mensile
This commit is contained in:
@@ -92,6 +92,96 @@ path_export_hourly = path_export.replace('.csv', '_hourly.csv')
|
|||||||
# Esporta il file orario
|
# Esporta il file orario
|
||||||
export_hourly_pv_productivity(result_ac_energies_to_csv_df, path_export_hourly)
|
export_hourly_pv_productivity(result_ac_energies_to_csv_df, path_export_hourly)
|
||||||
|
|
||||||
|
import pandas as pd
|
||||||
|
import plotly.express as px
|
||||||
|
|
||||||
|
# Carica il file CSV orario
|
||||||
|
df = pd.read_csv('files/gen_pv/output_gen_pv_hourly.csv', index_col=0, parse_dates=True)
|
||||||
|
|
||||||
|
# Raggruppa per giorno e somma la produzione
|
||||||
|
df_daily = df.resample('D').sum()
|
||||||
|
|
||||||
|
# Crea il grafico giornaliero
|
||||||
|
fig = px.line(
|
||||||
|
df_daily,
|
||||||
|
x=df_daily.index,
|
||||||
|
y='gen_pv_100_kWp',
|
||||||
|
title='Produttività Fotovoltaica Giornaliera',
|
||||||
|
labels={'gen_pv_100_kWp': 'Energia [kWh]', 'index': 'Data'}
|
||||||
|
)
|
||||||
|
fig.show()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Raggruppa per mese e somma la produzione
|
||||||
|
df_monthly = df.resample('M').sum()
|
||||||
|
df_monthly['Mese'] = df_monthly.index.strftime('%B %Y') # Nome mese e anno
|
||||||
|
|
||||||
|
# Crea il grafico a colonne mensili con colori diversi
|
||||||
|
fig = px.bar(
|
||||||
|
df_monthly,
|
||||||
|
x='Mese',
|
||||||
|
y='gen_pv_100_kWp',
|
||||||
|
color='Mese',
|
||||||
|
title='Produttività Fotovoltaica Mensile',
|
||||||
|
labels={'gen_pv_100_kWp': 'Energia [kWh]', 'Mese': 'Mese'},
|
||||||
|
color_discrete_sequence=px.colors.qualitative.Pastel
|
||||||
|
)
|
||||||
|
fig.show()
|
||||||
|
|
||||||
|
import plotly.graph_objects as go
|
||||||
|
|
||||||
|
# Estrai tutte le date disponibili (solo la parte di data, senza ora)
|
||||||
|
date_options = df.index.normalize().unique()
|
||||||
|
|
||||||
|
# Crea una lista di grafici, uno per ogni giorno
|
||||||
|
fig = go.Figure()
|
||||||
|
|
||||||
|
for date in date_options:
|
||||||
|
daily_data = df[df.index.normalize() == date]
|
||||||
|
fig.add_trace(
|
||||||
|
go.Scatter(
|
||||||
|
x=daily_data.index,
|
||||||
|
y=daily_data['gen_pv_100_kWp'],
|
||||||
|
name=str(date.date()),
|
||||||
|
visible=False
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
# Rendi visibile solo il primo giorno all'avvio
|
||||||
|
fig.data[0].visible = True
|
||||||
|
|
||||||
|
# Crea i pulsanti per il menu a tendina
|
||||||
|
buttons = []
|
||||||
|
for i, date in enumerate(date_options):
|
||||||
|
visible = [False] * len(date_options)
|
||||||
|
visible[i] = True
|
||||||
|
buttons.append(
|
||||||
|
dict(
|
||||||
|
label=str(date.date()),
|
||||||
|
method="update",
|
||||||
|
args=[{"visible": visible},
|
||||||
|
{"title": f"Produttività Fotovoltaica Oraria - {date.date()}"}]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
fig.update_layout(
|
||||||
|
updatemenus=[
|
||||||
|
dict(
|
||||||
|
active=0,
|
||||||
|
buttons=buttons,
|
||||||
|
x=0.5,
|
||||||
|
xanchor="center",
|
||||||
|
y=1.15,
|
||||||
|
yanchor="top"
|
||||||
|
)
|
||||||
|
],
|
||||||
|
title=f"Produttività Fotovoltaica Oraria - {date_options[0].date()}",
|
||||||
|
xaxis_title="Ora",
|
||||||
|
yaxis_title="Energia [kWh]"
|
||||||
|
)
|
||||||
|
|
||||||
|
fig.show()
|
||||||
|
|
||||||
if joePlaying:
|
if joePlaying:
|
||||||
joe.terminate()
|
joe.terminate()
|
||||||
|
|||||||
Reference in New Issue
Block a user