%  First try connect the points strategy...
clear all; close all;
load dataCTD; load dataN
otemp=ctdlog(:,temperature);

fix_temp_freq;

%  Replace the old with the new....

ctdlog(:, temp_frequency) = tft;

clear tft; clear tf; clear n;

% Compute depth in time-base of CTD data

ctd_depth = ctd_depth_prep(dataNav(:,1), dataNav(:,mDepth), ctdlog(:,1));

% Now compute pressure in dB from depth

dBar = sw_pres(ctd_depth, 36.8);  % Use 36.8 as latitude....

% Now compute temperature and conductivity using the correct coefficients

[temp,cond,mask] = ctd_freq_conv(dBar, ctdlog(:,cond_frequency), ctdlog(:,temp_frequency), 'day_old' );

ctdlog(:, temperature) = temp;

% clear temp;  clear cond; clear mask;

figure(1); clf; 
subplot(211); plot(otemp,'r'); hold on; 
title('Original Temperature'); ax=axis; 
subplot(212); plot(temp,'b'); title('Corrected'); axis(ax)
% keyboard
% save dataCTD OBS cond_frequency conductivity ctdlog fluor o2current o2temp pH spare temp_frequency temperature time
