def main(): print("============================================================================================") print("= Welcome to the London Underground System, please follow the instuctions on the screen =") print("============================================================================================") #This need some validation to make sure no bad input is done start = str(input("Please enter your starting station :")) end = str(input("Please enter the ending station :")) print(" Please wait while we calculate the how much this would cost...") print("") print("____________________________________________________________________________________________") print("") try: fares(start,end) except: print("Sorry we have hit a speed bump on the change machine, please try that again later.") print("") print("____________________________________________________________________________________________") print("") print(" Please wait while we now draw you the map of the London UnderGround with your route...") draw_map(start, end)
def plot_potential(grid, name): #Variables for plotting purposes longitude = np.arange(0, 361) latitude = np.arange(60, 90) LONGITUDE , LATITUDE = np.meshgrid(longitude, latitude) #Plotting a contour plot of the electrostatic potential pl.figure() contourPlot = pl.contourf(LONGITUDE,LATITUDE,grid) pl.title('Electrostatic potential in the higher latitudes') cbar = pl.colorbar(contourPlot) pl.xlabel('Longitude $ [ ^\circ] $') pl.ylabel('Latitude $ [ ^\circ] $') # print np.max(grid) # print np.min(grid) #Hardcoded the labels # cbar_labels = np.arange(-24 , 32 + 1, 24-16) # cbar.ax.set_yticklabels(cbar_labels) cbar.set_label(' $\Phi$ [kV]')#, rotation = 0) pl.savefig(name) #Drawing on a orthogonal projection of the north pole instead fig = plt.figure() my_map = draw_map() plt.savefig('empty_map') X, Y = my_map(LONGITUDE, LATITUDE) contour = my_map.contourf(X, Y , grid) pl.title('Electrostatic Potential') cbar = pl.colorbar(contour, orientation='vertical') cbar.set_label(' $\Phi$ [V]')#, rotation = 0) pl.savefig('map_' + name) #Plotting it on as a stereographic projection fig = plt.figure() X = (90 - LATITUDE)*np.sin(np.deg2rad(LONGITUDE)) Y = (90 - LATITUDE)*np.cos(np.deg2rad(LONGITUDE)) contour = pl.contourf(X,Y,grid) cbar = pl.colorbar(contour, orientation='vertical') cbar.set_label(' $\Phi$ [V]')#, rotation = 0) pl.title('Electrostatic Potential') plt.savefig('other_proj.eps') pl.show()
def plot_FACs(FACs): x = np.arange(0, 361) y = np.arange(60, 90) X, Y = np.meshgrid(x,y) #Since we the derivatives at the edges hasn't been done properly #we'll just shave them of the representation FACs[:, 0:2] = 0 FACs[:, -2:] = 0 FACs[0:2, :] = 0 FACs[-2:, :] = 0 print "Hello" print x.shape print FACs.shape # plt.figure() # contourPlot = pl.contourf(x,y,FACs) # # plt.title('Field Aligned Currents') # cbar = pl.colorbar(contourPlot) # plt.xlabel('Longitude $ [ ^\circ] $') # plt.ylabel('Latitude $ [ ^\circ] $') # cbar.set_label('$ms^{-1}$') # plt.savefig('facs.eps') #Let us also draw the currents on a map fig = plt.figure() my_map = draw_map() longitude, latitude = my_map(X, Y) contour = my_map.contourf(longitude, latitude, FACs) # my_map.quiver(longitude[:,::skipArrows],latitude[:,::skipArrows], FACs[:,::skipArrows], FACs[:,::skipArrows], angles = 'uv', scale = 40) cbar = plt.colorbar(contour) cbar.set_label('m/s') plt.savefig('field_aligned_currents.eps') return
if __name__ == "__main__": dir_name = os.getcwd() for filename in os.listdir(os.path.join(dir_name + '/boards/')): # Initiate grid filepath = dir_name + '/boards/' + filename grid = Grid(filepath) # Find path with additional info bfs = False dijkstra = False path, open_list, closed_list = find_path(grid, bfs=bfs, dijkstra=dijkstra) # Print the map including best path to console print_map(grid, path) # Draw the board to png-file, requires PIL. if bfs: new_file = dir_name + "/pictures/" + filename.replace( '.txt', '-bfs.png') elif dijkstra: new_file = dir_name + "/pictures/" + filename.replace( '.txt', '-dijkstra.png') else: new_file = dir_name + "/pictures/" + filename.replace( '.txt', '.png') draw_map(grid, new_file, path, open_list, closed_list)
print if __name__ == "__main__": dir_name = os.getcwd() for filename in os.listdir(os.path.join(dir_name + '/boards/')): # Initiate grid filepath = dir_name + '/boards/' + filename grid = Grid(filepath) # Find path with additional info bfs = False dijkstra = False path, open_list, closed_list = find_path(grid, bfs=bfs, dijkstra=dijkstra) # Print the map including best path to console print_map(grid, path) # Draw the board to png-file, requires PIL. if bfs: new_file = dir_name + "/pictures/" + filename.replace('.txt', '-bfs.png') elif dijkstra: new_file = dir_name + "/pictures/" + filename.replace('.txt', '-dijkstra.png') else: new_file = dir_name + "/pictures/" + filename.replace('.txt', '.png') draw_map(grid, new_file, path, open_list, closed_list)
def main(): """ This function is written by Sai... The main function brings all of the other function together. """ print("============================================================================================") print("= Welcome to the London Underground System, please follow the instuctions on the screen =") print("============================================================================================") double_check = False #This need some validation to make sure no bad input is done while double_check == False: check = False start = "" end = "" while check == False: start = str(input("Please enter your starting station :")) check, Dic = read_stations(start) if check == False: print("Sorry the station that you want to start from does not exist.") check = False while check == False: end = str(input("Please enter the ending station :")) check, Dic = read_stations(end) if check == False: print("Sorry the station that you want to go to does not exist.") print(start, end) if start != end: break else: print("You have entered the same station names, please choose different stations... ") #print("Please make sure your spelling is correct, and you are including Capital Letters...") print("____________________________________________________________________________________________") print("") print(" Please wait while we calculate the how much this would cost...") print("") print("") try: fares(start,end) except: print("Sorry we have hit a speed bump on the change machine, please try that again later.") print("") print("____________________________________________________________________________________________") print("") print(" Please wait while we now draw you the map of the London UnderGround with your route...") print("") try: draw_map(start,end) except: print("") print("Sorry we have hit a speed bump on the map drawing, please try that again later.") print("") print("____________________________________________________________________________________________") print("")