Fit curve not displayed after adding weighting
fknorr
the following code snippet is taken from my current project. After adding the weighting the fitting curve is not displayed after performing the fit. By removing the commands
/W=(theErrWave)/l=1 MyVoigt
I get the desired behaviour again.
// ...
// first a lorentzian fit is performed to get initial guesses for the Voigt fit
CurveFit/M=2/NTHR=0/TBOX=0 lor theYWave [pcsr(A),pcsr(B)] /X=theXWave /D
// get the coefficients I need
Wave point_W_coef = W_coef
coefs[0] = point_W_coef[0]
coefs[1] = point_W_coef[1]
coefs[3] = point_W_coef[2]
FuncFit/NTHR=0/TBOX=0/W=(theErrWave)/l=1 MyVoigt, kwCWave=coefs[0,4], theYWave[pcsr(A),pcsr(B)] /X=theXWave /D
//...
// first a lorentzian fit is performed to get initial guesses for the Voigt fit
CurveFit/M=2/NTHR=0/TBOX=0 lor theYWave [pcsr(A),pcsr(B)] /X=theXWave /D
// get the coefficients I need
Wave point_W_coef = W_coef
coefs[0] = point_W_coef[0]
coefs[1] = point_W_coef[1]
coefs[3] = point_W_coef[2]
FuncFit/NTHR=0/TBOX=0/W=(theErrWave)/l=1 MyVoigt, kwCWave=coefs[0,4], theYWave[pcsr(A),pcsr(B)] /X=theXWave /D
//...
I did not find a hint in the help files. Perhaps someone can help me.
Best regards
Fabian
P.S. I am quite new to Igor. For me the coefficient extraction seems like a mess, but so far I found no way to improve it. So if you have any tips for me: I am eager to learn.
Assume coefs is a wave of size 5. The lor function needs only the first four coefficients. The MyVoigt function needs all five.
CurveFit/M=2/NTHR=0/TBOX=0 lor kwCWave=coefs[0,3] theYWave [pcsr(A),pcsr(B)] /X=theXWave /D
// now fit MyVoigt using the guesses from above as initial parameters
FuncFit/NTHR=0/TBOX=0/W=(theErrWave)/l=1 MyVoigt, kwCWave=coefs theYWave[pcsr(A),pcsr(B)] /X=theXWave /D
//...
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
June 9, 2009 at 10:07 am - Permalink
The syntax for curve fitting has grown and metastasized over Igor's 20 years to be the mess it currently is. It is my ambition to one day create a totally new operation to support curve fitting that will have a more rational syntax.
Jeffrey Weimer is correct about the mismatch between the number of coefficients required for Lorentzian and Voigt peaks. It looks like you tried to handle that with kwCWave=w_coef[0,4]
That would work if W_coef already had five points, but that syntax will not manufacture new points. You need something like
CurveFit ... lor ...
Wave W_coef
Redimension/N=5 W_coef
FuncFit ...
But there is another possible problem- the width of a Voigt peak depends on both the width parameter and on the shape parameter. It is quite difficult to get good, automatic guesses for these. You can consult the technical note TN026 Voigt Profile for more information. You will find it in your Igor Pro folder, in Technical Notes:Igor Tech Notes:TN026 Voigt Profile.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
June 11, 2009 at 11:37 am - Permalink
For the past days I have had the chance to dig deeper into Igor and improve my first steps. I followed john`s advice and changed the parameter guesses so that the fits work better now. The only thing I could not figure out so far: Is there a possibility to add a weighting in x and consider it in the fit?
Cheers
Fabian
June 15, 2009 at 12:33 am - Permalink
Yes, we provide the Orthogonal Disance Regression as a curve fitting option. Execute this command on Igor's command line to learn more:
DisplayHelpTopic "Errors in Variables: Orthogonal Distance Regression"
Unfortunately, ODR fitting is not supported by the Curve Fit dialog, so you will need to compose a command yourself. You can get most of the way there with the dialog, then click the To Cmd button and edit the command.
You will also need to check out the CurveFit command reference documentation to learn all the options for ODR fitting:
DisplayHelpTopic "CurveFit"
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
June 17, 2009 at 04:59 pm - Permalink