def delayplotter(aircrafttype, ATA, begin,end,interval):                        # interval in months
    k = core.unpickle("./Data.txt")  
    k = core.getbyType(k,aircrafttype)                                          #getting the data ready
    k = core.sortata(k, 2)
    delay, date = core.getdelaylist([begin,end],interval,k)
    
    newdate = []
    newdelay = []
    years = []
    final = []
    mini = []
    maxi = []
    
    for i in range(len(delay)):
        for j in range(len(delay[i])):
            for l in range(len(ATA)):
                if delay[i][j][0] == ATA[l]:
                    newdate.append(date[i])
                    newdelay.append(delay[i][j])
                    
    for x in range(len(newdate)):
        year = newdate[x]
        year = year[-4:]
        years.append(year)
        
        average = round(float(newdelay[x][1])/float(newdelay[x][2]),2)
        minimum = min(newdelay[x][5])
        maximum = max(newdelay[x][5])
        newdelay[x].append(average)
        newdelay[x].append(minimum)
        newdelay[x].append(maximum)
       # print newdelay[x]
                             
  # now we create a list with [ata, total delay, delay freq., average delay, min delay, max delay]
        del newdelay[x][3] 
        del newdelay[x][3] 
        del newdelay[x][3]
   # print newdelay
        
    for z in range(len(newdate)):
        final.append(newdelay[z][3])
        mini.append(newdelay[z][4])
        maxi.append(newdelay[z][5])
            
   # print final            
    final = np.array(final)
    mini = np.array(mini)
    maxi = np.array(maxi)
        
    return years,final,mini,maxi
Esempio n. 2
0
def graphthis(year, ata, actype, data):
    k = core.getbyType(data, actype)
    canc_freq = []
    labels = []

    for m in range(len(ata)):
        canc_freq.append([0])

    print canc_freq, "initial"
    yearlst = []
    no_of_yrs = year[1] - year[0] + 1

    for p in range(no_of_yrs):
        yearlst.append(int(year[0] + p))

    for i in range(len(ata)):
        int_canc_freq = []
        labels.append(ata[i])

        delay, date = core.getdelaylist([year[0], year[1]], 12, k)

        for j in range(no_of_yrs):
            #if j not in yearlst:
            #    yearlst.append(year[0]+j)

            for n in range(len(delay[j])):
                if delay[j][n][0] == ata[i]:
                    int_canc_freq.append(delay[j][n][3])
            print int_canc_freq, "intermediate, per ata"
        canc_freq[i] = int_canc_freq
    """
        plt.xlabel('Year')
        plt.ylabel('Cancellation Frequency')
        plt.plot(yearlst, canc_freq[i])
        plt.legend()
        plt.show()"""
    print canc_freq, "cancel frequency"
    print yearlst, "yearlist"

    plt.xlabel('Year')
    plt.ylabel('Cancellation Frequency')
    for q, label in zip(range(len(ata)), labels):
        plt.plot(yearlst, canc_freq[q], marker='o', label=label)
        plt.xticks(yearlst)
    plt.legend()
    plt.savefig('Results/hopefullyitworks.png', dpi=200)
    plt.show()
# -*- coding: utf-8 -*-
"""
Created on Thu May 24 09:48:10 2018

@author: Laurens
"""
import lib.core as core

k = core.unpickle("./Data.txt")  #getting the data ready
k = core.sortata(k, 4)
delay, date = core.getdelaylist([1988, 2015], 36,
                                k)  #getting the data ready till here
output = core.ThreeDgraph(delay, 3, 0)
Created on Mon Apr 23 14:17:44 2018

@author: Laurens
"""

#Tijd tot failure
#Verwachte delay
#Kans cancellation als het faalt
#per aircraft values
import matplotlib.pyplot as plt
import lib.core as core

interval = 36
k = core.unpickle("./Data.txt")  #getting the data ready
k = core.sortata(k, 3)
final, date = core.getdelaylist([1988, 2015], interval, k)

final_delay = []
final_rel_year = []
final_rel_allyears = []
temp_rel = []
temp2_rel = []
final2_rel_allyears = []
#----------------------------------------------------------------------------------------actual program starts
for i in range(len(final)):  #relation loop
    for j in range(len(final[i])):
        if final[i][j][2] != 0:
            a = int(
                round(float((float(interval) / 12) * 365 / final[i][j][2]),
                      0))  #amount of days average delay
            b = round(float(final[i][j][1]) / final[i][j][2],
Esempio n. 5
0
    for atalevel in range(2, 5):
        for beginyear in [1988, 2011, 2014]:
            for actype in range(1, 4):
                for interval in [3, 6, 12, 36]:

                    newl = []
                    intl = []
                    if actype == 3 and beginyear < 1995:
                        beginyear = 1995
                    if (beginyear == 1988 or
                        (actype == 3 and beginyear == 1995)) and interval <= 6:
                        continue

                    a = core.getbyType(k, actype)
                    a = core.sortata(a, atalevel)
                    final, datelist = core.getdelaylist([beginyear, 2015],
                                                        interval, a)

                    for w in range(len(final)):
                        for l in range(10):
                            #print w, k
                            intl.append(final[w][l][0])
                            intl.append(l + 1)
                            intl.append(datelist[w])
                            newl.append(intl)
                            intl = []

                    filename = "DelayTop%d_ata%d_ac%d_%d-2015_interv%d" % (
                        top, atalevel, actype, beginyear, interval)
                    with open(os.path.join('Top10csv', filename + '.csv'),
                              'wb') as myfile:
                        wr = csv.writer(myfile, quoting=csv.QUOTE_ALL)
Esempio n. 6
0
actype = 1
atalevel = 2
interval = 36

with open("./Data.txt", "rb") as fp:   # Unpickling list all types
   b = pickle.load(fp)

a = copy.deepcopy(b)
a = core.getbyType(a, actype)
a = core.sortata(a, atalevel)

# importing the final top 10 lists
# from DelayTop10 import getdelaylist
# arguments are the atalevel, year range and interval in months. More are possible, check the function
final_delay, datelist = core.getdelaylist(timeframe = [1988,2015], interval = 28*12, k = a) # 28*12 are the months included on the total year range


delaycutoff = 15 # min aatime to actually consider something a delay
#binsize = 5 # unused at the moment, was used for debugging

#actype = 1 # all this was used for debugging
#atalevel = 3 # 2 means chapter. higher number means more detailed ata level
#atatest = 52
#timeframe = [2011,2012]
#c = core.getbyType(b,actype) # filter by type
#c = core.getbyDate(c, timeframe)
#c = core.getbyCancelled(c, 0)


### Section on fitting stuff to the delay time distributions