Page 1 of 1

Export components of composite spectra separately

Posted: Mon Jul 25, 2016 7:07 am
by thanasis
From what I have understood, ES can separate the various resonances of a single spectrum, or the individual orientations of a single-crystal calculation. (http://easyspin.org/documentation/pepper.html).

However, I need something a little simpler:
When I fit multicomponent systems, ES exports only the composite spectrum. In order to deconvolute the components, I have only come up with some tricks of my own, none of which is satisfactory.

E.g.: make a run with the best-fit parameters (I let just one vary by very-very little so that I don't get an error) once with Sys1.weight = 0 and then with Sys2.weight = 0. Then I get the individual components. However, they are not weighed to one another, so a composite plot (component + component2 + composite spectrum) will be out of scale.

I have devised a little hack, where I make a custom function and I use an else statement as Matt previously suggested (viewtopic.php?f=3&t=328#p1016). Then, after my custom function makes the calculation, I instruct it to export it to an ascii file:

Code: Select all

[x,y] = pepper(Sys,Exp,Opt);
sys1=y' ; save('sys1','sys1','-ascii');
That way I have the component spectra properly weighed to one another, but not to the composite spectrum given from the fit window within the fit structure (actually, in my example there is a 4.32:1 ratio between the sum of the composite spectra and the fit1.fitSpec).

Have I overlooked something? Is this possible in a clean manner out of the box, or by using a custom function?

Re: Export components of composite spectra separately

Posted: Tue Jul 26, 2016 1:36 pm
by joscha_nehrkorn
The fitting routine uses scaling via the function rescale. Therefore the returned weights are only relative if you use more than one system an d meaningless for a single system. In simulations this is different: If you test simulations of a single system with two different weights they will differ by this factor in integrated absorption (double integral of the usual EPR signal). That is what is missing!
As you already figured out the factor, just multiply your weights by it!

Re: Export components of composite spectra separately

Posted: Wed Jul 27, 2016 1:57 am
by thanasis
Yes, my solution was finally to print an ascii file with my fitting results ('fit') from the main script and at the same time export the two (or more) components through the custom function ('comp1', 'comp2', etc) using Matt's if/elseif approach.

Then I find the ratio fit/(comp1 + comp2 + ...) and then multiply all the components with that ratio.

The tricky part is to find some discriminating factor between the various systems for the custom function to tell them apart.

That could be the size of the systems (if length(Sys.S)==1 ... elseif length(Sys.S)==2 ...), the values of their parameters (if Sys.g(1,2)>=2.32 ... elseif Sys.g(1,2)<2.32 ...), etc.

Re: Export components of composite spectra separately

Posted: Mon Aug 29, 2016 2:39 am
by katarkon

Code: Select all

%define Sys1 and Sys2, Exp, Opt, FitOpt
%----------------------------------------------
[bestSys,y]=esfit(...,{Sys1,Sys2},...}
bestSys1=bestSys{1};
bestSys2=bestSys{2};
y1=pepper(bestSys1,...);
y2=pepper(bestSys2,...);
I=sum(cumsum(y));
I1=sum(cumsum(y1));
I2=sum(cumsum(y2));
y1=y1*I/I1;
y2=y2*I/I2;
y1=y1*bestSys1.weigth/(bestSys1.weigth+bestSys2.weigth);
y2=y1*bestSys2.weigth/(bestSys1.weigth+bestSys2.weigth);

Re: Export components of composite spectra separately

Posted: Wed Aug 31, 2016 12:14 am
by thanasis
Thanks katarkon,

If I understand correctly, sum(cumsum(y)) etc, are essentially double integrations to retrieve the intensity of each signal.

Then y1=y1*I/I1 and y2=y2*I/I2 should make the total intensities of the two subspectra equal to one another before taking the determined weights into account?

Shouldn't we then include a final declaration y=y1+y2? Or is it already the case?

Re: Export components of composite spectra separately

Posted: Wed Aug 31, 2016 3:01 am
by katarkon
If I understand correctly, sum(cumsum(y)) etc, are essentially double integrations to retrieve the intensity of each signal
Yes, the sum(cumsum(y)) is a rough double integration. This approximation should be enough.
Then y1=y1*I/I1 and y2=y2*I/I2 should make the total intensities of the two subspectra equal to one another before taking the determined weights into account?
This make intestities if the subspectra equal to result of the esfit() function (and equal one to enother of course).
Shouldn't we then include a final declaration y=y1+y2? Or is it already the case?
Yes, it's already assumed.