function [At, Av] = boxave(T, V, points=50, limit=1)

  An = 1;
  Rold = limit;

  for i = points : points: length(V)

    R = range(V(i-points+1 : i));
    if ( R < limit )
      if ( R < Rold )
        At(An) = T(fix(i-points/2));
        Av(An) = mean(V(i-points+1 : i));
        Rold = R;
      endif
    else
      if (Rold < limit)
        An = An + 1;
      endif
      Rold = limit;
    endif
    
  endfor

endfunction
