forked from rbergerpa/balloon_data
/
vert_speed.py
40 lines (27 loc) · 908 Bytes
/
vert_speed.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from pandas import Series, DataFrame
from json_util import load_json
import datetime as dt
import sys
DATE_FORMAT = '%Y-%m-%d %H:%M:%S'
def select_time(dict):
return dict['time']
def load_data(path):
json_data = list(load_json(path))
for d in json_data:
d['time'] = dt.datetime.strptime(d['time'], DATE_FORMAT)
return DataFrame(data=json_data, index=map(select_time, json_data))
gps_data = load_data('c1_gps.txt')
hgt = gps_data['hgt']
# Delete the samples when the balloon was on the ground
hgt = hgt[4:hgt.size-15]
# delta is the height difference between samples shifted by 2 minutes
delta = hgt.shift(-1, 'min') - hgt.shift(1, 'min')
miles = delta / 5280.0
mph = miles * 30 # delta shift is 30 periods per hour
p = mph.plot()
p.set_ylabel("Vertical Speed (MPH)")
p.set_xlabel("Time")
plt.show()