@@ -399,25 +399,27 @@ def get_group(
399
399
i1_multi = i1_ [nb1 >= 2 ]
400
400
i2_multi = i2_ [nb2 >= 2 ]
401
401
m_multi = in1d (i1 , i1_multi ) + in1d (i2 , i2_multi )
402
- group1 ["multi_match" ] = unique (i1 [m_multi ])
403
- group2 ["multi_match" ] = unique (i2 [m_multi ])
404
402
405
403
# Low scores
406
- m_low = score <= low
404
+ m_low = score < low
407
405
m_low *= ~ m_multi
408
406
group1 ["low" ] = i1 [m_low ]
409
407
group2 ["low" ] = i2 [m_low ]
410
408
# Intermediate scores
411
- m_i = (score > low ) * (score <= high )
409
+ m_i = (score >= low ) * (score < high )
412
410
m_i *= ~ m_multi
413
411
group1 ["intermediate" ] = i1 [m_i ]
414
412
group2 ["intermediate" ] = i2 [m_i ]
415
413
# High scores
416
- m_high = score > high
414
+ m_high = score >= high
417
415
m_high *= ~ m_multi
418
416
group1 ["high" ] = i1 [m_high ]
419
417
group2 ["high" ] = i2 [m_high ]
420
418
419
+ # Here for a nice display order
420
+ group1 ["multi_match" ] = unique (i1 [m_multi ])
421
+ group2 ["multi_match" ] = unique (i2 [m_multi ])
422
+
421
423
def get_twin (j2 , j1 ):
422
424
# True only if j1 is used only one
423
425
m = bincount (j1 )[j1 ] == 1
@@ -449,6 +451,11 @@ def quick_compare():
449
451
)
450
452
parser .add_argument ("ref" , help = "Identification file of reference" )
451
453
parser .add_argument ("others" , nargs = "+" , help = "Identifications files to compare" )
454
+ parser .add_argument (
455
+ "--area" ,
456
+ action = "store_true" ,
457
+ help = "Display in percent of area instead percent of observation" ,
458
+ )
452
459
parser .add_argument ("--high" , default = 40 , type = float )
453
460
parser .add_argument ("--low" , default = 20 , type = float )
454
461
parser .add_argument ("--invalid" , default = 5 , type = float )
@@ -461,6 +468,8 @@ def quick_compare():
461
468
* EddiesObservations .intern (args .intern , public_label = True ),
462
469
]
463
470
)
471
+ if args .area :
472
+ kw ["include_vars" ].append ("speed_area" if args .intern else "effective_area" )
464
473
465
474
ref = EddiesObservations .load_file (args .ref , ** kw )
466
475
print (f"[ref] { args .ref } -> { len (ref )} obs" )
@@ -484,28 +493,46 @@ def display(value, ref=None):
484
493
outs = list ()
485
494
for v in value :
486
495
if ref :
487
- outs .append (f"{ v / ref * 100 :.1f} % ({ v } )" )
496
+ if args .area :
497
+ outs .append (f"{ v / ref * 100 :.1f} % ({ v :.1f} Mkm²)" )
498
+ else :
499
+ outs .append (f"{ v / ref * 100 :.1f} % ({ v } )" )
488
500
else :
489
501
outs .append (v )
490
- return "" .join ([f"{ v :^15} " for v in outs ])
502
+ if args .area :
503
+ return "" .join ([f"{ v :^16} " for v in outs ])
504
+ else :
505
+ return "" .join ([f"{ v :^15} " for v in outs ])
491
506
492
- keys = list (gr1 .keys ())
507
+ def get_values (v , dataset ):
508
+ if args .area :
509
+ area = dataset ["speed_area" if args .intern else "effective_area" ]
510
+ return [area [v_ ].sum () / 1e12 for v_ in v .values ()]
511
+ else :
512
+ return [
513
+ v_ .sum () if v_ .dtype == "bool" else v_ .shape [0 ] for v_ in v .values ()
514
+ ]
515
+
516
+ labels = dict (
517
+ high = f"{ args .high :0.0f} <= high" ,
518
+ low = f"{ args .invalid :0.0f} <= low < { args .low :0.0f} " ,
519
+ )
520
+
521
+ keys = [labels .get (key , key ) for key in gr1 .keys ()]
493
522
print (" " , display (keys ))
523
+ if args .area :
524
+ ref_ = ref ["speed_area" if args .intern else "effective_area" ].sum () / 1e12
525
+ else :
526
+ ref_ = len (ref )
494
527
for i , v in enumerate (groups_ref .values ()):
495
- print (
496
- f"[{ i :2} ] " ,
497
- display (
498
- (v_ .sum () if v_ .dtype == "bool" else v_ .shape [0 ] for v_ in v .values ()),
499
- ref = len (ref ),
500
- ),
501
- )
528
+ print (f"[{ i :2} ] " , display (get_values (v , ref ), ref = ref_ ))
502
529
503
- print (display (keys ))
530
+ print (" Point of view of study dataset" )
531
+ print (" " , display (keys ))
504
532
for i , (k , v ) in enumerate (groups_other .items ()):
505
- print (
506
- f"[{ i :2} ] " ,
507
- display (
508
- (v_ .sum () if v_ .dtype == "bool" else v_ .shape [0 ] for v_ in v .values ()),
509
- ref = len (others [k ]),
510
- ),
511
- )
533
+ other = others [k ]
534
+ if args .area :
535
+ ref_ = other ["speed_area" if args .intern else "effective_area" ].sum () / 1e12
536
+ else :
537
+ ref_ = len (other )
538
+ print (f"[{ i :2} ] " , display (get_values (v , other ), ref = ref_ ))
0 commit comments