Skip to content
This repository has been archived by the owner on Sep 14, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release/release_1_1'
Browse files Browse the repository at this point in the history
  • Loading branch information
sco1 committed Jul 27, 2017
2 parents f9414b7 + e6846da commit 3f36a66
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 9 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# pyAltiForce
Python Parsing for AltiForce GoPro Backpack CSVs

The CSV file is processed and a plot of time vs. total acceleration is displayed.

## Usage
Calling `pyAltiForce` from the command line with no arguments opens a file selection GUI for the user to select a single CSV file to process and display.

Calling `pyAltiForce` with the optional `-f` or `--file` flag will allow the user to specify a single CSV file to process.

Examples Include:

python pyAltiForce -f './Data/GOPR0024.CSV'
python pyAltiForce --file 'C:/My Data/GOPR0024.CSV'
34 changes: 25 additions & 9 deletions AltiForce.py → pyAltiForce.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import matplotlib
matplotlib.use("TkAgg")
matplotlib.use("TkAgg") # Keep matplotlib and tkinter from conflicting and segfaulting
import matplotlib.pyplot as plt

from tkinter import Tk
from tkinter.filedialog import askopenfilename
import numpy as np
from numpy.lib import recfunctions as rfn
import argparse
from pathlib import Path

class AltiForce():
class pyAltiForce():
def __init__(self, filepath):
self.filepath = filepath
self.loadCSV()
Expand Down Expand Up @@ -44,6 +45,7 @@ def plotdata(self):
ax1.plot(x, y1, 'g-')
ax2.plot(x, y2, 'b-')

fig.suptitle(self.filepath.name)
ax1.set_xlabel('Time (seconds)')
ax1.set_ylabel('Altitude (feet)', color='g')
ax2.set_ylabel('Z Acceleration (Gees)', color='b')
Expand All @@ -52,11 +54,25 @@ def plotdata(self):


if __name__ == "__main__":
root = Tk()
root.withdraw()
filepath = askopenfilename()
root.destroy()
parser = argparse.ArgumentParser(description=('Parsing for AltiForce GoPro Backpack CSV, '
'specify a file with the -f or --file flags '
'or leave blank for a GUI prompt'
)
)
parser.add_argument("-f", "--file",
help="Parse manually specified file (relative or absolute path)",
action="store")
args = parser.parse_args()
if args.file:
filepath = Path(args.file)
else:
root = Tk()
root.withdraw()
filepath = Path(askopenfilename())
root.destroy()

if filepath:
mydata = AltiForce(filepath)
if filepath.exists():
mydata = pyAltiForce(filepath)
mydata.plotdata()
else:
raise(ValueError)

0 comments on commit 3f36a66

Please sign in to comment.