3636import json
3737#import time
3838#import datetime
39- import math
39+ # import math
4040import csv
4141from socket import *
4242import pprint
@@ -117,7 +117,7 @@ def matchAB5SSRecords(jWSPRRec1, jWSPRRec2):
117117#
118118# Sat status -
119119#
120- def decodeRecords (Packet1 , Packet2 ):
120+ def decodeAB5SS (Packet1 , Packet2 ):
121121 # use both packets to decode telemetry data
122122 PowerTable = {
123123 0 : {'alt1' : 0 , 'alt2' : 0 },
@@ -363,15 +363,15 @@ def getAB5SS(bCfg, last_date):
363363 jDecodedData = {}
364364 jUploadData = []
365365 for i in range (0 , len (aMatch ), 2 ):
366- jDecodedData [i ] = decodeRecords (aMatch [i ], aMatch [i + 1 ])
366+ jDecodedData [i ] = decodeAB5SS (aMatch [i ], aMatch [i + 1 ])
367367
368368 # reformat time from WSPR format to Zulu
369369 datetime1 = reformatDateTime (aMatch [i ]['time' ], 0 )
370370 datetime2 = reformatDateTime (aMatch [i ]['time' ], 10 )
371371
372372 # add telemetry data
373373 # build strComment channel, Sats?, voltage?, alt(m), 0C?, grid, callsign2, callsign1, comment
374- strComment = str (jDecodedData [i ]['channel' ]) + " Sats " + jDecodedData [i ]['sats' ] + " (voltage) " + str (jDecodedData [i ]['altitude' ]) + "m "
374+ strComment = str (jDecodedData [i ]['channel' ]) + " Sats " + jDecodedData [i ]['sats' ] + str (jDecodedData [i ]['altitude' ]) + "m "
375375 strComment += str (jDecodedData [i ]['temp' ]) + "C " + jDecodedData [i ]['grid' ] + " " + jDecodedData [i ]['callsign2' ] + " " + jDecodedData [i ]['callsign1' ] + " " + bCfg ['comment' ]
376376
377377 # put data into jUploadData format for uploading
@@ -387,7 +387,6 @@ def getAB5SS(bCfg, last_date):
387387 logging .info (f" Number of records ready for upload = { len (jUploadData )} " )
388388
389389 # create data file for John
390- # !!!!!!!!!!!!!!!!!!!!!!!!!
391390 if bCfg ['telemetryfile' ] == 'Y' :
392391 pprint .pp (jDecodedData , indent = 2 )
393392 outputFilename = BalloonCallsign + ".csv"
@@ -398,44 +397,3 @@ def getAB5SS(bCfg, last_date):
398397 csv_file .writerow (jDecodedData [item ].values ())
399398
400399 return 1 , jUploadData , aMatch [i ]['time' ]
401-
402-
403- """
404- Iterating Through a Nested Dictionary
405- people = {1: {'Name': 'John', 'Age': '27', 'Sex': 'Male'},
406- 2: {'Name': 'Marie', 'Age': '22', 'Sex': 'Female'}}
407-
408- for p_id, p_info in people.items():
409- print("\n Person ID:", p_id)
410-
411- for key in p_info:
412- print(key + ':', p_info[key])
413-
414- #--------------------------------------------------------------------------------------------------------------#
415- def delDupRecords(jData):
416- # remove duplicae records in JSON structure
417- jTemp = {}
418- for i in range(len(jData)):
419- result = next((item for item in jTemp if item["tx_band"] == jData[i]["band"] and item["tx_loc"] == jData[i]["tx_loc"]), None)
420- if result == None:
421- jTemp.append(jData[i])
422-
423- print(f"Lenght of jTemp = {len(jTemp)}")
424- return jTemp
425-
426- #--------------------------------------------------------------------------------------------------------------#
427-
428- names = ['Bruce', 'Clark', 'Peter']
429- heros = ['Batman', 'Superman', 'Spiderman']
430- my_dict = {}
431- for name, value in zip(names, heros):
432- mydict[name] = value
433- print mydict
434-
435- OR
436-
437- my_dict = {name: hero for name, hero in zip(names, heros)}
438- my_dict = {name: hero for name, hero in zip(names, heros) if name != 'Peter'}
439- print my_dict
440-
441- """
0 commit comments