clear
close all
%%Input from datafile
filename = '012wm_SSxLiPc120G';
[B,spc,params] = eprload(filename);
B = B/2.0022*2.000525;
spc = real(spc)-1.776;
plot(B/10,spc/max(spc),'b')
hold on

%% Define Experiment parameters
Exp.mwFreq = 9.396183;                      
Exp.Range = [332.9 (332.9 + 60)];                  
Exp.nPoints = 1200;

%% Li Pc
LiPc.S = [1/2];
LiPc.g = [2.0022];
LiPc.lw = [0.03]; %Correct in term of FWHM
[Field1, Spec1] = pepper(LiPc,Exp);
Spec1 = Spec1/max(Spec1)*max(spc);

%% DFB1 
DFB1.S = 1;
DFB1.g = 2.0027;
DFB1.lw = [0.365 0.75];
%From Wikipedia, there is a formula that allows you to understand the
%weight of Lorentzian and Gaussian starting from their FWHM in a
%pseudo-Voigt approximation
fL = DFB1.lw(2);
fG = DFB1.lw(1);
f = (fG^5 + 2.69269*fG^4*fL + 2.42843*fG^3*fG^2 + 4.47163*fG^2*fG^3 + 0.07842*fG*fL^4 + fL^5)^(1/5);
eta = 1.36603*fL/f - 0.47719*(fL/f)^2 +0.011116*(fL/f)^3;  %Lorentzian percentage
[Field2, Spec2] = pepper(DFB1,Exp);
Spec2 = Spec2/max(Spec2)*max(spc(1:11000));

%% Plot
Spec = Spec1+Spec2;
xlim([334.8 335.8])
Spec = Spec/max(Spec);
plot(Field1,Spec./max(Spec),'k')