%  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 >>>>>>>>>>>>>>>>>>>>
% DOC[PARAMETERS]{

ssp_file   = '[[BLK]:LSTSNDSP:ASC:00:OUT]';
plot_title = '[PROJECT]-[AREA]-ADCP-[DBNAME]-[BLK]: Speed of Sound at Transducer Depth';
year_base  = [YEAR_BASE];
const_ssp  = [ADCP:SOUND_SPEED];

% }DOC[PARAMETERS]
% <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 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

