%% new weighting function

%%  Kriging Software Package  version 1.0 beta,   October 29, 1998
%%  Copyright (c) 1998, property of Dezhang Chu and Woods Hole Oceanographic
%%  Institution.  All Rights Reserved.


fid=fopen('varioweight.dat','w');
if model > 0
   fprintf(fid,' Index    Range(km)   Gamma(h)    Current Weight    New Weight\n');
else
   fprintf(fid,' Index    Range(km)   Cov(h)      Current Weight    New Weight\n');
end
totcnt=mean_nan(cnt)+sum_nan(cnt);
cwgt=cnt/totcnt;
for i=1:length(gammah)
   if model > 0
      fprintf(fid,'%5g %10g %12g %14g %16g\n',i,lag(i),gammah(i),cwgt(i),cwgt(i));
   else
      fprintf(fid,'%5g %10.4g %12.4g %14.4g %16.4g\n',i,lag(i),1-gammah(i),cwgt(i),cwgt(i));
   end
end
fclose(fid);
!medit varioweight.dat
fid=fopen('varioweight.dat','r');
nwgt=zeros(size(cwgt));
str1=fgetl(fid);
for i=1:length(gammah)
   strline=fgetl(fid);
   dat=str2num(strline);
   nwgt(i)=dat(5);
end
nwgt=nwgt/sum_nan(nwgt);
cnt=round(nwgt*totcnt);
fclose(fid);
disp('finish')
