Page 1 of 2
Automatic definition of Exp.nPoints for esfit() function
Posted: Mon May 15, 2023 3:59 am
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
Re: Automatic definition of Exp.nPoints for esfit() function
Posted: Sat Sep 02, 2023 11:42 pm
by Stefan Stoll
Can you please provide an example where this error occurs?
Re: Automatic definition of Exp.nPoints for esfit() function
Posted: Thu Sep 07, 2023 10:48 pm
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.
Re: Automatic definition of Exp.nPoints for esfit() function
Posted: Tue Mar 26, 2024 10:37 pm
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.
Re: Automatic definition of Exp.nPoints for esfit() function
Posted: Wed Mar 27, 2024 10:23 pm
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.
Re: Automatic definition of Exp.nPoints for esfit() function
Posted: Wed Mar 27, 2024 10:45 pm
by Stefan Stoll
esfit
checks and sets Exp.nPoints
only if the simulation function is pepper
, garlic
, chili
or salt
.
Re: Automatic definition of Exp.nPoints for esfit() function
Posted: Fri Mar 29, 2024 2:02 am
by katarkon
Thanks. Is it able to make it for custom simulation functions? It should be usefull feature.
Re: Automatic definition of Exp.nPoints for esfit() function
Posted: Mon Apr 01, 2024 10:45 am
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.
Re: Automatic definition of Exp.nPoints for esfit() function
Posted: Thu Apr 11, 2024 10:28 pm
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.
Re: Automatic definition of Exp.nPoints for esfit() function
Posted: Mon Apr 22, 2024 8:54 am
by Stefan Stoll
Please post a specific example that has the behavior you are suggesting, so we can consider it.