Jump to content
The simFlight Network Forums

bingus

new Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by bingus

  1. This is awesome! I don't personally write in Rust or C/C++, so I also worked out a (fairly inelegant) solution in Python with Pandas dataframes and NumPy inspired by your Rust solution. Some caveats: I added headers to each schedule file manually, so if you want to run the code yourself you have to copy and paste the header line into the text file and save as a csv. The header line is: DEP,ARR,AIR,X,N,TIME,LOL,IDK,CALL You would need to put in your proper file path for each airfield. I really like the elegance of putting multiple airports in the Rust code and I'm thinking of adding that later to this Python code. This also means you have to be aware of the difference between ICAO and 3-letter code (eg, EDDM = MUC). Later I intend to add graphing support from MatPlotLib, to visualize frequencies across airfields. If you don't want to spend the time to compile and run this yourself or if you don't have Python or Rust on your machine, I've also attached each text document with arrival and departure frequency by hour for every airport below except JFK. I haven't quite worked out why, I'm assuming something with the way the JFK data is formatted but the text file turns out wrong each time I run it on the JFK schedule. Some possible uses: Like me, a gamer who just wants to play busy times for a more engaged experience. If you develop schedules, particularly busy schedules, a quick way to see when your busy times are without playtesting right away. import pandas as pd import numpy as np import matplotlib.pyplot as plt print('Hewwo!') #Reads schedule CSV into Pandas Dataframe, insert your chosen file path. df = pd.read_csv(r'''YOUR PATH HERE''') #Loads second clean Dataframe for later determination of arrival or departure. df2 = pd.DataFrame(columns = ['ARR','TIME','DEP','DEPTIME','ARRORDEPART'],index = df.index) df2['ARR']=df['ARR'] df2['DEP']=df['DEP'] #For loop to make all arrival time strings into just the first two digits, indicating hour of the 24 hour clock. EG, 11:24 -> 11, 21:31 -> 21. i = 0 for i in range(0,len(df2)): placeholder = df.TIME[i] placeholder2 = placeholder[:-3] df2.TIME[i] = placeholder2 i+1 #For loop to make all departure time strings into just the first two digits, indicating hour of the 24 hour clock. EG, 11:24 -> 11, 21:31 -> 21. j = 0 for j in range(0,len(df2)): placeholder = df.LOL[j] placeholder2 = placeholder[:-3] df2.DEPTIME[j] = placeholder2 j+1 #Nifty trick with Pandas and Numpy to find and assign arrival or departure values based on the Arrivals column in the second dataframe. Definitely #look up a good Stackoverflow if you're curious how this works, I'm still getting the hang of it myself after trying to write a lot of different more #standrad loops before this. NOTE: YOU NEED THE SPACE BEFORE THE AIRPORT CODE BASED ON HOW I PERSONALLY SET UP THIS DATAFRAME. I will likely fix this later. df2.ARRORDEPART = np.where(df2['ARR']==' 3 DIGIT AIRPORT CODE EG JFK or MUC','Arrive','Depart') #Actually builds out the text files provided. In lines 41 and 43, only standard print functions. In 42 and 44, group by functions to first select what we're counting, #then group by all the possible hours for arrivals and departures, based on the dataframe. print("Arrival Count:", file = open(r'''YOUR PATH HERE\0YOURCITY.txt''',"a")) print(df2[df2['ARRORDEPART'] == 'Arrive'].groupby('TIME')['ARRORDEPART'].count(), file = open(r'''YOUR PATH HERE\0YOURCITY.txt''',"a")) print("Departure Count:", file = open(r'''YOUR PATH HERE\0YOURCITY.txt''',"a")) print(df2[df2['ARRORDEPART'] == 'Depart'].groupby('DEPTIME')['ARRORDEPART'].count(), file = open(r'''YOUR PATH HERE\0YOURCITY.txt''',"a")) print("Goodbye!") #At some point, I also intend to explore graphing these sets with Matplotlib, and writing a file chooser so you don't have to manually enter your desired #airport info. 0atlanta.txt 0barcelona.txt 0boston.txt 0lasvegas.txt 0londongatwick.txt 0losangeles.txt 0memphis.txt 0munich.txt 0newyorklaguardia.txt 0orlando.txt 0philadelphia.txt 0phoenix.txt 0sandiego.txt 0sanfrancisco.txt 0stthomas.txt 0stuttgart.txt 0vancouver.txt
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.