function [nt,dayfrac,ut,wiav] = get_wi_nc(Fname,ht1,ht2,jj)

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

clear height
clear wi

    time=nc{'mtime'}(:);        % (day, ut_hour, ut_min)
    dayfrac=time(:,1)+time(:,2)/24.+time(:,3)/1440.;
    ut=time(:,2)+time(:,3)/60.;
    height=nc{'ZG'}(:);
    wi=nc{'WI_ExB'}(:); 
    close(nc)
    
    clear nc

nt = length(dayfrac);
nz = 29;

for it=1:nt
for ii=1:72
tem=0.;
nk = 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 + wi(it,kk,jj,ii);
     nk = nk + 1;
    end
   end
% Convert from cm/s to m/s
 wiav(ii,it) = tem*0.01/nk;
 end
end

    clear time

