Pepper fitting with esfit has bad edges/boundaries

A place to report and discuss potential bugs
Post Reply
SFree
Newbie
Posts: 3
Joined: Mon Jan 23, 2023 4:09 pm

Pepper fitting with esfit has bad edges/boundaries

Post by SFree »

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.

Screen Shot 2023-01-24 at 10.29.29 am.png
Screen Shot 2023-01-24 at 10.29.29 am.png (30.13 KiB) Viewed 6124 times

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'

Attachments
EasyPepperTest.DTA
(7.8 KiB) Downloaded 517 times
EasyPepperTest.DSC
(2.91 KiB) Downloaded 524 times
SFree
Newbie
Posts: 3
Joined: Mon Jan 23, 2023 4:09 pm

Re: Pepper fitting with esfit has bad edges/boundaries

Post by SFree »

It's worth noting that this also occurs for the GUI version of esfit, not just the CLI:

Screen Shot 2023-01-24 at 10.42.08 am.png
Screen Shot 2023-01-24 at 10.42.08 am.png (52.62 KiB) Viewed 6123 times
Matt Krzyaniak
EasySpin Guru
Posts: 153
Joined: Tue Jul 22, 2014 11:01 am
Location: Northwestern University

Re: Pepper fitting with esfit has bad edges/boundaries

Post by Matt Krzyaniak »

This is an artifact from the inclusion of the field modulation and the extremely narrow sweep range. You can think of the field modulation as an additional linewidth which the spectrum is convoluted with, as such if it is non-zero at the edges you're likely to get weird artifacts. So in your case, an extremely narrow sweep range and linewidths which don't allow for the spectrum to reach close to zero at the edges makes for convolution artifacts.
FYI the baseline('lsq1') is applied after the modulation so that won't help matters.

Unless your modulation is large relative to your linewidths (and you have structure), its effect is negligible and you can typically ignore it.

SFree
Newbie
Posts: 3
Joined: Mon Jan 23, 2023 4:09 pm

Re: Pepper fitting with esfit has bad edges/boundaries

Post by SFree »

This is an artifact from the inclusion of the field modulation and the extremely narrow sweep range. You can think of the field modulation as an additional linewidth which the spectrum is convoluted with, as such if it is non-zero at the edges you're likely to get weird artifacts. So in your case, an extremely narrow sweep range and linewidths which don't allow for the spectrum to reach close to zero at the edges makes for convolution artifacts.

Thank you Matt. Removing the line "Exp.ModAmp = 0.01;" completely fixes the issue. Thanks for explaining the situation where including modulation effects will lead to weird artefacts.

Post Reply