% um_add_vectors.m
% adds velocity vectors to a plot
% called from um_plot
% dim1==lon, dim2==lat; both are Ny by Nx arrays 
% or dim1 = x or y, dim2=z; both are Nz by Nx/Ny arrays

% set up scaling arrow
max_vect=25;
vec1_scale = [max_vect*ones(1,size(dim1,2))];
vec2_scale = zeros(1,size(dim1,2));
dy = (max(dim1(:,1)) - min(dim1(:,1)))/100;
dim1_scale = (min(dim1(:,1)) + 0.5*dy)*ones(1,size(dim1,2));
dim2_scale = min(dim2(1,:))*ones(1,size(dim1,2));

%set up index for plotting vectors; plot every nth vector
ii=[1:ivec:size(dim1,2)];
jj=[1:jvec:size(dim1,1)];
 
% plot vectors plus scaling vector
quiver([dim2(jj,ii); dim2_scale(ii)], [dim1(jj,ii); dim1_scale(ii)], ...
    [vec1(jj,ii); vec1_scale(ii)], [vec2(jj,ii); vec2_scale(ii)], 2, 'k');
text(dim2_scale(1), dim1_scale(1)-2*dy, [num2str(max_vect) ' m/s'],'Fontsize',8);
