% plottemp plots the ADCP mean and last transducer temperatures vs. time
%
% Input:  text file (output of lst_temp program) with following columns:
%         1) profile time (in decimal days)
%         2) mean transducer temperature
%         3) last transducer temperature
% Output: PostScript file plottemp.ps
% Usage:  1) Edit the file plottemp.m to specify the input parameters
%         2) In Matlab, type 'plottemp'
%

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

t0 = '';
t1 = 'EXEC[dbinfo [ADCP:DBPATH]/[DBNAME] -b [BLK] bt1]';

% DOC[PARAMETERS]{

infile = '[[BLK]:LST_TEMP:ASC:00:OUT]';
plot_title = '[PROJECT]-[AREA]-ADCP-[DBNAME]-[BLK]: Transducer T from ADCP ( EXEC[dbinfo -d [ADCP:DBPATH]/[DBNAME] -b [BLK] btr] )';
xaxis_label = '[YEAR_BASE] decimal days';

% }DOC[PARAMETERS]
% <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end editing <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
orient tall;
clf
yaxis_label = 'deg C';

[t, mn_temp, last_temp, snd_spd_used] = read_asc(infile);

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

n = length(t);
%axis([t(1) t(n) -10 40])
plot(t, mn_temp, '--', t, last_temp, '.')
xlabel(xaxis_label)
ylabel(yaxis_label)
grid
title(plot_title)
%show below only if axes are not auto-scaled:
%igood = find(~isnan(mn_temp));
%if ~isempty(igood)
%   text(0, 0.01, ...
%      ['Mean Temp. Range = ' num2str(min(mn_temp(igood))) ' to ' num2str(max(mn_temp(igood)))], 'sc')
%end
%igood = find(~isnan(last_temp));
%if ~isempty(igood)
%   text(0, 0.04, ...
%      ['Last Temp. Range = ' num2str(min(last_temp(igood))) ' to ' num2str(max(last_temp(igood)))], 'sc')
%end
%
print plottemp.ps

