function [nt,dayfrac,tnav,unav,vnav] = get_tuvw_nc(Fname,ht1,ht2,iin,jin,nij)

% open .nc file Fname
    nc=netcdf(Fname,'nowrite');

clear height
clear tn
clear un
clear vn
clear wn

    time=nc{'mtime'}(:);        % (day, ut_hour, ut_min)
    dayfrac=time(:,1)+time(:,2)/24.+time(:,3)/1440.;
    height=nc{'ZG'}(:);
    lev=nc{'lev'}(:);
    tn=nc{'TN'}(:);
    un=nc{'UN'}(:);
    vn=nc{'VN'}(:);
%   wn=nc{'WN'}(:); 
    close(nc)
    
    clear nc

nt = length(dayfrac);
nz = length(lev);

for it=1:nt
 for n=1:nij
  ii = iin(n);
  jj = jin(n);
tem=0.;
nk = 0;
temu = 0.;
temv = 0.;
% Find mean between ht1 and ht2 (in cm)
% Tn, Un, and composition are on midpts between ZG levels, but for a mean, this is not too important
   for kk=1:nz
    if (height(it,kk,jj,ii) >= ht1 & height(it,kk,jj,ii) <= ht2) 
     tem = tem + tn(it,kk,jj,ii);
     temu = temu + un(it,kk,jj,ii);
     temv = temv + vn(it,kk,jj,ii);
     nk = nk + 1;
    end
   end
 tnav(it,n) = tem/nk;
% Convert from cm/s to m/s
 unav(it,n)=temu*0.01/nk;
 vnav(it,n)=temv*0.01/nk;
 end
end

    clear time

