Skip to content
Snippets Groups Projects
Commit eb2a582e authored by Lionel GUEZ's avatar Lionel GUEZ
Browse files

Polish

parent eee8fdde
No related branches found
No related tags found
No related merge requests found
...@@ -91,12 +91,12 @@ args = parser.parse_args() ...@@ -91,12 +91,12 @@ args = parser.parse_args()
with open("e_overestim.txt") as f: e_overestim = int(f.read()) with open("e_overestim.txt") as f: e_overestim = int(f.read())
# Set some values needed for the cost function: # Set some values needed for the cost function:
delta_cent_mean = 3.8481 # [in km] delta_cent_mean = 3.8481 # in km
delta_cent_std = 8.0388 delta_cent_std = 8.0388
delta_ro_mean = -0.0025965 delta_ro_mean = -0.0025965
delta_ro_std = 5.2168 delta_ro_std = 5.2168
delta_r_mean = -0.0094709 * 1000 # [in m] delta_r_mean = -9.4709 # in m
delta_r_std = 8.6953 * 1000 delta_r_std = 8.6953e3
# Load the graph_tool file: # Load the graph_tool file:
...@@ -189,17 +189,14 @@ for edge in g.edges(): ...@@ -189,17 +189,14 @@ for edge in g.edges():
# because of the wrapping issue (360° wrapping incorrectly to 0°), # because of the wrapping issue (360° wrapping incorrectly to 0°),
# we check for that here # we check for that here
lon_diff = abs(g.vp.pos_last[source_node][0] \ lon_diff = abs(g.vp.pos_last[source_node][0]
- g.vp.pos_first[target_node][0]) - g.vp.pos_first[target_node][0])
if (lon_diff > 300): if lon_diff > 300: lon_diff = 360 - lon_diff
lon_diff = 360 - lon_diff
Delta_Cent = math.sqrt((lon_diff * 111.32 * math.cos(lat_for_conv))**2 Delta_Cent = math.sqrt((lon_diff * 111.32 * math.cos(lat_for_conv))**2
+ ((g.vp.pos_last[source_node][1] + ((g.vp.pos_last[source_node][1]
- g.vp.pos_first[target_node][1]) * 110.574)**2) - g.vp.pos_first[target_node][1]) * 110.574)**2)
first_term = ((Delta_Cent - delta_cent_mean)/delta_cent_std)**2
# calculate the first term
first_term = ((Delta_Cent - delta_cent_mean)/delta_cent_std) ** 2
# Rossbies: # Rossbies:
if (g.vp.first_av_ros[target_node] and g.vp.last_av_ros[source_node]): if (g.vp.first_av_ros[target_node] and g.vp.last_av_ros[source_node]):
...@@ -210,16 +207,13 @@ for edge in g.edges(): ...@@ -210,16 +207,13 @@ for edge in g.edges():
# Delta_Ro = delta_ro_mean # Delta_Ro = delta_ro_mean
Delta_Ro = 0 Delta_Ro = 0
# Calculate the second term second_term = ((Delta_Ro - delta_ro_mean)/delta_ro_std)**2
second_term = ((Delta_Ro - delta_ro_mean)/delta_ro_std ) ** 2
# R_Vmax 1 and 2 already exist, just get the delta # R_Vmax 1 and 2 already exist, just get the delta
Delta_R_Vmax = g.vp.last_av_rad[source_node] \ Delta_R_Vmax = g.vp.last_av_rad[source_node] \
- g.vp.first_av_rad[target_node] - g.vp.first_av_rad[target_node]
# Calculate the third term third_term = ((Delta_R_Vmax - delta_r_mean)/delta_r_std)**2
third_term = ((Delta_R_Vmax - delta_r_mean)/delta_r_std) ** 2
# Calculate the cost function and assign as weight to the edge: # Calculate the cost function and assign as weight to the edge:
g.ep.cost_function[edge] = math.sqrt(first_term + second_term + third_term) g.ep.cost_function[edge] = math.sqrt(first_term + second_term + third_term)
......
#!/usr/bin/env python3 #!/usr/bin/env python3
"""Read a graph of segments with cost functions."""
import graph_tool import graph_tool
import sys import sys
import pygraphviz as pgv import pygraphviz as pgv
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment