@@ -436,22 +436,41 @@ def fig_comply(f, day_comps, day_list, sta_comps, sta_list, skey=None,
436
436
ax .yaxis .get_offset_text ().set_fontsize (8 )
437
437
438
438
if day_list [key ]:
439
+ compliance_list = []
440
+ coherence_list = []
439
441
for i in range (len (day_comps )):
440
442
compliance = np .abs (day_comps [i ][key ][0 ])
443
+ coherence = np .abs (day_comps [i ][key ][1 ])
444
+ if not np .isnan (compliance ).any ():
445
+ compliance_list .append (compliance )
446
+ coherence_list .append (coherence )
447
+ compliance_mean = np .mean (np .array (compliance_list ), axis = 0 )
448
+ compliance_std = np .std (np .array (compliance_list ), axis = 0 )
449
+ coherence_mean = np .mean (np .array (coherence_list ), axis = 0 )
450
+ coherence_std = np .std (np .array (coherence_list ), axis = 0 )
451
+
452
+ ax .fill_between (
453
+ f [faxis ],
454
+ compliance_mean [faxis ]- compliance_std [faxis ],
455
+ compliance_mean [faxis ]+ compliance_std [faxis ],
456
+ fc = 'royalblue' , alpha = 0.3 , label = r'$\pm$ Std daily'
457
+ )
458
+ ax .plot (
459
+ f [faxis ], compliance_mean [faxis ], c = 'royalblue' ,
460
+ lw = 0.5 , label = 'Mean daily' )
461
+ ax .set_xlim (f_0 , f_c )
462
+ ytop = 1.2 * np .max (compliance_mean [(f > f_0 ) & (f < f_c )])
463
+ ybot = 0 / 8 * np .min (compliance_mean [(f > f_0 ) & (f < f_c )])
464
+ ax .set_ylim (ybot , ytop )
465
+
466
+ if sta_list [key ]:
467
+ for i in range (len (sta_comps )):
468
+ compliance = np .abs (sta_comps [i ][key ][0 ])
441
469
ax .plot (
442
470
f [faxis ],
443
471
compliance [faxis ],
444
- 'gray' , alpha = 0.3 , lw = 0.5 )
445
- ax .set_xlim (f_0 , f_c )
446
- ytop = np .max (compliance [(f > f_0 ) & (f < f_c )])
447
- ybot = np .min (compliance [(f > f_0 ) & (f < f_c )])
448
- ax .set_ylim (ybot , ytop )
449
-
450
- if sta_list [key ]:
451
- ax .plot (
452
- f [faxis ],
453
- np .abs (sta_comps [key ][0 ][faxis ]),
454
- 'k' , lw = 0.5 )
472
+ 'red' , lw = 0.5 , alpha = 0.5 ,
473
+ label = 'Sta average' )
455
474
456
475
if key == 'ZP' :
457
476
ax .set_title (skey + ' Compliance: ZP' ,
@@ -467,20 +486,32 @@ def fig_comply(f, day_comps, day_list, sta_comps, sta_list, skey=None,
467
486
ax .axvline (f_0 , ls = '--' , c = 'k' , lw = 0.75 )
468
487
ax .axvline (f_c , ls = '--' , c = 'k' , lw = 0.75 )
469
488
489
+ handles , labels = ax .get_legend_handles_labels ()
490
+ by_label = dict (zip (labels , handles ))
491
+ ax .legend (by_label .values (), by_label .keys (), fontsize = 6 )
492
+
470
493
ax = fig .add_subplot (ncomps , 2 , j * 2 + 2 )
471
494
ax .tick_params (labelsize = 8 )
472
495
473
496
if day_list [key ]:
474
- for i in range (len (day_comps )):
475
- ax .semilogx (
476
- f [faxis ],
477
- np .abs (day_comps [i ][key ][1 ][faxis ]),
478
- 'gray' , alpha = 0.3 , lw = 0.5 )
497
+ # for i in range(len(day_comps)):
498
+ ax .fill_between (
499
+ f [faxis ],
500
+ coherence_mean [faxis ]- coherence_std [faxis ],
501
+ coherence_mean [faxis ]+ coherence_std [faxis ],
502
+ fc = 'royalblue' , alpha = 0.3
503
+ )
504
+ ax .plot (
505
+ f [faxis ],
506
+ coherence_mean [faxis ],
507
+ c = 'royalblue' , lw = 0.75 )
479
508
if sta_list [key ]:
480
- ax .semilogx (
481
- f [faxis ],
482
- np .abs (sta_comps [key ][1 ][faxis ]),
483
- 'k' , lw = 0.5 )
509
+ for i in range (len (sta_comps )):
510
+ ax .plot (
511
+ f [faxis ],
512
+ np .abs (sta_comps [i ][key ][1 ][faxis ]),
513
+ 'red' , lw = 0.5 , alpha = 0.5 )
514
+ ax .set_xscale ('log' )
484
515
485
516
if key == 'ZP' :
486
517
ax .set_title (skey + ' Coherence: ZP' ,
0 commit comments