tadded position plotting - flytrexlog - read, manipulate, and plot flytrex logg… | |
git clone git://src.adamsgaard.dk/flytrexlog | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
commit 7b8316db1357a064a8cf36a0572626444ea74463 | |
parent ad248b5fa743cb400d401688004385d2e467b932 | |
Author: Anders Damsgaard <[email protected]> | |
Date: Fri, 6 Jun 2014 08:40:38 +0200 | |
added position plotting | |
Diffstat: | |
M flytrex_20140601.py | 1 + | |
M flytrexlog.py | 45 +++++++++++++++++++++++++++--… | |
2 files changed, 41 insertions(+), 5 deletions(-) | |
--- | |
diff --git a/flytrex_20140601.py b/flytrex_20140601.py | |
t@@ -2,3 +2,4 @@ | |
import flytrexlog | |
flight = flytrexlog.csvfile('flytrex_quadcopter_mission_20140601.csv') | |
+flight.plot_position() | |
diff --git a/flytrexlog.py b/flytrexlog.py | |
t@@ -1,6 +1,7 @@ | |
#!/usr/bin/env python | |
import csv | |
import numpy | |
+import matplotlib.pyplot as plt | |
class csvfile: | |
def __init__(self, filename): | |
t@@ -9,8 +10,8 @@ class csvfile: | |
def read_csv(self, filename): | |
log = numpy.genfromtxt(filename, delimiter=',') | |
- f_to_m = 0.3048 # factor to convert from feet to meter | |
- mph_to_ms = 0.447 # miles/hour to meter/second | |
+ f_to_m = 0.3048 # factor to convert from feet to meter | |
+ mph_to_ms = 0.447 # miles/hour to meter/second | |
self.latitude = log[1:,0] | |
self.longitude = log[1:,1] | |
self.altitude = log[1:,2]*f_to_m | |
t@@ -22,11 +23,45 @@ class csvfile: | |
self.max_speed = log[1:,8]*mph_to_ms | |
self.max_distance = log[1:,9]*f_to_m | |
self.time = log[1:,10]/1000.0 # ms to s | |
- self.datetime_utc = log[1:,11] | |
- self.datetime = log[1:,12] | |
+ self.datetime_utc = log[1:,11] # ERROR: Not parsed correctly | |
+ self.datetime = log[1:,12] # ERROR: Not parsed correctly | |
self.sattelites = log[1:,13] | |
self.pressure = log[1:,14] | |
- self.temperature = (log[1:,15] - 32.0)/1.8 # Fahrenheit to Celcius | |
+ self.temperature = (log[1:,15] - 32.0)/1.8 # F to C | |
+ def plot_position(self): | |
+ ''' | |
+ Plot the GPS coordinates from the log through time. | |
+ ''' | |
+ f, axarr = plt.subplots(3, sharex=True) | |
+ axarr[0].plot(self.time, self.latitude) | |
+ axarr[0].set_ylabel('Latitude, $\phi$, [$^\circ$]') | |
+ axarr[0].grid() | |
+ axarr[0].set_title(self.filename) | |
+ | |
+ axarr[1].plot(self.time, self.longitude) | |
+ axarr[1].set_ylabel('Longitude, $\lambda$, [$^\circ$]') | |
+ axarr[1].grid() | |
+ | |
+ axarr[2].plot(self.time, self.altitude) | |
+ axarr[2].set_xlabel('Time [s]') | |
+ axarr[2].set_ylabel('Altitude [m]') | |
+ axarr[2].grid() | |
+ | |
+ #f.subplots_adjust(hspace=0.0) | |
+ plt.show() | |
+ | |
+ def utm_coordinate(self, datetime, format='local'): | |
+ ''' | |
+ Determines the GPS coordinate at a specified time. If no | |
+ recorded value is available at the specified time, linear | |
+ interpolation will approximate the coordinate. | |
+ | |
+ :param datetime: The timestamp for which the approximate | |
+ location is required | |
+ :type datetime: str | |
+ :param format: Format of the timestamp. Can be 'local' or 'utc' | |
+ :type format: str | |
+ ''' | |