import numpy as np import pandas as pd import matplotlib.pyplot as plt import matplotlib import random import pickle import matplotlib.dates as mdates from matplotlib.ticker import LinearLocator import datetime fn = "ATL_schedule_GA_blockGroup_commuter_13_$20.0_0.0.csv" data = pd.read_csv(fn) start = "homeVertIdx" end = "workVertIdx" t1 = "departureFromHomeVert" t2 = "departureFromWorkVert" n = len(data[start]) random.seed(1) s = random.sample(range(n), n-10) s = range(n) starts = data[start][s].values ends = data[end][s].values t1s = data[t1][s].values t2s = data[t2][s].values A = np.zeros((13, 13)) for i in range(len(s)): m = [t1s[i], starts[i], ends[i]] m = [t2s[i], ends[i], starts[i]] A[starts[i], ends[i]] += 1 A[ends[i], starts[i]] += 1 A = A / A.sum() * 2*len(s) print(A.sum()) SMALL_SIZE = 8 MEDIUM_SIZE = 10 BIGGER_SIZE = 12 plt.rc('font', size=MEDIUM_SIZE) # controls default text sizes plt.rc('axes', titlesize=MEDIUM_SIZE) # fontsize of the axes title plt.rc('axes', labelsize=BIGGER_SIZE) # fontsize of the x and y labels plt.rc('xtick', labelsize=MEDIUM_SIZE) # fontsize of the tick labels plt.rc('ytick', labelsize=MEDIUM_SIZE) # fontsize of the tick labels plt.rc('legend', fontsize=MEDIUM_SIZE) # legend fontsize plt.rc('figure', titlesize=BIGGER_SIZE) # fontsize of the figure title plt.imshow(A, cmap = "Greens") for edge, spine in plt.gca().spines.items(): spine.set_visible(False) ax = plt.gca() ax.set_xticks(np.arange(A.shape[1]+1)-.5, minor=True) ax.set_yticks(np.arange(A.shape[0]+1)-.5, minor=True) plt.xticks(range(13)) plt.yticks(range(13)) ax.grid(which="minor", color="w", linestyle='-', linewidth=3) ax.tick_params(which="minor", bottom=False, left=False) plt.colorbar(label="Number of flights") plt.xlabel("Vertiport number") plt.ylabel("Vertiport number") plt.gcf().savefig('paper_ports_hist.pdf', dpi=150) plt.figure() _times = np.concatenate((t1s, t2s)) times = [] ts = datetime.datetime(2022, 1, 1, 0, 0) for t in _times: t2 = ts + datetime.timedelta(hours = int(t)) + datetime.timedelta(minutes=60*(t - int(t))) times.append(t2) plt.hist(times, bins=100, facecolor='green', alpha=0.75, edgecolor='black', linewidth=0.05) plt.xlabel("Time of day") plt.ylabel("Number of flights") myFmt = mdates.DateFormatter('%H:%M') plt.gca().xaxis.set_major_formatter(myFmt) plt.gcf().autofmt_xdate() ticks = [ts + datetime.timedelta(hours=2*i) for i in range(13)] plt.gca().set_xticks(ticks, minor=False) plt.xlim(ts,ts + datetime.timedelta(hours=24)) plt.gcf().savefig('paper_times_hist.pdf', dpi=150) plt.figure() B = A.sum(axis=0) plt.bar(range(13), B, facecolor='teal', alpha=0.75) plt.gca().set_xticks(range(13), minor=False) plt.xlabel("Vertiport number") plt.ylabel("Number of flights") plt.gcf().savefig('paper_ports2_hist.pdf', dpi=150)