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
 Origin Forum
 Get the parameter value

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
dominik.mierzwa Posted - 07/11/2019 : 07:54:54 AM
Origin Ver. and Service Release (Select Help-->About Origin): 9.5
Operating System:

Hi,

Is it initialize the fixed parameters during NLfit from a particular cell of the worksheet? Let me assume that I have a function:
y=a*x+b

and I would like to fix b and initialize its value from location [Book1]Sheet1!Col(1)[1] (cell A1 of sheet 1 in book 1)

I'm working on the batch processing of the multiple files but the parameter b is different for different files so I need to read its value from the worksheet.

A similar topic was discussed here:
https://my.originlab.com/forum/topic.asp?TOPIC_ID=19790

but it is quite old and I wonder how to define the value of the fixed parameter as a value of the particular cell from the worksheet.

Kind regards,
14   L A T E S T    R E P L I E S    (Newest First)
dominik.mierzwa Posted - 07/24/2019 : 3:11:18 PM
Brilliant! Thank you very much for explanation.

Kind regards,
Dominik
YimingChen Posted - 07/24/2019 : 08:49:36 AM
If you select "Delete intermediate workbooks", those workbooks are indeed deleted. What is saved with the project is only the info of each dataset like the worksheet with the data or the path of data file. When clicking 'Open workbook(s)', Origin actually load that dataset into analysis template and run the analysis again to generate output. Hope it is clear.

James
dominik.mierzwa Posted - 07/24/2019 : 02:46:20 AM
quote:

Make sure to create analysis template again after the function is modified. Thank you.

James



Is it possible to modify the analysis template instead of the creation of a new one?

EDIT:
Ok, I managed it. The clue: if you simply go to report sheet>change parameters>initialize parameters Origin will reload the old code. You need to choose another function from the library and then re-chose the proper one, then the code will be updated.

EDIT2:

Before Batch processing, I can choose the option "Delete intermediate workbooks". Then I receive a Report spreadsheet with data. However, I can see the intermediate workbooks by clicking the 'Open workbook(s)' button'. How these workbooks are stored? Is these connections connection permanent or are lost after a system restart? If they are permanent what is deleted by the 'Delete intermediate workbooks' option? I have noticed a meaningful difference in the file size if delete option is applied, but where these data are stored? Thanks for the explanation.


Kind regards,
Dominik
YimingChen Posted - 07/23/2019 : 10:34:06 AM
Yes. When the fitting function is modified, you need to make the analysis template again. Origin won't automatically find the fitting function from database, the fitting operation is saved in the analysis template.

In your case that D[1] is empty, the parameter initialization code needs to be modified to check whether D[1] exists, please change to:

        Worksheet wks = Project.ActiveLayer();
	WorksheetPage pg = wks.GetPage();
	Worksheet wksTgt = pg.Layers(0);
	Column colY(wksTgt, 3); 
	vectorbase& vec = colY.GetDataObject();
	if (vec.GetSize() == 0)
		L = 0;
	else
		L = vec[0];


Make sure to create analysis template again after the function is modified. Thank you.

James
dominik.mierzwa Posted - 07/23/2019 : 07:36:46 AM
Ok, it works however, I had to create a new analysis template with new parameters initialization code. I thought that during the batch processing NLfit works with the (actual) function from the database, and changes in the function structure are effective in the analysis. But, after processing, I noticed that despite the changes in the code, the template used the old one.

Moreover, I found the reason for "Vector operation dimension check error" message. This error occurs when the L value is missing in the worksheet (empty cell). What is interesting, the NLfit takes 0,01 for the calculation and does not indicate any problem with fitting.




Kind regards,
Dominik
YimingChen Posted - 07/22/2019 : 10:21:08 AM
Hi,

You are right. Please modify the script to

	Worksheet wks = Project.ActiveLayer();
	WorksheetPage pg = wks.GetPage();
	Worksheet wksTgt = pg.Layers(0);
	Column colY(wksTgt, 3); 
	vectorbase& vec = colY.GetDataObject();
	L = vec[0];


Notice here it references to the first worksheet of current workbook. Thank you.

James
dominik.mierzwa Posted - 07/22/2019 : 02:37:20 AM
Hi,

I faced another problem. Currently, the parameters are initialized through the script and during the first fitting it works fine but during recalculation, it fails.



It seems to me that the problem arises from reference to the active project layer:
Worksheet wks = Project.ActiveLayer();
During the recalculation the active layer is FitNL1.


Kind regards,
Dominik
YimingChen Posted - 07/16/2019 : 5:32:17 PM
That is case by case. Would you please sent your problematic file to <tech@originlab.com> so that we can check for you? -James


quote:
Originally posted by dominik.mierzwa

Batch processing works perfectly. However, I got sometimes "Vector operation dimension check error" message in LOG. What does it mean?

Kind regards,
Dominik

dominik.mierzwa Posted - 07/15/2019 : 08:05:58 AM
Batch processing works perfectly. However, I got sometimes "Vector operation dimension check error" message in LOG. What does it mean?

Kind regards,
Dominik
YimingChen Posted - 07/12/2019 : 09:18:16 AM
1. L is added to the model equation because it is used to calculate derived parameter after fitting.

2. The formula in function builder can use meta data from column header row to initialize fitting parameters. The User Parameter you saw is user defined meta data which is still within column header lines. So unfortunately you cannot assign worksheet cell to fitting parameter this way. OC code is the way to go.

3. You need to check the box of Fix for L in the NLFit dialog to fix L. 'Allow Initializing Fixed Parameters' in function builder is only ask whether to initialize fixed parameter, it does not fix the parameter. If you want to perform the fitting on other dataset, you will need to save the workbook as analysis template and then use batch processing.

James

dominik.mierzwa Posted - 07/12/2019 : 03:04:59 AM
I thought that it will be much easier. Technical question: why did you introduce the term '+0*L' to the model equation? I understand that from a mathematical point of view it does not change anything but do I need to define all parameters in the model equation?
In the Fitting Function Builder, I can define 'Initial Formula' for parameters. The formula looks quite simple for predefined values such as X MIN, X MAX, LAST X and so on. I thought that it is possible to define here the reference to the particular cell e.g. =[Book1]Sheet1!Col(1)[1] but it doesn't work. I wonder how to define 'User-defined parameters' (XD1, YD1...) and do I have to check the 'Allow Initializing Fixed Parameters'?




During the testing procedure, I have noticed that NFfit change value of L (which is in the second Y's column in current version) during the fitting procedure. I think that 'Fix' check-box should be checked.



Kind regards,
Dominik
YimingChen Posted - 07/11/2019 : 12:10:26 PM
OK, so in this case L is only used to calculate the derived parameter. We can use the following work around. Set the fitting function to A - B*x + 0*L so that L can be passed from worksheet cell to fitting parameter, then eventually be used to calculate Deff:


Here the code to initialize L is:

Worksheet wks = Project.ActiveLayer();
Column colY(wks, 3); 
vectorbase& vec = colY.GetDataObject();
L = vec[0];


And the derived parameter will be shown in the resulting sheet.


If you have more questions, please contact <tech@originlab.com>, thank you.

James
dominik.mierzwa Posted - 07/11/2019 : 11:20:40 AM
Let me describe it in detail.
1. After data import I have worksheet with data organized as follow:

2. Next, I use data from column C ln(MR) and fit with the function:
y=A-B*x
Both parameters A and B are variables.



3. After fitting the Deff parameter is calculated in accordance with the formula:
Deff=(B*4*(L/2)^2)/PI^2

The L parameter is the parameter which should read from the worksheet (cell D1). Currently this parameter is fixed and equal 0.001

I'm not sure if I correctly defined my function in NLfit library but it works fine so far. The only problem is that L is different for a different data set and I would like to change it automatically after import of new data set.


Kind regards,
Dominik
YimingChen Posted - 07/11/2019 : 09:50:01 AM
Hi,

Supposedly you want to initialize fitting parameter b to the first cell of col(A) of active worksheet, you can modify the parameter initialization OC code in the function definition. Here are the steps:
1. Select menu Tools: Fitting Function Organizer... or press F9.
2. Select Polynomial folder in the left, select Line function. Click Duplicate button on the right to make a copy.
3. Select the duplicated function CopyOfLine(User) in the left. in the middle panel, find Parameter Initialization entry. Click the button to the right of the entry box to launch code Builder.
4. Replace the body of function with code:

        sort( x_y_curve );
	double coeff[2];
	fitpoly( x_y_curve, 1, coeff);  
	A = coeff[0];
	Worksheet wks = Project.ActiveLayer();
	Column colY(wks, 0); 
	vectorbase& vec = colY.GetDataObject();
	B = vec[0];

The code is to set initial value of B to specific cell of active worksheet. Click Compile button to make sure it compiles fine.
5. Click Return to Dialog button. Click Save button to save the function.
6. Fitting data with this function automatically initializes B to col(A)[1] of the current worksheet.



Thanks,
James

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