Hi Charlie,

I ran into a little problem with the ADCP processing
software when we came up to the north flank.  Our survey
tracks reach out far enough (the 200m isobath) that we lose
bottom tracking.  When the bottom tracking goes out,
adcp4quoddy gets an error which prevents an .m3d file from
being generated.  As I understand it, one of the things that
interpbt_new.m is supposed to do is set the bottom depth to
Nan for each observation in which bottom tracking is not 
available.  What appears to be happening is that all of the
bottom depths are set to Nan if any record does not have
bottom tracking.  This occurs in the loop i=1:npiece:


for i = 1:npiece
  bt = bt_depth(p_start(i):p_end(i));
  igood = find(bt > 0 );
  ngood = length(igood);
  if ngood == length(bt)
    break;
  else
% Extrapolate the good depths at either end if necessary
    bt(1:igood(1)) = bt(igood(1))*ones(size(bt(1:igood(1))));
    .
    .
    .

    ed_bt(p_start(i):p_end(i)) = bt
  end
end


As I understand it, the command "break" exits the for-loop
altogether.  That means that if the all the bottom depths for
any segment are present, the program will escape the loop
and never execute the substitution 

ed_bt(p_start(i):p_end(i)) = bt

buried within it.

It seems to me what is needed here is a slightly different
structure.


for i = 1:npiece
  bt = bt_depth(p_start(i):p_end(i));
  igood = find(bt > 0 );
  ngood = length(igood);
%
% change here
%
  if ngood ~= length(bt)

%      Extrapolate the good depths at either end if necessary
       bt(1:igood(1)) = bt(igood(1))*ones(size(bt(1:igood(1))));
       .
       .
       .
%
% change here
%
    end

  ed_bt(p_start(i):p_end(i)) = bt;
 
end

If ngood==length(igood), then we just skip down
to fill ed_bt for that segment; otherwise we interpolate and 
then fill ed_bt.


I tried the new structure and it appears to work.  Would you
mind checking this over to see if it is right?

For your convenience I attach both versions of interpbt.

Thanks,

Dennis




