%%comes from read_glatm.f

iGas = input('enter gas ID : ')
for iG = iGas:iGas
  for iP = 1 : 6

    if iP == 1
      fname = ['trp_gasID_' num2str(iG)];
    elseif iP == 2
      fname = ['mls_gasID_' num2str(iG)];
    elseif iP == 3
      fname = ['mlw_gasID_' num2str(iG)];
    elseif iP == 4
      fname = ['sas_gasID_' num2str(iG)];
    elseif iP == 5
      fname = ['saw_gasID_' num2str(iG)];
    elseif iP == 6
      fname = ['std_gasID_' num2str(iG)];
      end

    haha = load(fname);
    alt(:,iP)   = haha(:,2);
    press(:,iP) = haha(:,3);
    temp(:,iP)  = haha(:,4);
    amt(:,iP)   = haha(:,5);

    %%now output them in the format that Dave Edwards *ip files are in
    %%which is <hgt press temp ppmv idunno>
    fname2 = [fname '.ip'];
    fid = fopen(fname2,'w');
    [m,n] = size(haha);
    for ii = 1 : m
      vector = [haha(ii,2:5) -1234.5];
      fprintf(fid,'  %7.3e   %6.3e   %6.3f  %6.3e %6.3e \n',vector');
      end
    fclose(fid);
    end
  end

semilogy(temp,press); set(gca,'ydir','reverse'); grid
  legend('trp','mls','mlw','sas','saw','std',0); 
  title(['gasID = ' num2str(iG)])

semilogy(amt,press); set(gca,'ydir','reverse'); grid
  legend('trp','mls','mlw','sas','saw','std',0); 
  title(['gasID = ' num2str(iG)])

figure(2);
for ii = 1 : 6
  pahamt(:,ii) = interp1(log(press(:,ii)),amt(:,ii),log(press(:,6)));
  end
semilogy(pahamt(:,1:5)./(pahamt(:,6)*ones(1,5)),press(:,6)); 
set(gca,'ydir','reverse'); grid; title('ratio of profs1:5 to prof 6')
  legend('trp','mls','mlw','sas','saw','std',0);  

iP = 6; 
daveedwards = load('atm_md.ip');
figure(3);
dave1000  = interp1(log(daveedwards(:,2)),daveedwards(:,4),log(1000));
glatm1000 = interp1(log(press(:,iP)),amt(:,iP),log(1000));
subplot(121); 
   semilogy(daveedwards(:,4)*glatm1000/dave1000,daveedwards(:,2),'.-',...
            amt(:,iP),press(:,iP),'r.-');
subplot(122); 
   semilogy(daveedwards(:,3),daveedwards(:,2),'.-',...
            temp(:,iP),press(:,iP),'r.-');

figure(4); clf; 
for ii = 1 : 4
  if ii == 1 de = load('atm_md.ip'); end
  if ii == 1 de = load('atm_mn.ip'); end
  if ii == 1 de = load('atm_ps.ip'); end
  if ii == 1 de = load('atm_pw.ip'); end
  semilogy(daveedwards(:,4),daveedwards(:,2),de(:,4),de(:,2));
  if ii == 1
    hold on
    end
  end