Loading API is central to a lot of nilmtk operations and provides a great deal of flexibility. Let's look at ways in which we can load data from a NILMTK DataStore into memory. To see the full range of possible queries, we'll use the iAWE data set (whose HDF5 file can be downloaded here).
The load
function returns a generator of DataFrames loaded from the DataStore based on the conditions specified. If no conditions are specified, then all data from all the columns is loaded. (If you have not come across Python generators, it might be worth reading this quick guide to Python generators.)
NOTE: If you are on Windows, remember to escape the back-slashes, use forward-slashs, or use raw-strings when passing paths in Python, e.g. one of the following would work:
iawe = DataSet('c:\\data\\iawe.h5')
iawe = DataSet('c:/data/iawe.h5')
iawe = DataSet(r'c:\data\iawe.h5')
In [1]:
from nilmtk import DataSet
iawe = DataSet('/data/iawe.h5')
elec = iawe.buildings[1].elec
elec
Out[1]:
Let us see what measurements we have for the fridge:
In [2]:
fridge = elec['fridge']
fridge.available_columns()
Out[2]:
In [3]:
df = next(fridge.load())
df.head()
Out[3]:
In [4]:
series = next(fridge.power_series())
series.head()
Out[4]:
or, to get reactive power:
In [5]:
series = next(fridge.power_series(ac_type='reactive'))
series.head()
Out[5]:
In [6]:
df = next(fridge.load(physical_quantity='power', ac_type='reactive'))
df.head()
Out[6]:
To load voltage data:
In [7]:
df = next(fridge.load(physical_quantity='voltage'))
df.head()
Out[7]:
In [8]:
df = next(fridge.load(physical_quantity = 'power'))
df.head()
Out[8]:
In [9]:
df = next(fridge.load(ac_type='active'))
df.head()
Out[9]:
In [10]:
# resample to minutely (i.e. with a sample period of 60 secs)
df = next(fridge.load(ac_type='active', sample_period=60))
df.head()
Out[10]: