analyzed[f.icao][2]=f.departure.time if f.arrival.time > analyzed[f.icao][3]: analyzed[f.icao][3]=f.arrival.time for icao in analyzed: print(icao+" : "+str(analyzed[icao][0])+" "+str(analyzed[icao][1])+str(analyzed[icao][2])+" "+str(analyzed[icao][3])) if __name__ == '__main__': #print(icaos_monthly_frequency()) #frequent_callsigns={'N961CC', 'N27XD', 'N3990A', 'N9641F', 'N3927R', 'N6026L', 'N51ED', 'N50EA', 'N155SH', 'N4195W', 'N95173', 'N469TS', 'N5918Q', 'N5058U', 'N227WA', 'N3933A', 'N45MM', 'N709SD', 'N9150M', 'N2334K', 'N9151H', 'N9113K', 'N1347B', 'N34164', 'N745TB', 'N52FW', 'N5161U', 'N192WW', 'N78708', 'N461SA', 'N1198Q', 'N3594F', 'N618LG', 'N3797W', 'N901ST'} frequent_icaos={'aaad00', 'ad6d83', 'a1fcf7', 'ad3bc7', 'a05121', 'a80d77', 'ac9d2d', 'acabc1', 'a570e2', 'a65006', 'a67a47', 'a7d1e2', 'a59ee3', 'aa06c8', 'a2a634', 'a48d94', 'a21693', 'a5bcc4', 'a3c44c', 'a171a2', 'a65f7e', 'a40926', 'a97791', 'a4a691', 'a08d5c', 'ac7485', 'a637fc', 'acaba2', 'a0de5a', 'a7a49d', 'a68727', 'a4589c', 'a4f8ab', 'a490b0', 'a796ad', 'a4f0cc'} #query_opensky(frequent_icaos) #flights=flightsFromFile('../data/ffl321/dec_flights.json') #flights.extend(flightsFromFile('../data/ffl321/jan_flights.json')) #filtered=filterFlights(flights) #filtered.to_file('../data/ffl321/filtered_dec-jan_flights.json') flights=flightsFromFile('../data/ffl321/filtered_dec-jan_flights.json') analyzeFlights(flights) # files[1] # multiple flights >5 # get icaos # get all flights """ oct2019 = {('N709SD', 14), ('N4195W', 17), ('N227WA', 13), ('N3990A', 28), ('N5161U', 78), ('N5058U', 96), ('N5918Q', 15), ('N155SH', 41), ('N3933A', 32), ('N52FW', 11), ('N9113K', 12), ('N3797W', 22), ('N3927R', 78), ('N9150M', 68), ('N961CC', 16), ('N45MM', 11), ('N34164', 16), ('N95173', 16)} nov2019 = {('N192WW', 48), ('N3927R', 71), ('N95173', 16), ('N5058U', 97), ('N3933A', 35), ('N1347B', 13), ('N155SH', 28), ('N5161U', 100), ('N1198Q', 12), ('N745TB', 15), ('N4195W', 15), ('N469TS', 16), ('N461SA', 11), ('N901ST', 13), ('N9150M', 37)} dec2019 = {('N95173', 13), ('N3990A', 19), ('N3927R', 43), ('N5058U', 87), ('N78708', 12), ('N34164', 11), ('N9150M', 53), ('N4195W', 12), ('N155SH', 26), ('N9151H', 68)} jan2020 = {('N3927R', 71), ('N3990A', 50), ('N51ED', 12), ('N155SH', 37), ('N50EA', 26), ('N2334K', 21), ('N745TB', 14), ('N5058U', 88), ('N27XD', 11), ('N5161U', 45), ('N3594F', 15), ('N52FW', 11), ('N9150M', 38), ('N618LG', 13), ('N95173', 15), ('N4195W', 23), ('N9151H', 76), ('N34164', 11), ('N6026L', 13), ('N9641F', 36)} """
from flights import flightsFromFile from datetime import datetime icaos = [ 'a4e931', 'a4e94e', 'a4e954', 'a4e970', 'a4ed4f', 'a4ede7', 'a4f0af', 'a4f0cc', 'a4f131', 'a4f4ad', 'a4f4e3', 'a4f4f6', 'a4f86a', 'a4f8a7', 'a4f8c4', 'a4fe94', 'a4ff46' ] allFlights = flightsFromFile('../data/flight_lists/2019-06_2020-04.json') airports = set() for f in allFlights.elements: if f.departure.time < datetime.strptime('2020-01-01', '%Y-%m-%d'): continue if f.icao in icaos and 'FFL' in f.callsign: airports.add(f.departure.airport) airports.add(f.arrival.airport) print(airports) print(len(airports))
from os.path import isfile, join months = ['oct02-31', 'november_test', 'december01-30_test', 'dec31-jan01_test', 'january02-31_test', 'feb_test', 'march01-30'] def correct_airports(flights): for f in flights: pass for month in months: mypath = '../data/'+month+"/" onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f)) and f.split('.')[1]=='json'] for file in onlyfiles: fullpath = mypath+file flights = flightsFromFile(fullpath) for f in flights.elements: if f.departure.airport is not None and f.departure.airport_position is None: ap = airports[f.departure.airport] if ap is not None: f.departure.airport_position=Position(altitude=ap.altitude,latitude=ap.latitude,longitude=ap.longitude) else: print(f.departure.airport) if f.arrival.airport is not None and f.arrival.airport_position is None: ap = airports[f.arrival.airport] if ap is not None: f.arrival.airport_position=Position(altitude=ap.altitude,latitude=ap.latitude,longitude=ap.longitude) else: print(f.arrival.airport) flights.to_file(fullpath)