% TSCAST - 
%
%    B. A. Moran, 04-Feb-1998

%    Copyright (C) 1995-1998
%    Massachussetts Institute of Technology
%    Sea Grant AUV Laboratory
%    $Id: waterv.m,v 1.1 1998/07/01 13:31:47 bamoran Exp $	

if exist( 'h_ts' ) ~= 1
    h_ts = figure;
    set( h_ts, 'Name', 'CTD Plot', 'DeleteFcn', 'clear h_ts' );
    if strcmp( computer, 'SGI' )
	winpos( [100+200*rand 100+100*rand 600 800] );
    end
else
    h_ts = figure(h_ts);
end

ind = find( data(:,m_depth) > 5 & finite(data(:,water_temp)) );

if isempty(ind)
    ind = find( data(:,m_depth) > 5 & finite(data(:,sbe_temp_freq)) );

    [temp,cond] = o2_ctpc( data(ind,m_pressure), data(ind,sbe_cond_freq), ...
	data(ind,sbe_temp_freq), 'xan0895' );

    salt = sw_salt(10*cond/sw_c3515, temp, 10*data(ind,m_pressure) );
    svel = sw_svel( salt, temp, 10*data(ind,m_pressure) );
    tscast( data(ind,m_depth), temp, salt, svel );
else
    salt = sw_salt(10*data(ind,water_cond)/sw_c3515, data(ind,water_temp), ...
	10*data(ind,m_pressure) );
    svel = sw_svel( salt, data(ind,water_temp), 10*data(ind,m_pressure) );
    tscast( data(ind,m_depth), data(ind,water_temp), salt, svel );
end

