Created
April 11, 2016 00:41
-
-
Save jwnelson/97389a3bb7f087208a6be5867b302048 to your computer and use it in GitHub Desktop.
Extracts time-series acceleration from a csv of Raven amateur rocket altimeter data and plots it.
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
import matplotlib.pyplot as plt | |
import numpy as np | |
import csv | |
def extract_raven_accel(ravenfile, start_time = 0.0, end_time = 60.0, trim_head = 0, print_interval = 1000000): | |
""" | |
Use this to pull acceleration data from a raven raw export file. | |
Returns an Nx2 array of times (col 1) and accel values (col 2) in ft/s/s | |
Assumes col 0 of the raven csv data is time, and col 15 is acceleration. | |
""" | |
raven_accel_col = 15 | |
accel = np.zeros((1,2)) | |
# Read through the rows of the csv file and read accel time and accel values | |
with open(ravenfile, 'r') as ravencsv: | |
ravenreader = csv.reader(ravencsv, delimiter =',') | |
i = 0 | |
for rowN, row in enumerate(ravenreader): | |
# Trim the first N lines of the csv | |
if rowN < trim_head: | |
continue | |
# Only extract accel values up to end_time | |
if float(row[0]) <= end_time: | |
if i > print_interval: | |
print row[0], rowN, row[15] | |
i = 0 | |
accel = np.append(accel, [[row[0], row[15]]], axis=0) | |
i += 1 | |
else: | |
break | |
# Returns an Nx2 array with time and accel values as the columns | |
return accel | |
#Plot the Raven accelerations | |
fig = plt.figure(1) | |
plt.subplot(211) | |
plt.scatter(accel[:,0], accel[:,1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment