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

Remove intermediary variables

Remove intermediary variables `first_term`, `second_term`, `third_term`.
parent 292b0046
No related branches found
No related tags found
No related merge requests found
...@@ -196,7 +196,6 @@ for edge in g.edges(): ...@@ -196,7 +196,6 @@ for edge in g.edges():
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
# 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]):
...@@ -206,16 +205,15 @@ for edge in g.edges(): ...@@ -206,16 +205,15 @@ for edge in g.edges():
# At least one of the rossbies is invalid. # At least one of the rossbies is invalid.
Delta_Ro = 0 Delta_Ro = 0
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]
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(((Delta_Cent - delta_cent_mean) / delta_cent_std)**2
+ ((Delta_Ro - delta_ro_mean) / delta_ro_std)**2
+ ((Delta_R_Vmax - delta_r_mean) / delta_r_std)**2)
t1 = time.perf_counter() t1 = time.perf_counter()
timings.write(f"iterating on edges: {t1 - t0:.0f} s\n") timings.write(f"iterating on edges: {t1 - t0:.0f} s\n")
......
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