import numpy as np
import pandas as pd
directory = '../data'
mission_data = pd.read_csv(f'{directory}/clean-data.csv', na_values="*", index_col=0)
mission_data.head()
millis | year | month | day | hour | minute | second | voltage | satellites | hdop | ... | latitude | longitude | temperature_C | pressure_Pa | pressure_altitude_m | humidity_RH | mission_millis | blended_altitude_m | altitude_m | ascent_rate_mps | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
timestamp | |||||||||||||||||||||
2021-09-25 17:28:11 | 135015 | 2021.0 | 9.0 | 25.0 | 17.0 | 28.0 | 11.0 | 4.40 | 6.0 | 15.71 | ... | 47.160885 | -120.848351 | 20.34 | 93890.44 | 638.23 | 39.34 | 0 | 640.489791 | 657.3 | NaN |
2021-09-25 17:28:12 | 136017 | 2021.0 | 9.0 | 25.0 | 17.0 | 28.0 | 12.0 | 4.37 | 7.0 | 2.05 | ... | 47.160892 | -120.848351 | 20.39 | 93892.72 | 638.02 | 39.21 | 1002 | 640.287907 | 660.1 | 2.800000 |
2021-09-25 17:28:13 | 137021 | 2021.0 | 9.0 | 25.0 | 17.0 | 28.0 | 13.0 | 4.37 | 7.0 | 2.06 | ... | 47.160877 | -120.848343 | 20.45 | 93891.80 | 638.10 | 39.26 | 2006 | 640.369369 | 662.6 | 2.645000 |
2021-09-25 17:28:14 | 138027 | 2021.0 | 9.0 | 25.0 | 17.0 | 28.0 | 14.0 | 4.37 | 8.0 | 2.05 | ... | 47.160824 | -120.848351 | 20.49 | 93893.68 | 637.94 | 39.78 | 3012 | 640.202904 | 663.1 | 1.881822 |
2021-09-25 17:28:15 | 139032 | 2021.0 | 9.0 | 25.0 | 17.0 | 28.0 | 15.0 | 4.43 | 8.0 | 1.86 | ... | 47.160759 | -120.848343 | 20.53 | 93889.08 | 638.34 | 40.20 | 4017 | 640.610215 | 661.0 | 0.784685 |
5 rows × 23 columns
burst_index = np.argmax(mission_data['gps_altitude_m'])
burst_time = mission_data.index[burst_index]
ascent_phase = mission_data[mission_data.index < burst_time]
descent_phase = mission_data[mission_data.index > burst_time]
ascent_rate = ascent_phase['ascent_rate_mps']
descent_rate = descent_phase['ascent_rate_mps'] * -1
burst_row = mission_data.iloc[burst_index]
burst_altitude = burst_row['altitude_m']
print(burst_altitude)
33502.8
import simplekml
kml = simplekml.Kml()
kml.document.name = "Graupel-2 Actual Flight Path"
def create_point(row, name):
point = kml.newpoint(name=name)
latitude = row['latitude']
longitude = row['longitude']
altitude = row['altitude_m']
time = row.name
coords = row[['longitude','latitude','altitude_m']].to_numpy()
coords.resize(1,3)
point.coords = coords
point.description = f'{name} at {latitude:0.4f}, {longitude:0.4f}, {altitude:0.0f}m at {time}'
point.altitudemode = simplekml.AltitudeMode.absolute
def summary_stats(series):
return f'{series.mean():0.1f}m/s ({series.max():0.1f} max)'
create_point(mission_data.iloc[0], 'Launch')
create_point(burst_row, 'Burst')
create_point(mission_data.iloc[-1], 'Landing')
every_minute_data = pd.concat([mission_data.iloc[::60], mission_data.iloc[[-1]]])
path = kml.newlinestring(name='Flight path')
path.description = f'Ascent rate: {summary_stats(ascent_rate)}, descent rate: {summary_stats(descent_rate)}'
path.coords = every_minute_data[['longitude','latitude','altitude_m']].to_numpy()
path.extrude = 1
path.altitudemode = simplekml.AltitudeMode.absolute
path.style.linestyle.color = "ffff0018"
path.style.linestyle.width = 4
path.style.polystyle.color = "ffff0018"
kml.save(f'{directory}/recorded-flight-path.kml')
print(kml.kml(format=True))
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
<Document id="1">
<Style id="10">
<LineStyle id="11">
<color>ffff0018</color>
<colorMode>normal</colorMode>
<width>4</width>
</LineStyle>
<PolyStyle id="12">
<color>ffff0018</color>
<colorMode>normal</colorMode>
<fill>1</fill>
<outline>1</outline>
</PolyStyle>
</Style>
<name>Graupel-2 Actual Flight Path</name>
<Placemark id="3">
<name>Launch</name>
<description>Launch at 47.1609, -120.8484, 657m at 2021-09-25 17:28:11</description>
<Point id="2">
<coordinates>-120.84835052,47.16088485,657.3</coordinates>
<altitudeMode>absolute</altitudeMode>
</Point>
</Placemark>
<Placemark id="5">
<name>Burst</name>
<description>Burst at 47.1632, -119.7372, 33503m at 2021-09-25 20:04:25</description>
<Point id="4">
<coordinates>-119.73724365,47.16323852,33502.8</coordinates>
<altitudeMode>absolute</altitudeMode>
</Point>
</Placemark>
<Placemark id="7">
<name>Landing</name>
<description>Landing at 47.1889, -119.4382, 343m at 2021-09-25 20:41:37</description>
<Point id="6">
<coordinates>-119.43823242,47.18886184,342.9</coordinates>
<altitudeMode>absolute</altitudeMode>
</Point>
</Placemark>
<Placemark id="9">
<name>Flight path</name>
<description>Ascent rate: 3.5m/s (6.4 max), descent rate: 14.9m/s (60.8 max)</description>
<styleUrl>#10</styleUrl>
<LineString id="8">
<extrude>1</extrude>
<altitudeMode>absolute</altitudeMode>
<coordinates>-120.84835052,47.16088485,657.3 -120.84776306,47.16085815,772.1 -120.84333801,47.16053771,1004.5 -120.83648681,47.15829467,1271.2542857142855 -120.82962036,47.15705108,1525.5 -120.82263946,47.15568923,1752.9 -120.81587219,47.1556015,1980.7 -120.80970764,47.15405273,2250.2 -120.80497741,47.15239334,2437.6 -120.79890441,47.15120697,2573.7 -120.7938919,47.15003967,2705.4 -120.78851318,47.14903259,2852.2 -120.78398895,47.14889907,3013.0 -120.77906799,47.14892959,3188.5 -120.77328491,47.14931106,3368.5 -120.76673889,47.14989852,3550.1 -120.75965881,47.1504898,3728.7 -120.75203704,47.15184402,3919.265909090909 -120.74409484,47.15299224,4117.3 -120.73657989,47.15447998,4300.7 -120.72917175,47.15605163,4501.2 -120.72077178,47.15848159,4654.3 -120.71237182,47.16009902,4802.3 -120.70377349,47.16132354,4946.9 -120.69529724,47.16323089,5092.2 -120.68722534,47.16501617,5247.7 -120.67948913,47.16647338,5411.6 -120.67230224,47.16791534,5576.8 -120.66547393,47.16878509,5746.7 -120.65926361,47.16941452,5911.8 -120.6533966,47.17050552,6087.0 -120.6472702,47.17139053,6257.8 -120.64120483,47.17163085,6434.3 -120.63391876,47.17178726,6605.6 -120.62591552,47.17201614,6783.8 -120.61787414,47.17142105,6956.2 -120.61027526,47.17155456,7128.685365853659 -120.60030364,47.17100143,7300.3 -120.59126281,47.17074966,7457.9 -120.58067321,47.17052078,7602.0 -120.57202148,47.17071533,7748.431034482758 -120.56150817,47.17091369,7898.7 -120.55189514,47.17054367,8053.9 -120.54261779,47.17048263,8228.7 -120.53153228,47.17144012,8446.8 -120.51983642,47.17293548,8643.0 -120.50776672,47.17504501,8855.5 -120.49460601,47.17723464,9091.6 -120.48130798,47.17971801,9295.5 -120.46775817,47.18044281,9497.0 -120.45413208,47.18113327,9687.5 -120.44124603,47.18160247,9873.7375 -120.42416381,47.18153381,10062.9 -120.40986633,47.18164825,10239.9 -120.39606475,47.18157958,10437.3 -120.38153839,47.18179321,10630.324444444444 -120.36707305,47.18187713,10837.4 -120.35285186,47.1831665,11037.9 -120.33837127,47.1843872,11222.3 -120.32254791,47.18563079,11404.547826086957 -120.30448913,47.18679046,11583.8 -120.28617858,47.18763732,11790.6 -120.26855468,47.18792724,11967.4 -120.25176239,47.18803024,12164.2 -120.2342987,47.18892669,12359.0 -120.21814727,47.19179534,12572.5 -120.20088958,47.19545745,12763.1 -120.18065643,47.19947052,12945.7 -120.15800476,47.20200347,13161.1 -120.139122,47.20278167,13359.1 -120.12239074,47.20547866,13582.2 -120.10591125,47.2087059,13786.2 -120.08994293,47.21302413,13979.371428571429 -120.07112884,47.21565628,14174.8 -120.05010223,47.21619796,14382.5 -120.03240966,47.21527481,14600.6 -120.01869201,47.21456909,14814.03953488372 -120.00527954,47.21489334,15019.7 -119.99079895,47.21556472,15212.9 -119.97610473,47.21562576,15417.0 -119.96601104,47.21514892,15660.585714285711 -119.95219421,47.21404647,15883.1 -119.94154357,47.21485519,16106.6 -119.93121337,47.2158966,16293.6 -119.9207611,47.21810531,16482.2 -119.90855407,47.21917343,16697.2 -119.89886474,47.21857833,16942.8 -119.88974761,47.21900177,17191.8 -119.8811264,47.21876907,17428.982608695653 -119.87081146,47.21885681,17647.8 -119.85953521,47.21746826,17851.6 -119.84751892,47.21429824,18046.2 -119.83870697,47.2109909,18295.067441860465 -119.83386993,47.21095275,18551.1 -119.83119201,47.21196746,18783.2 -119.82666778,47.21212768,19052.2 -119.82059478,47.21068191,19297.4625 -119.81473541,47.20575714,19523.8 -119.81420135,47.2035675,19872.0 -119.81130981,47.20253372,20103.4 -119.80838012,47.19981002,20346.5 -119.80702209,47.19741439,20594.5 -119.80316925,47.19478607,20856.0 -119.80193328,47.191082,21098.0 -119.80350494,47.18859863,21311.1 -119.80296325,47.18652343,21569.0 -119.80168914,47.18542861,21808.7 -119.80072021,47.1844635,22057.6 -119.79677581,47.18310165,22294.9 -119.79190826,47.17990875,22598.941176470587 -119.79097747,47.17537307,22853.8 -119.7904663,47.17280197,23110.3 -119.78870391,47.1704483,23365.2 -119.78942108,47.16698837,23678.525806451613 -119.78611755,47.16457366,23936.9 -119.78442382,47.16107559,24186.2 -119.78666687,47.15898895,24441.7 -119.78749084,47.16064071,24703.0 -119.78562164,47.16139221,24960.1 -119.78327941,47.16446304,25216.1 -119.77870178,47.16534805,25462.95609756097 -119.77244567,47.16245269,25716.4 -119.77171325,47.15977859,25967.9 -119.77111816,47.15956878,26229.7 -119.77124023,47.1598587,26488.19090909091 -119.77052307,47.15893936,26756.2 -119.77096557,47.15899658,27018.3 -119.77088928,47.16006851,27283.455 -119.76984405,47.16160583,27549.2 -119.76616668,47.1619606,27806.0 -119.76244354,47.16069793,28066.3 -119.76143646,47.15977478,28335.17837837838 -119.75930023,47.159729,28596.2 -119.75630187,47.16067123,28845.2 -119.75385284,47.15946197,29092.7 -119.75281524,47.15546798,29342.7 -119.75404357,47.15440368,29587.7 -119.75501251,47.15560913,29822.1 -119.7562561,47.1553421,30049.42857142857 -119.75728607,47.15431213,30287.6 -119.75569915,47.15465164,30523.9 -119.75302124,47.15610504,30749.2 -119.75054931,47.15572738,30962.155 -119.7498703,47.1534729,31176.3 -119.75042724,47.15145492,31395.6 -119.75190734,47.1504631,31613.1 -119.75309753,47.1502037,31817.075675675675 -119.75354003,47.15309906,32026.5 -119.75350189,47.15711593,32229.7 -119.75118255,47.15926742,32444.5 -119.74861907,47.16065979,32657.8 -119.7458496,47.16173171,32851.2 -119.74409484,47.16135787,33016.4 -119.74227142,47.16144943,33180.8 -119.73912048,47.16251373,33362.1 -119.73710632,47.16398239,32854.9 -119.73628234,47.16444396,29187.3 -119.73351287,47.16289138,26401.727272727272 -119.73047637,47.16257476,24078.4 -119.7289505,47.15934753,22116.4 -119.72675323,47.15730667,20436.4 -119.72412872,47.15536499,18956.68235294117 -119.71647644,47.15434265,17592.0 -119.70715332,47.15422058,16322.0 -119.69509124,47.15814971,15574.4 -119.68045043,47.15546798,14328.5 -119.66257476,47.1580162,13387.0 -119.6435852,47.16089248,12483.2 -119.62641143,47.16376876,11740.7 -119.61036682,47.16502761,11021.8 -119.59361267,47.16723632,10309.6 -119.57862091,47.16825103,9713.9 -119.56510925,47.16960144,9046.3 -119.55295562,47.17058563,8451.4 -119.54309082,47.17126464,7857.7 -119.53360748,47.17164611,7326.8 -119.52558135,47.17301177,6805.646874999999 -119.51774597,47.17409896,6294.2 -119.51052093,47.17494201,5788.2 -119.5033493,47.17636489,5259.8 -119.49451446,47.17691802,4820.254545454545 -119.48447418,47.17835235,4376.6 -119.47663879,47.1796379,3947.3 -119.47010803,47.18032073,3528.5 -119.46520233,47.18151473,3108.1 -119.4606781,47.18268966,2693.1 -119.45692443,47.18347167,2320.2 -119.45394134,47.18395996,1965.158536585366 -119.44699859,47.18545913,1593.6 -119.44029998,47.18672561,1194.0 -119.43817138,47.18702316,846.2 -119.43830108,47.18774795,543.06 -119.43823242,47.18886184,342.9</coordinates>
</LineString>
</Placemark>
</Document>
</kml>