In [1]:
import sys
sys.path.append('../..')
import disaggregator as da
from pandas.tseries.offsets import DateOffset
import numpy as np
Create dataset adapter
In [2]:
db_url = "postgresql://USERNAME:PASSWORD@db.wiki-energy.org:5432/postgres"
psda = da.PecanStreetDatasetAdapter(db_url)
Get data ids
In [3]:
dataids = psda.get_unique_dataids("curated",2013,1,group=1)
print dataids
Choose one (say 7989), and get some data for jan, feb 2013.
In [4]:
jan_traces = psda.get_month_traces("curated",2013,1,7989,group=1)
feb_traces = psda.get_month_traces("curated",2013,2,7989,group=1)
mar_traces = psda.get_month_traces("curated",2013,3,7989,group=1)
Concatenate traces
In [5]:
all_traces = da.concatenate_traces_lists([jan_traces,feb_traces,mar_traces])
all_traces[0].series
Out[5]:
Make instances from the traces
In [6]:
instances = [da.ApplianceInstance([trace],{"name":trace.series.name}) for trace in all_traces]
Make sets from the instances
In [7]:
set_7989 = da.ApplianceSet(instances,{"name": "full house 7989"})
set_7989.df.columns
Out[7]:
Get a set with top k appliances
In [8]:
top_5_set = set_7989.top_k_set(5)
top_5_appliance_names = [inst.traces[0].series.name for inst in top_5_set.instances]
print top_5_appliance_names
In [9]:
non_zero_set = set_7989.non_zero_set()
non_zero_appliance_names = [inst.traces[0].series.name for inst in non_zero_set.instances]
print non_zero_appliance_names
In [ ]: