%peter.m

%NOTE: don't forget to make the "make104_...._image.m files

clear all; close all;

colormap(cmap(1,100));         % make color map for -80 to -55 dB when
colmap=colormap;              % datrange = 1e-4 to 1e-8
%colmap=[colmap;ones(10,3)];   % add white for range -55 to -50dB
m=32;
g=[12:m-1]'/max(m-1,1);
g=1-g;
g=[g g g];
colmap=[colmap;g];            % add gray-scale for range -55 to -45dB
colmap=[colmap;zeros(20,3)];  % add black for range -45 to -40dB
colormap(colmap);
save colmap colmap -ascii
% datrange= max and min values for 10log(sv) data (Albatross IV data series)
datrange =[10*log10(1e-4) 10*log10(1e-10)]; %this sets range of color bar.
clegend5(datrange,'SV',.87);

filename='nbp103_119';
load (filename);

[r,c]=size(sv_1(:,8:end));

nplot=4;

ic=1;
bottom = 0.1; % start of bottom plot - window 0,0 to 1.0,1.0
left = 0.1;
step = 0.2;

%%start here to move code to plotting program
emat=sv_4;

%find zero values of volume backscattering and set equal to 1.01e-10
dd=0;
if dd==0
    lerow=length(emat(1,:))-7;
numrow=length(emat(:,1));
tmpcol=reshape(emat(:,8:length(emat(1,:))),lerow*numrow,1);
ifnd=find(tmpcol(:,1)==0);
te=ones(size(ifnd)).*(1.01e-10);
 if ifnd >0 
    tmpcol(ifnd,1)=te;
 end
 emat(:,8:length(emat(1,:))) = reshape(tmpcol,numrow,lerow);
end
%end find routine

for ic = 1:nplot    

img = emat(:,8:407)';
img = 10*log10(img);
yaxlab=(0:1:399);

xaxlab = sv_4(1:max(r),1);

% Compute width of plot
trandist = emat(1:length(emat(:,1)),1); %trandist = time in unit steps
  labelx='Time (year day)';
  mintime=min(emat(:,1));
  maxtime=max(emat(:,1));
  elapsetime=(maxtime-mintime)*24*60; % time of transect in minutes
  tscale=elapsetime/(24*60); % elapsetime in min divided by minutes in a day
  %scale horizontal axis of plot when plotting distance as time
width=((max(trandist)-min(trandist))/tscale)*.87;
%%%end 


depthint= emat(1,7);
yint=400;
maxdepth=399;
height=(yint*depthint/maxdepth)*step-.05; % scale height of plot


set(gcf,'units','normalized');

plax(ic)=axes('position', [left bottom .85*width height]);
set(gca,'drawmode','fast');

%%%%subplot(4,1,1)
clim=[-100 -40];
imagesc(xaxlab,yaxlab,img,clim);

xlabel('time(yrday)');
ylabel('depth(m)');

hold on;

%%%%%set(gca,'clim',[-100 -43]);   %This is to use same color scale for
%%%%%same channel day to day  -- get away from auto scaling

text(119.7, 521.664, '420 Khz','color','w','fontsize',[4]);
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

ic=2;
bottom = bottom+step;
emat=sv_3;

%find zero values of volume backscattering and set equal to 1.01e-10
dd=0;
if dd==0
    lerow=length(emat(1,:))-7;
numrow=length(emat(:,1));
tmpcol=reshape(emat(:,8:length(emat(1,:))),lerow*numrow,1);
ifnd=find(tmpcol(:,1)==0);
te=ones(size(ifnd)).*(1.01e-10);
 if ifnd >0 
    tmpcol(ifnd,1)=te;
 end
 emat(:,8:length(emat(1,:))) = reshape(tmpcol,numrow,lerow);
end
%end find routine

for ic = 1:nplot    
img = emat(:,8:407)';
img = 10*log10(img);
yaxlab=(0:1:399);

xaxlab = sv_3(1:max(r),1);

% Compute width of plot
trandist = emat(1:length(emat(:,1)),1); %trandist = time in unit steps
  labelx='Time (year day)';
  mintime=min(emat(:,1));
  maxtime=max(emat(:,1));
  elapsetime=(maxtime-mintime)*24*60; % time of transect in minutes
  tscale=elapsetime/(24*60); % elapsetime in min divided by minutes in a day
  %scale horizontal axis of plot when plotting distance as time
width=((max(trandist)-min(trandist))/tscale)*.87;
%%%end 


depthint= emat(1,7);
yint=400;
maxdepth=399;
height=(yint*depthint/maxdepth)*step-.05; % scale height of plot


set(gcf,'units','normalized');

plax(ic)=axes('position', [left bottom .85*width height]);
set(gca,'drawmode','fast');

%%%%subplot(4,1,1)
clim=[-100 -40];
imagesc(xaxlab,yaxlab,img,clim);
hold on;

%%%%%set(gca,'clim',[-100 -43]);   %This is to use same color scale for
%%%%%same channel day to day  -- get away from auto scaling

text(119.7, 521.664, '200 Khz','color','w','fontsize',[4]);
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

ic=3;
bottom = bottom+step;
emat=sv_2;

%find zero values of volume backscattering and set equal to 1.01e-10
dd=0;
if dd==0
    lerow=length(emat(1,:))-7;
numrow=length(emat(:,1));
tmpcol=reshape(emat(:,8:length(emat(1,:))),lerow*numrow,1);
ifnd=find(tmpcol(:,1)==0);
te=ones(size(ifnd)).*(1.01e-10);
 if ifnd >0 
    tmpcol(ifnd,1)=te;
 end
 emat(:,8:length(emat(1,:))) = reshape(tmpcol,numrow,lerow);
end
%end find routine

for ic = 1:nplot    
img = emat(:,8:407)';
img = 10*log10(img);
yaxlab=(0:1.5:599);

xaxlab = sv_2(1:max(r),1);

% Compute width of plot
trandist = emat(1:length(emat(:,1)),1); %trandist = time in unit steps
  labelx='Time (year day)';
  mintime=min(emat(:,1));
  maxtime=max(emat(:,1));
  elapsetime=(maxtime-mintime)*24*60; % time of transect in minutes
  tscale=elapsetime/(24*60); % elapsetime in min divided by minutes in a day
  %scale horizontal axis of plot when plotting distance as time
width=((max(trandist)-min(trandist))/tscale)*.87;
%%%end 


depthint= emat(1,7);
yint=400;
maxdepth=599;
height=(yint*depthint/maxdepth)*step-.05; % scale height of plot


set(gcf,'units','normalized');

plax(ic)=axes('position', [left bottom .85*width height]);
set(gca,'drawmode','fast');

%%%%subplot(4,1,1)
clim=[-100 -40];
imagesc(xaxlab,yaxlab,img,clim);
hold on;

%%%%%set(gca,'clim',[-100 -43]);   %This is to use same color scale for
%%%%%same channel day to day  -- get away from auto scaling

text(119.7, 521.664, '120 Khz','color','w','fontsize',[4]);
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

ic=4;
bottom = bottom+step;
emat=sv_1;

%find zero values of volume backscattering and set equal to 1.01e-10
dd=0;
if dd==0
    lerow=length(emat(1,:))-7;
numrow=length(emat(:,1));
tmpcol=reshape(emat(:,8:length(emat(1,:))),lerow*numrow,1);
ifnd=find(tmpcol(:,1)==0);
te=ones(size(ifnd)).*(1.01e-10);
 if ifnd >0 
    tmpcol(ifnd,1)=te;
 end
 emat(:,8:length(emat(1,:))) = reshape(tmpcol,numrow,lerow);
end
%end find routine

for ic = 1:nplot    
img = emat(:,8:407)';
img = 10*log10(img);
yaxlab=(0:1.5:599);

xaxlab = sv_1(1:max(r),1);

% Compute width of plot
trandist = emat(1:length(emat(:,1)),1); %trandist = time in unit steps
  labelx='Time (year day)';
  mintime=min(emat(:,1));
  maxtime=max(emat(:,1));
  elapsetime=(maxtime-mintime)*24*60; % time of transect in minutes
  tscale=elapsetime/(24*60); % elapsetime in min divided by minutes in a day
  %scale horizontal axis of plot when plotting distance as time
width=((max(trandist)-min(trandist))/tscale)*.87;
%%%end 


depthint= emat(1,7);
yint=400;
maxdepth=600;
height=(yint*depthint/maxdepth)*step-.05; % scale height of plot


set(gcf,'units','normalized');

plax(ic)=axes('position', [left bottom .85*width height]);
set(gca,'drawmode','fast');

%%%%subplot(4,1,1)
clim=[-100 -40];
imagesc(xaxlab,yaxlab,img,clim);
hold on;

%%%%%set(gca,'clim',[-100 -43]);   %This is to use same color scale for
%%%%%same channel day to day  -- get away from auto scaling

text(119.7, 521.664, '43 Khz','color','w','fontsize',[4]);
end

title('nbp0103\_119')

print -djpeg nbp103_119_all.jpg