From 4ec965718d2ac646cd275297327c23e60499e236 Mon Sep 17 00:00:00 2001 From: St33v Date: Sun, 1 Mar 2020 17:19:31 +1100 Subject: Remove initial sketchy attempts (pre dataframe) --- getPlanes.py | 72 ++++++++++++------------------------------------------------ 1 file changed, 14 insertions(+), 58 deletions(-) (limited to 'getPlanes.py') 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))) -- cgit v1.3