@@ -236,14 +236,36 @@ def load_from_netcdf(filename):
236236 eddies .sign_type = h_nc .variables ['cyc' ][0 ]
237237 return eddies
238238
239+ def cost_function (self , records_in , records_out ):
240+ cost = ((records_in ['amplitude' ] - records_out ['amplitude' ]
241+ ) / records_in ['amplitude' ]
242+ ) ** 2
243+ cost += ((records_in ['radius_s' ] - records_out ['radius_s' ]
244+ ) / records_in ['radius_s' ]
245+ ) ** 2
246+ return cost ** 0.5
247+
239248 def tracking (self , other ):
240249 """Track obs between self and other
241250 """
242- cost = self .distance (other )
251+ dist = self .distance (other )
252+ # Links available which are close (circle area selection)
253+ mask_accept_dist = dist < 100
254+ indexs_closest = where (mask_accept_dist )
255+ cost_values = self .cost_function (
256+ self .obs [indexs_closest [0 ]],
257+ other .obs [indexs_closest [1 ]])
258+
259+ cost_mat = ma .empty (dist .shape , dtype = 'f4' )
260+ cost_mat .mask = - mask_accept_dist
261+ cost_mat [mask_accept_dist ] = cost_values
243262 # Links available which respect a maximal cost
244- mask_accept_cost = cost < 40
263+ cost = dist
264+ mask_accept_cost = cost < 100
245265 cost = ma .array (cost , mask = - mask_accept_cost , dtype = 'i2' )
246266
267+ mask_accept_cost = mask_accept_dist
268+ cost = cost_mat
247269 # Count number of link by self obs and other obs
248270 self_links = mask_accept_cost .sum (axis = 1 )
249271 other_links = mask_accept_cost .sum (axis = 0 )
0 commit comments