diff --git a/Inst_eddies/Documentation_texfol/documentation.tex b/Inst_eddies/Documentation_texfol/documentation.tex index 5a83d2b243fa0337316d3e07a473bdce1d8ce324..d7bc17693a0f775bcbf3e4c0ca2ed5c6b88560a9 100644 --- a/Inst_eddies/Documentation_texfol/documentation.tex +++ b/Inst_eddies/Documentation_texfol/documentation.tex @@ -1025,7 +1025,6 @@ Ou encore : k = \left\lceil \frac{w - \lambda}{2 \pi} \right\rceil \end{equation*} - \subsection{set\_max\_speed} 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 contour. Certains points à distance $E(d) + 1$ peuvent être à l'extérieur. D'où : radius = $E(d) + 1$. -Dans le cas où radius vaut 1, je calcule \verb+max_speed+. Ce calcul -ne sera utile que dans weight si le tourbillon a une intersection avec -avec un tourbillon à une autre date. Donc, pour certains tourbillons, -ce calcul est inutile. Difficile d'éviter ces calculs inutiles. Il -faudrait les reporter à weight mais alors il faudrait avoir accès dans -weight à u et v, et même u, v à plusieurs dates. Cela remettrait en -question toute l'organisation des programmes. +En l'absence de calcul de poids des arêtes dans \verb+eddy_graph+, +\verb+max_speed+ ne sera pas utilisé dans +\verb+eddy_graph+. \verb+max_speed+ n'est pas non plus utilisé dans +\verb+inst_eddies+ en dehors de \verb+set_max_speed+. Il n'est utilisé que dans +\verb+set_max_speed+ pour choisir entre le contour extérieur et le +contour venant de \verb+max_speed_contour_ssh+. Il est écrit dans le +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} diff --git a/cost_function.py b/cost_function.py index bb5ea8137588032b07bd5336d011395c3295f377..72d4e6fd03a5e736afb39bcd51155f38cb43c0d9 100755 --- a/cost_function.py +++ b/cost_function.py @@ -1,14 +1,14 @@ #!/usr/bin/env python3 """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: - "node_id_param.json", expected to be in the current directory -- the graph of segments, "segments.gt" or "segments.graphml", expected - to be in the current directory +- the graph of segments without cost functions, "segments.gt" or + "segments.graphml", expected to be in the current directory - shapefiles, specified as command line arguments @@ -32,10 +32,8 @@ import bisect def calculate_radii_and_rossby(start, end, inc, segment, e_overestim, handlers, array_d_init): - radii = 0 #[m] - rossby = 0 #[1/s] - + rossby = 0 days_modifier = 0 for i in range(start, end, inc): @@ -66,10 +64,8 @@ def calculate_radii_and_rossby(start, end, inc, segment, e_overestim, handlers, Ro = 0 days_modifier += 1 - ####### RADII ####### - radii += R_Vmax # [m] - ####### ROSSBY ###### - rossby += Ro # [] + radii += R_Vmax # [in m] + rossby += Ro return {"radii": radii, "rossby": rossby, "days_modifier": days_modifier} @@ -86,23 +82,21 @@ if len(sys.argv) == 1: # Grab e_overestim: 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"] -################################################ -# 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_ro_mean = -0.0025965 # [] +delta_ro_mean = -0.0025965 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 # Load the graph_tool file: + print('Loading graph...') g = graph_tool.Graph() @@ -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] # (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 - +num_of_days_to_avg = 7 # number of days to average print("Iterating on vertices...") for n in g.vertices(): segment = g.vp.segment[n] 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_SHPC = get_SHPC(array_d_init, first['date_index']) @@ -153,7 +146,7 @@ for n in g.vertices(): last = report_graph.node_to_date_eddy(segment[-1], e_overestim) 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['date_index'], first['eddy_index']) @@ -177,8 +170,8 @@ for n in g.vertices(): first_radii = 0 # [m] last_radii = 0 # [m] - first_rossby = 0 # [] - last_rossby = 0 # [] + first_rossby = 0 + last_rossby = 0 # First 7 days calculation first_res = calculate_radii_and_rossby(0, num_of_days_to_avg, diff --git a/segments.py b/segments.py index fb9629aecf0318ee9c8ba038c278956e7e50bd4f..5d6b6e9804d266dc41fe944529d670adb8422af9 100755 --- a/segments.py +++ b/segments.py @@ -41,9 +41,7 @@ t0 = t1 # Processing # ############## -# Set property maps: g.vp['segment'] = g.new_vp('object') # this object will be a list - print('Collapsing into segments...') g.set_fast_edge_removal() verts_to_del = []