Skip to content

Commit

Permalink
Merge pull request #283 from antarctica/correcting_distance_metrics
Browse files Browse the repository at this point in the history
Correcting distance metric to rhumb line distance inline with the paper information
  • Loading branch information
Ulvetanna authored Jul 10, 2024
2 parents de28fd1 + ebcf8ae commit 87092cc
Show file tree
Hide file tree
Showing 9 changed files with 562 additions and 535 deletions.
29 changes: 28 additions & 1 deletion polar_route/crossing_smoothing.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,32 @@ def _traveltime_in_cell(self,xdist,ydist,U,V,S):
traveltime = np.inf
return self._unit_time(traveltime), dist

def _rhumb_line_distance(self,start_waypoint,end_waypoint):
'''
Defining the rhumbline distance from a given waypoint start and end point
Inputs:
start_waypoints - (list([Long,lat])) Start Waypoint location with long lat
end_waypoints - (list([Long,lat])) End Waypoint location with long lat
'''

# Defining a corrected distance based on rhumb lines
Xs,Ys = start_waypoint
Xe,Ye = end_waypoint

R = 6371.1*1000.
dY_corrected = np.log(np.tan((np.pi/4) + (Ye*(np.pi/180))/2)/np.tan((np.pi/4) + (Ys*(np.pi/180))/2))
dX = (Xe-Xs)*(np.pi/180)
dY = (Ye-Ys)*(np.pi/180)
if dY_corrected==0 and dY==0:
q = np.cos(Ye*(np.pi/180))
else:
q = dY/dY_corrected

distance = np.sqrt(dY**2 + (q**2)*(dX**2))*R
return distance


def _waypoint_correction(self,path_requested_variables,source_graph,Wp,Cp):
'''
Applies an in-cell correction to a path segments to determine 'path_requested_variables'
Expand Down Expand Up @@ -247,7 +273,8 @@ def _waypoint_correction(self,path_requested_variables,source_graph,Wp,Cp):
Su = source_graph['Vector_x']
Sv = source_graph['Vector_y']
Ssp = self._unit_speed(source_graph['speed'][case])
traveltime, distance = self._traveltime_in_cell(x,y,Su,Sv,Ssp)
traveltime, _ = self._traveltime_in_cell(x,y,Su,Sv,Ssp)
distance = self._rhumb_line_distance(Wp,Cp)

# Given the traveltime and distance between the two waypoints
# determine the path related variables (e.g. fuel usage, traveltime)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22760,44 +22760,44 @@
"total_fuel": 107.63021863420842,
"distance": [
0.0,
76943.5089895132,
79482.82302285596,
231556.63899840153,
237903.4804014587,
387019.07397845836,
395851.1284982241,
543255.6084927082,
553370.2990931387,
700185.4753225743,
710507.2664334131,
857723.014846368,
867309.2852303212,
1015778.5024545479,
1023823.955645559,
1174259.0857677322,
1180098.6955817647,
1333069.7879520983,
1336180.295615822,
1492114.5342685804,
1647767.7363456355,
1651480.9369088325,
1803616.87257245,
1810603.954119681,
1959721.824314893,
1969368.2726269152,
2116144.0120014558,
2127661.7210400845,
2272947.035736897,
2285375.748603994,
2430197.5192640973,
2442405.717915849,
2587966.2248749165,
2598651.03952557,
2746329.5334088104,
2754015.1822501537,
2905371.451732926,
2908405.5666062236,
2985164.8904109565
76862.75354351009,
79398.53285840174,
231357.02745594122,
237695.10858270116,
386684.26882247056,
395504.16438528436,
542771.6199934519,
552872.3632521764,
699539.8879173539,
709847.3849163705,
856904.3944346025,
866477.3147818437,
1014775.9284610373,
1022810.1127293683,
1173061.7683221416,
1178893.1579765282,
1331666.7456867578,
1334772.8594739996,
1490494.3213615306,
1645923.375065881,
1649631.3154378708,
1801537.1293590176,
1808514.2841936299,
1957396.2110186035,
1967028.894984362,
2113562.440494205,
2125063.634388154,
2270099.417479196,
2282510.230442009,
2427073.302017129,
2439263.8729117415,
2584553.839071541,
2595223.2377478406,
2742615.6960224803,
2750290.3225098485,
2901340.2448313427,
2904370.0666898643,
2980995.201252911
],
"speed": [
0.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172929,79 +172929,79 @@
"total_fuel": 860.6751663153256,
"distance": [
0.0,
35548.417127253095,
71217.74935922032,
106779.8547565928,
142245.9192300127,
177570.80041200324,
212739.1636623334,
247958.12414793708,
318101.4478612052,
387840.83110440726,
457492.45895268925,
492310.45610338356,
527138.475587749,
562065.6734686303,
597193.7711800262,
632261.0156250363,
681411.0264293844,
718747.1605311859,
755683.3591241662,
791589.6056891335,
827915.8530143223,
901629.5059872278,
1050600.6633184985,
1091672.3363468647,
1123783.1219107523,
1158768.2669264015,
1193483.0080186892,
1228669.6313553278,
1263567.4998624094,
1332642.8529506063,
1401718.206038803,
1470793.559127,
1625486.9401243008,
1625533.38328205,
1700149.2340161449,
1776745.4905458936,
1935273.4513196084,
1936195.3359689268,
2098520.636289827,
2130080.456006055,
2141688.739088927,
2181316.387575055,
2194511.0913467454,
2255240.815694055,
2394473.647308885,
2540162.3167727217,
2614714.5326484316,
2663924.831043186,
2702313.7661964544,
2741775.798822842,
2779775.9957962357,
2819687.1177001745,
2858599.702844696,
2895326.0379263917,
2930196.594339614,
2965051.8819454787,
2999860.0069454787,
3036166.664193648,
3073499.48877465,
3109979.347477576,
3146202.307585913,
3182389.3257304966,
3217919.2752683125,
3252890.6409052955,
3287742.167420243,
3322641.652640994,
3357459.1651517483,
3392352.1599675855,
3462058.8209636835,
3535288.8956064754,
3696108.349095897,
3833640.0887293736,
4141934.7638093885,
4239938.423334197
35488.87872709868,
71098.6670419338,
106601.2549279216,
142007.8284948063,
177273.27468376773,
212382.27499773633,
247541.8322653005,
317566.45914018527,
387187.4123937346,
456720.6773125003,
491479.5017385457,
526248.3400691987,
561116.27261354,
596184.9254300913,
631192.7706891977,
680268.6588858882,
717543.1363911857,
754418.0186782264,
790263.9682857272,
826529.4353826985,
900118.0041697912,
1048848.3177718027,
1089866.4036720844,
1121936.8946956417,
1156880.607043095,
1191557.5481348217,
1226706.3060285924,
1261566.4048299575,
1330564.611626729,
1399562.8184235003,
1468561.0252202717,
1623141.9689808919,
1623188.3576903394,
1697729.9216311206,
1774249.0300536668,
1932647.747709485,
1933568.2996379458,
2095681.7183862801,
2127196.3415229004,
2138786.8711739504,
2178353.877960961,
2191530.6280696015,
2252157.128493606,
2391153.300161884,
2536603.700096552,
2611034.572195789,
2660174.708133361,
2698502.034287866,
2737901.5339865913,
2775840.2211855776,
2815688.174660517,
2854551.0591016146,
2891232.8757293522,
2926064.025043561,
2960879.95806484,
2995628.918056656,
3031875.1670324216,
3069146.629684569,
3105565.8356229872,
3141728.3341606394,
3177854.8837982058,
3213324.9695549896,
3248237.0082289027,
3283029.3254299494,
3317869.54960171,
3352627.8869613837,
3387461.6224672482,
3457049.793683305,
3530154.7335932907,
3690663.327075782,
3828041.465414562,
4136347.2066818653,
4234246.46050802
],
"speed": [
0.0,
Expand Down
Loading

0 comments on commit 87092cc

Please sign in to comment.