% Prepare non-etalon analysis
% All IRcurve0 are of the same spectral range!

% read nonetalon_n.txt 
filename = 'C:\LevInfinite\Config\nonetalon_n.txt';
fid = fopen(filename,'rt');
s = fgetl(fid);
nc = str2double(strtok(s));
names = cell(nc,1);
exp_concentr = zeros(nc,1);
for i = 1:nc
    line = fgetl(fid);
    names{i} = strcat(line,'\');
end % i
for i = 1:nc
    s = fgetl(fid);
    exp_concentr(i) = str2double(strtok(s));
end % i
fclose(fid);

% prepare "experimental" IR curve for imitation; 
IRcurve0i =[];
for i = 1:nc
    modelfolder = strcat('C:\LevInfinite\MOLECULES\',names{i});
    filename = strcat(modelfolder,'IRcurve0.txt');
    load(filename);
    IRcurve0i = [IRcurve0i,IRcurve0];
end % i
clear IRcurve0
exp_curve = IRcurve0i*exp_concentr;
filename = strcat(modelfolder,'x0.txt');
load(filename);
nx = length(x0);
plot(x0,exp_curve,'r');
hold on
for i = 1:nc
    modelfolder = strcat('C:\LevInfinite\MOLECULES\',names{i});
    filename = strcat(modelfolder,'IRcurve0.txt');
    load(filename);
    plot(x0,IRcurve0,'g');
end % i
clear IRcurve0
hold off 

ni = zeros(nc,1);
FrInt = cell(nc,3);
for i = 1:nc
    modelfolder = strcat('C:\LevInfinite\MOLECULES\',names{i});
    filename = strcat(modelfolder,'FreqsInts.mat');
    load(filename);
    FrInt{i,1} = freqsB;
    FrInt{i,2} = absintsB;
    ni(i) = size(freqsB,2);
    filename = strcat(modelfolder,'sigma.txt');
    load(filename);
    FrInt{i,3} = sigma;
end % i
nB = size(freqsB,1); % bootstrap trials