@@ -399,25 +399,27 @@ def get_group(
399399 i1_multi = i1_ [nb1 >= 2 ]
400400 i2_multi = i2_ [nb2 >= 2 ]
401401 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 ])
404402
405403 # Low scores
406- m_low = score <= low
404+ m_low = score < low
407405 m_low *= ~ m_multi
408406 group1 ["low" ] = i1 [m_low ]
409407 group2 ["low" ] = i2 [m_low ]
410408 # Intermediate scores
411- m_i = (score > low ) * (score <= high )
409+ m_i = (score >= low ) * (score < high )
412410 m_i *= ~ m_multi
413411 group1 ["intermediate" ] = i1 [m_i ]
414412 group2 ["intermediate" ] = i2 [m_i ]
415413 # High scores
416- m_high = score > high
414+ m_high = score >= high
417415 m_high *= ~ m_multi
418416 group1 ["high" ] = i1 [m_high ]
419417 group2 ["high" ] = i2 [m_high ]
420418
419+ # Here for a nice display order
420+ group1 ["multi_match" ] = unique (i1 [m_multi ])
421+ group2 ["multi_match" ] = unique (i2 [m_multi ])
422+
421423 def get_twin (j2 , j1 ):
422424 # True only if j1 is used only one
423425 m = bincount (j1 )[j1 ] == 1
@@ -449,6 +451,11 @@ def quick_compare():
449451 )
450452 parser .add_argument ("ref" , help = "Identification file of reference" )
451453 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+ )
452459 parser .add_argument ("--high" , default = 40 , type = float )
453460 parser .add_argument ("--low" , default = 20 , type = float )
454461 parser .add_argument ("--invalid" , default = 5 , type = float )
@@ -461,6 +468,8 @@ def quick_compare():
461468 * EddiesObservations .intern (args .intern , public_label = True ),
462469 ]
463470 )
471+ if args .area :
472+ kw ["include_vars" ].append ("speed_area" if args .intern else "effective_area" )
464473
465474 ref = EddiesObservations .load_file (args .ref , ** kw )
466475 print (f"[ref] { args .ref } -> { len (ref )} obs" )
@@ -484,28 +493,46 @@ def display(value, ref=None):
484493 outs = list ()
485494 for v in value :
486495 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 } )" )
488500 else :
489501 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 ])
491506
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 ()]
493522 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 )
494527 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_ ))
502529
503- print (display (keys ))
530+ print (" Point of view of study dataset" )
531+ print (" " , display (keys ))
504532 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