%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% PURPOSE: Plot raw CTD data from dual CTDs
% AUTHOR:  Initial; rsm; nst
% DATE:    99/12/14
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Units and Fundamental Constants:
  units

  str = [' ',titleStr, ' ',myDate];
  PaperPosn = [.5 .5 3.75 2.5];
  FigurePosn = [5 30 815 760];
  i = 0;
  if exist( 'ctdFig1' ) ~= 1
      ctdFig1 = figure;
  else 
      figure( ctdFig1 ); 
  end
  
  
  if (exist('cond2') == 1)
     if (min(cond1) > min(cond2))
        condmin = (min(cond2))-0.2;
     else
        condmin = (min(cond1))-0.2;
     end
     if (max(cond1) > max(cond2))
        condmax = (max(cond1))+0.2;
     else
        condmax = (max(cond2))+0.2;
     end
     condax = [condmin condmax];
  else
     condax = [(min(cond1)-0.2) (max(cond1)+0.2)];
  end
  
  if (exist('temp1') == 1)
   tempax = [floor(min(temp1)) ceil(max(temp1))];
  end

  
  set( ctdFig1, 'name', 'CTD1 data', ...
       'DeleteFcn', 'clear ctdFig1' );
  set(gcf,'position',position)
  clf

    subplot(3,1,1)
    [xx,yy] = stairs(time1,cond1);
    plot(xx,yy);
    ylabel('S/m')
    title(['Conductivity 1',str]);
    set(gca,'Ylim',condax);
    grid on
    zoom on

    subplot(3,1,2)
    [xx,yy] = stairs(time1,temp1);
    plot(xx,yy);
    ylabel('Degrees Celsius')
    title(['Temperature 1',str]);
    set(gca,'Ylim',tempax);
    grid on
    zoom on

    subplot(3,1,3)
 if ( exist('dataNav') == 1 )
    [xx,yy] = stairs( dataNav(:,m_present_time), dataNav(:,mDepth));
    plot(xx,yy);
 end
    set( gca, 'ydir', 'reverse' );
    ylabel('Meters')
    xlabel('Time (s)')
    title(['Depth',str]);
    grid on
    zoom on
   
if (exist('cond2') == 1)
  if exist( 'ctdFig2' ) ~= 1
      ctdFig2 = figure;
  else 
      figure( ctdFig2 ); 
  end
    
  set( ctdFig2, 'name', 'CTD2 data', ...
       'DeleteFcn', 'clear ctdFig2' );
  set(gcf,'position',position)
  clf

    subplot(3,1,1)
    [xx,yy] = stairs(time2,cond2);
    plot(xx,yy);
    ylabel('S/m')
    title(['Conductivity 2',str]);
    set(gca,'Ylim',condax);
    grid on
    zoom on

    subplot(3,1,2)
    [xx,yy] = stairs(time2,temp2);
    plot(xx,yy);
    ylabel('Degrees Celsius')
    title(['Temperature 2',str]);
    set(gca,'Ylim',tempax);
    grid on
    zoom on

    subplot(3,1,3)
 if ( exist('dataNav') == 1 )
    [xx,yy] = stairs( dataNav(:,m_present_time), dataNav(:,mDepth));
    plot(xx,yy);
 end
    set( gca, 'ydir', 'reverse' );
    ylabel('Meters')
    xlabel('Time (s)')
    title(['Depth',str]);
    grid on
    zoom on
end
    
    
  if exist( 'ctdFig3' ) ~= 1
      ctdFig3 = figure;
  else 
      figure( ctdFig3 ); 
  end
    
  set( ctdFig3, 'name', 'O2 & OBS data', ...
       'DeleteFcn', 'clear ctdFig3' );
  set(gcf,'position',position)
  clf

  if (exist('oxygen') == 1 )
    subplot(3,1,1)
    [xx,yy] = stairs(time1,oxygen);
    plot(xx,yy);
    ylabel('Volts')
    title(['Dissolved Oxygen',str]);
    grid on
    zoom on
  end
    
  if (exist('obs') == 1 )
    subplot(3,1,2)
    [xx,yy] = stairs(time1,obs);
    plot(xx,yy);
    ylabel('Volts')
    title(['Optical Backscatter',str]);
    grid on
    zoom on
  end
    
    subplot(3,1,3)
 if ( exist('dataNav') == 1 )
    [xx,yy] = stairs( dataNav(:,m_present_time), dataNav(:,mDepth));
    plot(xx,yy);
 end
    set( gca, 'ydir', 'reverse' );
    ylabel('Meters')
    xlabel('Time (s)')
    title(['Depth',str]);
    grid on
    zoom on
    

  if ((exist( 'flowsensor1' ) == 1) | (exist('humidity') == 1))
    if exist( 'ctdFig4' ) ~= 1
       ctdFig4 = figure;
    else 
       figure( ctdFig4 ); 
    end
    
    set( ctdFig4, 'name', 'Flow Meter 1 & Humidity', ...
       'DeleteFcn', 'clear ctdFig4' );
    set(gcf,'position',position)
    clf

  if (exist('flowsensor1') == 1 )
    subplot(3,1,1)
    [xx,yy] = stairs(time1, flowsensor1);
    plot(xx,yy);
    ylabel('Volts')
    title(['Flow 1',str]);
    grid on
    zoom on
  end

  if (exist('humidity') == 1 )
    subplot(3,1,2)
    [xx,yy] = stairs(time1,humidity);
    plot(xx,yy);
    ylabel('Volts')
    title(['Humidity',str]);
    grid on
    zoom on
  end

    subplot(3,1,3)
    if ( exist('dataNav') == 1 )
       [xx,yy] = stairs( dataNav(:,m_present_time), dataNav(:,mDepth));
       plot(xx,yy);
    end
    set( gca, 'ydir', 'reverse' );
    ylabel('Meters')
    xlabel('Time (s)')
    title(['Depth',str]);
    grid on
    zoom on
  end
  
  
    if (exist( 'flowsensor2' ) == 1)
    if exist( 'ctdFig5' ) ~= 1
       ctdFig5 = figure;
    else 
       figure( ctdFig5 ); 
    end
    
    set( ctdFig5, 'name', 'Flow Meter 2', ...
       'DeleteFcn', 'clear ctdFig5' );
    set(gcf,'position',position)
    clf

  if (exist('flowsensor2') == 1 )
    subplot(3,1,1)
    [xx,yy] = stairs(time2, flowsensor2);
    plot(xx,yy);
    ylabel('Volts')
    title(['Flow 2',str]);
    grid on
    zoom on
  end

    subplot(3,1,2)
    if ( exist('dataNav') == 1 )
       [xx,yy] = stairs( dataNav(:,m_present_time), dataNav(:,mDepth));
       plot(xx,yy);
    end
    set( gca, 'ydir', 'reverse' );
    ylabel('Meters')
    xlabel('Time (s)')
    title(['Depth',str]);
    grid on
    zoom on
  end