In [5]:
%pylab inline
import pandas as pd
from pykalman import KalmanFilter


Populating the interactive namespace from numpy and matplotlib

In [6]:
df = pd.read_csv("../data/ChungCheonDC/CompositeETCdata.csv")
df_DC = pd.read_csv("../data/ChungCheonDC/CompositeDCdata.csv")
df_DCstd = pd.read_csv("../data/ChungCheonDC/CompositeDCstddata.csv")

In [7]:
print pd.read_csv


<function read_csv at 0x00000000079366D8>

In [119]:
# missininds = np.arange(df_DC[electrodeID[elecind]].values.size)[np.isnan(df_DC[electrodeID[elecind]].values)]
electrodeID = df_DC.keys()[1:-1]

In [7]:
ax1 = plt.subplot(111)
ax1_1 = ax1.twinx()
df.plot(figsize=(12,3), x='date', y='reservoirH', ax=ax1_1, color='k', linestyle='-', lw=2)
df.plot(figsize=(12,3), x='date', y='upperH_med', ax=ax1_1, color='b', linestyle='-', lw=2)
df.plot(figsize=(12,3), x='date', y='Temp (degree)', ax=ax1, color='r', linestyle='-', lw=2)
ax1.legend(loc=3, bbox_to_anchor=(1.05, 0.7))
ax1_1.legend(loc=3, bbox_to_anchor=(1.05, 0.4))
itime_ref0 = 255
itime_ref1 = 115
ax1.plot(np.r_[itime_ref0, itime_ref0], np.r_[-5, 35], 'k-')
ax1.plot(np.r_[itime_ref1, itime_ref1], np.r_[-5, 35], 'k-')
print df['date'].values[itime_ref]


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-7-341585624561> in <module>()
     10 ax1.plot(np.r_[itime_ref0, itime_ref0], np.r_[-5, 35], 'k-')
     11 ax1.plot(np.r_[itime_ref1, itime_ref1], np.r_[-5, 35], 'k-')
---> 12 print df['date'].values[itime_ref]

NameError: name 'itime_ref' is not defined

In [8]:
print itime
print df.values[itime]


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-8-af96ef4c52b7> in <module>()
----> 1 print itime
      2 print df.values[itime]

NameError: name 'itime' is not defined

In [1]:
from ipywidgets import interact, IntSlider, ToggleButtons
itime = 100
itime_ref = 100
print df['date'].values[itime]
elecind = () #[15, 150,200]
 

# vizDCtimeSeries(elecind, itime, itime_ref, ['k','b','r'])
viz = lambda idatum, itime, flag: vizDCtimeSeries([idatum], itime, itime_ref, ['r'], flag)
interact(viz, idatum=IntSlider(min=0, max=379, step=1, value=294)\
         ,itime=IntSlider(min=0, max=360, step=1, value=200)\
         ,flag=ToggleButtons(options=["std", "rho"]))


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-1-9cbab4a89666> in <module>()
      2 itime = 100
      3 itime_ref = 100
----> 4 print df['date'].values[itime]
      5 elecind = () #[15, 150,200]
      6 

NameError: name 'df' is not defined

In [4]:
print df['1'].values[itime]


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-4-ed475532665d> in <module>()
----> 1 print df['1'].values[itime]

NameError: name 'df' is not defined

In [10]:
ax1 = plt.subplot(111)
ax1_1 = ax1.twinx()
df_DC.plot(figsize=(12,3), x='date', y=electrodeID[elecind], ax=ax1, colors=['k', 'b', 'r'])
df.plot(figsize=(12,3), x='date', y='reservoirH', ax=ax1_1, color='k', linestyle='-', lw=2)
ax1.legend(loc=3, bbox_to_anchor=(1.05, 0.7))
ax1_1.legend(loc=3, bbox_to_anchor=(1.05, 0.4))
ax1.set_yscale('linear')


C:\Users\sungkeun\Anaconda2\lib\site-packages\pandas\tools\plotting.py:929: UserWarning: 'colors' is being deprecated. Please use 'color'instead of 'colors'
  warnings.warn(("'colors' is being deprecated. Please use 'color'"

In [11]:
print elecind


()

In [13]:
ax1 = plt.subplot(111)
df_DCstd.plot(figsize=(12,3), x='date', y=electrodeID[elecind], ax=ax1, colors=['k', 'b', 'r'], linestyle="-", marker='.', lw=1)
ax1.set_yscale('log')
ax1.legend(loc=3, bbox_to_anchor=(1.05, 0.7))


Out[13]:
<matplotlib.legend.Legend at 0xbc4cda0>

In [14]:
txrxID =  df_DC.keys()[1:-1]
xmasking = lambda x: np.ma.masked_where(np.isnan(x.values), x.values)

In [15]:
#x= electrodeID[elecind] 
x= df_DC[txrxID[elecind]]
max3 = pd.rolling_max(x, 3)

In [19]:
#pd.rolling_max??

In [20]:
#plt.plot(x)
plt.plot(max3)


Out[20]:
[<matplotlib.lines.Line2D at 0xec00128>,
 <matplotlib.lines.Line2D at 0xec00b00>,
 <matplotlib.lines.Line2D at 0xec00e48>,
 <matplotlib.lines.Line2D at 0xec00780>,
 <matplotlib.lines.Line2D at 0xec005c0>,
 <matplotlib.lines.Line2D at 0xec002b0>,
 <matplotlib.lines.Line2D at 0xec000f0>,
 <matplotlib.lines.Line2D at 0x123300b8>,
 <matplotlib.lines.Line2D at 0xec00940>,
 <matplotlib.lines.Line2D at 0xec00668>,
 <matplotlib.lines.Line2D at 0xec00ef0>,
 <matplotlib.lines.Line2D at 0xeaeda90>,
 <matplotlib.lines.Line2D at 0xeaedb00>,
 <matplotlib.lines.Line2D at 0xeaed358>,
 <matplotlib.lines.Line2D at 0xec00b70>,
 <matplotlib.lines.Line2D at 0xeaedc88>,
 <matplotlib.lines.Line2D at 0xeaed240>,
 <matplotlib.lines.Line2D at 0xeaed048>,
 <matplotlib.lines.Line2D at 0xeaed710>,
 <matplotlib.lines.Line2D at 0xeaed470>,
 <matplotlib.lines.Line2D at 0xeaed198>,
 <matplotlib.lines.Line2D at 0xeaedda0>,
 <matplotlib.lines.Line2D at 0xeaedf60>,
 <matplotlib.lines.Line2D at 0xeaedd68>,
 <matplotlib.lines.Line2D at 0xeaedcf8>,
 <matplotlib.lines.Line2D at 0xecdd6a0>,
 <matplotlib.lines.Line2D at 0xecdd978>,
 <matplotlib.lines.Line2D at 0xecdd240>,
 <matplotlib.lines.Line2D at 0xeaed208>,
 <matplotlib.lines.Line2D at 0xecddc50>,
 <matplotlib.lines.Line2D at 0xecdd940>,
 <matplotlib.lines.Line2D at 0xecdd780>,
 <matplotlib.lines.Line2D at 0xecdd2b0>,
 <matplotlib.lines.Line2D at 0xecdd358>,
 <matplotlib.lines.Line2D at 0xecdd668>,
 <matplotlib.lines.Line2D at 0xecdd0b8>,
 <matplotlib.lines.Line2D at 0xecdda20>,
 <matplotlib.lines.Line2D at 0xecddb70>,
 <matplotlib.lines.Line2D at 0xecdd828>,
 <matplotlib.lines.Line2D at 0xecdd2e8>,
 <matplotlib.lines.Line2D at 0x11ef8f98>,
 <matplotlib.lines.Line2D at 0x11ef87b8>,
 <matplotlib.lines.Line2D at 0xecddc88>,
 <matplotlib.lines.Line2D at 0x11ef8b00>,
 <matplotlib.lines.Line2D at 0x11ef8c88>,
 <matplotlib.lines.Line2D at 0x11ef86a0>,
 <matplotlib.lines.Line2D at 0x11ef8588>,
 <matplotlib.lines.Line2D at 0x11ef8208>,
 <matplotlib.lines.Line2D at 0x11ef8080>,
 <matplotlib.lines.Line2D at 0x11ef8048>,
 <matplotlib.lines.Line2D at 0x11ef8860>,
 <matplotlib.lines.Line2D at 0x11ef89b0>,
 <matplotlib.lines.Line2D at 0x11ef8668>,
 <matplotlib.lines.Line2D at 0xecd01d0>,
 <matplotlib.lines.Line2D at 0xecd0b00>,
 <matplotlib.lines.Line2D at 0xecd0240>,
 <matplotlib.lines.Line2D at 0x11ef8ac8>,
 <matplotlib.lines.Line2D at 0xecd0940>,
 <matplotlib.lines.Line2D at 0xecd0ac8>,
 <matplotlib.lines.Line2D at 0xecd04e0>,
 <matplotlib.lines.Line2D at 0xecd0400>,
 <matplotlib.lines.Line2D at 0xecd00b8>,
 <matplotlib.lines.Line2D at 0xecd09b0>,
 <matplotlib.lines.Line2D at 0xecd0320>,
 <matplotlib.lines.Line2D at 0xecd0a58>,
 <matplotlib.lines.Line2D at 0xecd0160>,
 <matplotlib.lines.Line2D at 0x1246b1d0>,
 <matplotlib.lines.Line2D at 0x1246be48>,
 <matplotlib.lines.Line2D at 0x1246b5f8>,
 <matplotlib.lines.Line2D at 0x1246b160>,
 <matplotlib.lines.Line2D at 0xecd0780>,
 <matplotlib.lines.Line2D at 0x1246b940>,
 <matplotlib.lines.Line2D at 0x1246b5c0>,
 <matplotlib.lines.Line2D at 0x1246b048>,
 <matplotlib.lines.Line2D at 0x1246b860>,
 <matplotlib.lines.Line2D at 0x1246b978>,
 <matplotlib.lines.Line2D at 0x1246b6d8>,
 <matplotlib.lines.Line2D at 0x1246bb70>,
 <matplotlib.lines.Line2D at 0x1246bcc0>,
 <matplotlib.lines.Line2D at 0x1246be10>,
 <matplotlib.lines.Line2D at 0xead5400>,
 <matplotlib.lines.Line2D at 0xead5828>,
 <matplotlib.lines.Line2D at 0xead5908>,
 <matplotlib.lines.Line2D at 0xead5f98>,
 <matplotlib.lines.Line2D at 0x1246beb8>,
 <matplotlib.lines.Line2D at 0xead56a0>,
 <matplotlib.lines.Line2D at 0xead54e0>,
 <matplotlib.lines.Line2D at 0xead51d0>,
 <matplotlib.lines.Line2D at 0xead5978>,
 <matplotlib.lines.Line2D at 0xead5780>,
 <matplotlib.lines.Line2D at 0xead58d0>,
 <matplotlib.lines.Line2D at 0xead5d68>,
 <matplotlib.lines.Line2D at 0xead5588>,
 <matplotlib.lines.Line2D at 0xead5ac8>,
 <matplotlib.lines.Line2D at 0x124799b0>,
 <matplotlib.lines.Line2D at 0x12479a20>,
 <matplotlib.lines.Line2D at 0x12479518>,
 <matplotlib.lines.Line2D at 0x12479860>,
 <matplotlib.lines.Line2D at 0xead5c50>,
 <matplotlib.lines.Line2D at 0x124794e0>,
 <matplotlib.lines.Line2D at 0x12479208>,
 <matplotlib.lines.Line2D at 0x124798d0>,
 <matplotlib.lines.Line2D at 0x124796a0>,
 <matplotlib.lines.Line2D at 0x12479e80>,
 <matplotlib.lines.Line2D at 0x12479fd0>,
 <matplotlib.lines.Line2D at 0x124799e8>,
 <matplotlib.lines.Line2D at 0x12479c88>,
 <matplotlib.lines.Line2D at 0xe9778d0>,
 <matplotlib.lines.Line2D at 0xe977940>,
 <matplotlib.lines.Line2D at 0xe977438>,
 <matplotlib.lines.Line2D at 0xe977198>,
 <matplotlib.lines.Line2D at 0xe977860>,
 <matplotlib.lines.Line2D at 0x12479048>,
 <matplotlib.lines.Line2D at 0xe977b00>,
 <matplotlib.lines.Line2D at 0xe977080>,
 <matplotlib.lines.Line2D at 0xe977400>,
 <matplotlib.lines.Line2D at 0xe9776a0>,
 <matplotlib.lines.Line2D at 0xe9779e8>,
 <matplotlib.lines.Line2D at 0xe977588>,
 <matplotlib.lines.Line2D at 0xe977cc0>,
 <matplotlib.lines.Line2D at 0xe977dd8>,
 <matplotlib.lines.Line2D at 0x12486f98>,
 <matplotlib.lines.Line2D at 0x124867b8>,
 <matplotlib.lines.Line2D at 0x12486048>,
 <matplotlib.lines.Line2D at 0x12486ba8>,
 <matplotlib.lines.Line2D at 0x12486a90>,
 <matplotlib.lines.Line2D at 0xe977f98>,
 <matplotlib.lines.Line2D at 0x124865c0>,
 <matplotlib.lines.Line2D at 0x124864a8>,
 <matplotlib.lines.Line2D at 0x12486128>,
 <matplotlib.lines.Line2D at 0x12486a20>,
 <matplotlib.lines.Line2D at 0x12486d68>,
 <matplotlib.lines.Line2D at 0x124868d0>,
 <matplotlib.lines.Line2D at 0x12486160>,
 <matplotlib.lines.Line2D at 0xe96be80>,
 <matplotlib.lines.Line2D at 0xe96b978>,
 <matplotlib.lines.Line2D at 0xe96b208>,
 <matplotlib.lines.Line2D at 0xe96bf60>,
 <matplotlib.lines.Line2D at 0xe96b400>,
 <matplotlib.lines.Line2D at 0xe96b748>,
 <matplotlib.lines.Line2D at 0x12486518>,
 <matplotlib.lines.Line2D at 0xe96b240>,
 <matplotlib.lines.Line2D at 0xe96bc18>,
 <matplotlib.lines.Line2D at 0xe96ba20>,
 <matplotlib.lines.Line2D at 0xe96bd68>,
 <matplotlib.lines.Line2D at 0xe96b828>,
 <matplotlib.lines.Line2D at 0xe9a0a58>,
 <matplotlib.lines.Line2D at 0xe96b3c8>,
 <matplotlib.lines.Line2D at 0xe9a0978>,
 <matplotlib.lines.Line2D at 0xe9a0860>,
 <matplotlib.lines.Line2D at 0xe9a0908>,
 <matplotlib.lines.Line2D at 0xe9a0080>,
 <matplotlib.lines.Line2D at 0xe9a0828>,
 <matplotlib.lines.Line2D at 0xe9a0358>,
 <matplotlib.lines.Line2D at 0xe9a03c8>,
 <matplotlib.lines.Line2D at 0xe9a0c50>,
 <matplotlib.lines.Line2D at 0xe9906a0>,
 <matplotlib.lines.Line2D at 0xe990898>,
 <matplotlib.lines.Line2D at 0xe990048>,
 <matplotlib.lines.Line2D at 0xe990cc0>,
 <matplotlib.lines.Line2D at 0xe990940>,
 <matplotlib.lines.Line2D at 0xe9a0ef0>,
 <matplotlib.lines.Line2D at 0xe990278>,
 <matplotlib.lines.Line2D at 0xe9903c8>,
 <matplotlib.lines.Line2D at 0xe990c18>,
 <matplotlib.lines.Line2D at 0xe990a20>,
 <matplotlib.lines.Line2D at 0xe9907b8>,
 <matplotlib.lines.Line2D at 0xe990da0>,
 <matplotlib.lines.Line2D at 0xe9901d0>,
 <matplotlib.lines.Line2D at 0xeb41400>,
 <matplotlib.lines.Line2D at 0xeb410b8>,
 <matplotlib.lines.Line2D at 0xeb41b00>,
 <matplotlib.lines.Line2D at 0xeb41e80>,
 <matplotlib.lines.Line2D at 0xeb413c8>,
 <matplotlib.lines.Line2D at 0xeb41208>,
 <matplotlib.lines.Line2D at 0xeb41f98>,
 <matplotlib.lines.Line2D at 0xeb41d68>,
 <matplotlib.lines.Line2D at 0xeb41898>,
 <matplotlib.lines.Line2D at 0xeb41668>,
 <matplotlib.lines.Line2D at 0xeb34160>,
 <matplotlib.lines.Line2D at 0xeb34518>,
 <matplotlib.lines.Line2D at 0xeb344a8>,
 <matplotlib.lines.Line2D at 0xeb410f0>,
 <matplotlib.lines.Line2D at 0xeb345c0>,
 <matplotlib.lines.Line2D at 0xeb34240>,
 <matplotlib.lines.Line2D at 0xeb349b0>,
 <matplotlib.lines.Line2D at 0xeb34710>,
 <matplotlib.lines.Line2D at 0xeb34f98>,
 <matplotlib.lines.Line2D at 0xeb349e8>,
 <matplotlib.lines.Line2D at 0xeb34ac8>,
 <matplotlib.lines.Line2D at 0xeb4bcf8>,
 <matplotlib.lines.Line2D at 0xeb4b438>,
 <matplotlib.lines.Line2D at 0xeb4be10>,
 <matplotlib.lines.Line2D at 0xeb4b748>,
 <matplotlib.lines.Line2D at 0xeb4b080>,
 <matplotlib.lines.Line2D at 0xeb4b828>,
 <matplotlib.lines.Line2D at 0xeb4bc88>,
 <matplotlib.lines.Line2D at 0xeb4bef0>,
 <matplotlib.lines.Line2D at 0xeb4bc18>,
 <matplotlib.lines.Line2D at 0xeb4b9e8>,
 <matplotlib.lines.Line2D at 0xeb59a20>,
 <matplotlib.lines.Line2D at 0xeb59940>,
 <matplotlib.lines.Line2D at 0xeb59668>,
 <matplotlib.lines.Line2D at 0xeb4b358>,
 <matplotlib.lines.Line2D at 0xeb59cc0>,
 <matplotlib.lines.Line2D at 0xeb59320>,
 <matplotlib.lines.Line2D at 0xeb59128>,
 <matplotlib.lines.Line2D at 0xeb599e8>,
 <matplotlib.lines.Line2D at 0xeb59518>,
 <matplotlib.lines.Line2D at 0xeb59dd8>,
 <matplotlib.lines.Line2D at 0xeb592e8>,
 <matplotlib.lines.Line2D at 0xeb66908>,
 <matplotlib.lines.Line2D at 0xeb66978>,
 <matplotlib.lines.Line2D at 0xeb66358>,
 <matplotlib.lines.Line2D at 0xeb66e48>,
 <matplotlib.lines.Line2D at 0xeb661d0>,
 <matplotlib.lines.Line2D at 0xeb66198>,
 <matplotlib.lines.Line2D at 0xeb66390>,
 <matplotlib.lines.Line2D at 0xeb66b70>,
 <matplotlib.lines.Line2D at 0xeb668d0>,
 <matplotlib.lines.Line2D at 0xeb66eb8>,
 <matplotlib.lines.Line2D at 0xed3b6a0>,
 <matplotlib.lines.Line2D at 0xed3bba8>,
 <matplotlib.lines.Line2D at 0xed3b278>,
 <matplotlib.lines.Line2D at 0xeb66080>,
 <matplotlib.lines.Line2D at 0xed3b390>,
 <matplotlib.lines.Line2D at 0xed3b320>,
 <matplotlib.lines.Line2D at 0xed3b438>,
 <matplotlib.lines.Line2D at 0xed3b2b0>,
 <matplotlib.lines.Line2D at 0xed3bb00>,
 <matplotlib.lines.Line2D at 0xed3bdd8>,
 <matplotlib.lines.Line2D at 0xed3b7f0>,
 <matplotlib.lines.Line2D at 0xed49a20>,
 <matplotlib.lines.Line2D at 0xed49f28>,
 <matplotlib.lines.Line2D at 0xed49080>,
 <matplotlib.lines.Line2D at 0xed49898>,
 <matplotlib.lines.Line2D at 0xed49cc0>,
 <matplotlib.lines.Line2D at 0xed49320>,
 <matplotlib.lines.Line2D at 0xed3bd30>,
 <matplotlib.lines.Line2D at 0xed499e8>,
 <matplotlib.lines.Line2D at 0xed49518>,
 <matplotlib.lines.Line2D at 0xed49e80>,
 <matplotlib.lines.Line2D at 0xed492b0>,
 <matplotlib.lines.Line2D at 0x11dcedd8>,
 <matplotlib.lines.Line2D at 0x11dce5f8>,
 <matplotlib.lines.Line2D at 0xed49128>,
 <matplotlib.lines.Line2D at 0x11dcee80>,
 <matplotlib.lines.Line2D at 0x11dce278>,
 <matplotlib.lines.Line2D at 0x11dce240>,
 <matplotlib.lines.Line2D at 0x11dce518>,
 <matplotlib.lines.Line2D at 0x11dce9b0>,
 <matplotlib.lines.Line2D at 0x11dce748>,
 <matplotlib.lines.Line2D at 0x11dce438>,
 <matplotlib.lines.Line2D at 0xed6ecf8>,
 <matplotlib.lines.Line2D at 0xed6e3c8>,
 <matplotlib.lines.Line2D at 0xed6eb70>,
 <matplotlib.lines.Line2D at 0xed6e6a0>,
 <matplotlib.lines.Line2D at 0xed6e748>,
 <matplotlib.lines.Line2D at 0xed6e048>,
 <matplotlib.lines.Line2D at 0x11dcef98>,
 <matplotlib.lines.Line2D at 0xed6e390>,
 <matplotlib.lines.Line2D at 0xed6ef98>,
 <matplotlib.lines.Line2D at 0xed6eef0>,
 <matplotlib.lines.Line2D at 0xed60e10>,
 <matplotlib.lines.Line2D at 0xed60978>,
 <matplotlib.lines.Line2D at 0xed600b8>,
 <matplotlib.lines.Line2D at 0xed6e630>,
 <matplotlib.lines.Line2D at 0xed60940>,
 <matplotlib.lines.Line2D at 0xed60080>,
 <matplotlib.lines.Line2D at 0xed60668>,
 <matplotlib.lines.Line2D at 0xed60198>,
 <matplotlib.lines.Line2D at 0xed60d30>,
 <matplotlib.lines.Line2D at 0xed60a90>,
 <matplotlib.lines.Line2D at 0xed60cc0>,
 <matplotlib.lines.Line2D at 0xe985eb8>,
 <matplotlib.lines.Line2D at 0xe985240>,
 <matplotlib.lines.Line2D at 0xe9854a8>,
 <matplotlib.lines.Line2D at 0xe9858d0>,
 <matplotlib.lines.Line2D at 0xe9854e0>,
 <matplotlib.lines.Line2D at 0xe985048>,
 <matplotlib.lines.Line2D at 0xed60dd8>,
 <matplotlib.lines.Line2D at 0xe9856a0>,
 <matplotlib.lines.Line2D at 0xe985a58>,
 <matplotlib.lines.Line2D at 0xe985d68>,
 <matplotlib.lines.Line2D at 0xed55cc0>,
 <matplotlib.lines.Line2D at 0xed55240>,
 <matplotlib.lines.Line2D at 0xed55f60>,
 <matplotlib.lines.Line2D at 0xe985898>,
 <matplotlib.lines.Line2D at 0xed555c0>,
 <matplotlib.lines.Line2D at 0xed550f0>,
 <matplotlib.lines.Line2D at 0xed55908>,
 <matplotlib.lines.Line2D at 0xed55710>,
 <matplotlib.lines.Line2D at 0xed554a8>,
 <matplotlib.lines.Line2D at 0xed55ba8>,
 <matplotlib.lines.Line2D at 0xed55940>,
 <matplotlib.lines.Line2D at 0x11f05908>,
 <matplotlib.lines.Line2D at 0xecec438>,
 <matplotlib.lines.Line2D at 0x1233fe48>,
 <matplotlib.lines.Line2D at 0x11eec438>,
 <matplotlib.lines.Line2D at 0x11eec710>,
 <matplotlib.lines.Line2D at 0xecc4da0>,
 <matplotlib.lines.Line2D at 0xed55ef0>,
 <matplotlib.lines.Line2D at 0x18df0860>,
 <matplotlib.lines.Line2D at 0xec327b8>,
 <matplotlib.lines.Line2D at 0xec32b00>,
 <matplotlib.lines.Line2D at 0xec258d0>,
 <matplotlib.lines.Line2D at 0xec17710>,
 <matplotlib.lines.Line2D at 0xec17048>,
 <matplotlib.lines.Line2D at 0x1215ecc0>,
 <matplotlib.lines.Line2D at 0x11db5ba8>,
 <matplotlib.lines.Line2D at 0x11db5128>,
 <matplotlib.lines.Line2D at 0x11db5668>,
 <matplotlib.lines.Line2D at 0x11db5e48>,
 <matplotlib.lines.Line2D at 0x11db5240>,
 <matplotlib.lines.Line2D at 0x11db5780>,
 <matplotlib.lines.Line2D at 0x11db5ac8>,
 <matplotlib.lines.Line2D at 0x11db52b0>,
 <matplotlib.lines.Line2D at 0x11db5be0>,
 <matplotlib.lines.Line2D at 0x11db5cf8>,
 <matplotlib.lines.Line2D at 0x11db5b70>,
 <matplotlib.lines.Line2D at 0x11da8eb8>,
 <matplotlib.lines.Line2D at 0x11da8240>,
 <matplotlib.lines.Line2D at 0x11db55c0>,
 <matplotlib.lines.Line2D at 0x11da8ac8>,
 <matplotlib.lines.Line2D at 0x11da85c0>,
 <matplotlib.lines.Line2D at 0x11da80f0>,
 <matplotlib.lines.Line2D at 0x11da8908>,
 <matplotlib.lines.Line2D at 0x11da8780>,
 <matplotlib.lines.Line2D at 0x11da8fd0>,
 <matplotlib.lines.Line2D at 0x11da8198>,
 <matplotlib.lines.Line2D at 0x11da8d30>,
 <matplotlib.lines.Line2D at 0x11dc0860>,
 <matplotlib.lines.Line2D at 0x11dc0780>,
 <matplotlib.lines.Line2D at 0x11dc0278>,
 <matplotlib.lines.Line2D at 0x11dc05c0>,
 <matplotlib.lines.Line2D at 0x11dc0908>,
 <matplotlib.lines.Line2D at 0x11da8128>,
 <matplotlib.lines.Line2D at 0x11dc0828>,
 <matplotlib.lines.Line2D at 0x11dc0358>,
 <matplotlib.lines.Line2D at 0x11dc0ef0>,
 <matplotlib.lines.Line2D at 0x11dc0c18>,
 <matplotlib.lines.Line2D at 0x11dc09b0>,
 <matplotlib.lines.Line2D at 0x11dc06a0>,
 <matplotlib.lines.Line2D at 0x11dc0080>,
 <matplotlib.lines.Line2D at 0x11dda048>,
 <matplotlib.lines.Line2D at 0x11dda4e0>,
 <matplotlib.lines.Line2D at 0x11ddaf60>,
 <matplotlib.lines.Line2D at 0x11dda240>,
 <matplotlib.lines.Line2D at 0x11dda588>,
 <matplotlib.lines.Line2D at 0x11dda2b0>,
 <matplotlib.lines.Line2D at 0x11dda6d8>,
 <matplotlib.lines.Line2D at 0x11ddab38>,
 <matplotlib.lines.Line2D at 0x11dda9b0>,
 <matplotlib.lines.Line2D at 0x11e37ac8>,
 <matplotlib.lines.Line2D at 0x11e37b38>,
 <matplotlib.lines.Line2D at 0x11e37550>,
 <matplotlib.lines.Line2D at 0x11e376a0>,
 <matplotlib.lines.Line2D at 0x11ddaa20>,
 <matplotlib.lines.Line2D at 0x11e37320>,
 <matplotlib.lines.Line2D at 0x11e37438>,
 <matplotlib.lines.Line2D at 0x11e372b0>,
 <matplotlib.lines.Line2D at 0x11e37f28>,
 <matplotlib.lines.Line2D at 0x11e37a58>,
 <matplotlib.lines.Line2D at 0x11e374a8>,
 <matplotlib.lines.Line2D at 0x11e37390>,
 <matplotlib.lines.Line2D at 0x11e29400>,
 <matplotlib.lines.Line2D at 0x11e292e8>,
 <matplotlib.lines.Line2D at 0x11e29a90>,
 <matplotlib.lines.Line2D at 0x11e29780>,
 <matplotlib.lines.Line2D at 0x11e29358>,
 <matplotlib.lines.Line2D at 0x11e29240>,
 <matplotlib.lines.Line2D at 0x11e29f98>,
 <matplotlib.lines.Line2D at 0x11e29860>,
 <matplotlib.lines.Line2D at 0x11e29ef0>,
 <matplotlib.lines.Line2D at 0x11e29eb8>,
 <matplotlib.lines.Line2D at 0x11e5c978>,
 <matplotlib.lines.Line2D at 0x11e5c0b8>,
 <matplotlib.lines.Line2D at 0x11e5ce10>,
 <matplotlib.lines.Line2D at 0x11e29a58>,
 <matplotlib.lines.Line2D at 0x11e5c390>]

In [21]:
from ipywidgets import interact

In [22]:
# making matrix like max3 (but with zeros)
newdata = np.zeros_like(max3)

In [23]:
newdata.shape


Out[23]:
(365L, 380L)

In [24]:
ndata = newdata.shape[1]
for i in range(ndata):
    x= df_DC[txrxID[i]]
    #median10 = pd.rolling_median(x, 6)
    mean10 = pd.rolling_max(x, 3)
    # Masking array having NaN
    xm = xmasking(mean10)
    kf = KalmanFilter(transition_matrices = [1],
                      observation_matrices = [1],
                      initial_state_mean = x[0],
                      initial_state_covariance = 1,
                      observation_covariance=1,
                      transition_covariance=1)
    # Use the observed values of the price to get a rolling mean
    state_means, _ = kf.filter(xm)    
    newdata[:,i] = state_means.flatten()

In [25]:
for i in range(0,379, 50):
    x= df_DC[txrxID[i]]
    plt.plot(newdata[:,i], 'k')
    plt.plot(x, 'k.', ms=2)



In [26]:
df_DC_new = df_DC.copy()

In [27]:
print i, txrxID[i]


350 16152425

In [28]:
newdata[:,0].flatten()


Out[28]:
array([ 63.84345   ,  63.84345   ,  64.1983125 ,  64.27358636,
        64.30028448,  64.57029671,  64.67327261,  64.72338186,
        64.79700106,  64.92440815,  65.05057476,  65.14156496,
        65.39998663,  65.79226106,  65.94676272,  66.0401398 ,
        66.12589832,  66.22157102,  66.33703768,  66.39832336,
        66.50618676,  66.60038332,  66.76979675,  66.94952304,
        67.03708422,  67.07052961,  67.08330461,  67.07594716,
        67.0865482 ,  67.17304317,  67.29897182,  67.47753925,
        67.59614662,  67.67494804,  67.74525062,  67.84197256,
        67.93775388,  68.0489049 ,  68.1166693 ,  68.20982599,
        68.24540869,  68.25900007,  68.45992287,  68.63771712,
        68.75253725,  68.83891538,  68.87190889,  68.98352033,
        69.02615211,  69.042436  ,  69.03292693,  69.02929479,
        68.9854176 ,  68.88852989,  68.85152208,  68.76927901,
        68.635055  ,  68.52232251,  68.42333046,  68.34503763,
        68.40978433,  68.40978433,  68.40978433,  68.40978433,
        68.52364446,  68.5395631 ,  68.54499763,  68.54499763,
        68.54499763,  68.54499763,  68.54499763,  68.54499763,
        68.54499763,  68.54499763,  68.54499763,  68.54499763,
        68.54499763,  68.54499763,  68.54499763,  68.54499763,
        68.54499763,  68.54499763,  68.54499763,  68.54499763,
        68.54499763,  68.54499763,  68.54499763,  68.54499763,
        68.54499763,  68.54499763,  68.54499763,  65.97481161,
        65.76693022,  65.59045458,  65.33807031,  65.05323629,
        64.74443422,  64.49861981,  64.26001538,  64.01303947,
        63.77952183,  63.67221764,  63.63123108,  63.61557561,
        63.58632678,  63.44379159,  63.36054761,  63.27047063,
        63.21103391,  63.15335038,  63.03175196,  62.83617389,
        62.62457519,  62.39233335,  62.17720601,  61.96979009,
        61.88883376,  61.83025418,  61.66165192,  61.3937021 ,
        60.92934096,  60.75197079,  60.6492716 ,  60.47370569,
        60.13755349,  60.00186197,  59.83529441,  59.70412015,
        59.50840723,  59.2780924 ,  59.1182117 ,  58.87395744,
        58.72210189,  58.66409823,  58.64194281,  58.5900633 ,
        58.39114084,  58.21355443,  57.92990499,  57.63018632,
        57.42281347,  57.32289995,  57.19067161,  57.02657023,
        56.84012777,  56.59972629,  56.34186626,  56.12659497,
        55.86844528,  55.40699312,  55.09791857,  54.79578118,
        54.68037496,  54.51281052,  54.27958889,  54.04724588,
        53.80819288,  53.57328256,  53.46519919,  53.31850933,
        53.08742065,  52.93073627,  52.73634217,  52.49228539,
        52.37227222,  52.3016481 ,  52.15091079,  52.04472588,
        51.94094198,  51.82645614,  51.77747315,  51.62974872,
        51.43615036,  51.36220237,  51.28096034,  51.21760547,
        52.4361488 ,  52.93972364,  53.13207211,  53.20554269,
        53.07430769,  52.93302037,  52.87905341,  52.72998151,
        52.63898743,  52.55410823,  52.43256676,  52.31129813,
        52.15608005,  51.98291926,  51.91677772,  51.8769283 ,
        51.84715247,  51.8972117 ,  51.91633262,  51.92363616,
        51.80760883,  51.61273726,  51.53830294,  51.50987156,
        51.23687262,  51.08426605,  51.02597553,  50.9868073 ,
        51.00095577,  51.00636   ,  51.00842423,  50.99991129,
        50.81202198,  51.55281484,  51.90477602,  52.03921323,
        52.09056368,  51.98700363,  51.55249259,  50.71725514,
        50.0088614 ,  49.61216924,  49.44927449,  49.37571331,
        49.28266007,  49.10292956,  48.9157706 ,  48.81341144,
        48.74140341,  48.71389879,  48.61773345,  48.50470526,
        48.36369756,  48.22186027,  48.14527951,  48.01729733,
        47.87842674,  47.77615649,  47.79008915,  47.79541095,
        47.79744369,  47.85004228,  47.8946073 ,  47.9238667 ,
        47.93504279,  47.93931168,  47.91850762,  47.8674842 ,
        47.75566072,  47.60720233,  47.42967063,  47.36185955,
        47.31120576,  47.22223621,  47.16146109,  47.09486107,
        46.9870073 ,  46.86803124,  46.74338538,  46.77846784,
        46.79186815,  46.79698662,  46.79368841,  46.7924286 ,
        46.79136027,  46.7909522 ,  46.78004254,  46.76740836,
        46.73523452,  46.72408857,  46.75332864,  46.77293352,
        46.80399991,  46.81586622,  46.84082477,  46.85035809,
        46.85399949,  46.93313906,  47.14568771,  47.25511822,
        47.3411991 ,  47.48297665,  47.6178461 ,  47.7686488 ,
        47.89673709,  47.99983314,  48.04999702,  48.22932142,
        48.49033484,  48.68817689,  48.80657558,  48.90451816,
        48.99402916,  49.06724817,  49.17182065,  49.25255403,
        49.32912595,  49.37379377,  49.39493438,  49.40300938,
        49.4270451 ,  49.5920323 ,  49.75059986,  51.01370691,
        52.69290099,  53.59025483,  54.08622412,  54.39417555,
        54.59397015,  54.85025639,  55.03204714,  55.14020486,
        55.1992859 ,  55.23813805,  55.25297825,  56.37938954,
        56.80964037,  56.97398156,  57.0093445 ,  57.14284324,
        57.30919127,  57.44581308,  57.49799797,  57.51793082,
        57.41052837,  57.32871404,  57.27533813,  57.12766624,
        57.02670035,  57.02920317,  57.25033377,  57.33479815,
        57.36706067,  57.36706067,  57.36706067,  57.36706067,
        57.36706067,  57.36706067,  57.36706067,  57.36706067,
        57.36706067,  57.36706067,  57.36706067,  57.36706067,
        57.36706067,  57.36706067,  57.36706067,  57.36706067,
        57.36706067,  57.36706067,  57.36706067,  57.36706067,
        57.36706067,  57.36706067,  57.36706067,  57.36706067,
        57.36706067,  57.36706067,  57.36706067,  60.85577968,
        61.03943794,  61.2564095 ,  61.53493891,  61.85327246,
        62.10032561,  62.29981209,  62.50650623,  62.73047792,  62.9401287 ])

In [29]:
electrode_index = df_DC_new.keys()[1:381]
    
  #   for j in range(0,365,1):
        for i in range(0,ndata,1):
    df_DC_new.set_value(df_DC_new.keys(i), 380, newdata[:,i].flatten(), True)


  File "<ipython-input-29-ec5d5b4568be>", line 4
    for i in range(0,ndata,1):
    ^
IndentationError: unexpected indent

In [ ]:
df_DC_new.shape

In [52]:
df_DC_new.set_value??

In [ ]:
help set_value

In [29]:
newdata.shape


Out[29]:
(365L, 380L)

In [23]:
print i, ndata,df_DC_new.set_value


360 380 <bound method DataFrame.set_value of      Unnamed: 0      2134      3245      4356      5467      6578      7689  \
0             0  63.84345  66.09970  67.69065  89.47975  81.04410  76.86380   
1             1  64.12665  66.34525  67.99035  89.92135  81.35560  76.95140   
2             2  64.31660  66.56720  68.25520  90.20550  81.64690  77.02590   
3             3  38.68695  40.10530  41.14775  54.28520  49.22445  46.24525   
4             4  12.92015  13.41135  13.76705  18.15720  16.44970  15.47975   
5             5  64.73690  67.16850  69.57090  90.88410  82.22460  78.00320   
6             6  64.68790  67.20010  69.72875  91.09095  80.53285  80.31280   
7             7  64.75435  67.27780  69.97565  91.49855  80.65630  80.75105   
8             8  64.84250  67.43710  70.15050  91.77090  81.01820  81.44230   
9             9  65.00315  67.65530  70.38895  92.16490  82.93330  79.51215   
10           10  65.12855  67.81270  70.47380  92.44715  83.82115  78.35055   
11           11  65.19780  67.92440  70.52660  92.62010  83.97950  78.31900   
12           12  65.55970  68.13640  70.71980  92.93680  84.28010  78.35760   
13           13  66.03470  68.20100  71.03690  92.87130  84.76270  77.88310   
14           14  66.04225  68.45875  71.00625  93.20965  84.55440  78.93770   
15           15  66.09785  68.53605  71.05955  93.39910  84.49930  79.23785   
16           16  66.17890  68.61520  71.12500  93.51740  84.58460  79.34910   
17           17  66.28070  68.79385  71.33380  93.87785  84.84470  79.49515   
18           18  66.40840  68.98655  71.57365  93.98625  85.16840  79.56635   
19           19  66.43620  69.07890  71.64240  94.19590  85.29520  79.63940   
20           20  66.57285  69.27775  71.85690  94.41275  85.46720  80.03050   
21           21  66.65860  69.39185  71.99350  94.48340  85.53740  80.48005   
22           22  66.87450  69.43230  72.00340  94.73790  85.47050  80.78830   
23           23  67.06060  69.57655  72.15140  94.95465  85.57980  81.10070   
24           24  67.09120  69.64205  72.23385  95.12430  85.51905  81.42960   
25           25  67.07140  69.68870  72.28900  95.03000  85.61850  81.54600   
26           26  67.02710  69.69620  72.34930  95.14310  85.38850  81.96450   
27           27  66.90510  69.82155  72.40260  95.46825  85.56145  81.90650   
28           28  67.09310  69.98560  72.60380  95.80290  85.95210  82.05590   
29           29  67.22650  70.05345  72.72585  95.93010  86.26455  81.85895   
..          ...       ...       ...       ...       ...       ...       ...   
335         335       NaN       NaN       NaN       NaN       NaN       NaN   
336         336       NaN       NaN       NaN       NaN       NaN       NaN   
337         337       NaN       NaN       NaN       NaN       NaN       NaN   
338         338       NaN       NaN       NaN       NaN       NaN       NaN   
339         339       NaN       NaN       NaN       NaN       NaN       NaN   
340         340       NaN       NaN       NaN       NaN       NaN       NaN   
341         341       NaN       NaN       NaN       NaN       NaN       NaN   
342         342       NaN       NaN       NaN       NaN       NaN       NaN   
343         343       NaN       NaN       NaN       NaN       NaN       NaN   
344         344       NaN       NaN       NaN       NaN       NaN       NaN   
345         345       NaN       NaN       NaN       NaN       NaN       NaN   
346         346       NaN       NaN       NaN       NaN       NaN       NaN   
347         347       NaN       NaN       NaN       NaN       NaN       NaN   
348         348       NaN       NaN       NaN       NaN       NaN       NaN   
349         349       NaN       NaN       NaN       NaN       NaN       NaN   
350         350       NaN       NaN       NaN       NaN       NaN       NaN   
351         351  60.49480  64.05265  66.07475  87.05525  77.59515  77.29400   
352         352       NaN       NaN       NaN       NaN       NaN       NaN   
353         353  60.77620  64.28690  66.23685  87.37760  77.69835  77.52445   
354         354  60.91985  64.45135  66.25100  87.75880  77.53580  79.48670   
355         355  60.98210  64.55925  66.06395  88.62870  78.32275  78.37365   
356         356  61.13290  65.64830  64.88725  88.55525  79.47965  76.87415   
357         357  61.38690  65.99650  64.24260  88.45295  79.55600  76.42270   
358         358  61.70640  66.12420  64.17610  88.58915  79.58845  76.55560   
359         359  62.04990  66.26990  64.17000  88.89870  79.54090  76.60510   
360         360  62.25300  66.28915  64.35285  89.20460  79.49845  76.84445   
361         361  62.42310  66.37210  64.45750  89.82705  79.63040  77.01460   
362         362  62.63425  66.53280  64.73035  90.31155  79.71145  77.41180   
363         363  62.86890  66.80610  64.83395  90.78230  79.81140  77.71345   
364         364  63.06970  66.91875  65.01635  90.93830  79.92965  77.81615   

        87910    981011   1091112     ...      37364546   38374647   39384748  \
0    81.09030  69.45025  52.62985     ...      84.25525   96.45110   99.13210   
1    81.65155  69.89650  53.08180     ...      83.82325   96.37420   99.14110   
2    81.94750  70.40970  53.82110     ...      83.68640   96.24240   99.03590   
3    49.62015  42.22920  31.94895     ...      50.29575   58.00980   59.68305   
4    16.65150  14.09755  10.61750     ...      16.74225   19.33945   19.87175   
5    84.08220  70.33240  52.36220     ...      84.58890   97.25810   99.57770   
6    84.06995  70.45825  52.47435     ...      84.59965   97.16925   98.71760   
7    84.03320  70.68680  52.87395     ...      84.73475   97.26035   98.55810   
8    83.75610  70.69710  52.95310     ...      85.18720   97.30560   98.63440   
9    83.96960  70.97800  53.40170     ...      85.84030   97.49610   99.09305   
10   84.38050  71.00205  53.26835     ...      86.10215   97.37170   99.32945   
11   84.64860  71.10990  53.24910     ...      85.47100   97.13820   99.24060   
12   85.09260  71.62830  53.82770     ...      85.16340   97.25010   99.56640   
13   85.47705  71.82765  54.25325     ...      85.29685   97.52215   99.65855   
14   86.05435  71.91245  54.21225     ...      84.85580   97.65840   99.53925   
15   86.47330  72.16880  54.04495     ...      84.85355   97.61090   99.39165   
16   86.64010  72.40210  54.27540     ...      85.23920   97.56570   99.30060   
17   86.85030  72.88605  54.87250     ...      85.31610   97.51080   99.12190   
18   87.37240  72.98410  54.66230     ...      85.54340   97.89985   99.27685   
19   87.52700  73.15890  54.74190     ...      85.63730   97.77720   99.04950   
20   87.87145  73.43790  54.84515     ...      85.89175   98.04350   99.20335   
21   88.22300  73.41810  54.51715     ...      86.52625   98.17305   99.15695   
22   88.41010  73.40110  54.31120     ...      86.78300   98.44780   98.95680   
23   88.67350  73.61785  54.44695     ...      87.23370   98.76845   98.85215   
24   88.83135  73.80730  54.54450     ...      87.50905   98.73285   98.77070   
25   89.07170  73.64620  54.03600     ...      87.33380   98.75090   98.86290   
26   88.98970  73.91950  54.50730     ...      87.54860   98.49080   98.72040   
27   88.93030  74.16260  54.88615     ...      87.53505   98.25785   98.53210   
28   89.14520  74.58200  55.28480     ...      88.29510   98.57450   98.83120   
29   89.35635  74.75030  55.50815     ...      88.40420   98.58865   99.03655   
..        ...       ...       ...     ...           ...        ...        ...   
335       NaN       NaN       NaN     ...           NaN        NaN        NaN   
336       NaN       NaN       NaN     ...           NaN        NaN        NaN   
337       NaN       NaN       NaN     ...           NaN        NaN        NaN   
338       NaN       NaN       NaN     ...           NaN        NaN        NaN   
339       NaN       NaN       NaN     ...           NaN        NaN        NaN   
340       NaN       NaN       NaN     ...           NaN        NaN        NaN   
341       NaN       NaN       NaN     ...           NaN        NaN        NaN   
342       NaN       NaN       NaN     ...           NaN        NaN        NaN   
343       NaN       NaN       NaN     ...           NaN        NaN        NaN   
344       NaN       NaN       NaN     ...           NaN        NaN        NaN   
345       NaN       NaN       NaN     ...           NaN        NaN        NaN   
346       NaN       NaN       NaN     ...           NaN        NaN        NaN   
347       NaN       NaN       NaN     ...           NaN        NaN        NaN   
348       NaN       NaN       NaN     ...           NaN        NaN        NaN   
349       NaN       NaN       NaN     ...           NaN        NaN        NaN   
350       NaN       NaN       NaN     ...           NaN        NaN        NaN   
351  80.04275  67.29340  50.32550     ...      77.22795  104.10000  102.56900   
352       NaN       NaN       NaN     ...           NaN        NaN        NaN   
353  80.14785  66.68170  49.60405     ...      66.58890  104.69500  104.82500   
354  80.62285  65.76845  48.85475     ...      73.11345  105.24950  106.11300   
355  79.99845  66.07055  49.84575     ...      74.24615  104.78450  108.68800   
356  80.17750  66.47815  50.20295     ...      69.98405  105.03450  110.76150   
357  80.75950  67.05540  50.62565     ...      78.94815  104.77000  106.78300   
358  81.20720  67.41025  51.06815     ...      90.91725  104.46900  102.32550   
359  81.87350  67.64590  51.30190     ...      92.80315  104.74000  105.00500   
360  82.27595  67.96490  51.60115     ...      92.48420  104.26100  101.72050   
361  82.80890  68.54215  52.25425     ...      92.90495  104.28850  102.91550   
362  83.37675  68.95875  52.60155     ...      93.61855  104.67400  103.90450   
363  84.08175  69.26505  52.64260     ...      91.24865  105.00150  105.38250   
364  84.55020  69.34325  52.34000     ...      64.63285  104.80750  109.33850   

     40394849  41404950   42415051   43425152  44435253   45445354        date  
0    82.51245  77.35290   75.41105   70.74580  66.13875  151.79960  2015-01-01  
1    82.52715  77.50845   77.32860   72.01700  64.59440  196.19095  2015-01-02  
2    82.43440  77.35070   76.98420   72.13120  64.69170   44.89400  2015-01-03  
3    49.64645  47.01330   48.40995   43.71540  35.14285   76.87385  2015-01-04  
4    16.53710  15.85995   16.39960   14.25875  11.85625   82.61085  2015-01-05  
5    83.03150  81.68460   83.46580   68.43410  58.01330   83.76780  2015-01-06  
6    82.80425  77.56270   74.59620   70.39175  66.47465   81.43405  2015-01-07  
7    82.95350  77.50615   72.85220   70.35840  65.40760   80.80975  2015-01-08  
8    82.92070  78.17170  101.67700   85.02210  60.67450   68.19540  2015-01-09  
9    82.92690  77.91785   94.04665   84.73255  64.28055  240.47350  2015-01-10  
10   82.90490  78.07450   92.37360   83.84585  64.64190  400.20600  2015-01-11  
11   82.79630  77.65600   80.59540   76.96390  66.62560   80.78200  2015-01-12  
12   82.96820  77.97500   88.93640   82.63230  64.80250  256.14300  2015-01-13  
13   83.03270  78.43810   94.08115   86.12930  64.75955   86.12585  2015-01-14  
14   83.12090  78.28880   86.73945   81.84345  66.21510   81.28305  2015-01-15  
15   83.05415  78.84865  106.61105   90.27090  60.81245   81.16995  2015-01-16  
16   82.97610  78.13100   82.56670   78.94420  66.53400   76.73310  2015-01-17  
17   82.86585  78.23905   98.14455   86.96560  61.79020   81.03595  2015-01-18  
18   83.05980  78.85655  102.85350   91.79430  63.03765   81.70210  2015-01-19  
19   82.93770  78.57100   95.93480   88.99630  63.58110   81.48100  2015-01-20  
20   83.06435  78.75360  101.16350   90.90310  61.25915   81.66930  2015-01-21  
21   82.92010  83.84980  127.15550  108.21650  58.21120   82.86475  2015-01-22  
22   83.04850  81.46060  121.73800   98.19220  53.36720   82.93310  2015-01-23  
23   83.50825  78.87575  104.71280   92.64425  59.80700   82.94275  2015-01-24  
24   83.57330  80.51230  118.45250   97.73925  53.53460   83.26055  2015-01-25  
25   83.71690  87.04990  121.81700  108.29100  55.83500   82.66060  2015-01-26  
26   83.64000  78.20120   83.31430   82.18900  66.45370   82.75670  2015-01-27  
27   83.45170  77.85790   82.72730   80.95340  66.35985   82.28625  2015-01-28  
28   83.71010  78.01450   85.11930   83.42960  66.29200   82.31220  2015-01-29  
29   83.40305  77.98230   84.20150   82.13580  66.43735   82.26360  2015-01-30  
..        ...       ...        ...        ...       ...        ...         ...  
335       NaN       NaN        NaN        NaN       NaN        NaN  2015-12-02  
336       NaN       NaN        NaN        NaN       NaN        NaN  2015-12-03  
337       NaN       NaN        NaN        NaN       NaN        NaN  2015-12-04  
338       NaN       NaN        NaN        NaN       NaN        NaN  2015-12-05  
339       NaN       NaN        NaN        NaN       NaN        NaN  2015-12-06  
340       NaN       NaN        NaN        NaN       NaN        NaN  2015-12-07  
341       NaN       NaN        NaN        NaN       NaN        NaN  2015-12-08  
342       NaN       NaN        NaN        NaN       NaN        NaN  2015-12-09  
343       NaN       NaN        NaN        NaN       NaN        NaN  2015-12-10  
344       NaN       NaN        NaN        NaN       NaN        NaN  2015-12-11  
345       NaN       NaN        NaN        NaN       NaN        NaN  2015-12-12  
346       NaN       NaN        NaN        NaN       NaN        NaN  2015-12-13  
347       NaN       NaN        NaN        NaN       NaN        NaN  2015-12-14  
348       NaN       NaN        NaN        NaN       NaN        NaN  2015-12-15  
349       NaN       NaN        NaN        NaN       NaN        NaN  2015-12-16  
350       NaN       NaN        NaN        NaN       NaN        NaN  2015-12-17  
351  84.44920  81.32830   75.64120   83.10615  72.49880   97.28070  2015-12-18  
352       NaN       NaN        NaN        NaN       NaN        NaN  2015-12-19  
353  84.54480  82.89300   74.71890   85.65485  71.11450  101.23165  2015-12-20  
354  84.55780  82.22350   75.36805   86.61390  71.47470  100.26880  2015-12-21  
355  84.10370  82.24435   73.08690   91.03035  71.76930  101.04650  2015-12-22  
356  84.12465  82.63290   72.24545   93.97540  69.47005  102.73305  2015-12-23  
357  84.26430  81.88985   74.87325   90.24600  70.16615   98.93945  2015-12-24  
358  84.33105  80.72435   77.59775   79.99715  67.96245   95.32920  2015-12-25  
359  84.17775  81.15750   77.34670   82.57860  73.06255   94.35145  2015-12-26  
360  84.10205  80.66325   77.87205   78.83450  67.36135   94.29320  2015-12-27  
361  83.89790  80.59315   77.69670   79.90555  69.54410   93.23520  2015-12-28  
362  83.98555  80.99805   77.43495   81.53585  74.53005   92.97055  2015-12-29  
363  84.23320  81.56975   76.86940   82.76295  77.73295   93.16900  2015-12-30  
364  83.94990  84.24790   77.09560   84.99490  71.55385   97.53740  2015-12-31  

[365 rows x 382 columns]>

In [24]:
print index, electrode_index


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-24-6447e01f62f2> in <module>()
----> 1 print index, electrode_index

NameError: name 'index' is not defined

In [31]:
#df_DC_new.set_value??

In [32]:
electrode_index = df_DC_new.keys()[1:381]
for index in electrode_index:
    df_DC_new.set_value(newdata[:,i].flatten())

In [33]:
df_DC_new[electrode_index[0]].values.


  File "<ipython-input-33-3d2cea811643>", line 1
    df_DC_new[electrode_index[0]].values.
                                         ^
SyntaxError: invalid syntax

In [34]:
i = 112
def viz(i):
    x= df_DC[txrxID[i]]
    #median10 = pd.rolling_median(x, 6)
    mean10 = pd.rolling_max(x, 3)
    #x1 = median10
    #x2 = mean10
    # Masking array having NaN
    xm = xmasking(mean10)
    # Construct a Kalman filter
    kf = KalmanFilter(transition_matrices = [1],
                      observation_matrices = [1],
                      initial_state_mean = x[0],
                      initial_state_covariance = 1,
                      observation_covariance=1,
                      transition_covariance=1)
    # Use the observed values of the price to get a rolling mean
    state_means, _ = kf.filter(xm)

    plt.plot(x)
    plt.plot(mean10, 'k.')
    #plt.plot(x1)
    #plt.plot(x2)
    plt.plot(state_means)
    # plt.legend([ i, 'Kalman Estimate'])
    # print df_DC[txrxID[i]]
interact(viz, i=(0,389,10))



In [35]:
print df_DC[txrxID[i]]


0      75.78185
1      75.81855
2      75.46700
3      45.30735
4      15.08860
5      75.70830
6      75.36995
7      75.18660
8      74.73750
9      75.25070
10     75.50000
11     75.25210
12     75.28320
13     75.76720
14     75.14280
15     75.11595
16     75.25870
17     75.03020
18     74.90390
19     74.98350
20     75.04575
21     75.76670
22     77.90430
23     78.44480
24     78.63185
25     79.02390
26     79.80810
27     79.54745
28     79.30950
29     78.72380
         ...   
335         NaN
336         NaN
337         NaN
338         NaN
339         NaN
340         NaN
341         NaN
342         NaN
343         NaN
344         NaN
345         NaN
346         NaN
347         NaN
348         NaN
349         NaN
350         NaN
351    81.11340
352         NaN
353    81.30380
354    81.46540
355    81.54740
356    81.66620
357    81.94185
358    82.01205
359    82.10020
360    82.23215
361    82.35040
362    82.50260
363    82.69065
364    82.79715
Name: 13121617, dtype: float64

In [36]:
i = 105


x= df_DC[txrxID[i]]
#median10 = pd.rolling_median(x, 6)
mean10 = pd.rolling_max(x, 3)
#x1 = median10
#x2 = mean10
# Masking array having NaN
xm = xmasking(mean10)
# Construct a Kalman filter
kf = KalmanFilter(transition_matrices = [1],
                  observation_matrices = [1],
                  initial_state_mean = 67.6,
                  initial_state_covariance = 1,
                  observation_covariance=1,
                  transition_covariance=1)
# Use the observed values of the price to get a rolling mean
state_means, _ = kf.filter(xm)

#plt.plot(x1)
plt.plot(x)
#plt.plot(x1)
#plt.plot(x2)
plt.plot(state_means)
plt.legend([  'origin x','Kalman Estimate'])


Out[36]:
<matplotlib.legend.Legend at 0x1c106c88>

In [37]:
i = 300


x= df_DC[txrxID[i]]
#median10 = pd.rolling_median(x, 6)
mean10 = pd.rolling_max(x, 3)
#x1 = median10
#x2 = mean10
# Masking array having NaN
xm = xmasking(mean10)
# Construct a Kalman filter
kf = KalmanFilter(transition_matrices = [1],
                  observation_matrices = [1],
                  initial_state_mean = 67.6,
                  initial_state_covariance = 1,
                  observation_covariance=1,
                  transition_covariance=1)
# Use the observed values of the price to get a rolling mean
state_means, _ = kf.filter(xm)

#plt.plot(x1)
plt.plot(x)
#plt.plot(x1)
#plt.plot(x2)
plt.plot(state_means)
plt.legend([  'origin x','Kalman Estimate'])


Out[37]:
<matplotlib.legend.Legend at 0x1c346d30>

In [112]:
import pylab
import random
import math


random.seed = 1

#x1 = [1,4,7,8]
x1 = newdata[:,290]
#y1= df.upperH_med
#y1 = [1,3,5,7]
y1= df.reservoirH

In [113]:
print x1


[  96.91505      96.91505      96.91505      86.25637273   82.47595517
  126.27256184  142.97549095  149.35400134  104.1075824    86.82507132
  106.32072482  113.76740105  116.61177823   88.63289858   77.94591753
   74.18028741   72.74194469   72.19254666   72.18655379   72.18426472
   72.18830375   72.85525281   73.11000468   73.24158123   73.38318442
   73.43727202   73.45793165   73.33368726   73.28623012   73.09360121
   72.9759886    72.90007017   72.71124832   72.542866     72.68732156
   72.82732383   72.97539005   73.1754538    73.25187135   73.28106026
   73.06879015   72.68926156   72.98136818   73.09294298   98.76101133
  108.56534102  112.31026172   88.58170473   80.08249839   76.94047639
   75.80395738   75.59978529   75.52179849   75.49201019   85.33159942
   89.08998807   90.52556479   80.87881763   77.17616511   75.76187769
  102.62989938  102.62989938  102.62989938  102.62989938  143.7132616
  149.4570756   151.41797727  151.41797727  151.41797727  151.41797727
  151.41797727  151.41797727  151.41797727  151.41797727  151.41797727
  151.41797727  151.41797727  151.41797727  151.41797727  151.41797727
  151.41797727  151.41797727  151.41797727  151.41797727  151.41797727
  151.41797727  151.41797727  151.41797727  151.41797727  151.41797727
  151.41797727   98.03796473   96.65786041   88.05065374   84.84601073
   82.00168388   81.09201148   80.74457496   80.61186755   80.49266884
   80.48301586   80.4891246    86.95819476   89.42915969   90.37298431
   88.39961148   87.64585013   84.26560585   82.97446743   82.48129644
   80.4532201    79.67856388   82.63479728   83.78026316   84.21779219
   84.38491341   83.0135495    85.15797324   85.97707022   86.28993743
   89.61261953   90.88177116   91.36654394   88.69098584   95.23183371
   97.73021527   98.68451212   85.82683282   84.19056755   83.56556983
   83.32684195   81.01756293   78.92860006   74.96663133   76.91582937
   80.86189643   85.26576163   87.74688279   88.69458674  102.59195442
  107.90027652  131.84459645  140.99051282  144.48394202  125.29927579
   94.85926271   88.7904701    88.49642801   88.38411392   88.34121376
   79.67423652   80.35145559   80.61013026   80.70893519   79.05048104
   78.20984293   88.23065039  100.05821381  109.96918373  121.40418225
  125.77196303  127.44030683  103.04421435   93.72573621   87.92858592
   98.18468325  102.10216384  103.59850828   98.24639062   82.6536461
   76.27204585   74.50317334   73.82752416   73.56944914   73.21157709
   72.8269578    74.80843175   75.56528745   75.85438061   75.87676542
   75.48733267   74.87051456   74.19456179   73.89558056   73.40953974
   72.97923992   72.68601992   72.31144811   71.88784878   71.55154634
   71.20288473   70.58368591   70.34717301   73.09144601   74.61589111
   75.19817733   75.42059087   75.29841119   75.00548707   74.03082456
   72.98821694   72.11863265   71.57282666   71.30072072   72.25853699
   74.11836381   74.9298648    75.2398306    75.358227     74.91090821
   74.71069103   74.63421487   74.60500357   74.20729649   73.52369127
   72.40307744   71.97340325   71.42273296   70.72476681   69.96398748
   69.19225618   68.44242262   67.83145114   67.32246854   66.96334843
   66.81638092   66.39653132   66.01435065   65.67919041   65.40926999
   65.25073192   65.04663737   64.76973505   64.91019251   65.1677319
   65.2661032    65.30367769   65.32943259   65.33927009   65.34302768
   64.99218358   64.85817306   64.80698559   64.76459737   64.7337282
   64.72193722   64.39126603   64.26496088   64.37654019   64.62956937
   64.76209479   64.81271499   64.83205019   64.81820611   64.79823984
   64.53295503   64.5017412    64.81437913   64.9337962    64.97940946
   64.96583777   64.94925111   64.86136599   64.76905273   64.7337922
   64.72032388   64.88319198   64.94540206   64.96916419   65.20493539
   65.39121986   65.67927323   65.78929982   66.2178756    68.2147894
   68.9775426    69.2688884    68.96754219   68.85243819   68.47575377
   68.08070412   67.39156277   66.94403647   66.80245324   67.14471846
   67.27545214   67.32538796   67.26127438   66.99541199   66.8938616
   66.89258746   66.89210078   66.89191489   66.77441743   66.72953739
   66.61125348   66.40136699   67.40903      67.79392303   69.30117009
   70.48849367   70.94201092   71.1152391    70.93515073   70.51893529
   70.27516087   69.76941694   69.49629725   69.17019332   69.0456327
   68.9458618    71.41941194   73.21884142   74.61724133   75.15138256
   75.35540636   75.22623333   75.17689362   75.85444822   76.91567548
   77.32102823   77.6177598    77.73110118   77.77439373   78.77768308
   79.16090551   79.30728346   79.73664189   79.90064222   79.90064222
   79.90064222   79.90064222   79.90064222   79.90064222   79.90064222
   79.90064222   79.90064222   79.90064222   79.90064222   79.90064222
   79.90064222   79.90064222   79.90064222   79.90064222   79.90064222
   79.90064222   79.90064222   79.90064222   79.90064222   79.90064222
   79.90064222   79.90064222   79.90064222   79.90064222   79.90064222
   81.94676358   81.99586349   81.8482983    82.340595     82.52793454
   82.59945293   82.30056848   82.1864061    81.73341427   81.70392523]

In [116]:
print "Mean of x is", pylab.mean(x1)
print "Sample variance of x is", pylab.var(x1,ddof=1)
print "Sample SD of x is", pylab.std(x1,ddof=1)
print "Mean of y is", pylab.mean(y1)
print "Sample variance of y is", pylab.var(y1,ddof=1)
print "Sample SD of y is", pylab.std(y1,ddof=1)

print "Correlation of X and Y is", pylab.corrcoef(x1,y1)
print "Covariance of X and Y is", pylab.cov(x1,y1)


pylab.scatter(x1,y1,c="blue",marker="s")
pylab.xlabel("Variable X",size='x-large')
pylab.ylabel("Variable Y",size='x-large')
pylab.title("Scatter plot of two variables",size='x-large')
pylab.savefig("scatterXYExample.png")
pylab.show()


pylab.scatter(x1,y1,c="blue",marker="s")
pylab.xlabel("Variable X",size='x-large')
pylab.ylabel("Variable Y",size='x-large')
pylab.title("Scatter plot of two variables",size='x-large')
pylab.axhline(y=4)
pylab.axvline(x=5)
pylab.annotate('Mean of X = 5',
               xy=(5, 6),
               xycoords='data',
               xytext=(2,6),
               size='large',
               arrowprops=dict(arrowstyle="->"),
               ha='center',
               va='center')
pylab.annotate('Mean of Y = 4',
               xy=(7, 4),
               xycoords='data',
               xytext=(7,2),
               size='large',
               arrowprops=dict(arrowstyle="->"),
               ha='center',
               va='center')

pylab.savefig("scatterXYWithMeans.png")
#pylab.show()


#pylab.scatter(x1,y1,c="blue",marker="s")
pylab.xlabel("Variable X",size='x-large')
pylab.ylabel("Variable Y",size='x-large')
pylab.title("Scatter plot of two variables",size='x-large')
pylab.axhline(y=40)
pylab.axvline(x=50)
pylab.annotate('Mean of X = 5',
               xy=(50, 60),
               xycoords='data',
               xytext=(20,60),
               size='large',
               arrowprops=dict(arrowstyle="->"),
               ha='center',
               va='center')
pylab.annotate('Mean of Y = 4',
               xy=(70, 40),
               xycoords='data',
               xytext=(70,20),
               size='large',
               arrowprops=dict(arrowstyle="->"),
               ha='center',
               va='center')
pylab.annotate('(-4,-3)',
               xy=(10, 10),
               xycoords='data',
               xytext=(30,10),
               arrowprops=dict(arrowstyle="->",shrinkA=80,shrinkB=80),
               ha='center',
               va='center')
pylab.annotate('(-1,-1)',
               xy=(40, 30),
               xycoords='data',
               xytext=(20,30),
               arrowprops=dict(arrowstyle="->",shrinkA=80,shrinkB=80),
               ha='center',
               va='center')
pylab.annotate('(+2,+1)',
               xy=(70, 50),
               xycoords='data',
               xytext=(60,50),
               arrowprops=dict(arrowstyle="->",shrinkA=80,shrinkB=80),
               ha='center',
               va='center')
pylab.annotate('(+3,+3)',
               xy=(80, 70),
               xycoords='data',
               xytext=(60,70),
               arrowprops=dict(arrowstyle="->",shrinkA=80,shrinkB=80),
               ha='center',
               va='center')
pylab.savefig("scatterXYWithMeansAndDevs.png")
#pylab.show()


sampleSize = 50
x2 = []
y2 = []

for i in range(sampleSize):
    x2.append(random.normalvariate(100,10))

for i in range(sampleSize):
    y2.append(x2[i] + random.normalvariate(100,10))


pylab.scatter(x2,y2,c="red",marker="o")
pylab.xlabel("Variable X",size='x-large')
pylab.ylabel("Variable Y",size='x-large')
pylab.title("Scatter plot of two variables",size='x-large')
pylab.savefig("scatterXYCorrelated.png")
pylab.show()

print "Correlation of X and Y is", pylab.corrcoef(x2,y2)[0,1]


x3 = []
y3 = []

for i in range(sampleSize):
    if x2[i] > 95 and x2[i] < 105:
        x3.append(x2[i])
        y3.append(y2[i])

pylab.scatter(x3,y3,c="green",marker="o")
pylab.xlabel("Variable X",size='x-large')
pylab.ylabel("Variable Y",size='x-large')
pylab.title("Scatter plot of two variables, limited range",size='x-large')
pylab.savefig("scatterXYLimitedRange.png")
pylab.show()

print "Correlation of X and Y over limited range is", pylab.corrcoef(x3,y3)[0,1]



##Calculate repeated correlation coefficients for samples of 50
sampleSize = 50

print "Sampling experiment"

for k in range(20):
    x2 = []
    y2 = []
    for i in range(sampleSize):
        x2.append(random.normalvariate(100,10))
    for i in range(sampleSize):
        y2.append(x2[i] + random.normalvariate(100,10))
    print pylab.corrcoef(x2,y2)[0,1]


Mean of x is 84.3387505257
Sample variance of x is 543.685365319
Sample SD of x is 23.3170616785
Mean of y is 36.0108219178
Sample variance of y is 12.0501960259
Sample SD of y is 3.47133922657
Correlation of X and Y is [[ 1.          0.55645814]
 [ 0.55645814  1.        ]]
Covariance of X and Y is [[ 543.68536532   45.04051779]
 [  45.04051779   12.05019603]]
Correlation of X and Y is 0.7795909778
Correlation of X and Y over limited range is -0.04978364322
Sampling experiment
0.652439013768
0.508220090961
0.761799541879
0.804108032194
0.680426942706
0.644063069541
0.680994489301
0.730568739082
0.766915518096
0.678529132152
0.703095741891
0.733769439014
0.650814964177
0.644987557668
0.487235896004
0.757487432159
0.697478863609
0.6259042221
0.710477889717
0.714996046733

In [ ]: