@@ -236,14 +236,36 @@ def load_from_netcdf(filename):
236
236
eddies .sign_type = h_nc .variables ['cyc' ][0 ]
237
237
return eddies
238
238
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
+
239
248
def tracking (self , other ):
240
249
"""Track obs between self and other
241
250
"""
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
243
262
# Links available which respect a maximal cost
244
- mask_accept_cost = cost < 40
263
+ cost = dist
264
+ mask_accept_cost = cost < 100
245
265
cost = ma .array (cost , mask = - mask_accept_cost , dtype = 'i2' )
246
266
267
+ mask_accept_cost = mask_accept_dist
268
+ cost = cost_mat
247
269
# Count number of link by self obs and other obs
248
270
self_links = mask_accept_cost .sum (axis = 1 )
249
271
other_links = mask_accept_cost .sum (axis = 0 )
0 commit comments