function [nt,dayfrac,jroav_wi,crit1,crit2] = get_wi_nc(Fname,ii,jj,ht1,ht2)

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

clear height
clear wi
clear crit2
clear crit1

    time=nc{'mtime'}(:);        % (day, ut_hour, ut_min)
    dayfrac=time(:,1)+time(:,2)/24.+time(:,3)/1440.;
%    clear time
% size(height)=[nt,29,36,72] (until num=37 when it is [29,36,72,1]????)
    height=nc{'ZG'}(:);
    lev=nc{'lev'}(:);
    wi=nc{'WI_VEL'}(:); 
    crit1=nc{'crit1'}(:);
    crit2=nc{'crit2'}(:);
    close(nc)
    
    clear nc

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

for it=1:nt
tem=0.;
nk = 0;
   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
 jroav_wi(it)=tem*0.01/nk;
end

    clear time

