homedir = pwd;

lala = load('/asl/data/hitran/H2016/LineMix/hit16_test2_04_2020.dat');
semilogy(lala(:,1),lala(:,2:4)) %% no linemix, first order linemix, full linemix  units /cm-1

%% see /home/sergio/HITRAN2UMBCLBL/MAKEIR/H2016_G2015/MAKEIR_CO2_O3_N2O_CO_CH4_othergases_LBLRTM12p8/clust_runXtopts_savegasN_file.m
%% Stoffset = 1;
%% cd /home/sergio/HITRAN2UMBCLBL/LBLRTM/Toff_' num2str(Stoffset,'%02d')];
%% [w,dglab,dlblrtm] = driver_glab_lblrtm_forn_MANYLAY_noN2con(gasid,fmin,fmax,['/home/sergio/SPECTRA/' fip],-1,-1);

cd /home/sergio/HITRAN2UMBCLBL/LBLRTM
f1 = 600.0; f2 = 900.0;
ipfile = ['/asl/data/hitran/H2016/LineMix/test_compare_to_lblrtm12_8.txt'];
[xw,xdglab,xdlblrtm] = driver_glab_lblrtm_self_MANYLAY(2,f1,f2,ipfile,-1);
cder = ['cd ' homedir];
eval(cder)

q = 1.0;            %% kilomoles/cm2
q = q*1e4*1e3;      %% moles/m2
R = 8.31;
T = 305.0;
p = 1.0*4.06e-4 *101325;
L = q*R*T/p*100;   %% in cm       

wall = xw;
odall = xdlblrtm;
semilogy(lala(:,1),L*100*lala(:,2:4),wall,odall) %% no linemix, first order linemix, full linemix, lblrtm
hl = legend('no','first','full','lblrtm'); set(hl,'fontsize',10)

semilogy(lala(:,1),L*100*lala(:,2:4),wall,odall) %% no linemix, first order linemix, full linemix, lblrtm
hl = legend('no','first','full','lblrtm'); set(hl,'fontsize',10)

semilogy(lala(:,1),L*100*lala(:,4),wall,odall) %% full linemix, lblrtm
hl = legend('full','lblrtm'); set(hl,'fontsize',10)

addpath /home/sergio/SPECTRA
[lala5pt] = boxint_many(lala(1:600000,:),5);
whos lal* wall odall

plot(lala5pt(1,:) - wall)
plot(lala5pt(1,:),100*lala5pt(4,:) ./ odall')
plot(lala5pt(1,:),1e11*lala5pt(4,:) ./ odall')

plot(lala5pt(1,:),1/1.6*1e11*lala5pt(4,:) ./ odall')
semilogy(lala5pt(1,:),1/1.6*1e11*lala5pt(4,:),lala5pt(1,:), odall')

figure(1); plot(lala5pt(1,:),L*lala5pt(4,:) ./ odall')
figure(2); semilogy(lala5pt(1,:),L*lala5pt(4,:),lala5pt(1,:), odall')

figure(2); semilogy(lala5pt(1,:),L*lala5pt(2:4,:),lala5pt(1,:), odall')
  hl = legend('voigt','first order','full','LBLRTM 12.8','location','best'); grid
figure(1); 
   plot(lala5pt(1,:),L*lala5pt(2,:) ./ odall',lala5pt(1,:),L*lala5pt(3,:) ./ odall', ...
        lala5pt(1,:),L*lala5pt(4,:) ./ odall')
  title('LM / LBLRTM 12.8'); grid
  hl = legend('voigt','first order','full','location','best'); grid
