The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Access to NLSF object values
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

sterw

Netherlands
Posts

Posted - 08/07/2008 :  06:32:00 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
OriginPro 8 SR2 on Windows XP

In a previous topic ( http://www.originlab.com/forum/topic.asp?TOPIC_ID=6406 ) I asked a question about how to access the NLSF values. It was possible in 7.5 (NLSF.p1, NLSF.e1 etc), but not in version 8. It would be made possible again in a new service release.
How does it work in SR2?

Regards, Wim

Fay_Guo

China
Posts

Posted - 08/12/2008 :  02:04:14 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Wim,

In SR2, the NLSF values can be accessed by NLSF.pn, NLSF.en etc.

For more detailed information, please see our LabTalk help file.

Open this file by clicking Help: Programming: Labtalk.
Type NLSF in the Search Tab and click List Topics button.

You can find the NLSF page.



Thanks
Fay Guo
Originlab Technical Service
Go to Top of Page

sterw

Netherlands
Posts

Posted - 08/12/2008 :  03:20:30 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks for the answer, but that is not what I meant.
When I did a non-linear fit in O7.5 the nlsf values were available and I could access them in the script window by typing nlsf.p1 =, nlsf.e1=, etc. and I could also use them in Origin C.
In O8 this is not possible. Apparently the non-linear fit objects are not passed on automatically to the nlsf objects anymore. That's why I posted topic http://www.originlab.com/forum/topic.asp?TOPIC_ID=6406 , which concluded with the promise that these objects would work again in the next patch.
My question is: does it work again in SR2 and if yes, how?

Wim
Go to Top of Page

SMCA

22 Posts

Posted - 08/12/2008 :  04:34:15 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,
sorry for not directly answering to Wim, but I thought this would be a good place to post a similar question: Is there a possibility to access the fit parameters programmatically after SEVERAL fits have been performed? What Wim addresses, as far as I understand, would be the access to the nlsf object directly after the fit. But this object would be changed on subsequent fits, right? So if I perform fit1, then do fit2, and then want to extract the fitted parameters for fit1 programmatically, is there a way to do this? I fiddled around a little bit with the analysis report tables, but except directly reading out the cells I found no way to extract the fit parameters.
Best,
Stefan

OriginPro 8SR2 B0891
Go to Top of Page

Echo_Chu

China
Posts

Posted - 08/12/2008 :  06:29:06 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi, Wim,

In SR2, you can use nlsf object to calculate and access NLSF values. It is the same as Origin 75. But in 80, the object is no longer related to the dialog.

However, you can use getnlr in SR2 to access NLSF result after you worked with dialog. It's usage is similar to getresult but result is simpler.

1. Active the report worksheet,
2. Type

getnlr


Then you can access the value such as tr.A=

If you want to access parameter such P1, P2. you can use it in following way

getnlr p:=1;


Then you can access the value such as tr.P1=

I hope this helps.

Echo
Originlab Corp

quote:
Originally posted by sterw

Thanks for the answer, but that is not what I meant.
When I did a non-linear fit in O7.5 the nlsf values were available and I could access them in the script window by typing nlsf.p1 =, nlsf.e1=, etc. and I could also use them in Origin C.
In O8 this is not possible. Apparently the non-linear fit objects are not passed on automatically to the nlsf objects anymore. That's why I posted topic http://www.originlab.com/forum/topic.asp?TOPIC_ID=6406 , which concluded with the promise that these objects would work again in the next patch.
My question is: does it work again in SR2 and if yes, how?

Wim

Go to Top of Page

Echo_Chu

China
Posts

Posted - 08/12/2008 :  07:02:18 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi, Wim and Stefan


In Origin 8 SR2, we have 3 ways to calculate and access NLSF results

1. nlbegin, nlfit, nlend...
There is a new set of X-Functions to control the new Origin 8 NLFit engine. If you want to use global fit, or fit with replica, you can use these xfs. And it is easier to be handled than nlsf object.

For simple examples of these x-functions, you can type "help nlbegin" in command window and check the Example part of document.

For more complicated applicaton, please refer to this page/

http://www.originlab.com/www/helponline/Origin8/en/Programming/LabTalk/Curve_Fitting.html#Nonlinear_Fit

2. nlsf object
It is same as Origin 75. We prepare this for old user from 75. You can refer more details from this page:

http://www.originlab.com/www/helponline/Origin8/en/Programming/LabTalk/Scripting_for_Non-Linear_Curve_Fitting.html


3. getnlr
The xf is used to get result from report tree after NLSF is performed from dialog. But please note that you need to active result sheet first. Usually the result sheet of NLSF is called NLSF1, NLSF2...
So you can use script below to active corresponding worksheet

page.active$=FitNL2



Echo
OriginLab Corp

Go to Top of Page

sterw

Netherlands
Posts

Posted - 08/12/2008 :  08:21:41 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks for the answer.
getnlr works but tr.A= does not.
Similarly getnlr p:=1; works, but tr.p1= does not.
Moreover where can I find information about using getnlr?
The present information in the help file is rather short. For instance your suggested getnlr p:=1 command is not described.
I would appreciate a more detailed description of its possibilities and an example of its use in Origin C.
Furthermore page.active$=FitNL2 only works when the workbook where FitNL2 is part of is active. When a graph is in front it does not work. Is there a way to force the result sheet to be active also in cases where other windows such as graphs are active?

I still think it is a pity that the NLSF objects (nlsf.p1, nlsf.e1 etc.) are not automatically filled with the fit results. In that case I would not have to worry about making the correct worksheet active.

Wim
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 08/12/2008 :  08:26:55 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
There should be no need to activate the result sheet to use an X-Function like getnlr. To see how to use any X-Function, from script window type

xfname -h

so for getnlr, do

getnlr -h

Assuming that your source book is Book1, to get the result from the fit, use following:


getnlr myfit iw:=[Book1]FitNL1 p:=1;


Then you can see the result tree myfit by

myfit.=

As you can see from getnlr, p:=1 is to turn on the pnotation.


We will post some examples in Origin C soon.

CP
Go to Top of Page

sterw

Netherlands
Posts

Posted - 08/12/2008 :  09:36:32 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks for the explanation. I 'm eager to see examples of using getnlr in Origin C. Could you please give me one simple example in the mean time.

Wim
Go to Top of Page

greg

USA
1380 Posts

Posted - 08/12/2008 :  12:15:25 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You can make use of some new system string variables available in SR2. You can list these varaiables with:
list vs

After fitting, the __REPORT string variable contains the sheet range of the last fit result. Using the getnlr command you can directly access the tree contained in the Report page. For a GAUSS function (4 parameters) you can use:

getnlr iw:=__REPORT$ tr:=FitRes pn:=1;
type y0 \x3D $(FitRes.p1) ($(FitRes.e1));
type xc \x3D $(FitRes.p2) ($(FitRes.e2));
type w \x3D $(FitRes.p3) ($(FitRes.e3));
type A \x3D $(FitRes.p4) ($(FitRes.e4));

P.S.
This is a much better mechanism than the old NLSF. You can still use the old fitter with NLSF.Control(), but learning the newer code will make going forward much easier.
Go to Top of Page

eparent

118 Posts

Posted - 08/12/2008 :  1:42:47 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I have created an Origin C example of calling the getnlr X-Function and put it on the Origin C wiki.

http://ocwiki.originlab.com/index.php?title=OriginC:Accessing_X-Function#Example_calling_the_getnlr_X-Function

quote:
Originally posted by sterw

Thanks for the explanation. I 'm eager to see examples of using getnlr in Origin C. Could you please give me one simple example in the mean time.

Wim

Go to Top of Page

sterw

Netherlands
Posts

Posted - 08/13/2008 :  03:09:50 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks greg and eparent for your contributions.
They helped me a lot!

Wim
Go to Top of Page

sterw

Netherlands
Posts

Posted - 08/13/2008 :  09:38:48 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I have one more question:
Is there a command to get the names of the fit parameters? In NLSF it is possible with NLSF.n1$=, nlsf.n2$=, etc but the parameter names are not included in getnlr (their values are, but not their names).

Wim
Go to Top of Page

eparent

118 Posts

Posted - 08/13/2008 :  11:44:02 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The pnotation argument determines the names that are used in the tree.

0 = Parameter names
1 = Abbreviations (p1, p2, etc.)
2 = Both

My example was using 1, abbreviations, which uses p1, p2, etc. in the tree. If you change it to 0 or 2 then the parameter names will be used in the tree. I have updated the example to use 2 and added comments to indicate the allowed values.

There is not a function, method, or easy way to get a parameter name from a fit tree using the parameter's index. I have written the following Origin C function that will do the trick for you. Be sure your fit tree was generated with the pnotation argument set to 2, as shown in the updated example, otherwise calling get_param_name will fail. Also note that the first parameter index is 1 not zero.

bool get_param_name(Tree& trFit, int nPIndex, string& strPName)
{
	string strPAbbr;
	strPAbbr.Format("p%d", nPIndex);
	TreeNode tn = trFit.GetNode(strPAbbr);
	if( tn.IsValid() )
	{
		tn = tn.NextNode; // node after pN has same name as pN
		if( tn.IsValid() )
		{
			strPName = tn.tagName;
			return true;
		}
	}
	return false;
}



quote:
Originally posted by sterw

I have one more question:
Is there a command to get the names of the fit parameters? In NLSF it is possible with NLSF.n1$=, nlsf.n2$=, etc but the parameter names are not included in getnlr (their values are, but not their names).

Wim

Go to Top of Page

sterw

Netherlands
Posts

Posted - 08/13/2008 :  12:23:28 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
That works! Thank you very much.
Wim
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000