示例#1
0
max_altitude_time = gps_data['hgt'].idxmax()
max_altitude = gps_data['hgt'].max()
print "Max altitude", max_altitude, " at ", max_altitude_time

field = sys.argv[1]

# Set ascendeing and descending each to a Series of the specified field vs. time
try:
    ascending = logger_data.ix[logger_data.time <= max_altitude_time, field]
    descending = logger_data.ix[logger_data.time >= max_altitude_time, field]
except:
    ascending = gps_data.ix[gps_data.time <= max_altitude_time , field]
    descending = gps_data.ix[gps_data.time >= max_altitude_time, field]

y_label = sys.argv[len(sys.argv)-1]

# Plot specified field vs time
p = DataFrame({'Ascending': ascending, 'Descending': descending}).plot()
p.set_ylabel(y_label)
p.set_xlabel("Time")

# Plot specified field vs altitude
if field != 'hgt':
    p = DataFrame({'Ascending': by_altitude(ascending, gps_data), 'Descending': by_altitude(descending, gps_data)}).plot()
    p.set_ylabel(y_label)
    p.set_xlabel("Altitude")

# show both plots
plt.show()
示例#2
0
hgt = gps_data["hgt"]
# Delete the samples when the balloon was on the ground
hgt = hgt[4 : hgt.size - 15]

max_altitude_time = hgt.idxmax()
max_altitude = hgt.max()

# 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

offset = timedelta(minutes=1)
ascending = mph.ix[mph.index < max_altitude_time - offset]
descending = mph.ix[mph.index > max_altitude_time - offset]

# Plot vertical speed vs time
p = DataFrame({"Ascending": ascending, "Descending": descending}).plot()
p.set_ylabel("Vertical Speed (MPH)")
p.set_xlabel("Time")
plt.show()

# Plot descent speed vs altitude
b = by_altitude(descending, gps_data)
b = b.ix[b.index < max_altitude - 1000]  # Time window causes artifacs at the altitude peak
p = b.mul(-1).plot()
p.set_ylabel("Descent Speed (MPH)")
p.set_xlabel("Altitude")
plt.show()