T O P I C R E V I E W |
CStorey |
Posted - 06/05/2013 : 11:53:07 AM /* Origin Ver. and Service Release: 8.5 SR 1 Operating System: Win XP SP3
I've been using the same LabTalk script with a custom fit function since Origin 6. With a few tweaks I've always been able to migrate, but not so to v8.5. The fitting function is working manually from the NLSF dialog on my data just fine, but the script doesn't seem to be able to use of it properly.
I get no error messages, or warnings but the parameters are empty and no curve is created (column is filled with zeros). My script and FitFunc are below.
I'd like some help getting it running again please if anyone can test or offer suggestions to try. Thanks. Craig
Data Worksheet (FitCol = R, FitCurve should end up in CorbFit) ============================================================= X(X) Sep(Y) R(Y) Corbfit(Y) 0.47000 3.0E+01 209.000 0.40547 2.5E+01 191.000 0.33647 2.0E+01 179.000 0.26236 1.5E+01 163.000 0.18232 1.0E+01 141.700
LabTak script to do fitting.. =========================== [FitCorbino] nlsf.begin(); nlsf.init(); // Initialize the fitter nlsf.cleanUpFitData(); // Cleanup old memory allocations nlsf.func$="Corbino1"; // initialize function to be used nlsf.fitWksName$=%1; // Fit worksheet nlsf.fitData$=%(%1,3); // Set Dependent dataset nlsf.funcx$=%(%1,1); // Set Independant (X) dataset nlsf.xmode=2; // Use Specified X dataset to create curve nlsf.funcCol$=%(%1,4); // dataset to store generated fitting curve nlsf.p1=200; // initialize the parameter values nlsf.p2=50; nlsf.Execute("parainit"); nlsf.iterate(10); nlsf.iterate(10); nlsf.makecurve(func); //dataset generated for the fitted curve
///// Calculations based on nlsf.p1 & nlsf.p2 go here. Omitted for simplicity. //// nlsf.unInit(); nlsf.end(); Return;
FitFunc = "Corbino1" ==================== Its very simple y=P1*x + P2*(1+exp(-x)). Here's the function file..
[General Information] Function Name = Corbino1 Brief Description = Corbino Test Pattern Fitting Function Source = N/A Number Of Parameters = 2 Function Type = User-Defined Function Form = Expression Path = Number Of Independent Variables = 1 Number Of Dependent Variables = 1
[Fitting Parameters] Names = P1,P2 Initial Values = 1(V),1(V) Meanings = ?,? Lower Bounds = --(I, Off),--(I, Off) Upper Bounds = --(I, Off),--(I, Off) Naming Method = User-Defined Number Of Significant Digits = 0,0 Unit = ,
[Independent Variables] x =
[Dependent Variables] y =
[Formula] (P1*x) + (P2*(1+exp(-x)))
[Constraints]
[Initializations]
[After Fitting]
[Constants]
[Controls] General Linear Constraints = 0 Initialization Scripts = 0 Scripts After Fitting = 0 Number Of Duplicates = N/A Duplicate Offset = N/A Duplicate Unit = N/A Generate Curves After Fitting = 1 Curve Point Spacing = Uniform on X-Axis Scale Generate Peaks After Fitting = 1 Generate Peaks During Fitting = 1 Generate Peaks with Baseline = 1 Paste Parameters to Plot After Fitting = 1 Paste Parameters to Notes Window After Fitting = 1 Generate Residuals After Fitting = 0 Keep Parameters = 0 Compile On Param Change Script = 0 Enable Parameters Initialization = 1
[Compile Function] Compile = 0 Compile Parameters Initialization = 1 OnParamChangeScriptsEnabled = 0.
[Parameters Initialization] //Code to be executed to initialize parameters
[Origin C Function Header]
[Origin C Parameter Initialization Header]
[Derived Parameter Settings] Unit = Names = Meanings =
[QuickCheck] x=1 P1=1 P2=1 */
Craig
|
5 L A T E S T R E P L I E S (Newest First) |
aeolian1 |
Posted - 11/06/2013 : 12:44:21 PM Hi Greg,
Thank you for your help! Before your reply appeared, I ended up doing
nlbegin iy:=(%(rngSheet)1[2:7],%(rngSheet)2[2:7]) func:=Gauss nltree:=Paramtree;
which also worked. |
greg |
Posted - 11/05/2013 : 11:37:56 AM These two changes should fix the problem:
range r1= %(rngSheet)(1,2); //1[2]:2[7];
nlbegin iy:=r1[2:7] func:=Gauss nltree:=Paramtree;
|
aeolian1 |
Posted - 10/24/2013 : 05:11:04 AM Hello,
I am having major problems trying to get nlsf fitting to work in a script in OriginPro 8.5.1 SR 2. As for the previous poster, the fitting function works just fine manually via the NLSF dialog, but does not work from within my test script (which will eventually be included within a larger script): it produces results, but the fit results are off by many orders of magnitude (they don't agree with the manual results). I deselected "auto parameter initialization" within the fdf file for "Gauss", but this didn't make any difference to the fit results.
Thank you for your help!
// a graph window is open with pts. 1-8 plotted range -w rngData = 1; range rngBook = rngData.GetPage()$; range rngSheet = rngData.GetLayer()$; range r1= %(rngSheet)1[2]:2[7];
nlbegin iy:=r1 func:=Gauss nltree:=Paramtree; Paramtree.xc = 4; // Assign the peak center an X-value of 5. // ParamTree.f_xc = 1; // Fix the peak center (f_xc = 0 is unfixed). Paramtree.y0 = 4; // Assign the peak center an X-value of 5. Paramtree.A = 4; // Assign the peak center an X-value of 5. Paramtree.w = 3; // Assign the peak center an X-value of 5.
nlfit; type Baseline y0 is $(ParamTree.y0),; type Peak Center is $(ParamTree.xc), and; type Peak width (FWHM) is $(ParamTree.w); nlend 1;
|
CStorey |
Posted - 06/06/2013 : 4:19:24 PM Yeah, that fixed it.
Thanks for the prompt reply, you've saved me a lot of time now that its working again!
Much appreciated.
Craig
|
greg |
Posted - 06/06/2013 : 4:07:42 PM In your FDF, change
Enable Parameters Initialization = 1 to Enable Parameters Initialization = 0 (or uncheck the "Enable Auto Initialization" box in Fitting Function Organizer.) and you should be all set.
You do not have any parameter initialization code. Maybe in the past it did not matter and Origin just ignored it, but moving forward, if you check that option you should have parameter initialization code. |
|
|