% clustcmd -s -n 17 27 '/usr/local/bin/matlabR14.2 -nojvm -nodisplay < 
% /home/sergio/KCARTADATA/NLTE/UA/loop_background_Sept05_clustcmd.m  >
% /airs/s1/sergio/nltelogfileUA 2>&1 &' 

%path(path,'/home/sergio/KCARTADATA/General/NLTE/');
path(path,'/home/sergio/KCARTADATA/NLTE/UA'); 

%cd /home/sergio/KCARTADATA/General/NLTE/
cd /home/sergio/KCARTADATA/NLTE/UA 

airs_nodes_co2back;

homedir = pwd;

clear toptsRMV topts

topts.RemoveSomeBands = +1; 
toptsRMV.iKCBand = [2310 2311 2320 2321 2350 2351 2352 2353 2354 2355]; 
toptsRMV.iISO =    [   1    2    1    2    1    2    3    1    1    4];   
toptsRMV.iL =      [   4    4    2    2    1    1    1    3    5    1]; 
toptsRMV.iU =      [  24   24   16   16    9    9    9   23   25    9]; 
 
toptsRMV.iKCBand = [toptsRMV.iKCBand 2253 2254 2322]; 
toptsRMV.iISO    = [toptsRMV.iISO       2    2    3]; 
toptsRMV.iL      = [toptsRMV.iL         3    5    2]; 
toptsRMV.iU      = [toptsRMV.iU        23   25   16]; 
 
toptsRMV.iKCBand = [toptsRMV.iKCBand 2110 2120 ]; 
toptsRMV.iISO    = [toptsRMV.iISO       1    1 ]; 
toptsRMV.iL      = [toptsRMV.iL         2    3 ]; 
toptsRMV.iU      = [toptsRMV.iU        15   25 ]; 
 
toptsRMV.iKCBand = [toptsRMV.iKCBand 2140 2160 2170 2180];  
toptsRMV.iISO    = [toptsRMV.iISO       1    1    1    1];  
toptsRMV.iL      = [toptsRMV.iL         5    6    7    8];  
toptsRMV.iU      = [toptsRMV.iU        23   36   37   38];  
 
%manuel does not compute NLTE vibtemps for these two 
%toptsRMV.iKCBand = [toptsRMV.iKCBand 2130 2150]; 
%toptsRMV.iISO    = [toptsRMV.iISO       1    1]; 
%toptsRMV.iL      = [toptsRMV.iL         4    3]; 
%toptsRMV.iU      = [toptsRMV.iU        22   22]; 

iaTemp = -50:10:50;
iaFr = 2205 : 25 : 2505;

iT = iDoJob;    %%%from airs_nodes_co2back

%% make the reference profile
fprintf('doing temperature = %4i \n',iaTemp(iT));
prof = load('refgas2');
prof(:,4) = prof(:,4) + iaTemp(iT);
fname = ['refgas2_' num2str(iT)];
fid = fopen(fname,'w');
fprintf(fid,'%3i  %10.8e %10.8e %7.3f %10.8e \n',prof');  
fclose(fid);

profname = pwd;
profname = [profname '/' fname];

iaFr
for iF = 1 : length(iaFr)
  %% run run7lbl
  clear fr k
  f1 = iaFr(iF);
  f2 = f1 + 25.0;

  fprintf(1,'doing %3i of %3i : %8.4f %8.4f\n',iF,length(iaFr),f1,f2);

  cd /home/sergio/SPECTRA;

  %topts.HITRAN = '/asl/data/hitran/h96.by.gas';
  %topts.xfar = 250;

  [fr,k] = run7co2_weakbackgnd(2,f1,f2,profname,topts,toptsRMV);      

  %% save the data

  %outname = ['/carrot/s1/sergio/AIRSCO2/BACKGND_MAY2005_COUSIN_UPPER/' fname];
%outname = ['/carrot/s1/sergio/AIRSCO2/BACKGND_SEPT2005_COUSIN_UPPER/' fname];
outname = ['/carrot/s1/sergio/AIRSCO2/BACKGND_11SEPT2005_COUSIN_UPPER/' fname];

  outname = [outname '_' num2str(f1) '.mat'];
  saver = ['save ' outname ' fr k prof f1 f2 topts toptsRMV profname'];
  eval(saver);
  end

iRead = -1;
if iRead > 0
  %%%%now read in the data
  frall = [];
  kall = [];
  iaFr = 2205 : 25 : 2505; 
  for iF = 1 : length(iaFr)
    f1 = iaFr(iF);
    iname= ['/carrot/s1/sergio/AIRSCO2/BACKGND_MAY2005_COUSIN_UPPER/'];
    iname = [iname 'refgas2_' num2str(iT)];
    iname = [iname '_' num2str(f1) '.mat'];
    loader = ['load ' iname]
    eval(loader);
    [f1 f2]
    frall = [frall fr];
    kall = [kall k];
    end
 end


  