set(0,'DefaultFigureWindowStyle','docked')%set all lots to open within the matlab window

axisrange=[-1 7 0 72];%set axis range [hour_start hour_end range_start range_end]
axisrange_bedaligned=[-1 7 -70 0];%set axis range [hour_start hour_end range_start range_end]
caxisrange=[0 6];%set colormap range (m/s)
image_folder='E:\Monterey\Docs\AGU_slides\';
data_location_folder='E:\Monterey\Data\Jan15\';

%range from transducers for all ADCPs
r1=3.23+[0:69];
r2=3.23+[0:69];
r3=3.23+[0:69];
r4=3.2+[0:71];
r5=3.23+[0:69];
r7=3.22+[0:71];
rb300=3.24+[0:80];
rb600=1.6+0.5*[0:73];
rb1200=0.81+0.25*[0:42];

%MS1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eval(['load ',char(data_location_folder),'Monterey_300kHz_MS1_FirstDeployment_Jan15'])
SerMagmmpersec(SerMagmmpersec<-9999)=NaN;%overwrite bad values with NaN

figure(1)
clf
imagesc([-120:840].*.5/60,r1,SerMagmmpersec(481:1441,:)'./1000)% plot image with t=0 at MS1 arrival
caxis(caxisrange)
axis(axisrange) 
xlabel('Time (hours)')
ylabel({'Range below','transducers (m)'})    
title('MS1')
colormap(jet)
colorbar
set(gcf,'PaperPositionMode','auto');%set print ratio to window size
eval(['print -dtiff ',char(image_folder),'V_MS1'])

bed_bin_number=57;

figure(101)
clf
imagesc([-120:840].*.5/60,-r1(bed_bin_number)+r1(1:bed_bin_number-1),SerMagmmpersec(481:1441,1:bed_bin_number-1)'./1000)% plot image with t=0 at MS1 arrival and aligned to bed
caxis(caxisrange)
axis(axisrange_bedaligned) 
xlabel('Time (hours)')
ylabel({'Height above bed (m)'})    
title('MS1')
colormap(jet)
colorbar
set(gcf,'PaperPositionMode','auto');%set print ratio to window size
set(gca,'YTickLabel',-1*str2num(char(get(gca,'YTickLabel'))))%reverse the axis number polarity
line([(481-481).*.5/60 (481-481).*.5/60],[-70 0],'color','black','Linewidth',1)
line([(481-432).*.5/60 (481-432).*.5/60],[-70 0],'color','black','Linewidth',1)
eval(['print -dtiff ',char(image_folder),'V_MS1_relative_to_bed'])


%MS2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eval(['load ',char(data_location_folder),'Monterey_300kHz_MS2_FirstDeployment_Jan15'])
SerMagmmpersec(SerMagmmpersec<-9999)=NaN;%overwrite bad values with NaN

figure(2)
clf
imagesc([-120:840].*.5/60,r2,SerMagmmpersec(429:1389,:)'./1000)% plot image with t=0 at MS1 arrival
caxis(caxisrange)
axis(axisrange) 
xlabel('Time (hours)')
ylabel({'Range below','transducers (m)'})    
title('MS2')
colormap(jet)
colorbar
set(gcf,'PaperPositionMode','auto');%set print ratio to window size
eval(['print -dtiff ',char(image_folder),'V_MS2'])

bed_bin_number=64;

figure(201)
clf
imagesc([-120:840].*.5/60,-r2(bed_bin_number)+r2(1:bed_bin_number-1),SerMagmmpersec(429:1389,1:bed_bin_number-1)'./1000)% plot image with t=0 at MS1 arrival and aligned to bed
caxis(caxisrange)
axis(axisrange_bedaligned) 
xlabel('Time (hours)')
ylabel({'Height above bed (m)'})    
title('MS2')
colormap(jet)
colorbar
set(gcf,'PaperPositionMode','auto');%set print ratio to window size
set(gca,'YTickLabel',-1*str2num(char(get(gca,'YTickLabel'))))%reverse the axis number polarity
line([(481-429).*.5/60 (481-429).*.5/60],[-70 0],'color','black','Linewidth',1)
line([(481-429+36).*.5/60 (481-429+36).*.5/60],[-70 0],'color','black','Linewidth',1)
eval(['print -dtiff ',char(image_folder),'V_MS2_relative_to_bed'])

%MS3%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eval(['load ',char(data_location_folder),'Monterey_300kHz_MS3_FirstDeployment_Jan15'])
SerMagmmpersec(SerMagmmpersec<-9999)=NaN;%overwrite bad values with NaN

figure(3)
clf
imagesc([-120:840].*.5/60,r3,SerMagmmpersec(382:1342,:)'./1000)% plot image with t=0 at MS1 arrival
caxis(caxisrange)
axis(axisrange) 
xlabel('Time (hours)')
ylabel({'Range below','transducers (m)'})    
title('MS3')
colormap(jet)
colorbar
set(gcf,'PaperPositionMode','auto');%set print ratio to window size
eval(['print -dtiff ',char(image_folder),'V_MS3'])

bed_bin_number=59;

figure(301)
clf
imagesc([-120:840].*.5/60,-r3(bed_bin_number)+r3(1:bed_bin_number-1),SerMagmmpersec(382:1342,1:bed_bin_number-1)'./1000)% plot image with t=0 at MS1 arrival and aligned to bed
caxis(caxisrange)
axis(axisrange_bedaligned) 
xlabel('Time (hours)')
ylabel({'Height above bed (m)'})    
title('MS3')
colormap(jet)
colorbar
set(gcf,'PaperPositionMode','auto');%set print ratio to window size
set(gca,'YTickLabel',-1*str2num(char(get(gca,'YTickLabel'))))%reverse the axis number polarity
line([(481-382+2).*.5/60 (481-382+2).*.5/60],[-70 0],'color','black','Linewidth',1)
line([(481-382+7).*.5/60 (481-382+7).*.5/60],[-70 0],'color','black','Linewidth',1)
eval(['print -dtiff ',char(image_folder),'V_MS3_relative_to_bed'])

%MS4%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eval(['load ',char(data_location_folder),'Monterey_300kHz_MS4_FirstDeployment_Jan15'])
SerMagmmpersec(SerMagmmpersec<-9999)=NaN;%overwrite bad values with NaN

figure(4)
clf
imagesc([-120:840].*.5/60,r4,SerMagmmpersec(304:1264,:)'./1000)% plot image with t=0 at MS1 arrival
caxis(caxisrange)
axis(axisrange) 
xlabel('Time (hours)')
ylabel({'Range below','transducers (m)'})    
title('MS4')
colormap(jet)
colorbar
set(gcf,'PaperPositionMode','auto');%set print ratio to window size
eval(['print -dtiff ',char(image_folder),'V_MS4'])

bed_bin_number=69;

figure(401)
clf
imagesc([-120:840].*.5/60,-r4(bed_bin_number)+r4(1:bed_bin_number-1),SerMagmmpersec(304:1264,1:bed_bin_number-1)'./1000)% plot image with t=0 at MS1 arrival and aligned to bed
caxis(caxisrange)
axis(axisrange_bedaligned) 
xlabel('Time (hours)')
ylabel({'Height above bed (m)'})    
title('MS4')
colormap(jet)
colorbar
set(gcf,'PaperPositionMode','auto');%set print ratio to window size
set(gca,'YTickLabel',-1*str2num(char(get(gca,'YTickLabel'))))%reverse the axis number polarity
line([(481-304).*.5/60 (481-304).*.5/60],[-70 0],'color','black','Linewidth',1)
line([(481-304+9).*.5/60 (481-304+9).*.5/60],[-70 0],'color','black','Linewidth',1)
eval(['print -dtiff ',char(image_folder),'V_MS4_relative_to_bed'])

%MS5%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eval(['load ',char(data_location_folder),'Monterey_300kHz_MS5_FirstDeployment_Jan15'])
SerMagmmpersec(SerMagmmpersec<-9999)=NaN;%overwrite bad values with NaN

figure(5)
clf
imagesc([-120:840].*.5/60,r5,SerMagmmpersec(283:1243,:)'./1000)% plot image with t=0 at MS1 arrival
caxis(caxisrange)
axis(axisrange) 
xlabel('Time (hours)')
ylabel({'Range below','transducers (m)'})    
title('MS5')
colormap(jet)
colorbar
set(gcf,'PaperPositionMode','auto');%set print ratio to window size
eval(['print -dtiff ',char(image_folder),'V_MS5'])

bed_bin_number=63;

figure(501)
clf
imagesc([-120:840].*.5/60,-r5(bed_bin_number)+r5(1:bed_bin_number-1),SerMagmmpersec(283:1243,1:bed_bin_number-1)'./1000)% plot image with t=0 at MS1 arrival and aligned to bed
caxis(caxisrange)
axis(axisrange_bedaligned) 
xlabel('Time (hours)')
ylabel({'Height above bed (m)'})    
title('MS5')
colormap(jet)
colorbar
set(gcf,'PaperPositionMode','auto');%set print ratio to window size
set(gca,'YTickLabel',-1*str2num(char(get(gca,'YTickLabel'))))%reverse the axis number polarity
% line([(481-429).*.5/60 (481-429).*.5/60],[-70 0],'color','black','Linewidth',1)
% line([(481-429+36).*.5/60 (481-429+36).*.5/60],[-70 0],'color','black','Linewidth',1)
eval(['print -dtiff ',char(image_folder),'V_MS5_relative_to_bed'])

%BIN300%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eval(['load ',char(data_location_folder),'Monterey_300kHz_BIN300_FirstDeployment_Jan15'])
SerMagmmpersec(SerMagmmpersec<-9999)=NaN;%overwrite bad values with NaN

figure(6)
clf
imagesc([-360:2520]./(6*60),-rb300,SerMagmmpersec(607:3487,:)'./1000)% plot image with t=0 at MS1 arrival
caxis(caxisrange)
axis([-1 7 -72 0]) 
xlabel('Time (hours)')
ylabel({'Range below','transducers (m)'})    
title('BIN 300')
colormap(jet)
colorbar
set(gcf,'PaperPositionMode','auto');%set print ratio to window size
set(gca,'YTickLabel',-1*str2num(char(get(gca,'YTickLabel'))))%reverse the axis number polarity
eval(['print -dtiff ',char(image_folder),'V_BIN300'])

figure(601)
clf
imagesc([-360:2520]./(6*60),-rb300(end)+rb300(1:end),flipud(SerMagmmpersec(607:3487,1:end)'./1000))% plot image with t=0 at MS1 arrival and aligned to bed
caxis(caxisrange)
axis(axisrange_bedaligned) 
xlabel('Time (hours)')
ylabel({'Height above bed (m)'})    
title('BIN 300')
colormap(jet)
colorbar
set(gcf,'PaperPositionMode','auto');%set print ratio to window size
set(gca,'YTickLabel',-1*str2num(char(get(gca,'YTickLabel'))))%reverse the axis number polarity
line([(1441-607+11)/360 (1441-607+11)/360],[-72 0],'color','black','Linewidth',1)
line([(1441-607+13)/360 (1441-607+13)/360],[-72 0],'color','black','Linewidth',1)
axis([-1 7 -70 0]) 
eval(['print -dtiff ',char(image_folder),'V_BIN300_relative_to_bed'])

%MS7%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eval(['load ',char(data_location_folder),'Monterey_300kHz_MS7_FirstDeployment_Jan15'])
SerMagmmpersec(SerMagmmpersec<-9999)=NaN;%overwrite bad values with NaN

figure(7)
clf
imagesc([-120:840].*.5/60,r7,SerMagmmpersec(200:1160,:)'./1000)% plot image with t=0 at MS1 arrival
caxis(caxisrange)
axis(axisrange) 
xlabel('Time (hours)')
ylabel({'Range below','transducers (m)'})    
title('MS7')
colormap(jet)
colorbar
set(gcf,'PaperPositionMode','auto');%set print ratio to window size
eval(['print -dtiff ',char(image_folder),'V_MS7'])

bed_bin_number=72;

figure(701)
clf
imagesc([-120:840].*.5/60,-r7(bed_bin_number)+r7(1:bed_bin_number-1),SerMagmmpersec(200:1160,1:bed_bin_number-1)'./1000)% plot image with t=0 at MS1 arrival and aligned to bed
caxis(caxisrange)
axis(axisrange_bedaligned) 
xlabel('Time (hours)')
ylabel({'Height above bed (m)'})    
title('MS7')
colormap(jet)
colorbar
set(gcf,'PaperPositionMode','auto');%set print ratio to window size
set(gca,'YTickLabel',-1*str2num(char(get(gca,'YTickLabel'))))%reverse the axis number polarity
eval(['print -dtiff ',char(image_folder),'V_MS7_relative_to_bed'])

