Number of points affects resonance position

General forum for EasySpin: questions, how to's, etc.
Post Reply
michkern
Newbie
Posts: 2
Joined: Tue Apr 21, 2020 8:48 am

Number of points affects resonance position

Post by michkern »

I've noticed a weird shift when comparing a spectrum with small number of points (same as experiment) and one with plenty of points calculated based on fitted parameters. It drove me crazy, thinking I was plotting wrong things, until I've discovered I can easily reproduce it with just calculated spectra:

Code: Select all

Sys.S=0.5;
Sys.g=2.0023;
Sys.lwpp=0.5;

Exp.mwFreq=9.4;
Exp.Range=[330 340];
Exp.Points=500;
[Field500,Spec500]=pepper(Sys,Exp);
Exp.nPoints=100;
[Field100,Spec100]=pepper(Sys,Exp);
Exp.nPoints=50;
[Field50,Spec50]=pepper(Sys,Exp);
plot(Field500,Spec500,Field100,Spec100,Field50,Spec50)
legend('500 points','100 points','50 points')
xlim([334,337])
xlabel('Magnetic field / mT')
ylabel('Intensity / arb.u.')
Image is attached. Is this behavior expected?
Attachments
EasySpin_subsampling.png
EasySpin_subsampling.png (43.3 KiB) Viewed 2639 times
thanasis
Local Expert
Posts: 242
Joined: Thu Jan 21, 2016 6:28 am
Location: Strasbourg

Re: Number of points affects resonance position

Post by thanasis »

Try changing from 50 to 40 or 60 points. You will see that they are much closer to the 500 point curve.*

*In your code, the 500-point curve is actually the default 1024 points, because you have specified Exp.Points instead of the correct Exp.nPoints.
michkern
Newbie
Posts: 2
Joined: Tue Apr 21, 2020 8:48 am

Re: Number of points affects resonance position

Post by michkern »

Indeed it does that, and thanks for noticing the typo.

I've now just made a small loop where I calculated just the resonance field with resfields and plotted it against the number of points. Here everything looks fine. Where does this shift then come from? And should it be there or is it a bug?
Attachments
EasySpin_subsampling_nPoints_resfields.png
EasySpin_subsampling_nPoints_resfields.png (16.29 KiB) Viewed 2633 times
Matt Krzyaniak
EasySpin Guru
Posts: 153
Joined: Tue Jul 22, 2014 11:01 am
Location: Northwestern University

Re: Number of points affects resonance position

Post by Matt Krzyaniak »

This is an issue with the binning of the datapoints when you are under-sampling to this extent.
Resfields calculates the resonant field position, that in-turn gets interpolated to fit your desired field range and number of points.

Try setting your linewidth to zero and the harmonic to zero. What ends up happening is that based on your field range and the number of points in the range, you end up capturing only the edge of the real resonance, and when things are convoluted you end up with a shifted crossing point.

Try:

Code: Select all

clear
Sys.S=0.5;
Sys.g=2.0023;
Sys.lwpp=0;

Exp.Harmonic = 0;
Exp.mwFreq=9.4;
Exp.Range=[330 340];
Exp.nPoints=500;

[Field500,Spec500]=pepper(Sys,Exp);
Exp.nPoints=100;
[Field100,Spec100]=pepper(Sys,Exp);
Exp.nPoints=50;
[Field50,Spec50]=pepper(Sys,Exp);
plot(Field500,Spec500,Field100,Spec100,Field50,Spec50)
legend('500 points','100 points','50 points')
xlim([334,337])
xlabel('Magnetic field / mT')
ylabel('Intensity / arb.u.')
You would find that if you look at 5000 points or even more, the resonance shifts even from 500pt simulation

If you are trying to simulate something with such sparse point density and you want to avoid this, I would suggest that perhaps you run the initial simulation with a large number of points, then down interpolate to match your experimental range/points.
Stefan Stoll
EasySpin Creator
Posts: 1053
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: Number of points affects resonance position

Post by Stefan Stoll »

A practically useful rule is that the expected error of the line position can be as large as half the field increment.

Example:
- You have 50 points over 10 mT.
- That's about 0.2 mT field increment.
- Therefore, the expected error in the line position can be up to 0.1 mT.

This error results from the shifting of the stick spectrum that's required to fit it into one of the bins of the spectral vector.
Post Reply