@@ -351,7 +351,15 @@ def keep_tracks_by_date(self, date, nb_days):
351
351
return self .extract_with_mask (mask )
352
352
353
353
def particle_candidate_atlas (
354
- self , cube , space_step , dt , start_intern = False , end_intern = False , callback_coherence = None , finalize_coherence = None , ** kwargs
354
+ self ,
355
+ cube ,
356
+ space_step ,
357
+ dt ,
358
+ start_intern = False ,
359
+ end_intern = False ,
360
+ callback_coherence = None ,
361
+ finalize_coherence = None ,
362
+ ** kwargs
355
363
):
356
364
"""Select particles within eddies, advect them, return target observation and associated percentages
357
365
@@ -383,7 +391,9 @@ def particle_candidate_atlas(
383
391
kw_coherence = dict (space_step = space_step , dt = dt , c = cube )
384
392
kw_coherence .update (kwargs )
385
393
for t in times :
386
- logger .info ("Coherence for time step : %s in [%s:%s]" , t , times [0 ], times [- 1 ])
394
+ logger .info (
395
+ "Coherence for time step : %s in [%s:%s]" , t , times [0 ], times [- 1 ]
396
+ )
387
397
# Get index for origin
388
398
i = t - t_start
389
399
indexs0 = i_sort [i_start [i ] : i_end [i ]]
@@ -393,15 +403,37 @@ def particle_candidate_atlas(
393
403
if indexs0 .size == 0 or indexs1 .size == 0 :
394
404
continue
395
405
396
- results .append (callback_coherence (self , i_target , pct , indexs0 , indexs1 , start_intern , end_intern , t_start = t , ** kw_coherence ))
406
+ results .append (
407
+ callback_coherence (
408
+ self ,
409
+ i_target ,
410
+ pct ,
411
+ indexs0 ,
412
+ indexs1 ,
413
+ start_intern ,
414
+ end_intern ,
415
+ t_start = t ,
416
+ ** kw_coherence
417
+ )
418
+ )
397
419
indexs [results [- 1 ]] = indexs0 , indexs1
398
420
399
421
if finalize_coherence is not None :
400
422
finalize_coherence (results , indexs , i_target , pct )
401
423
return i_target , pct
402
424
403
425
@classmethod
404
- def fill_coherence (cls , network , i_targets , percents , i_origin , i_end , start_intern , end_intern , ** kwargs ):
426
+ def fill_coherence (
427
+ cls ,
428
+ network ,
429
+ i_targets ,
430
+ percents ,
431
+ i_origin ,
432
+ i_end ,
433
+ start_intern ,
434
+ end_intern ,
435
+ ** kwargs
436
+ ):
405
437
"""_summary_
406
438
407
439
:param array i_targets: global target
@@ -412,21 +444,29 @@ def fill_coherence(cls, network, i_targets, percents, i_origin, i_end, start_int
412
444
:param bool end_intern: Use intern or extern contour at end of advection
413
445
"""
414
446
# Get contour data
415
- contours_start = [network [label ][i_origin ] for label in cls .intern (start_intern )]
447
+ contours_start = [
448
+ network [label ][i_origin ] for label in cls .intern (start_intern )
449
+ ]
416
450
contours_end = [network [label ][i_end ] for label in cls .intern (end_intern )]
417
451
# Compute local coherence
418
- i_local_targets , local_percents = particle_candidate_step (contours_start = contours_start , contours_end = contours_end ,** kwargs )
452
+ i_local_targets , local_percents = particle_candidate_step (
453
+ contours_start = contours_start , contours_end = contours_end , ** kwargs
454
+ )
419
455
# Store
420
- cls .merge_particle_result (i_targets , percents , i_local_targets , local_percents , i_origin , i_end )
421
-
456
+ cls .merge_particle_result (
457
+ i_targets , percents , i_local_targets , local_percents , i_origin , i_end
458
+ )
459
+
422
460
@staticmethod
423
- def merge_particle_result (i_targets , percents , i_local_targets , local_percents , i_origin , i_end ):
461
+ def merge_particle_result (
462
+ i_targets , percents , i_local_targets , local_percents , i_origin , i_end
463
+ ):
424
464
"""Copy local result in merged result with global indexation
425
465
426
466
:param array i_targets: global target
427
- :param array percents:
467
+ :param array percents:
428
468
:param array i_local_targets: local index target
429
- :param array local_percents:
469
+ :param array local_percents:
430
470
:param array i_origin: indices of origins
431
471
:param array i_end: indices of ends
432
472
"""
0 commit comments