Automatic definition of Exp.nPoints for esfit() function

A place to report and discuss potential bugs
katarkon
Local Expert
Posts: 186
Joined: Mon Jan 12, 2015 4:01 am

Automatic definition of Exp.nPoints for esfit() function

Post by katarkon »

I've found that automatic definition of the number of the spectral points isn't works properly in latest EasySpin 6.0.0dev51 version. The Exp.nPoints parameter should be defined else the error of matrices index mismatch occur. Is it a bug either custom simulation function should worry about it?
UPD. A fragment of esfit() source code should parse the Exp.nPoints, really not

% Check or set Exp.nPoints
if isfield(p0{2},'nPoints')
if p0{2}.nPoints~=numel(data)
error('Exp.nPoints is %d, but the data vector has %d elements.',...
p0{2}.nPoints,numel(data));
end
else
p0{2}.nPoints = numel(data);
end

Stefan Stoll
EasySpin Creator
Posts: 1050
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: Automatic definition of Exp.nPoints for esfit() function

Post by Stefan Stoll »

Can you please provide an example where this error occurs?

katarkon
Local Expert
Posts: 186
Joined: Mon Jan 12, 2015 4:01 am

Re: Automatic definition of Exp.nPoints for esfit() function

Post by katarkon »

The problem is kept in dev53 version. It looks like esfit() send Exp structure 'as is' regardless checking of its parameters. Correspondingly, the mismatch on the number of datapoints occur because simulation function sets it to default value.

Stefan Stoll
EasySpin Creator
Posts: 1050
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: Automatic definition of Exp.nPoints for esfit() function

Post by Stefan Stoll »

Can you please provide an example where you experience this problem? As is, esfit sets Exp.nPoints to match the number of datapoints, but only if Exp.nPoints is not already set. If the set value of Exp.nPoints provided to esfit doesn't match the number of datapoints, an error is issued.

katarkon
Local Expert
Posts: 186
Joined: Mon Jan 12, 2015 4:01 am

Re: Automatic definition of Exp.nPoints for esfit() function

Post by katarkon »

My simulation function have a follow code:
if ~isfield(Exp,'nPoints'), Exp.nPoints = 1024; end
If Exp.nPoints is not defined, the follow error is throwed:
Running optimization algorithm with 21 active parameters...
esfit
error:

Experimental data and model have unequal total number of points:
experimental: 12102
model: 1024

It seems that esfit does not parse Exp.nPoints parameter however.

Stefan Stoll
EasySpin Creator
Posts: 1050
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: Automatic definition of Exp.nPoints for esfit() function

Post by Stefan Stoll »

esfit checks and sets Exp.nPoints only if the simulation function is pepper, garlic, chili or salt.

katarkon
Local Expert
Posts: 186
Joined: Mon Jan 12, 2015 4:01 am

Re: Automatic definition of Exp.nPoints for esfit() function

Post by katarkon »

Thanks. Is it able to make it for custom simulation functions? It should be usefull feature.

Stefan Stoll
EasySpin Creator
Posts: 1050
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: Automatic definition of Exp.nPoints for esfit() function

Post by Stefan Stoll »

We are not planning to implement this. EasySpin has no control over custom simulation functions, and Exp.nPoints might mean something else in a custom function. Also, we don't want to impose any restrictions on fields for custom functions.

katarkon
Local Expert
Posts: 186
Joined: Mon Jan 12, 2015 4:01 am

Re: Automatic definition of Exp.nPoints for esfit() function

Post by katarkon »

Thanks. You should be right, the custom simulation functions is a topic for advanced EasySpin users. Howewer, I suggest that this functional may be included via additional field for FitOpt in future releases.

Stefan Stoll
EasySpin Creator
Posts: 1050
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: Automatic definition of Exp.nPoints for esfit() function

Post by Stefan Stoll »

Please post a specific example that has the behavior you are suggesting, so we can consider it.

Post Reply