% Program that plots sections for various parameters
%Abaco Section
pressure=1:5700';
%load ab0409_db.mat
pot_temp_abaco=zeros(5700,30)*NaN;
sal_abaco=zeros(5700,30)*NaN;
sigma0_abaco=zeros(5700,30)*NaN;
oxygen_abaco=zeros(5700,30)*NaN;
%order=[20:31 33 32 34:40 42 41];
for i=1:30
   sta=i+1;
   lon(i)=cnv_dlp(sta).longitude;
   max_depth=find(cnv_dlp(sta).pressure==max(cnv_dlp(sta).pressure))
   prof(i)=max_depth-40;
   for j=1:max_depth
   pot_temp_abaco(j,i)=cnv_dlp(sta).thetapri(j);
   sal_abaco(j,i)=cnv_dlp(sta).salpri(j);
   oxygen_abaco(j,i)=cnv_dlp(sta).oxmllpri(j);
   sigma0_abaco(j,i)=cnv_dlp(sta).sigmapri(j);
   end
end
%Ploting the potential temperature

c_color=[1:9 11:14 16:19 21:40];
contourf(repmat(lon,5700,1),repmat(pressure',1,30),pot_temp_abaco,c_color)
colormap(cejet)
colorbar
hold on

c1=[1:9 11:14 16:19 21:40];
[C,h]=contour(lon,pressure',pot_temp_abaco,c1,'k');
axis([-77 -69 0 5700])
ax1=gca;
set(ax1,'FontSize',14,'ydir','reverse','XAxisLocation','top','Xtick',[-76 -75 -74 -73 -72],'XtickLabel',[]);
hold on
set(0,'DefaultTextFontSize',14);
text(-76.35,-260,'76^oW')
text(-75.35,-260,'75^oW')
text(-74.35,-260,'74^oW')
text(-73.35,-260,'73^oW')
text(-72.35,-260,'72^oW')
[C,h]=contour(lon,pressure',pot_temp_abaco,[10 15 20],'k');
clabel(C,h);
set(h,'LineWidth',2);
ylabel('Pressure (dbar)');
for t=1:length(prof)
    plot([lon(t) lon(t)],[0 prof(t)],'k--')
end
xlabel('Abaco Section')
ax2=gca;
set(ax2,'XAxisLocation','bottom');set(0,'DefaultTextFontSize',14);
[C,h]=contour(lon,pressure',pot_temp_abaco,[2 3 4 5],'k');
clabel(C,h);
set(h,'LineWidth',2);
patch([ lon -77 -77 -69.2 -69.2 ] ,[ prof-200 500 5700 5700 5500 ],'w','LineWidth',3);
ylabel('Pressure (dbar)');
text(-76.98,5200,'Potential Temperature [^{o}C]')
noaalogo([0.42 0.13 0.12 0.12])

figure
% Ploting the salinity
c_color=[34:0.1:38];
contourf(lon,pressure,sal_abaco,c_color)
colormap(cejet)
colorbar
hold on

csal1=34:0.01:35;
csal2=35:0.05:35.1;
csal3=35.1:0.1:38
[C,h]=contour(lon,pressure',sal_abaco,csal1,'k');
axis([-77 -71.9 0 5400])
ax1=gca;
set(ax1,'FontSize',14,'ydir','reverse','XAxisLocation','top','Xtick',[-76 -75 -74 -73 -72],'XtickLabel',[]);
hold on
set(0,'DefaultTextFontSize',14);
text(-76.35,-260,'76^oW')
text(-75.35,-260,'75^oW')
text(-74.35,-260,'74^oW')
text(-73.35,-260,'73^oW')
text(-72.35,-260,'72^oW')
for t=1:length(prof)
    plot([lon(t) lon(t)],[0 prof(t)],'k--')
end
xlabel('Abaco Section')
ax2=gca;
set(ax2,'XAxisLocation','bottom');set(0,'DefaultTextFontSize',14);
[C,h]=contour(lon,pressure',sal_abaco,csal2,'k');
[C,h]=contour(lon,pressure',sal_abaco,csal3,'k');
[C,h]=contour(lon,pressure',sal_abaco,[35 35.5 36 36.5],'k');
clabel(C,h,[35 35.5 36 36.5]);
set(h,'LineWidth',2)
patch([ lon -77 -77 -71.9 -71.9 ] ,[ prof-200 500 5400 5400 5200 ],'w','LineWidth',3);
ylabel('Pressure (dbar)');
text(-76.98,5200,'Salinity[psu]')
noaalogo([0.42 0.13 0.12 0.12])

figure
% Ploting the potential density
c_color=[22:0.1:28];
contourf(lon,pressure,sigma0_abaco,c_color)
colormap(cejet)
colorbar
hold on

cpd1=22:0.5:26;
cpd2=26:0.2:26.4;
cpd3=26.5:0.1:27.9;

[C,h]=contour(lon,pressure',sigma0_abaco,cpd1,'k');
axis([-77 -71.9 0 5400])
ax1=gca;
set(ax1,'FontSize',14,'ydir','reverse','XAxisLocation','top','Xtick',[-76 -75 -74 -73 -72],'XtickLabel',[]);
hold on
set(0,'DefaultTextFontSize',14);
text(-76.35,-260,'76^oW')
text(-75.35,-260,'75^oW')
text(-74.35,-260,'74^oW')
text(-73.35,-260,'73^oW')
text(-72.35,-260,'72^oW')
for t=1:length(prof)
    plot([lon(t) lon(t)],[0 prof(t)],'k--')
end
xlabel('Abaco Section')
ax2=gca;
set(ax2,'XAxisLocation','bottom');set(0,'DefaultTextFontSize',14);
[C,h]=contour(lon,pressure',sigma0_abaco,cpd2,'k');
[C,h]=contour(lon,pressure',sigma0_abaco,cpd3,'k');
[C,h]=contour(lon,pressure',sigma0_abaco,...
    [26.4 26.8 27.2 27.4],'k');
clabel(C,h);
[C,h]=contour(lon,pressure',sigma0_abaco,[26 27],'k');
clabel(C,h);
set(h,'LineWidth',2)
patch([ lon -77 -77 -71.9 -71.9 ] ,[ prof-200 500 5400 5400 5200 ],'w','LineWidth',3);
ylabel('Pressure (dbar)');
text(-76.98,5200,'Sigma0')
noaalogo([0.42 0.13 0.12 0.12])

% Ploting the oxygen
figure
c_color=[2:0.2:8];
contourf(lon,pressure,oxygen_abaco,c_color)
colormap(cejet)
colorbar
hold on

coxy1=2.1:0.1:2.9;
coxy2=3.1:0.2:3.9;
coxy3=4.1:0.2:8.0;

[C,h]=contour(lon,pressure',oxygen_abaco,coxy1,'k');
axis([-77 -71.9 0 5400])
ax1=gca;
set(ax1,'FontSize',14,'ydir','reverse','XAxisLocation','top','Xtick',[-76 -75 -74 -73 -72],'XtickLabel',[]);
hold on
set(0,'DefaultTextFontSize',14);
text(-76.35,-260,'76^oW')
text(-75.35,-260,'75^oW')
text(-74.35,-260,'74^oW')
text(-73.35,-260,'73^oW')
text(-72.35,-260,'72^oW')
for t=1:length(prof)
    plot([lon(t) lon(t)],[0 prof(t)],'k--')
end
xlabel('Abaco Section')
ax2=gca;
set(ax2,'XAxisLocation','bottom');set(0,'DefaultTextFontSize',14);
[C,h]=contour(lon,pressure',oxygen_abaco,coxy1,'k');
[C,h]=contour(lon,pressure',oxygen_abaco,coxy2,'k');
[C,h]=contour(lon,pressure',oxygen_abaco,coxy3,'k');
[C,h]=contour(lon,pressure',oxygen_abaco,[2 3 4 5],'k');
clabel(C,h);
set(h,'LineWidth',3)
ylabel('Pressure (dbar)')
patch([ lon -77 -77 -71.9 -71.9 ] ,[ prof-200 500 5400 5400 5200 ],'w','LineWidth',3);
text(-76.98,5200,'Dissolved Oxygen [ml/l]')
noaalogo([0.42 0.13 0.12 0.12])

