In [1]:
from paramiko import SSHClient, SSHConfig
import os
import sys
sys.path.append('../../')
import datetime
import calendar
from xml.dom import minidom
from lxml import etree

In [2]:
from disaggregator import GreenButtonDatasetAdapter as gbda


/Users/sabina/anaconda/lib/python2.7/site-packages/pandas/io/excel.py:626: UserWarning: Installed openpyxl is not supported at this time. Use >=1.6.1 and <2.0.0.
  .format(openpyxl_compat.start_ver, openpyxl_compat.stop_ver))

In [3]:
from disaggregator import appliance

In [4]:
reload(appliance)


Out[4]:
<module 'disaggregator.appliance' from '../../disaggregator/appliance.pyc'>

In [5]:
import get_files


['identityfile', 'forwardx11', 'hostname', 'user', 'forwardagent']

In [6]:
reload(get_files)


['identityfile', 'forwardx11', 'hostname', 'user', 'forwardagent']
Out[6]:
<module 'get_files' from 'get_files.pyc'>

In [ ]:
f = get_files.get()

In [95]:
fi = f[0].read()

In [96]:
fi


Out[96]:
''

In [51]:
file_strings=[t+'\n      </IntervalBlock>\n    </content>\n  </entry>\n</feed>' for t in file_strings]

In [42]:
xml_string = file_strings[1]
xmldoc = minidom.parseString(xml_string)

In [43]:
trace = gbda.get_trace_from_xml(file_strings[1])

In [53]:
traces = [gbda.get_trace_from_xml(t) for t in file_strings]

In [54]:
traces[0].metadata


Out[54]:
{'source': 'GreenButtonXML'}

In [101]:
trace.series.index.month


Out[101]:
array([6, 6, 6, ..., 7, 7, 7])

In [60]:
def get_month_info(year,month):
    day_one = calendar.monthrange(year,month)[0]
    day_last = calendar.monthrange(year,month)[1]
    range_start = datetime.datetime(year,month,day_one,0,0)
    range_end = datetime.datetime(year,month,day_last,0,0) 
    good_traces = [] 
    for t in traces:
        rng = [dt.to_datetime() for dt in t.series.index]
        if range_start in rng and range_end in rng:
            good_traces.append(t)
    return good_traces

In [61]:
gt = get_month_info(2014,6)