In [73]:
%matplotlib inline
import imp
import os
import glob
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib import rcParams

pd.options.display.mpl_style = 'default'

from hmm_disaggregator import HMMDeviceInstance

data_dir = "../data"
rcParams['figure.figsize'] = 12,6

Create devices


Import raw building data from Pecan Street Home Group A


In [70]:
def import_building_csv(filename):
    with open(filename,'r') as f:
        return pd.read_csv(f)

buildings_data=[]
for filename in glob.glob(os.path.join(data_dir, "2014-04","DATA_*")):
    building_data = import_building_csv(filename)
    buildings_data.append(building_data)

Dump raw building data (1 days worth of 15min data for 25 buildings in April)


In [75]:
# one day of data
for i, building_data in enumerate(buildings_data):
    print "Building {}".format(i + 1)
    num_days = 1
    for day in range(0,24*4*num_days,24*4):
        building_data[day:day+24*4].use.plot()
        plt.show()


Building 1
Building 2
Building 3
Building 4
Building 5
Building 6
Building 7
Building 8
Building 9
Building 10
Building 11
Building 12
Building 13
Building 14
Building 15
Building 16
Building 17
Building 18
Building 19
Building 20
Building 21
Building 22
Building 23
Building 24
Building 25

Display buildings slighly more logically


In [81]:
def display_building(building, days=1):
    disaggregated = building.dropna(axis=1).drop(['utc','use','dataid'],1)
    ylim = (0,10)
    _, axes = plt.subplots(ncols=2)
    building.use[0:24*4].plot(ax=axes[0],ylim=ylim)
    disaggregated[0:24*4].plot(ax=axes[1],ylim=ylim)
    axes[0].set_title("total")
    axes[1].set_title("disaggregated")
    plt.show()

for building in buildings_data[0:3]:
    display_building(building,days=2)