def main(fname=None, outname=None):
    assert fname
    assert outname
    tcx = TCX(src=fname)
    time_position_sequence = [(parse_time(p), Position(*parse_position(p))) for p in tcx.position_points]

    fig1 = plt.figure()
    ax_locs = fig1.add_subplot(111)
    t = [dates.date2num(tp[0]) for tp in time_position_sequence]
    alt = [tp[1].altitude for tp in time_position_sequence]
    ax_locs.plot_date(t, alt, fmt='b-')
    fig1.savefig(outname)
def main(fname=None, outname=None):
    assert fname
    assert outname
    tcx = TCX(src=fname)
    time_position_sequence = ((parse_time(p), Position(*parse_position(p))) for p in tcx.position_points)
    time_speed_sequence = [(p2[0], speed_miles(p1, p2)) for p1, p2 in pairwise(time_position_sequence) if p1[0] != p2[0]]

    fig1 = plt.figure()
    ax_locs = fig1.add_subplot(111)
    t = [dates.date2num(tp[0]) for tp in time_speed_sequence]
    speed = [tp[1] for tp in time_speed_sequence]
    ax_locs.plot_date(t, speed, fmt='b-')
    fig1.savefig(outname)