Page 1 of 1
Number of points affects resonance position
Posted: Wed Apr 22, 2020 2:50 am
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?
Re: Number of points affects resonance position
Posted: Wed Apr 22, 2020 4:38 am
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
.
Re: Number of points affects resonance position
Posted: Wed Apr 22, 2020 5:24 am
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?
Re: Number of points affects resonance position
Posted: Mon Sep 07, 2020 2:23 pm
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.
Re: Number of points affects resonance position
Posted: Wed Sep 09, 2020 2:19 pm
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.