Visualization of electricity consumption with focus on night time


In [ ]:
import os
import sys
import time
import inspect
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

from opengrid import config
from opengrid.library import plotting
from opengrid.library import houseprint

c=config.Config()

try:
    if os.path.exists(c.get('tmpo', 'data')):
        path_to_tmpo_data = c.get('tmpo', 'data')
except:
    path_to_tmpo_data = None
    
%matplotlib inline
plt.rcParams['figure.figsize'] = 16,8

# path to data
path_to_data = c.get('data', 'folder')
if not os.path.exists(path_to_data):
    raise IOError("Provide your path to the data in your config.ini file.  This is a folder containing a 'zip' and 'csv' subfolder.")
else:
    path_to_fig = os.path.join(path_to_data, 'figures')
    if not os.path.isdir(path_to_fig): os.makedirs(path_to_fig)

In [ ]:
hp = houseprint.load_houseprint_from_file('new_houseprint.pkl')
hp.init_tmpo(path_to_tmpo_data=path_to_tmpo_data)

#set start date
number_of_days = 60
start = pd.Timestamp(time.time() - number_of_days*86400, unit='s')

In [ ]:
sensor = hp.get_sensors(sensortype='electricity')[0]
df = sensor.get_data(head = start)
df = df.diff()*60 #from Wh/min to W

In [ ]:
plotting.carpet(df, title=sensor.device.key, zlabel=r'Power [W]')

In [ ]:
plotting.fanchart(df, title=sensor.device.key, ylabel=r'Power [W]', start_hour=0, end_hour=3)

In [ ]:
begin = pd.Timestamp('20150701')
end = begin + pd.Timedelta('1 day')
df.truncate(begin,end).plot(title=sensor.device.key)
plt.xlabel(begin)

In [ ]: