I have noticed that when I run esfit('pepper',spc,...) I am getting fits that don't behave as a Lorentzian near the edges/boundaries of the fit.
The output spectrum seems to suddenly jump in amplitude at the edges, giving an erroneous fit.
When the gain on the experimental spectrum is high enough, you can't really notice these jumps in the fit, but when you do low-gain spectra like the attached 'EasyPepperTest' it is a significant error.
I couldn't find any mention of this in other posts and I haven't been able to fix it with any FitOpt.Scaling settings ('lsq1', 'lsq2', 'minmax', etc). Can anyone identify the cause of this and help to fix it? I don't want to manually change the output fit spectra to remove these non-Lorentzian artefacts but I'm unable to find a way to fix it within the EasySpin documentation.
Here is some test code to replicate the issue using the attached Bruker files:
% Clear and load data
clear, clc
[B, spc] = eprload('EasyPepperTest');
% Set up the experiment
Exp.mwFreq = 9.858; % GHz
Exp.Range = [350.98 351.979]; % mT
Exp.nPoints = 999;
Exp.Harmonic = 1; % first harmonic (default), dispersion (1st derivative of absorption)
Exp.ModAmp = 0.01; % mT, modulation amplitude
Sys0.g = 2.004; % g-factor
Sys0.lw = [0.12 0.12]; % mT, linewidth [Gaussian Lorentzian]
% Set up Vary structure with all parameters that can be varied and by how much.
SysVary.g = 0.005; % vary g +-0.005
SysVary.lw = [0.12 0.12]; % mT, vary lw +-0.12 for each
% Run the fit
SimOpt.Method = 'matrix'; % Default simulation via matrix diagonalisation
FitOpt.Method = 'simplex fcn'; % simplex algorithm, data as is
FitOpt.Scaling = 'lsq1'; % least-squares fitting, with linear baseline correction
FitOpt.PrintLevel = 0; % Don't print to command window while fitting
[BestSys,BestSpc] = esfit('pepper',spc,Sys0,SysVary,Exp,SimOpt,FitOpt);
% Plot
fSim = figure;
plot(B,spc);
hold on
plot(B,BestSpc,'--r')
legend('data','fit','Location','southeast')
hold off
xlabel('Magnetic Field (mT)')
xlim 'tight'