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
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 nlsf paramater initialization

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
bnahir Posted - 11/03/2006 : 10:47:13 AM
Origin Version (Select Help-->About Origin): Pro 7.5
Operating System: XP

Hopefully this is an easy question:
I am trying to automate a Gaussian fitting function using the nlsf package. This script was working, for the most part, until about an hour ago, when I suddently started receiving a runtime error saying the LabTalk command had failed. After a little error checking, I narrowed it down to the line
nlsf.execute("parainit");

It seems that all nlsf commands before that function fine but as soon as that line is called, the program generates the error. As I said, this function was working fine not too long ago and I didn't make any changes that should have affected that function call. Any suggestions?

My script (called by another function):
(cc_Rename is an in house, commonly used function)

double fitGauss(vector<int>& vCounts, int rangeBegin, int rangeEnd){
Dataset dsFreq;
string wksName="wksTemp";
string strData=wksName + "_b";

Worksheet wksTemp;
if (!wksTemp.Attach(wksName)){
if(wksTemp.Create()){
cc_Rename(wksTemp, wksName);
}
}
dsFreq.Attach(wksTemp.Columns(1));
dsFreq.Append(vCounts);

using nlsf = LabTalk.nlsf;
nlsf.init();
nlsf.cleanupfitdata();
nlsf.dataBegin=rangeBegin;
nlsf.dataEnd=rangeEnd;
nlsf.func$="Gauss";
nlsf.constr$="";
nlsf.fitData$=strData;
nlsf.execute("parainit");
out_str("Parameter initialization:");
out_double("y0=",nlsf.p1);
out_double("xc=",nlsf.p2);
out_double("w=",nlsf.p3);
out_double("A=",nlsf.p4);
nlsf.output(0);
nlsf.fit(100);
nlsf.end(13);

// wksTemp.Destroy();
out_double("Gaussian center (p2) = ",nlsf.p2);
return nlsf.p2;
}
6   L A T E S T    R E P L I E S    (Newest First)
Mike Buess Posted - 11/06/2006 : 11:14:21 AM
Not sure why but nlsf.output(0) must appear before nlsf.fitData$=strData.

Mike Buess
Origin WebRing Member
bnahir Posted - 11/06/2006 : 10:29:32 AM
Hi easwar,

Thanks for your help. I actually managed to figure out what my problem was (the data I'm working with is rather large and I didn't want to overwhelm our server..). I didn't realize that, in order to perform a nlsf fitting algorithm, I needed to supply both x and y values. I assumed that if only y values were used, the function would default to row numbers (or vector indices) as the x-values. Once I passed both vectors, it worked fine.

I do have one other question though. At the end, I'm trying to suppress all worksheet and graph outputs. I thought the way to do that is how I've written it, however, the function still creates both the nlsf data sheet and the fit window. Since method is called in an iterative loop, that generates a lot of wasted memory. Am I missing something regarding the output from the nslf?

Thanks
easwar Posted - 11/03/2006 : 3:21:38 PM
Hi bnahir,

Does this happen with a particular dataset or any dataset? Does it happen with a dataset that used to fit fine with same code before? Did you try restart Origin? Do the parameters at that point have any value, or all are missing value?

It is hard to tell what is going on without having exact data and code to test with...

Easwar
OriginLab



Edited by - easwar on 11/03/2006 3:22:18 PM
bnahir Posted - 11/03/2006 : 3:18:00 PM
The gist of the error is that the parameters are not being initialized. The error text (in a pop up box) is:
Error! Parameter(s) y0, xc, w, A is(are) not properly initialized. Check their values.

This is where I am confused, because I was using the nlsf.execute("parainit") specifically for the parameter initialization...
easwar Posted - 11/03/2006 : 11:41:42 AM
Hi bnahir,

I took your function and did some simple modification as pasted below and tested and it worked fine on a gaussian dataset in my worksheet col B.

Not sure what is causing the error, and not easy to tell without specific data, range etc on which it fails.

Can you send your data and the actual error message that you got to tech support?

Easwar
OriginLab


void test(int rangeBegin, int rangeEnd)
{
Worksheet wks = Project.ActiveLayer();
string wksName = wks.GetPage().GetName();
string strData=wksName + "_b";


using nlsf = LabTalk.nlsf;
nlsf.init();
nlsf.cleanupfitdata();
nlsf.dataBegin=rangeBegin;
nlsf.dataEnd=rangeEnd;
nlsf.func$="Gauss";
nlsf.constr$="";
nlsf.fitData$=strData;
nlsf.execute("parainit");
out_str("Parameter initialization:");
out_double("y0=",nlsf.p1);
out_double("xc=",nlsf.p2);
out_double("w=",nlsf.p3);
out_double("A=",nlsf.p4);
nlsf.output(0);
nlsf.fit(100);
nlsf.end(13);

}


Mike Buess Posted - 11/03/2006 : 11:40:21 AM
Before losing any sleep over this problem I suggest you restart Origin. Sometimes strange things like this happen during extended Origin sessions, especially when programming is involved, and a restart is sometimes necessary to set things straight.

Mike Buess
Origin WebRing Member

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000