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

Polish

parent edb16459
No related branches found
No related tags found
No related merge requests found
...@@ -1025,7 +1025,6 @@ Ou encore : ...@@ -1025,7 +1025,6 @@ Ou encore :
k = \left\lceil \frac{w - \lambda}{2 \pi} \right\rceil k = \left\lceil \frac{w - \lambda}{2 \pi} \right\rceil
\end{equation*} \end{equation*}
\subsection{set\_max\_speed} \subsection{set\_max\_speed}
Notons $d$ la distance dans l'espace des indices entre l'extremum Notons $d$ la distance dans l'espace des indices entre l'extremum
...@@ -1034,13 +1033,19 @@ les points à distance $E(d)$ de l'extremum cible sont à l'intérieur du ...@@ -1034,13 +1033,19 @@ les points à distance $E(d)$ de l'extremum cible sont à l'intérieur du
contour. Certains points à distance $E(d) + 1$ peuvent être à contour. Certains points à distance $E(d) + 1$ peuvent être à
l'extérieur. D'où : radius = $E(d) + 1$. l'extérieur. D'où : radius = $E(d) + 1$.
Dans le cas où radius vaut 1, je calcule \verb+max_speed+. Ce calcul En l'absence de calcul de poids des arêtes dans \verb+eddy_graph+,
ne sera utile que dans weight si le tourbillon a une intersection avec \verb+max_speed+ ne sera pas utilisé dans
avec un tourbillon à une autre date. Donc, pour certains tourbillons, \verb+eddy_graph+. \verb+max_speed+ n'est pas non plus utilisé dans
ce calcul est inutile. Difficile d'éviter ces calculs inutiles. Il \verb+inst_eddies+ en dehors de \verb+set_max_speed+. Il n'est utilisé que dans
faudrait les reporter à weight mais alors il faudrait avoir accès dans \verb+set_max_speed+ pour choisir entre le contour extérieur et le
weight à u et v, et même u, v à plusieurs dates. Cela remettrait en contour venant de \verb+max_speed_contour_ssh+. Il est écrit dans le
question toute l'organisation des programmes. shapefile extremum comme simple diagnostic.
Dans le cas où radius vaut 1, je calcule \verb+max_speed+ et cette
valeur n'est pas utilisée dans \verb+set_max_speed+. Ce calcul ne
serait utile que dans weight si le tourbillon a une intersection avec
un tourbillon à une autre date. Donc, pour certains tourbillons, ce
calcul est complètement inutile.
\subsection{spher\_polyline\_area} \subsection{spher\_polyline\_area}
......
#!/usr/bin/env python3 #!/usr/bin/env python3
"""A script that takes the graph of segments without cost functions """A script that takes the graph of segments without cost functions
and computes the non-local cost functions attributed to edges. and computes the non-local cost functions applied to edges.
Input: Input:
- "node_id_param.json", expected to be in the current directory - "node_id_param.json", expected to be in the current directory
- the graph of segments, "segments.gt" or "segments.graphml", expected - the graph of segments without cost functions, "segments.gt" or
to be in the current directory "segments.graphml", expected to be in the current directory
- shapefiles, specified as command line arguments - shapefiles, specified as command line arguments
...@@ -32,10 +32,8 @@ import bisect ...@@ -32,10 +32,8 @@ import bisect
def calculate_radii_and_rossby(start, end, inc, segment, e_overestim, handlers, def calculate_radii_and_rossby(start, end, inc, segment, e_overestim, handlers,
array_d_init): array_d_init):
radii = 0 #[m] radii = 0 #[m]
rossby = 0 #[1/s] rossby = 0
days_modifier = 0 days_modifier = 0
for i in range(start, end, inc): for i in range(start, end, inc):
...@@ -66,10 +64,8 @@ def calculate_radii_and_rossby(start, end, inc, segment, e_overestim, handlers, ...@@ -66,10 +64,8 @@ def calculate_radii_and_rossby(start, end, inc, segment, e_overestim, handlers,
Ro = 0 Ro = 0
days_modifier += 1 days_modifier += 1
####### RADII ####### radii += R_Vmax # [in m]
radii += R_Vmax # [m] rossby += Ro
####### ROSSBY ######
rossby += Ro # []
return {"radii": radii, "rossby": rossby, "days_modifier": days_modifier} return {"radii": radii, "rossby": rossby, "days_modifier": days_modifier}
...@@ -86,23 +82,21 @@ if len(sys.argv) == 1: ...@@ -86,23 +82,21 @@ if len(sys.argv) == 1:
# Grab e_overestim: # Grab e_overestim:
with open("node_id_param.json") as f: node_id_param = json.load(f) with open("node_id_param.json") as f: node_id_param = json.load(f)
# assign attributes to the whole graphs
e_overestim = node_id_param["e_overestim"] e_overestim = node_id_param["e_overestim"]
################################################ # Set some values needed for the cost function:
# set some values needed for the cost function #
################################################
delta_cent_mean = 3.8481 # [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 #[m] delta_r_mean = -0.0094709 * 1000 # [in m]
delta_r_std = 8.6953 * 1000 delta_r_std = 8.6953 * 1000
# Load the graph_tool file: # Load the graph_tool file:
print('Loading graph...') print('Loading graph...')
g = graph_tool.Graph() g = graph_tool.Graph()
...@@ -136,16 +130,15 @@ handlers = [util_eddies.open_shpc(shp_dir) for shp_dir in sys.argv[1:]] ...@@ -136,16 +130,15 @@ handlers = [util_eddies.open_shpc(shp_dir) for shp_dir in sys.argv[1:]]
array_d_init = [handler["d_init"] for handler in handlers] array_d_init = [handler["d_init"] for handler in handlers]
# (create the list once and for all) # (create the list once and for all)
# change if there is a change over the number of days to average num_of_days_to_avg = 7 # number of days to average
num_of_days_to_avg = 7
print("Iterating on vertices...") print("Iterating on vertices...")
for n in g.vertices(): for n in g.vertices():
segment = g.vp.segment[n] segment = g.vp.segment[n]
num_of_days = len(segment) num_of_days = len(segment)
# Calculate the indexes and dates: # Calculate the date index, the eddy index and the SHPC index of
# the first and last instantaneous eddies in the segment:
first = report_graph.node_to_date_eddy(segment[0], e_overestim) first = report_graph.node_to_date_eddy(segment[0], e_overestim)
first_SHPC = get_SHPC(array_d_init, first['date_index']) first_SHPC = get_SHPC(array_d_init, first['date_index'])
...@@ -153,7 +146,7 @@ for n in g.vertices(): ...@@ -153,7 +146,7 @@ for n in g.vertices():
last = report_graph.node_to_date_eddy(segment[-1], e_overestim) last = report_graph.node_to_date_eddy(segment[-1], e_overestim)
last_SHPC = get_SHPC(array_d_init, last['date_index']) last_SHPC = get_SHPC(array_d_init, last['date_index'])
# calculate the location in the shapefile # Calculate the location in the shapefiles:
first_loc = util_eddies.comp_ishape(handlers[first_SHPC], first_loc = util_eddies.comp_ishape(handlers[first_SHPC],
first['date_index'], first['date_index'],
first['eddy_index']) first['eddy_index'])
...@@ -177,8 +170,8 @@ for n in g.vertices(): ...@@ -177,8 +170,8 @@ for n in g.vertices():
first_radii = 0 # [m] first_radii = 0 # [m]
last_radii = 0 # [m] last_radii = 0 # [m]
first_rossby = 0 # [] first_rossby = 0
last_rossby = 0 # [] last_rossby = 0
# First 7 days calculation # First 7 days calculation
first_res = calculate_radii_and_rossby(0, num_of_days_to_avg, first_res = calculate_radii_and_rossby(0, num_of_days_to_avg,
......
...@@ -41,9 +41,7 @@ t0 = t1 ...@@ -41,9 +41,7 @@ t0 = t1
# Processing # # Processing #
############## ##############
# Set property maps:
g.vp['segment'] = g.new_vp('object') # this object will be a list g.vp['segment'] = g.new_vp('object') # this object will be a list
print('Collapsing into segments...') print('Collapsing into segments...')
g.set_fast_edge_removal() g.set_fast_edge_removal()
verts_to_del = [] verts_to_del = []
......
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