%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% 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
    
  set( ctdFig1, 'name', 'CTD data', ...
       'DeleteFcn', 'clear ctdFig1' );
  set(gcf,'position',position)
  clf

    subplot(3,1,1)
    [xx,yy] = stairs( ctdlog(:,m_present_time), ctdlog(:,conductivity));
    plot(xx,yy);
    ylabel('S/m')
    title(['Conductivity',str]);
    grid on
    zoom on

    subplot(3,1,2)
    [xx,yy] = stairs( ctdlog(:,m_present_time), ctdlog(:,temperature));
    plot(xx,yy);
    ylabel('Degrees Celsius')
    title(['Temperature',str]);
    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')
    title(['Depth',str]);
    grid on
    zoom on
    
    
    
  if exist( 'ctdFig2' ) ~= 1
      ctdFig2 = figure;
  else 
      figure( ctdFig2 ); 
  end
    
  set( ctdFig2, 'name', 'O2 & OBS data', ...
       'DeleteFcn', 'clear ctdFig2' );
  set(gcf,'position',position)
  clf

    subplot(3,1,1)
    [xx,yy] = stairs( ctdlog(:,m_present_time), ctdlog(:,dissolvedO2));
    plot(xx,yy);
    ylabel('Volts')
    title(['Dissolved Oxygen',str]);
    grid on
    zoom on

    subplot(3,1,2)
    [xx,yy] = stairs( ctdlog(:,m_present_time), ctdlog(:,OBS));
    plot(xx,yy);
    ylabel('Volts')
    title(['Optical Backscatter',str]);
    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')
    title(['Depth',str]);
    grid on
    zoom on
    

  if exist( 'flowMeter' ) == 1
      
    if exist( 'ctdFig3' ) ~= 1
       ctdFig3 = figure;
    else 
       figure( ctdFig3 ); 
    end
    
    set( ctdFig3, 'name', 'Flow Meter', ...
       'DeleteFcn', 'clear ctdFig3' );
    set(gcf,'position',position)
    clf

    subplot(3,1,1)
    [xx,yy] = stairs( ctdlog(:,m_present_time), ctdlog(:,flowMeter));
    plot(xx,yy);
    ylabel('Volts')
    title(['Flow',str]);
    grid on
    zoom on

    subplot(3,1,2)
    [xx,yy] = stairs( ctdlog(:,m_present_time), ctdlog(:,OBS));
    plot(xx,yy);
    ylabel('Volts')
    title(['Optical Backscatter',str]);
    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')
    title(['Depth',str]);
    grid on
    zoom on

  else
    disp ' Flow meter data not present.'  
    
  end