summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgetPlanes.py72
1 files changed, 14 insertions, 58 deletions
diff --git a/getPlanes.py b/getPlanes.py
index 8adf264..54a8939 100755
--- a/getPlanes.py
+++ b/getPlanes.py
@@ -12,13 +12,14 @@ import statistics as stat
import pandas as pd
import datetime as dt
-
-epoch = dt.datetime.utcfromtimestamp(0)
-
-def unixSecs(myTime):
- return (myTime - epoch).total_seconds()
+# epoch = dt.datetime.utcfromtimestamp(0)
+#def unixSecs(myTime):
+# return (myTime - epoch).total_seconds()
def isNum(item):
+ """
+ Not used - exporting data to R
+ """
try:
float(item)
return True
@@ -28,6 +29,7 @@ def isNum(item):
def stats(vals):
"""
Assumes vals is a list of numerics
+ (I ended up not using this function - export data to csv and let R handle it)
"""
rawLen = len(vals)
vals = [x for x in vals if isNum(x)]
@@ -39,69 +41,23 @@ def stats(vals):
median = stat.median(vals)
return {'n':n, 'min':minimum, 'max':maximum, 'mean':mean, 'median':median, 'NaN': nans}
-def makeDict(StateVector):
+def makeListofDicts(StateVector):
"""
- just ge the data back from the complicated object FFS
+ Just get the data back from the complicated object FFS
"""
data = [] # empty list. Each element will be a dict
for plane in StateVector:
- dic = plane.__dict__
- data.append(dic)
+ data.append(plane.__dict__)
return data
-print("dude")
-#api = sky()
planes = sky().get_states().states
-
-flying = [x for x in planes if not x.on_ground]
-
-baroAlt = [x.baro_altitude for x in flying]
-
-geoAlt = [x.geo_altitude for x in flying]
-velocity = [x.velocity for x in flying]
-verticalRate = [x.vertical_rate for x in flying if isNum(x.vertical_rate)]
-ascending = [x for x in verticalRate if x > 0]
-descending = [x for x in verticalRate if x < 0]
-cruising = [x for x in verticalRate if x == 0]
-
-baroAltStats = stats(baroAlt)
-print('Planes: {} Flying {}'.format(len(planes), len(flying)))
-print("baro: ", baroAltStats)
-print("geo Alt: ", stats(geoAlt))
-print('vel: ', stats(velocity))
-print('Ascending: ', stats(ascending))
-print('Descending: ', stats(descending))
-print('Cruising: ', stats(cruising))
-
-
-#print(type(s))
-
-planeDict = makeDict(planes)
-
+planeDict = makeListofDicts(planes)
planeFrame = pd.DataFrame.from_dict(planeDict)
planeFrame['timeStamp'] = "{:%Y%m%dT%H%M}".format(dt.datetime.now())
with open('covidPlanes.csv', 'a') as out:
planeFrame.to_csv(out, mode = 'a', index = False, header = out.tell()==0)
-
-#print(len(s))
-#print(planes.states)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+# Brief info for Journald
+flying = [x for x in planes if not x.on_ground]
+print('Planes: {} Flying: {}'.format(len(planes), len(flying)))