<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Quick Tmpo demo
To get started, clone the tmpo-py repository from the opengrid github page. Then specify the path to this repo on your hard drive in your opengrid.cfg file.
Step1:  Create a tmpo session, and enter debug mode to get more output.
Step2:  Add a sensor and token to start tracking the data for this given sensor.  You only have to do this once for each sensor.
Step3:  Sync all available data to your hard drive.  All sensors previously added will be synced.
Step4:  Now you can create a pandas timeseries with all data from a given sensor.
Step5:  When plotting the data, you'll notice that this ts contains cumulative data, and the time axis (= pandas index) contains seconds since the epoch.  Not very practical.
Step6:  To show differential data (eg instantaneous power), we first have to resample this cumulative data to the interval we want to obtain.  We use linear interpolation to approximate the cumulative value between two datapoints.  In the example below, we resample to minute values. Then, we take the difference between the cumulative values at minute intervals in order to get the average power (per minute). As the original data is in Wh, we have to convert it to W.
Step7:  If we want to plot only a specific period, we can slice the data with the .ix[from
<ASSISTANT_TASK:>
Python Code:
import sys
import os
import inspect
import tmpo
import pandas as pd
import datetime as dt
import matplotlib.pyplot as plt
import pytz
from opengrid.library import houseprint
from opengrid import config
c=config.Config()
%matplotlib inline
plt.rcParams['figure.figsize'] = 14,8
Explanation: Quick Tmpo demo
To get started, clone the tmpo-py repository from the opengrid github page. Then specify the path to this repo on your hard drive in your opengrid.cfg file.
End of explanation
s = tmpo.Session()
s.debug = True
Explanation: Create a tmpo session, and enter debug mode to get more output.
End of explanation
s.add('d209e2bbb35b82b83cc0de5e8b84a4ff','e16d9c9543572906a11649d92f902226')
Explanation: Add a sensor and token to start tracking the data for this given sensor.  You only have to do this once for each sensor.
End of explanation
s.sync()
Explanation: Sync all available data to your hard drive.  All sensors previously added will be synced.
End of explanation
ts = s.series('d209e2bbb35b82b83cc0de5e8b84a4ff')
print(ts)
Explanation: Now you can create a pandas timeseries with all data from a given sensor.
End of explanation
ts.plot()
plt.show()
Explanation: When plotting the data, you'll notice that this ts contains cumulative data, and the time axis (= pandas index) contains seconds since the epoch.  Not very practical.
End of explanation
tsmin = ts.resample(rule='60s')
tsmin=tsmin.interpolate(method='linear')
tsmin=tsmin.diff()*3600/60
tsmin.plot()
Explanation: To show differential data (eg instantaneous power), we first have to resample this cumulative data to the interval we want to obtain.  We use linear interpolation to approximate the cumulative value between two datapoints.  In the example below, we resample to minute values. Then, we take the difference between the cumulative values at minute intervals in order to get the average power (per minute). As the original data is in Wh, we have to convert it to W.
End of explanation
tsmin.ix['20141016':'20141018'].plot()
ts.name
Explanation: If we want to plot only a specific period, we can slice the data with the .ix[from:to] method.
End of explanation
<END_TASK>