
!rcp arm1:/home3/waynef/public_html/camexiii/archive/goes/*.cdf . 

[s,w] = unix('ls -1 *.cdf');
no_files = length(w)/13;
w=reshape(w,13,length(w)/13)';
w=w(:,1:12);


TPW = [];
NSS1970 = [];

fid=fopen('goes_values.asc','w');

for i = 1:no_files

  fname = w(i,:);

  [s,w2] = unix(['wc -l ' fname]);
  ind = findstr(w2,fname);
  eval(['filelength = ' w2(1:ind-1) ';'])
  if filelength ~= 0

    ret = rd_netcdf(fname);  

    for j = 1:length(ret.time_offset)
    
      time = datestr(dn(ret.base_time+ret.time_offset(j)));
      surftemp = ret.surfaceTemp(j,1);
      surfpres = ret.surfacePressure(j,1);
      surfheight = ret.surfaceAltitude(1);
      lat = ret.lat;
      lon = ret.lon;
      alt = ret.alt;
      ind=find(ret.Pressure >= 0);
      mr = dp2mr(ret.Pressure(ind)',ret.tdry(j,ind),ret.dp(j,ind))';
      tpw = pwv(ret.Pressure(ind),mr);

      TPW = [TPW tpw];
      NSS1970 = [NSS1970 ret.base_time+ret.time_offset(j)];
    
      arg1=integral(ret.alt(j,ind)',ret.Pressure(ind)./ret.tdry(j,ind)');
      arg2=integral(ret.alt(j,ind)',ret.Pressure(ind)./(ret.tdry(j,ind)'.^2));
      imt = arg1/arg2;
    
      fprintf(fid,'%s %10.3f %10.3f %10.3f %10.3f %10.3f\n',...
	    time,surfpres,surfheight,surftemp,tpw,imt);
      disp(sprintf('%s %10.3f %10.3f %10.3f %10.3f %10.3f',...
	    time,surfpres,surfheight,surftemp,tpw,imt))
      end
  end
end

fclose(fid);
     
goes.nss1970 = NSS1970;
goes.pwv = TPW;

save goes_values goes
