Created
September 5, 2013 19:39
-
-
Save sirishn/6455076 to your computer and use it in GitHub Desktop.
Open .csv log file and plot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python | |
# Open .csv log file, plot elbow feed forward force and elbow load | |
import sys | |
import numpy as np | |
from pylab import * | |
from struct import pack, unpack | |
import csv | |
def plot_csv(filein): | |
time = [] | |
load = [] | |
uff = [] | |
filename = filein | |
#with open('d00007.csv', 'rb') as f: | |
with open(filename, 'rb') as f: | |
reader = csv.reader(f) | |
for row in reader: | |
if row[0] == "time (s)": # TAG ROW 0 | |
print row | |
else: | |
time.append( float(row[0] ) ) | |
load.append( float(row[5] ) ) | |
uff.append( float(row[8] ) ) | |
subplots_adjust(hspace=0.5) | |
subplot(2,1,1) | |
plot(time, load) | |
title("Right elbow load (Nm)") | |
xlabel("time (s)") | |
ylabel("Force (Nm)") | |
grid() | |
subplot(2,1,2) | |
plot(time, uff) | |
title("Right elbow feed forward force (Nm)") | |
xlabel("time (s)") | |
ylabel("Force (Nm)") | |
grid() | |
show() | |
if __name__ == '__main__': | |
filename = sys.argv[1] | |
print filename | |
plot_csv(filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment