# Extra: Venue 7 electrics#

If you see a straight line, it’s interpolated missing data. Try the sliders to see detail!

This plot is interesting because it shows around a 1 kW base load with lots of 2.5 kW spikes even when the building is unoccupied. If that electricity isn’t doing useful work, getting those under control could substantially cut the electricity bill. We aren’t sure yet what it is, but it looks a bit like once before in another building when we found thermostatically controlled electric heating left on. It’s a lot of data, so we only show a week.

import plotly.graph_objects as go
import plotly.express as px
import numpy as np
import pandas as pd

#df["timestamp"] = pd.to_datetime(df['created_at']) # done in preprocessing
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"
)
)

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.update_yaxes(range=[50, 60])

# fig.update_yaxes(range = [-5, df['temperature'].max()+5])

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)