%%-------------------------------------------------------------------------
%% 
%% plotssp.m -- 
%% 
%% Author          : Pierre Jaccard
%% Created On      : 1999/11/16 14:24:44
%% Last Modified By: Pierre Jaccard
%% Last Modified On: 1999/11/16 14:25:45
%% Update Count    : 1
%% Directory       : /pcdata1/jaccard/codas3c/gfi/matlab/matlab50/
%% Version         : 0.0
%% Status          : Unknown
%% --------------------------------------------------------------------- ++
%% DESCRIPTION: 
%% 
%%    Undocumented.
%% 
%% --------------------------------------------------------------------- ++
%% REVISIONS: 
%% --------------------------------------------------------------------- ++
%% CHANGES: 
%%-------------------------------------------------------------------------

%  1.  NAME
%
%  plotssp - Plot corrected speed of sound
%
%  2.  USAGE
%
%  plotssp
%
%  3.  DESCRIPTION
%
%  This Matlab scripts makes a plot of the speed of sound vs. time. The
%  input file must contain the following columns:
%
%  1. Profile time in decimal days
%
%  2. Speed of sound
%
%  4.  PARAMETERS
%
%  The following parameters must be edited:
%
%     ssp_file
%        Name of input data file.
%
%     plot_title
%        Title for plot.
%
%     year_base
%        Base year used in input file.
%
%     const_ssp
%        Constant speed of sound used. Since all VM-ADCP encountered
%        until now are not equipped with a CTD,I dont configure the
%        aquisiton software for speed of sound correction as a function
%        of temperature',but use a contsant value.  Corrections are
%        carried out during post-processing,together with CTD data.  This
%        constant value will be plotted together with the speed of sound.
%
%  5.  FILES
%
%  o  plotssp.ps
%
%  6.  AUTHORS
%
%  Pierre Jaccard, Geophysical Institute, University of Bergen, 1999
%

% >>>>>>>>>>>>>>>>>>>> user must edit the following lines >>>>>>>>>>>>>>>>>>>>

ssp_file   = 'ssp.asc';
plot_title = 'VEINS-SVINOY-001: Speed of Sound at Transducer Depth';
year_base  = 1998;
const_ssp  = 1500;

% <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end editing <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
orient tall;
clf;

[t_s, ssp] = read_asc(ssp_file);

% NaN-out missing values (coded as BADFLOAT = 1e38):
ssp = tonan(ssp);

% Choose the time axis:
t = t_s;

time1 = to_date(year_base, t(1), 'string');
time2 = to_date(year_base, t(length(t)), 'string');
xaxis_label = sprintf('%4d decimal days (from %s to %s)', ...
		year_base, time1, time2);

cssp = [];
if const_ssp,
	cssp = [ const_ssp, const_ssp ];
	tssp = [ t(1), t(length(t)) ];
end

hold on;
plot(t, ssp, '-')
if cssp,
	plot(tssp, cssp, '-o')
end

xlabel(xaxis_label)
ylabel('Speed of Sound [m/s]')
grid
title(plot_title)

print plotssp.ps

