In [ ]:
import numpy as np
import csv
from datetime import datetime
from collections import OrderedDict
In [ ]:
eigenforce_log = OrderedDict()
with open('/home/viki/denso_log/topic_log/20170420/20170420-10_42_08_eigenforce3d_cut2.log', 'rb') as logfile:
reader = csv.DictReader(logfile)
#eigenforce_log = list(reader)
for row in reader:
eigenforce_log[datetime.strptime(row['eventtime'],
'%Y-%m-%d %H:%M:%S.%f')] = float(row['eigenforce3d'])
In [ ]:
skills_log = OrderedDict()
skill_legend = OrderedDict()
with open('/home/viki/denso_log/topic_log/20170420/20170420-10_42_08_status_cut2.log', 'rb') as logfile:
reader = csv.DictReader(logfile)
#eigenforce_log = list(reader)
for row in reader:
skills_log[datetime.strptime(row['eventtime'],
'%Y-%m-%d %H:%M:%S.%f')] = int(row['id_number'])
skill_legend[int(row['id_number'])] = row['skill_name']
#print skills_log.values()
#print skill_legend
In [ ]:
import matplotlib.pyplot as plt
#%matplotlib notebook
fig = plt.figure()
ax1 = fig.add_subplot(211)
plt.xticks(rotation=30)
ax1.grid(color='black', alpha=0.3, linestyle=':', linewidth=1)
ax1.set_yticks(range(len(skill_legend.values())))
ax1.set_yticklabels(skill_legend.values())
ax1.plot(skills_log.keys(), skills_log.values(), 'r', drawstyle='steps-mid')
ax2 = fig.add_subplot(212)
ax2.plot(eigenforce_log.keys(), eigenforce_log.values())
plt.xticks(rotation=30)
plt.show()
In [ ]:
import matplotlib.pyplot as plt
#%matplotlib notebook
fig, ax1 = plt.subplots()
plt.xticks(rotation=30)
ax1.plot(eigenforce_log.keys(), eigenforce_log.values(), 'r')
ax1.set_ylabel('eigenforce_3d', color='r')
ax1.tick_params('y', colors='r')
ax2 = ax1.twinx()
# Make the y-axis label, ticks and tick labels match the line color.
ax2.plot(skills_log.keys(), skills_log.values(), 'b', drawstyle='steps')
ax2.set_ylabel('skills', color='b')
ax2.tick_params('y', colors='b')
ax2.grid(color='black', alpha=0.3, linestyle=':', linewidth=1)
ax2.set_yticks(skill_legend.keys())
ax2.set_yticklabels(skill_legend.values())
fig.tight_layout()
plt.show()
In [ ]:
def keybyvalue(dic, val):
# find key by values :-/
for key, value in dic.iteritems():
if value == val:
return key
break
else:
return None
In [ ]:
import pandas as pd
import numpy as np
from pandas import Series, DataFrame, Panel
%pylab inline
plt.rcParams['figure.figsize'] = (15, 15)
data = pd.Series(data=eigenforce_log)
data_skills = pd.Series(data=skills_log)
data_skills_visual = pd.Series(data=0.5*(np.array(skills_log.values())-np.min(skills_log.values())), index=skills_log.keys())
data.plot()
data_skills_visual.plot(kind = 'line', drawstyle = 'steps')
data.rolling(window=5, center=True).mean().plot(style='-')
data.rolling(window=5, center=True).min().plot(style=':')
data.rolling(window=5, center=True).max().plot(style=':')
#data[data_skills > 27]
#data_skills
data