Extra: Venue 20 electrics#
Show code cell source
import plotly.graph_objects as go
import plotly.express as px
import numpy as np
import pandas as pd
# comment out the stuff that takes a long time to process in the public data.
# df = pd.read_csv("venue-20/venue_20_electricity_one_week_detail.csv")
# df['timestamp'] = pd.to_datetime(df['timestamp'])
# df["total_kW"] = (df['field3']+df['field2']+df['field1'])/1000
# df = df.fillna(value=0)
# phase1trace = go.Scatter(customdata=df,
# y=df['field1'],
# x = df['timestamp'],
# mode='lines',
# hoverinfo='all',
# name='phase 1',
# )
# phase2trace = go.Scatter(customdata=df,
# y=df['field2'],
# x = df['timestamp'],
# mode='lines',
# hoverinfo='all',
# name='phase 2',
# )
# phase3trace = go.Scatter(customdata=df,
# y=df['field3'],
# x = df['timestamp'],
# mode='lines',
# hoverinfo='all',
# name='phase 3',
# )
# g = go.FigureWidget(data=[phase1trace,phase2trace,phase3trace])
# g.layout.title = 'CurrentCost clamp-on meter readings - one week only'
# g.layout.xaxis.title= 'timestamp'
# g.layout.yaxis.title = "Watts"
# g.layout.width = 1000
# g.layout.height = 500
# fig = go.Figure(g)
# fig.update_layout(
# hovermode='x unified',
# hoverlabel=dict(
# bgcolor="white",
# # font_size=16,
# font_family="Rockwell"
# )
# )
# # Add range slider
# fig.update_layout(
# xaxis=dict(
# rangeselector=dict(
# buttons=list([
# dict(
# label="All",
# step="all"
# ),
# dict(count=1,
# label="Hour",
# step="hour",
# stepmode="todate"),
# dict(count=1,
# label="Day",
# step="day",
# stepmode="backward"),
# dict(count=7,
# label="Week",
# step="day",
# stepmode="backward"),
# dict(count=1,
# label="Year",
# step="year",
# stepmode="backward")
# ])
# ),
# rangeslider=dict(
# visible=True,
# ),
# type="date"
# )
# )
# fig.show()
# hist = go.Histogram(customdata=df,
# x=(df['total_kW']),
# name='sum of phases',
# xbins = {'size': 1}
# #nbinsx = 15
# )
# hist_g = go.FigureWidget()
# hist_g.layout.title = 'Histogram of total kW spot readings over 1 week'
# hist_g.layout.xaxis.title= 'kW draw'
# hist_g.layout.yaxis.title = "number of spot readings"
# hist_g.layout.width = 1000
# hist_g.layout.height = 500
# hist_fig = go.Figure(hist_g)
# hist_fig.add_trace(hist)
# hist_fig.show()
Show code cell source
# preprocessed downsampled data and stored in this file - see downsample-data.py
s = pd.read_csv("venue-20/venue_20_electricity_downsampled.csv")
s['timestamp'] = pd.to_datetime(s['timestamp'])
s = s.fillna(value=0)
downsampled_tot_trace = go.Scatter(customdata=s,
y=s['total_kW'],
x = s['timestamp'],
mode='lines',
hoverinfo='all',
name='total',
)
g3 = go.FigureWidget(data=[downsampled_tot_trace])
g3.layout.title = 'CurrentCost clamp-on meter readings - aggregated for half hour slots'
g3.layout.xaxis.title= 'timestamp'
g3.layout.yaxis.title = "kW"
g3.layout.width = 1000
g3.layout.height = 500
fig3 = go.Figure(g3)
fig3.update_layout(
hovermode='x unified',
hoverlabel=dict(
bgcolor="white",
# font_size=16,
font_family="Rockwell"
)
)
# Add range slider
fig3.update_layout(
xaxis=dict(
rangeselector=dict(
buttons=list([
dict(
label="All",
step="all"
),
dict(count=1,
label="Hour",
step="hour",
stepmode="todate"),
dict(count=1,
label="Day",
step="day",
stepmode="backward"),
dict(count=7,
label="Week",
step="day",
stepmode="backward"),
dict(count=1,
label="Year",
step="year",
stepmode="backward")
])
),
rangeslider=dict(
visible=True,
),
type="date"
)
)
fig3.show()
Summarised by day in kilowatt-hours.
Show code cell source
d = pd.read_csv("venue-20/venue_20_electricity_by_day.csv")
d['timestamp'] = pd.to_datetime(d['timestamp'])
d = d.fillna(value=0)
#print(d.sample)
#d = d.fillna(value=0)
daily_trace = go.Bar(customdata=d,
y=d['kwh'],
x = d['timestamp'],
#mode='bars',
hoverinfo='all',
name='sum of phases'
)
summ_g = go.FigureWidget(data=[daily_trace])
summ_g.layout.title = 'Estimated daily electricity use'
summ_g.layout.xaxis.title= 'timestamp'
summ_g.layout.yaxis.title = "kilowatt-hours"
summ_g.layout.width = 1000
summ_g.layout.height = 500
summ_fig = go.Figure(summ_g)
summ_fig.show()