Skip to content

Commit 052ec24

Browse files
isolate freefall model to its own file
1 parent 7c24b99 commit 052ec24

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

packetraven/model.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import numpy
2+
3+
# `dh/dt` based on historical flight data
4+
DESCENT_RATE = lambda altitude: -5.8e-08 * altitude ** 2 - 6.001
5+
6+
# integration of `(1/(dh/dt)) dh` based on historical flight data
7+
# TODO make this model better via ML
8+
SECONDS_TO_GROUND = lambda altitude: 1695.02 * numpy.arctan(9.8311e-5 * altitude)

packetraven/tracks.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import numpy
66
from pyproj import CRS
77

8+
from .model import SECONDS_TO_GROUND
89
from .packets import APRSPacket, DEFAULT_CRS, LocationPacket
910
from .structures import DoublyLinkedList
1011

@@ -22,9 +23,13 @@ def __init__(self, name: str, packets: [LocationPacket] = None, crs: CRS = None)
2223
"""
2324

2425
self.name = name
25-
self.packets = DoublyLinkedList(packets)
26+
self.packets = DoublyLinkedList(None)
2627
self.crs = crs if crs is not None else DEFAULT_CRS
2728

29+
if packets is not None:
30+
for packet in packets:
31+
self.append(packet)
32+
2833
def append(self, packet: LocationPacket):
2934
if packet not in self.packets:
3035
if packet.crs != self.crs:
@@ -161,17 +166,9 @@ def __init__(self, name: str, packets: [LocationPacket] = None, crs: CRS = None)
161166

162167
@property
163168
def time_to_ground(self) -> timedelta:
164-
165169
if self.has_burst:
166170
# TODO implement landing location as the intersection of the predicted descent track with a local DEM
167-
168-
# dh/dt, with a coefficient determined manually from historical flight data
169-
# descent_rate = lambda altitude: -5.8e-08 * altitude ** 2 - 6.001
170-
171-
# integration of (1/(dh/dt))dh
172-
seconds_to_ground = lambda altitude: 1695.02 * numpy.arctan(9.8311e-5 * altitude)
173-
174-
return timedelta(seconds=seconds_to_ground(self.altitudes[-1]))
171+
return timedelta(seconds=SECONDS_TO_GROUND(self.altitudes[-1]))
175172
else:
176173
return timedelta(seconds=-1)
177174

0 commit comments

Comments
 (0)