@@ -564,6 +564,8 @@ def make_pcolor_ne(nc: xr.Dataset, dest_dir, time_lim, bin_depths_lim,
564564 else :
565565 vminvmax = colourmap_lim
566566
567+ instrument_depth = np .round (float (nc .instrument_depth .data ), 1 )
568+
567569 fig = plt .figure (figsize = (13.75 , 10 ))
568570 ax = fig .add_subplot (2 , 1 , 1 )
569571
@@ -577,17 +579,17 @@ def make_pcolor_ne(nc: xr.Dataset, dest_dir, time_lim, bin_depths_lim,
577579 ax .set_title (
578580 'ADCP ({}North, 30h average) {}-{} {}m{}' .format (
579581 magnetic , nc .attrs ['station' ], nc .attrs ['deployment_number' ],
580- np . round ( nc . instrument_depth . data , 1 ) , resampled_str ), fontsize = 14 )
582+ instrument_depth , resampled_str ), fontsize = 14 )
581583 elif filter_type == 'Godin' :
582584 ax .set_title (
583585 'ADCP ({}North, Godin Filtered) {}-{} {}m{}' .format (
584586 magnetic , nc .attrs ['station' ], nc .attrs ['deployment_number' ],
585- np . round ( nc . instrument_depth . data , 1 ) , resampled_str ), fontsize = 14 )
587+ instrument_depth , resampled_str ), fontsize = 14 )
586588 elif filter_type == 'raw' :
587589 ax .set_title (
588590 'ADCP ({}North, raw) {}-{} {}m{}' .format (
589591 magnetic , nc .attrs ['station' ], nc .attrs ['deployment_number' ],
590- np . round ( nc . instrument_depth . data , 1 ) , resampled_str ), fontsize = 14 )
592+ instrument_depth , resampled_str ), fontsize = 14 )
591593 else :
592594 ValueError ('Not a recognized data type; choose one of \' raw\' , \' 30h\' or \' Godin\' ' )
593595
@@ -604,16 +606,16 @@ def make_pcolor_ne(nc: xr.Dataset, dest_dir, time_lim, bin_depths_lim,
604606 if 'h' in filter_type : # xxh-average; e.g. '30h', '35h'
605607 ax2 .set_title ('ADCP ({}East, {} average) {}-{} {}m{}' .format (
606608 magnetic , filter_type , nc .attrs ['station' ], nc .attrs ['deployment_number' ],
607- np . round ( nc . instrument_depth . data , 1 ) , resampled_str ), fontsize = 14 )
609+ instrument_depth , resampled_str ), fontsize = 14 )
608610 elif filter_type == 'Godin' :
609611 ax2 .set_title ('ADCP ({}East, Godin Filtered) {}-{} {}m{}' .format (
610612 magnetic , nc .attrs ['station' ], nc .attrs ['deployment_number' ],
611- np . round ( nc . instrument_depth . data , 1 ) , resampled_str ), fontsize = 14 )
613+ instrument_depth , resampled_str ), fontsize = 14 )
612614 elif filter_type == 'raw' :
613615 ax2 .set_title (
614616 'ADCP ({}East, raw) {}-{} {}m{}' .format (
615617 magnetic , nc .attrs ['station' ], nc .attrs ['deployment_number' ],
616- np . round ( nc . instrument_depth . data , 1 ) , resampled_str ), fontsize = 14 )
618+ instrument_depth , resampled_str ), fontsize = 14 )
617619
618620 ax2 .invert_yaxis ()
619621
@@ -626,12 +628,12 @@ def make_pcolor_ne(nc: xr.Dataset, dest_dir, time_lim, bin_depths_lim,
626628 if level0 :
627629 plot_name = plot_dir + '{}-{}_{}_{}m-magn_NE_{}{}.png' .format (
628630 nc .attrs ['station' ], nc .attrs ['deployment_number' ], nc .instrument_serial_number .data ,
629- int (np .round (nc . instrument_depth . data )), filter_type , resampled_4fname
631+ int (np .round (instrument_depth )), filter_type , resampled_4fname
630632 )
631633 else :
632634 plot_name = plot_dir + '{}-{}_{}_{}m-NE_{}{}.png' .format (
633635 nc .attrs ['station' ], nc .attrs ['deployment_number' ], nc .instrument_serial_number .data ,
634- int (np .round (nc . instrument_depth . data )), filter_type , resampled_4fname
636+ int (np .round (instrument_depth )), filter_type , resampled_4fname
635637 )
636638 fig .savefig (plot_name )
637639 plt .close ()
@@ -730,11 +732,11 @@ def determine_dom_angle(u_true, v_true):
730732 return along_angle , cross_angle
731733
732734
733- def make_pcolor_ac (data : xr .Dataset , dest_dir , time_lim , bin_depths_lim , ns_lim , ew_lim ,
735+ def make_pcolor_ac (nc : xr .Dataset , dest_dir , time_lim , bin_depths_lim , ns_lim , ew_lim ,
734736 filter_type = 'raw' , along_angle = None , colourmap_lim = None , resampled = None ):
735737 """
736738 Function for plotting north and east velocities from ADCP data.
737- :param data : ADCP dataset from a netCDF file read in using the xarray package
739+ :param nc : ADCP dataset from a netCDF file read in using the xarray package
738740 :param dest_dir: name of directory for containing output files
739741 :param time_lim: cleaned time data; array type
740742 :param bin_depths_lim: cleaned bin depth data; array type
@@ -767,6 +769,8 @@ def make_pcolor_ac(data: xr.Dataset, dest_dir, time_lim, bin_depths_lim, ns_lim,
767769 cross_angle = along_angle - 90 # deg
768770 # print(along_angle, cross_angle)
769771
772+ instrument_depth = np .round (float (nc .instrument_depth .data ), 1 )
773+
770774 u_along , u_cross = resolve_to_alongcross (ew_lim , ns_lim , along_angle )
771775 AS = u_along
772776 CS = u_cross
@@ -789,19 +793,19 @@ def make_pcolor_ac(data: xr.Dataset, dest_dir, time_lim, bin_depths_lim, ns_lim,
789793 # XXh-type filter (e.g., 30h rolling mean, etc)
790794 ax1 .set_title (
791795 'ADCP (along, {} average) {}$^\circ$ (CCW from E) {}-{} {}m{}' .format (
792- filter_type , along_angle , data .attrs ['station' ], data .attrs ['deployment_number' ],
793- np . round ( data . instrument_depth . data , 1 ) , resampled_str ),
796+ filter_type , along_angle , nc .attrs ['station' ], nc .attrs ['deployment_number' ],
797+ instrument_depth , resampled_str ),
794798 fontsize = 14 )
795799 elif filter_type == 'Godin' :
796800 ax1 .set_title (
797801 'ADCP (along, Godin Filtered) {}$^\circ$ (CCW from E) {}-{} {}m{}' .format (
798- along_angle , data .attrs ['station' ], data .attrs ['deployment_number' ],
799- np . round ( data . instrument_depth . data , 1 ) , resampled_str ),
802+ along_angle , nc .attrs ['station' ], nc .attrs ['deployment_number' ],
803+ instrument_depth , resampled_str ),
800804 fontsize = 14 )
801805 elif filter_type == 'raw' :
802806 ax1 .set_title ('ADCP (along, raw) {}$^\circ$ (CCW from E) {}-{} {}m{}' .format (
803- along_angle , data .attrs ['station' ], data .attrs ['deployment_number' ],
804- np . round ( data . instrument_depth . data , 1 ) , resampled_str ),
807+ along_angle , nc .attrs ['station' ], nc .attrs ['deployment_number' ],
808+ instrument_depth , resampled_str ),
805809 fontsize = 14 )
806810 else :
807811 ValueError ('Not a recognized data type; choose one of \' raw\' , \' 30h\' or \' Godin\' ' )
@@ -819,34 +823,34 @@ def make_pcolor_ac(data: xr.Dataset, dest_dir, time_lim, bin_depths_lim, ns_lim,
819823 if 'h' in filter_type : # xxh-average; e.g. '30h', '35h'
820824 ax2 .set_title (
821825 'ADCP (cross, {} average) {}$^\circ$ (CCW from E) {}-{} {}m{}' .format (
822- filter_type , cross_angle , data .attrs ['station' ], data .attrs ['deployment_number' ],
823- np . round ( data . instrument_depth . data , 1 ) , resampled_str ),
826+ filter_type , cross_angle , nc .attrs ['station' ], nc .attrs ['deployment_number' ],
827+ instrument_depth , resampled_str ),
824828 fontsize = 14 )
825829 elif filter_type == 'Godin' :
826830 ax2 .set_title (
827831 'ADCP (cross, Godin Filtered) {}$^\circ$ (CCW from E) {}-{} {}m{}' .format (
828- str (cross_angle ), data .attrs ['station' ], data .attrs ['deployment_number' ],
829- np . round ( data . instrument_depth . data , 1 ) , resampled_str ),
832+ str (cross_angle ), nc .attrs ['station' ], nc .attrs ['deployment_number' ],
833+ instrument_depth , resampled_str ),
830834 fontsize = 14 )
831835 elif filter_type == 'raw' :
832836 ax2 .set_title (
833837 'ADCP (cross, raw) {}$^\circ$ (CCW from E) {}-{} {}m{}' .format (
834- str (cross_angle ), data .attrs ['station' ], data .attrs ['deployment_number' ],
835- np . round ( data . instrument_depth . data , 1 ) , resampled_str ),
838+ str (cross_angle ), nc .attrs ['station' ], nc .attrs ['deployment_number' ],
839+ instrument_depth , resampled_str ),
836840 fontsize = 14 )
837841 else :
838842 ValueError ('Not a recognized data type; choose one of \' raw\' , \' 30h\' or \' Godin\' ' )
839843
840844 ax2 .invert_yaxis ()
841845
842846 # Create plots subfolder if not made already
843- plot_dir = get_plot_dir (data .filename , dest_dir )
847+ plot_dir = get_plot_dir (nc .filename , dest_dir )
844848 if not os .path .exists (plot_dir ):
845849 os .makedirs (plot_dir )
846850
847851 plot_name = '{}-{}_{}_{}m-AC_{}{}.png' .format (
848- data .attrs ['station' ], data .attrs ['deployment_number' ], data .instrument_serial_number .data ,
849- int (np .round (data . instrument_depth . data )), filter_type , resampled_4fname
852+ nc .attrs ['station' ], nc .attrs ['deployment_number' ], nc .instrument_serial_number .data ,
853+ int (np .round (instrument_depth )), filter_type , resampled_4fname
850854 )
851855 fig .savefig (plot_dir + plot_name )
852856 plt .close ()
0 commit comments