@@ -575,24 +575,22 @@ def make_pcolor_ne(nc: xr.Dataset, dest_dir, time_lim, bin_depths_lim,
575575 cbar .set_label ('Velocity [m s$^{-1}$]' , fontsize = 14 )
576576 ax .set_ylabel ('Depth [m]' , fontsize = 14 )
577577
578- if filter_type == '30h' :
579- ax .set_title (
580- 'ADCP ({}North, 30h average) {}-{} {}m{}' .format (
581- magnetic , nc .attrs ['station' ], nc .attrs ['deployment_number' ],
582- instrument_depth , resampled_str ), fontsize = 14 )
578+ if 'h' in filter_type : # xxh-average; e.g. '30h', '35h'
579+ filter_type_title = '{} average' .format (filter_type )
583580 elif filter_type == 'Godin' :
584- ax .set_title (
585- 'ADCP ({}North, Godin Filtered) {}-{} {}m{}' .format (
586- magnetic , nc .attrs ['station' ], nc .attrs ['deployment_number' ],
587- instrument_depth , resampled_str ), fontsize = 14 )
581+ filter_type_title = 'Godin filtered'
588582 elif filter_type == 'raw' :
589- ax .set_title (
590- 'ADCP ({}North, raw) {}-{} {}m{}' .format (
591- magnetic , nc .attrs ['station' ], nc .attrs ['deployment_number' ],
592- instrument_depth , resampled_str ), fontsize = 14 )
583+ filter_type_title = filter_type
593584 else :
594585 ValueError ('Not a recognized data type; choose one of \' raw\' , \' 30h\' or \' Godin\' ' )
595586
587+ ax .set_title (
588+ 'ADCP ({}North, {}) {}-{} {}m{}' .format (
589+ magnetic , filter_type_title , nc .attrs ['station' ], nc .attrs ['deployment_number' ],
590+ instrument_depth , resampled_str
591+ ), fontsize = 14
592+ )
593+
596594 ax .invert_yaxis ()
597595
598596 ax2 = fig .add_subplot (2 , 1 , 2 )
@@ -603,19 +601,14 @@ def make_pcolor_ne(nc: xr.Dataset, dest_dir, time_lim, bin_depths_lim,
603601 cbar .set_label ('Velocity [m s$^{-1}$]' , fontsize = 14 )
604602
605603 ax2 .set_ylabel ('Depth [m]' , fontsize = 14 )
606- if 'h' in filter_type : # xxh-average; e.g. '30h', '35h'
607- ax2 .set_title ('ADCP ({}East, {} average) {}-{} {}m{}' .format (
608- magnetic , filter_type , nc .attrs ['station' ], nc .attrs ['deployment_number' ],
609- instrument_depth , resampled_str ), fontsize = 14 )
610- elif filter_type == 'Godin' :
611- ax2 .set_title ('ADCP ({}East, Godin Filtered) {}-{} {}m{}' .format (
612- magnetic , nc .attrs ['station' ], nc .attrs ['deployment_number' ],
613- instrument_depth , resampled_str ), fontsize = 14 )
614- elif filter_type == 'raw' :
615- ax2 .set_title (
616- 'ADCP ({}East, raw) {}-{} {}m{}' .format (
617- magnetic , nc .attrs ['station' ], nc .attrs ['deployment_number' ],
618- instrument_depth , resampled_str ), fontsize = 14 )
604+
605+ ax2 .set_title (
606+ 'ADCP ({}East, {}) {}-{} {}m{}' .format (
607+ magnetic , filter_type_title , nc .attrs ['station' ], nc .attrs ['deployment_number' ],
608+ instrument_depth , resampled_str
609+ ),
610+ fontsize = 14
611+ )
619612
620613 ax2 .invert_yaxis ()
621614
@@ -626,15 +619,15 @@ def make_pcolor_ne(nc: xr.Dataset, dest_dir, time_lim, bin_depths_lim,
626619 os .makedirs (plot_dir )
627620
628621 if level0 :
629- plot_name = plot_dir + '{}-{}_{}_{}m-magn_NE_{}{}.png' .format (
630- nc .attrs ['station' ], nc .attrs ['deployment_number' ], nc .instrument_serial_number .data ,
631- int (np .round (instrument_depth )), filter_type , resampled_4fname
632- )
622+ vel_type = 'magn_NE'
633623 else :
634- plot_name = plot_dir + '{}-{}_{}_{}m-NE_{}{}.png' .format (
635- nc .attrs ['station' ], nc .attrs ['deployment_number' ], nc .instrument_serial_number .data ,
636- int (np .round (instrument_depth )), filter_type , resampled_4fname
637- )
624+ vel_type = 'NE'
625+
626+ # Have to round instrument depth twice due to behaviour of the float
627+ plot_name = plot_dir + '{}-{}_{}_{}m_{}_{}{}.png' .format (
628+ nc .attrs ['station' ], nc .attrs ['deployment_number' ], nc .instrument_serial_number .data ,
629+ int (np .round (np .round (instrument_depth , 1 ))), vel_type , filter_type , resampled_4fname
630+ )
638631 fig .savefig (plot_name )
639632 plt .close ()
640633
@@ -781,65 +774,50 @@ def make_pcolor_ac(nc: xr.Dataset, dest_dir, time_lim, bin_depths_lim, ns_lim, e
781774 vminvmax = colourmap_lim
782775
783776 fig = plt .figure (figsize = (13.75 , 10 ))
784- ax1 = fig .add_subplot (2 , 1 , 1 )
777+ ax1 = fig .add_subplot (2 , 1 , 1 ) # along-shore subplot
785778
786779 f1 = ax1 .pcolormesh (time_lim , bin_depths_lim , AS [:, :], cmap = 'RdBu_r' , vmin = vminvmax [0 ],
787780 vmax = vminvmax [1 ], shading = 'auto' )
788781 cbar = fig .colorbar (f1 , shrink = 0.8 )
789782 cbar .set_label ('Velocity [m s$^{-1}$]' , fontsize = 14 )
790783
791784 ax1 .set_ylabel ('Depth [m]' , fontsize = 14 )
792- if 'h' in filter_type :
793- # XXh-type filter (e.g., 30h rolling mean, etc)
794- ax1 .set_title (
795- 'ADCP (along, {} average) {}$^\circ$ (CCW from E) {}-{} {}m{}' .format (
796- filter_type , along_angle , nc .attrs ['station' ], nc .attrs ['deployment_number' ],
797- instrument_depth , resampled_str ),
798- fontsize = 14 )
785+
786+ if 'h' in filter_type : # xxh-average; e.g. '30h', '35h'
787+ filter_type_title = '{} average' .format (filter_type )
799788 elif filter_type == 'Godin' :
800- ax1 .set_title (
801- 'ADCP (along, Godin Filtered) {}$^\circ$ (CCW from E) {}-{} {}m{}' .format (
802- along_angle , nc .attrs ['station' ], nc .attrs ['deployment_number' ],
803- instrument_depth , resampled_str ),
804- fontsize = 14 )
789+ filter_type_title = 'Godin filtered'
805790 elif filter_type == 'raw' :
806- ax1 .set_title ('ADCP (along, raw) {}$^\circ$ (CCW from E) {}-{} {}m{}' .format (
807- along_angle , nc .attrs ['station' ], nc .attrs ['deployment_number' ],
808- instrument_depth , resampled_str ),
809- fontsize = 14 )
791+ filter_type_title = filter_type
810792 else :
811793 ValueError ('Not a recognized data type; choose one of \' raw\' , \' 30h\' or \' Godin\' ' )
812794
795+ ax1 .set_title (
796+ 'ADCP (along, {}) {}$^\circ$ (CCW from E) {}-{} {}m{}' .format (
797+ filter_type_title , along_angle , nc .attrs ['station' ], nc .attrs ['deployment_number' ],
798+ instrument_depth , resampled_str
799+ ),
800+ fontsize = 14
801+ )
802+
813803 ax1 .invert_yaxis ()
814804
815- ax2 = fig .add_subplot (2 , 1 , 2 )
805+ ax2 = fig .add_subplot (2 , 1 , 2 ) # cross-shore subplot
816806
817807 f2 = ax2 .pcolormesh (time_lim , bin_depths_lim , CS [:, :], cmap = 'RdBu_r' , vmin = vminvmax [0 ],
818808 vmax = vminvmax [1 ], shading = 'auto' )
819809 cbar = fig .colorbar (f2 , shrink = 0.8 )
820810 cbar .set_label ('Velocity [m s$^{-1}$]' , fontsize = 14 )
821811
822812 ax2 .set_ylabel ('Depth [m]' , fontsize = 14 )
823- if 'h' in filter_type : # xxh-average; e.g. '30h', '35h'
824- ax2 .set_title (
825- 'ADCP (cross, {} average) {}$^\circ$ (CCW from E) {}-{} {}m{}' .format (
826- filter_type , cross_angle , nc .attrs ['station' ], nc .attrs ['deployment_number' ],
827- instrument_depth , resampled_str ),
828- fontsize = 14 )
829- elif filter_type == 'Godin' :
830- ax2 .set_title (
831- 'ADCP (cross, Godin Filtered) {}$^\circ$ (CCW from E) {}-{} {}m{}' .format (
832- str (cross_angle ), nc .attrs ['station' ], nc .attrs ['deployment_number' ],
833- instrument_depth , resampled_str ),
834- fontsize = 14 )
835- elif filter_type == 'raw' :
836- ax2 .set_title (
837- 'ADCP (cross, raw) {}$^\circ$ (CCW from E) {}-{} {}m{}' .format (
838- str (cross_angle ), nc .attrs ['station' ], nc .attrs ['deployment_number' ],
839- instrument_depth , resampled_str ),
840- fontsize = 14 )
841- else :
842- ValueError ('Not a recognized data type; choose one of \' raw\' , \' 30h\' or \' Godin\' ' )
813+
814+ ax2 .set_title (
815+ 'ADCP (cross, {}) {}$^\circ$ (CCW from E) {}-{} {}m{}' .format (
816+ filter_type_title , str (cross_angle ), nc .attrs ['station' ], nc .attrs ['deployment_number' ],
817+ instrument_depth , resampled_str
818+ ),
819+ fontsize = 14
820+ )
843821
844822 ax2 .invert_yaxis ()
845823
@@ -848,9 +826,10 @@ def make_pcolor_ac(nc: xr.Dataset, dest_dir, time_lim, bin_depths_lim, ns_lim, e
848826 if not os .path .exists (plot_dir ):
849827 os .makedirs (plot_dir )
850828
851- plot_name = '{}-{}_{}_{}m-AC_{}{}.png' .format (
829+ # have to round instrument depth twice due to behaviour of float
830+ plot_name = '{}-{}_{}_{}m_AC_{}{}.png' .format (
852831 nc .attrs ['station' ], nc .attrs ['deployment_number' ], nc .instrument_serial_number .data ,
853- int (np .round (instrument_depth )), filter_type , resampled_4fname
832+ int (np .round (np . round ( instrument_depth , 1 ) )), filter_type , resampled_4fname
854833 )
855834 fig .savefig (plot_dir + plot_name )
856835 plt .close ()
0 commit comments