daily pastebin goal
17%
SHARE
TWEET

Untitled

a guest Nov 5th, 2018 113 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def main():
  2.  
  3.     the_dictionary = {}
  4.     new_list = []
  5.     depot_list = []
  6.     dest_id = []
  7.     horiz_dist = []
  8.     bearing = []
  9.     new_dictionary = []
  10.     longitude = []
  11.     latitude = []
  12.     final_list = []
  13.  
  14.     dictionary_list = observatory_read_csv()
  15.     depot_dictionary_list = depot_read_csv()
  16.  
  17.     for line in dictionary_list:
  18.         depot_ID = line[1:]
  19.         if depot_ID[0][0] == "D":
  20.             new_list.append(depot_ID)
  21.  
  22.     new_list.sort()
  23.  
  24.     for line in depot_dictionary_list:
  25.         lat_lon = line[0:][0:]
  26.         depot_list.append(lat_lon)
  27.  
  28.     depot_list.sort()
  29.  
  30.     for line in new_list:
  31.         dest_id.append(line[0])
  32.         horiz_dist.append(line[1])
  33.         bearing.append(line[2])
  34.  
  35.     dest_id.pop(-1)
  36.     horiz_dist.pop(-1)
  37.     bearing.pop(-1)
  38.  
  39.     for line in depot_list:
  40.         latitude.append(line[1])
  41.         longitude.append(line[2])
  42.  
  43.     longitude.pop(-1)
  44.     latitude.pop(-1)
  45.  
  46.     final_list = [dest_id, horiz_dist, bearing, latitude, longitude]
  47.  
  48.     def get_values():
  49.         d = float(final_list[1][0])
  50.         brng = float(final_list[2][0])
  51.         lat1 = float(final_list[3][0])
  52.         lon1 = float(final_list[4][0])
  53.         get_lat_lon(lat1, lon1, d, brng)
  54.     get_values()
  55.  
  56.  
  57. def get_lat_lon(lat1, lon1, d, brng):
  58.     R = 6371.0 #Radius of the Earth
  59.  
  60.     lat1 = math.radians(lat1)
  61.     lon1 = math.radians(lon1)
  62.     brng = math.radians(brng)
  63.  
  64.     lat2 = math.asin( math.sin(lat1)*math.cos(d/R) + math.cos(lat1)*math.sin(d/R)*math.cos(brng))
  65.     lon2 = lon1 + math.atan2(math.sin(brng)*math.sin(d/R)*math.cos(lat1), math.cos(d/R)-math.sin(lat1)*math.sin(lat2))
  66.  
  67.     lat2 = math.degrees(lat2)
  68.     lon2 = math.degrees(lon2)
  69.  
  70.     return lat2, lon2
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77. def depot_read_csv():
  78.     my_data = open("depot_data.csv", 'rU', newline='')
  79.     csv_data = csv.reader(my_data)
  80.     depot_dictionary_list = list(csv_data)
  81.     my_data.close()
  82.  
  83.     return depot_dictionary_list
  84.  
  85. def observatory_read_csv():
  86.  
  87.     my_data = open("observatory_data.csv", 'rU', newline='')
  88.     csv_data = csv.reader(my_data)
  89.     dictionary_list = list(csv_data)
  90.     my_data.close()
  91.  
  92.     return dictionary_list
  93.  
  94. main()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top