Normalisation during fitting?

General forum for EasySpin: questions, how to's, etc.
Post Reply
Flixii
Newbie
Posts: 1
Joined: Thu Sep 11, 2014 8:49 am

Normalisation during fitting?

Post by Flixii »

Dear readers,

I have one question regarding the fitting procedure in EasySpin:

Is there any kind of normalisation or scaling of the y axis carried out before the fitting? I did not find any clue that there is one in the documentation, but I noticed when I fitted a spectrum, obtaining good results and then using the same parameters to simulate the spectrum with pepper and plotting it, that the simulation gave me a much larger signal. I have attached two pictures of the fitting window and the result of the pepper simulation, as well as my code.

What am I making wrong?

Thank you!
Best regards,
Felix

My code:

Code: Select all

clear

% load data
[index fieldQ12Cu2Plus intensityQ12Cu2Plus] = textread('LK051404.006', '%u %f %f', 'headerlines', 1);
[intensityQ12Cu2Plus BlineQ12Cu2Plus] = normalise( intensityQ12Cu2Plus);

[index fieldMn12Cu2Plus intensityMn12Cu2Plus] = textread('LK051104.001', '%u %f %f', 'headerlines', 1);
[intensityMn12Cu2Plus BlineMn12Cu2Plus] = normalise( intensityMn12Cu2Plus);

intensity = intensityMn12Cu2Plus - intensityQ12Cu2Plus;
intensity = intensity*(-1);
field = fieldQ12Cu2Plus/10;

zoomStart = 570;
zoomEnd = 853;

g2 = [ 2.2676    2.0358    2.0642];
A2 = [520.0056    1.1631  12.0101];

lwpp = 3.3096;
Exp2 = struct('mwFreq', 9.5, 'Range', [ field(1) field(end) ], 'nPoints', length(field));
Sys2 = struct('S',1/2,'g', g2, 'lwpp', lwpp);
Sys2 = nucspinadd(Sys2,'63Cu', A2);

Exp3 = struct('mwFreq', 9.5, 'Range', [ field(zoomStart) field(zoomEnd) ], 'nPoints', length(field(zoomStart:zoomEnd)));
[x3 y3]= pepper(Sys2, Exp3);

%With normalising the simulation results are looking as in the
%fitting window.
y3 = y3 / (max(y3) - min(y3));

 Vary = struct('lwpp', 0.5, 'g', [0.05 0.05 0.05], 'A', [30 30 30]);
esfit('pepper', intensity(zoomStart:zoomEnd), Sys2, Vary, Exp3);

figure
plot(x3,y3, '-r', field(zoomStart:zoomEnd), intensity(zoomStart:zoomEnd),'-b');
legend('fit','data');
title('Zoom');
xlabel('Magnetic Field [mT]');
ylabel('Intensity [a. u.]');
grid on
Attachments
Fitting window
Fitting window
fitresult.png (41.91 KiB) Viewed 4736 times
Pepper simulation result
Pepper simulation result
sim.png (10.02 KiB) Viewed 4736 times
Matt Krzyaniak
EasySpin Guru
Posts: 153
Joined: Tue Jul 22, 2014 11:01 am
Location: Northwestern University

Re: Normalisation during fitting?

Post by Matt Krzyaniak »

Yes, when fitting, ES scales the results to provide the optimal fit. To replicate the scaling try something like:

Code: Select all

% first ensure that the data is in column form
intensity = intensity(:); 
y3 = y3(:);
 % calculate the scaling factor
A = (y3' * y3) \ (y3 ' * intensity(zoomStart:zoomEnd));
% scale the simulation
y3 = A * y3; 
The above method could also be used to scale a sum of spectra.

Code: Select all

% first ensure that the data is in column form
intensity = intensity(:);
y1 = y1(:);
y2 = y2(:); 
y3 = y3(:);

y = [y1, y2, y3];
 % calculate the scaling factor
A = (y' * y) \ (y ' * intensity(zoomStart:zoomEnd));
% scale the simulation
y = A * y;
Stefan Stoll
EasySpin Creator
Posts: 1041
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: Normalisation during fitting?

Post by Stefan Stoll »

In esfit, you can actually specify how you want ES to scale experimental and simulated spectra to fit to each other.

Programmatically, the option is FitOpt.Scaling. It has the basic scaling (to same minimum and maxmimum, etc), but also more fancy least-squares fitting methods that can automatically take care of a constant, linear or quadratic baseline. You can access all these option on the graphical interface of esfit.
Post Reply