problem with esfit

General forum for EasySpin: questions, how to's, etc.
Post Reply
chemshd
User
Posts: 15
Joined: Sun Sep 28, 2014 8:51 am
Location: Stuttgart, Grenoble, Beijing

problem with esfit

Post by chemshd »

I encountered a problem when using esfit. Here is my code,

Code: Select all

clear all;
messdata = importdata('data.dat');
f331 = messdata(:,1);
s331 = messdata(:,2);

Sys.S = 2;
Sys.g= [2.0 2.0];
Sys.D = [3.58 0.5]*clight/10000;
Sys.lw = 200;

Exp.Range = [0000 15000];
Exp.Temperature = 15;
Exp.Orientations = [];
Exp.mwFreq= 331.2;

Sys0=Sys;
Vary.g=[0.05 0.05];
Vary.D=[0.1 0.2]*clight/10000;

esfit('pepper',s331,Sys0,Vary,Exp);


[simuf331,simuspec331] = pepper(Sys,Exp);
plotyy(f331,s331,simuf331/1000,simuspec331);
The last two lines are the normal pepper simulation with my initial parameters. as following,
pepper simulation
pepper simulation
pepper.PNG (12.74 KiB) Viewed 6248 times
However, it is very different from the esfit simulation from the center of the variable.
esfit simulation
esfit simulation
esfit.PNG (42.42 KiB) Viewed 6248 times

I guess this might be because my field sweeping rate is not a constant: the sweeping rate is lower at higher field to avoid quenching. The result is that the number of the data points in various field ranges are not uniformly distributed. I enclosed my data file below.
data.zip
experimental data
(47.2 KiB) Downloaded 255 times
In the pepper simulation, I plot the spectra by the function of "plotyy", where the specific relation between the spectrum and field are included in the data;
while in the esfit function, the spectra information is introduced by a 1D array(the abscissa values are not included), and they are assumed to be uniformly distributed in the whole field range(are they? otherwise one need the abscissa values).

I am not sure if there is a way to solve this problem, and am looking forward to your help.
thanks very much

ShangDa Jiang
Matt Krzyaniak
EasySpin Guru
Posts: 153
Joined: Tue Jul 22, 2014 11:01 am
Location: Northwestern University

Re: problem with esfit

Post by Matt Krzyaniak »

Well as far as I know ES can only handle a linear field axis, unless there is an undocumented feature in the experimental setup(but you'll have to wait for a reply from Stefan in regard to that).

My suggestion would be to down interpolate your experimental data to produce a linear field range. To do this within Matlab something like this should work:

Code: Select all

 
clear all;
messdata = importdata('data.dat');
f331 = messdata(:,1)*1000; % mT
s331 = messdata(:,2);

B = linspace(0,15000,4096); % make a new field vector
s331i = interp1(f331,s331,B,'spline'); % interpolate to that field vector 

clight = 30000;

Sys.S = 2;
Sys.g = [2.0 2.0];
Sys.D = [3.58 0.5]*clight;
Sys.lw = 200;

Exp.Range = [0 15000];
Exp.nPoints = length(B);
Exp.Temperature = 15;
Exp.Orientations = [];
Exp.mwFreq = 331.2;


Sys0=Sys;
Vary.g = [0.05 0.05];
Vary.D = [0.1 0.2]*clight;

esfit('pepper',s331i,Sys0,Vary,Exp);


[simuf331,simuspec331] = pepper(Sys,Exp);
plot(f331,s331,simuf331,simuspec331);
chemshd
User
Posts: 15
Joined: Sun Sep 28, 2014 8:51 am
Location: Stuttgart, Grenoble, Beijing

Re: problem with esfit

Post by chemshd »

I've tried this, it does work. Thank you very much Matt.
I am just curious why the field axis is not included,
otherwise this problem will be very often, since for high field EPR, a non-linear sweeping rate is normal.
chemshd
User
Posts: 15
Joined: Sun Sep 28, 2014 8:51 am
Location: Stuttgart, Grenoble, Beijing

Re: problem with esfit

Post by chemshd »

Hi Matt, I tried your solution in another case, but an error is encountered.
Here is the part of the code:

Code: Select all

clear all;
messdata = importdata('270GHz-5K.dat');
f270 = messdata(:,1)*1000;
s270 = -messdata(:,2);
B = linspace(0,15000,4096); % make a new field vector
s270i = interp1(f270,s270,B,'spline'); % interpolate to that field vector 
interp1 does not go and the following error shows up:

Error using griddedInterpolant
The point coordinates are not sequenced in strict monotonic order.

enclosed you can find my data.
270GHz-5K.zip
(28.46 KiB) Downloaded 261 times
Thank you!
Matt Krzyaniak
EasySpin Guru
Posts: 153
Joined: Tue Jul 22, 2014 11:01 am
Location: Northwestern University

Re: problem with esfit

Post by Matt Krzyaniak »

The above error is due to there being quite a few repetitions within your field vector. I'm not sure if it was an error in collection(software rounded the field values) or a result of some post processing. I guess the followup question is how do you want to handle these repetitions? Just throw them out, average the points, or recalculate the field vector.

Just throw them out:

Code: Select all

clear all;
messdata = importdata('270GHz-5K.dat');
field = messdata(:,1)*1000;
spec = -messdata(:,2);

% find and keeps the first unique entry in the vector
% change 'first' to 'last' if you'd keep the last entry
[field,ind] = unique(field,'first');
spec=spec(ind);

B = linspace(0,15000,2^(nextpow2(length(spec))-1)); % make a new field vector
speci = interp1(field,spec,B,'spline'); % interpolate to that field vector

plot(B,speci,field,spec)
Average them:

Code: Select all

clear all;
messdata = importdata('270GHz-5K.dat');
field = messdata(:,1)*1000;
spec = -messdata(:,2);

% calculate the mean
[~,indf] = unique(field,'first');
[fieldm,indl] = unique(field,'last');
specm=zeros(size(fieldm));
for i=1:length(fieldm)
    specm(i)=mean(spec(indf(i):indl(i)));
end

B = linspace(0,15000,2^(nextpow2(length(specm))-1)); % make a new field vector
speci = interp1(fieldm,specm,B,'spline'); % interpolate to that field vector

plot(B,speci,fieldm,specm)
There might be better ways to do the above.

And as for recalculating the field vector, I'll leave that up to you since I'm not clear exactly why or where the field repetition came from.
Stefan Stoll
EasySpin Creator
Posts: 1041
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: problem with esfit

Post by Stefan Stoll »

ES does not have the capability to handle non-linear field axes. Matt's solution with unique() and interp1() is great.
chemshd
User
Posts: 15
Joined: Sun Sep 28, 2014 8:51 am
Location: Stuttgart, Grenoble, Beijing

Re: problem with esfit

Post by chemshd »

thank you very much for your effort!
Post Reply