#! /usr/bin/env python3
# -*- coding:utf8 -*-
import numpy as np
import matplotlib.pyplot as plt
# data source: https://www.scienceworld.ca/resource/stratos-jump-data-analysis/
t_h_v = np.array([
[0, 38969, 0],
[2, 38948, 67],
[5, 38827, 187],
[8, 38635, 287],
[10, 38439, 364],
[12, 38233, 430],
[15, 37842, 530],
[17, 37471, 612],
[19, 37175, 670],
[21, 36715, 749],
[23, 36274, 808],
[25, 35797, 866],
[27, 35306, 924],
[30, 34487, 1013],
[32, 33919, 1076],
[33, 33661, 1107],
[34, 33340, 1126],
[36, 32676, 1174],
[38, 32002, 1212],
[40, 31326, 1260],
[42, 30642, 1285],
[44, 29884, 1301],
[46, 29183, 1317],
[48, 28448, 1340],
[50, 27710, 1355],
[52, 26883, 1334],
[54, 26250, 1314],
[56, 25454, 1307],
[58, 24746, 1261],
[60, 24112, 1196],
[62, 23413, 1104],
[64, 22857, 1056],
[66, 22307, 993],
[68, 21729, 957],
[70, 21268, 917],
[72, 20752, 850],
[74, 20247, 822],
[76, 19840, 803],
[78, 19406, 762],
[80, 19026, 726],
[82, 18587, 690],
[84, 18117, 665],
[86, 17852, 647],
[88, 17527, 627],
[90, 17131, 611],
[92, 16853, 592],
[94, 16496, 568],
[96, 16188, 548],
[98, 15881, 526],
[102, 15324, 485],
[104, 15096, 470],
[106, 14811, 457],
[108, 14581, 447],
[110, 14328, 440],
[112, 14077, 427],
[114, 13838, 415],
[116, 13609, 403],
[118, 13412, 394],
[120, 13179, 386],
[122, 12958, 375],
[124, 12756, 372],
[126, 12547, 374],
[128, 12353, 375],
[130, 12137, 375],
[132, 11928, 373],
[134, 11712, 371],
[136, 11513, 367],
[138, 11314, 361],
[140, 11104, 359],
[142, 10912, 358],
[144, 10706, 361],
[146, 10526, 355],
[148, 10308, 351],
[150, 10124, 347],
[152, 9926, 339],
[154, 9744, 329],
[156, 9569, 322],
[158, 9389, 313],
[160, 9210, 312],
[162, 9040, 308],
[164, 8872, 298],
[166, 8705, 293],
[168, 8533, 290],
[170, 8393, 286],
[172, 8232, 289],
[174, 8055, 289],
[176, 7915, 289],
[178, 7747, 289],
[180, 7589, 285],
[182, 7432, 282],
[184, 7273, 279],
[186, 7112, 279],
[188, 6966, 279],
[190, 6811, 271],
[192, 6665, 265],
[194, 6513, 259],
[196, 6378, 254],
[198, 6218, 241],
[200, 6112, 229],
[202, 5996, 221],
[204, 5839, 223],
[206, 5745, 220],
[208, 5609, 224],
[210, 5501, 221],
[212, 5356, 220],
[214, 5245, 222],
[216, 5120, 221],
[218, 4997, 221],
[220, 4876, 219],
[222, 4752, 218],
[224, 4634, 218],
[226, 4509, 217],
[228, 4388, 215],
[230, 4273, 213],
[232, 4149, 212],
[234, 4033, 215],
[236, 3915, 214],
[238, 3796, 215],
[240, 3667, 210],
[242, 3570, 210],
[244, 3441, 208],
[246, 3330, 205],
[248, 3213, 204],
[250, 3101, 203],
[252, 2989, 199],
[254, 2882, 203],
[256, 2767, 203],
[258, 2651, 203],
[260, 2544, 182],
[262, 2457, 125],
[264, 2433, 36],
[266, 2406, 37],
[268, 2408, 21],
[270, 2397, 19],
[272, 2385, 20],
[274, 2376, 14],
[276, 2368, 13],
[278, 2360, 17],
[280, 2351, 17],
[282, 2341, 17],
[284, 2331, 18],
[286, 2321, 15],
[288, 2315, 15],
[290, 2307, 10],
[292, 2301, 14],
[294, 2292, 14],
[296, 2283, 16],
[298, 2273, 16],
[300, 2266, 11],
[310, 2234, 12],
[320, 2191, 15],
[330, 2144, 17],
[340, 2091, 18],
[350, 2041, 19],
[360, 1995, 12],
[370, 1959, 10],
[380, 1923, 10],
[390, 1887, 12],
[400, 1859, 7],
[410, 1836, 12],
[420, 1810, 10],
[430, 1787, 8],
[440, 1762, 8],
[450, 1734, 11],
[460, 1704, 13],
[470, 1669, 13],
[480, 1630, 15],
[490, 1597, 13],
[500, 1563, 13],
[510, 1514, 20],
[520, 1469, 21],
[530, 1424, 20],
[540, 1370, 13],
[550, 1363, 0] ])
plt.rcParams.update({'text.usetex':False, "svg.fonttype":"none", "font.size":14})
fig, ax1 = plt.subplots(figsize=(800 / 90.0, 560 / 90.0), dpi=72)
colors = plt.rcParams['axes.prop_cycle'].by_key()['color']
ax2 = ax1.twinx()
ax1.plot(t_h_v[:,0]/60, t_h_v[:,1] / 1000, lw=2.4, label="h [km]")
ax2.plot(np.nan, lw=2.4, label="h [km]") # for legend
ax2.plot(t_h_v[:,0]/60, t_h_v[:,2], color=colors[1], lw=2.4, label="v [km/h]")
ax1.axhline(1.119, color='k', lw=0.8)
plt.xlim(-0.2, t_h_v[-1,0]/60 + 0.2)
ax1.set_ylim(0, 40)
ax2.set_ylim(0, 1600)
ax1.set_xlabel('t [min]')
ax1.set_ylabel('h [km]')
ax2.set_ylabel('v [km/h]')
plt.title("Stratos descent")
ax1.grid(True)
ax1.xaxis.set_major_locator(ticker.MultipleLocator(1))
ax2.legend(loc='upper center', framealpha=1, borderpad=0.8, borderaxespad=2.7)
plt.tight_layout()
plt.savefig("Stratos_descent_graph.svg")