%plotOcCTD.m
%
%Program which takes all of the CTD data saved in the file "oc_ctd_mat" from 
%the Oceanus cruise and plots the various parameters of T, S, Sigma T,
%beam attenuation, optical backscatter, and fluorescence.
%
%Soupy Alexander, 03/26/02

load C:\NewYork\NewYorkCD\Data_Files\CTD_Data\Mat_Files\oc_ctd_mat

%Set up the plot parameters
Tlimits = [6 16];
Tdelim = [6:2:16];
Slimits = [26 36];
Sdelim = [26:2:36];
Siglimits = [18 28];
Sigdelim = [18:2:28];
ATlimits = [0 5];
ATdelim = [0:1:5];
OBSlimits = [0 100];
OBSdelim = [0:20:100];
Flimits = [0 10];
Fdelim = [0:2:10];
depthlimits = [0 100];

color_list = ['r';'y';'g';'b';'m';'r';'y';'g';'b';'m';];
color_list = [color_list; color_list; color_list; color_list;];

for index = 1:39;
    
    cast = evalin('base',['ctd' num2str(index,'%02d') 'b']);
    
    %Plot the salinity, temperature, and sigma T on one plot
    figure(index*2-1)
    
    %Temperature
    T = plot(cast(:,7),cast(:,17));
    axis ij
    Taxis = gca;
    xlabel('Temperature (^oC)')
    ylabel('Depth (m)')
    set(Taxis,'xlim',Tlimits);
    set(Taxis,'ylim',depthlimits);
    set(Taxis,'xtick',Tdelim);
    set(Taxis,'xcolor','b');
    set(Taxis,'fontsize',12);
    set(Taxis,'xaxislocation','top')
    grid on
    
    %Salinity
    Saxis = axes('Position',get(Taxis,'Position'));
    S = plot(cast(:,9),cast(:,17),'r')
    xlabel('Salinity (o/oo)')
    axis ij
    set(Saxis,'xlim',Slimits);
    set(Saxis,'ylim',depthlimits);
    set(Saxis,'xtick',Sdelim);
    set(Saxis,'xcolor','r');
    set(Saxis,'Color','none')
    set(Saxis,'fontsize',12);
    grid on
    
    %SigmaT
    Sigaxis = axes('Position',get(Taxis,'Position'));
    Sig = plot(cast(:,14),cast(:,17))
    set(Sig,'color',[0.2 0.7 0.6])
    xlabel('Sigma T (mg/cm^3)')
    axis ij
    set(Sigaxis,'xlim',Siglimits);
    set(Sigaxis,'ylim',depthlimits);
    set(Sigaxis,'xtick',Sigdelim);
    set(Sigaxis,'xcolor',[0.2 0.7 0.6]);
    set(Sigaxis,'Color','none')
    set(Sigaxis,'fontsize',12);
    grid on
    
    titlename = ['oc' num2str(index,'%02d') '_TSSig'];
    title(titlename)
    command = ['print -depsc ' num2str(titlename)];
    evalin('base',command)
    
    %Add each cast to a waterfall plot of the data of all stations
    figure(100)
    hold on
    T = plot(cast(:,7),cast(:,17),color_list(index));
    Taxis = gca;
    axis ij
    xlabel('Temperature (^oC)')
    ylabel('Depth (m)')
    set(Taxis,'xlim',Tlimits);
    set(Taxis,'ylim',depthlimits);
    set(Taxis,'xtick',Tdelim);
    set(Taxis,'fontsize',12);
    grid on
    title('Temperature, All Casts, Oceanus Cruise')
    print -depsc oc_T_wfall
    
    figure(101)
    hold on
    S = plot(cast(:,9),cast(:,17),color_list(index))
    Saxis = gca;
    xlabel('Salinity (o/oo)')
    ylabel('Depth (m)')
    title('Salinity, All Casts, Oceanus Cruise')
    axis ij
    set(Saxis,'xlim',Slimits);
    set(Saxis,'ylim',depthlimits);
    set(Saxis,'xtick',Sdelim);
    set(Saxis,'fontsize',12);
    grid on
    print -depsc oc_S_wfall
    
    figure(102)
    hold on
    Sig = plot(cast(:,14),cast(:,17),color_list(index))
    Sigaxis = gca;
    xlabel('Sigma T (mg/cm^3)')
        ylabel('Depth (m)')
    title('Sigma T, All Casts, Oceanus Cruise')
    axis ij
    set(Sigaxis,'xlim',Siglimits);
    set(Sigaxis,'ylim',depthlimits);
    set(Sigaxis,'xtick',Sigdelim);
    set(Sigaxis,'fontsize',12);
    grid on    
    print -depsc oc_Sig_wfall
    
    %Plot Beam Attenuation, backscatter, and flouresencse
    
    figure(index*2)
    
    ATTN = -4*log((cast(:,16)./100));
    
    %Beam attenuation
    AT = plot(ATTN,cast(:,17))
    xlabel('Beam Attenuation (m^-1)')
    ylabel('Depth (m)')
    axis ij
    ATaxis = gca;
    set(ATaxis,'xlim',ATlimits);
    set(ATaxis,'ylim',depthlimits);
    set(ATaxis,'xtick',ATdelim);
    set(ATaxis,'xcolor','b');
    set(ATaxis,'fontsize',12);    
    set(ATaxis,'xaxislocation','top')
    grid on

    
    %fluorescence
    Faxis = axes('Position',get(ATaxis,'Position'));
    F = plot(cast(:,15),cast(:,17),'r')
    xlabel('Fluorescence')
    axis ij
    set(Faxis,'xlim',Flimits);
    set(Faxis,'ylim',depthlimits);
    set(Faxis,'xtick',Fdelim);
    set(Faxis,'xcolor','r');
    set(Faxis,'Color','none')   
    set(Faxis,'fontsize',12);
    
        %OBS
    OBSaxis = axes('Position',get(ATaxis,'Position'));
    OBS = plot(cast(:,11)*100,cast(:,17));
    set(OBS,'color',[0.2 0.7 0.6])
    xlabel('Optical Backscatter (mV)')
    axis ij
    set(OBSaxis,'xlim',OBSlimits);
    set(OBSaxis,'ylim',depthlimits);
    set(OBSaxis,'xtick',OBSdelim);
    set(OBSaxis,'xcolor',[0.2 0.7 0.6]);
    set(OBSaxis,'Color','none')
    set(OBSaxis,'fontsize',12);
    grid on
    
    titlename = ['oc' num2str(index,'%02d') '_OPT'];
    title(titlename)
    command = ['print -depsc ' num2str(titlename)];
    evalin('base',command)
    grid on
    
    figure(104)
    hold on
    AT = plot(ATTN,cast(:,17),color_list(index))
    xlabel('Beam Attenuation (m^-1)')
    ylabel('Depth (m)')
    title('Beam Attenuation, All Casts, Oceanus Cruise')
    axis ij
    ATaxis = gca;
    set(ATaxis,'xlim',ATlimits);
    set(ATaxis,'ylim',depthlimits);
    set(ATaxis,'xtick',ATdelim);
    set(ATaxis,'fontsize',12);    
    set(ATaxis,'xaxislocation','top')
    grid on
    print -depsc oc_AT_wfall
    
    figure(105)
    hold on
    F = plot(cast(:,15),cast(:,17),color_list(index))
    Faxis = gca;
    xlabel('Fluorescence')
    ylabel('Depth (m)')
    title('Fluorescence, All Casts, Oceanus Cruise')
    axis ij
    set(Faxis,'xlim',Flimits);
    set(Faxis,'ylim',depthlimits);
    set(Faxis,'xtick',Fdelim); 
    set(Faxis,'fontsize',12);
    grid on
    print -depsc oc_F_wfall
    
    figure(110)
        %OBS
        hold on
    OBS = plot(cast(:,11)*100,cast(:,17),color_list(index))
    OBSaxis = gca;
    xlabel('Optical Backscatter (mV)')
    ylabel('Depth (m)')
    title('Optical Backscatter, All Casts, Oceanus Cruise')
    axis ij
    set(OBSaxis,'xlim',OBSlimits);
    set(OBSaxis,'ylim',depthlimits);
    set(OBSaxis,'xtick',OBSdelim);
    set(OBSaxis,'fontsize',12);
    grid on
    print -depsc oc_OBS_wfall
    
end