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
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()
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)
In [82]:
device = HMMDeviceInstance()
In [83]:
trace = None
device.set_traces(trace)
In [84]:
device
Out[84]:
In [ ]: