Author |
Topic |
|
Clairekun
Germany
175 Posts |
Posted - 02/25/2013 : 05:03:58 AM
|
Origin Ver. and Service Release (Select Help-->About Origin): 9 Operating System: Windows 7
Hello,
I have an XYYYY workbook with multiple peak data. First, I would need to plot all XY data on different graphs (line plot). I would like to set Y column comments as long names in my graphs.
Then, I would need to perform a gaussian fit for the same ranges in every graph, i.e. rows 100 to 200 and 250 to 600. Since I know the range, I could specify the peak maximum if needed.
Thank you kindly in advance. |
Edited by - Clairekun on 02/25/2013 05:05:18 AM |
|
greg
USA
1378 Posts |
Posted - 02/28/2013 : 2:54:55 PM
|
Starting from your workbook ...
string strBook$ = page.name$; string strSheet$ = layer.name$; ncols = wks.ncols; loop(ii,2,ncols) { range rad = [%(strBook$)]"%(strSheet$)"!$(ii); plotxy iy:=rad plot:=line; range rap = !(1[100:200],1[250:600]); nlbegin iy:=rap func:=gauss; nlfit; nlend out:=1 auto:=1; }
|
|
|
Clairekun
Germany
175 Posts |
Posted - 03/04/2013 : 04:46:04 AM
|
Thank you, this works almost perfectly: Origin creates only one graph, plotting everything in different layers (and, therefore, graphs aren't renamed, but this isn't the main issue).
I would need different graphs, since these stacked layers make it impossible to study them separately. |
|
|
Clairekun
Germany
175 Posts |
Posted - 03/12/2013 : 6:41:32 PM
|
I have been browsing the wiki and find no way of doing this; however, if there was a way to move layers to new graphs -including fitting results-, what I need could be achieved.
Could this be done?
Thanks again. |
|
|
easwar
USA
1964 Posts |
Posted - 03/16/2013 : 10:07:50 PM
|
Hi,
You can just create a new graph page for each column by changing this line:
plotxy iy:=rad plot:=line ogl:=[<new>];
The [<new>] notation means a new graph page is created each time.
Easwar OriginLab |
|
|
Clairekun
Germany
175 Posts |
Posted - 03/19/2013 : 05:32:17 AM
|
Thank you!! This was all I needed.
By the way, if I needed to export certain fitting results to a new worksheet, how could this be achieved? For example:
I would need to extract FWHM and its standard error to a new worksheet. This new worksheet would need to have a column with FWHM and standard error for all my fitting results.
Thanks in advance.
|
Edited by - Clairekun on 03/19/2013 07:32:27 AM |
|
|
easwar
USA
1964 Posts |
|
Clairekun
Germany
175 Posts |
Posted - 03/21/2013 : 06:05:53 AM
|
Thank you!
I realized I need to do multiple peak fitting for some of my XYYY worksheets. I have browsed the wiki and I know a replica is needed for this (replica = no. of peaks - 1), but I can't find how to specify peak centers.
What would I need to add to the code? |
|
|
easwar
USA
1964 Posts |
Posted - 03/21/2013 : 7:49:47 PM
|
Hi,
You need to look at x-functions nlbegin, nlfit, nlend etc, and see how to use the tree to get and set parameters.
Here is an example:
// Use sample file
string fname$=system.path.program$+"Samples\Curve Fitting\Multiple Peaks.dat";
newbook;
impasc;
// plot col D
plotxy iy:=col(d);
//Fit with gauss function, three peaks
int npeaks=3;
nlbegin func:=gauss nltree:=myt replica:=npeaks-1 pnotation:=abbr;
// peak parameters should be automatically initialized
// so go ahead and fit
nlfit;
// print out the peak centers
for(int ipk=1; ipk<=npeaks; ipk++)
{
type peak#: $(ipk), peak center: $(myt.p$(2+(ipk-1)*3));
}
// can change some parameter if desired
// such as fix center of 2nd peak to be at 5.1
myt.p5 = 5.1;
myt.f5 = 1;
// fit again
nlfit;
// end fit and create report
nlend out:=1 autoupdate:=AU_AUTO;
Hope this helps.
Easwar OriginLab |
|
|
Clairekun
Germany
175 Posts |
Posted - 03/22/2013 : 06:11:43 AM
|
First of all, thank you. I learned a lot with this.
I modified the script to my needs and it works, although I am finding some problems with finding the peaks correctly (they are not as clearly separated as the ones in the sample).
Whenever I specify peak centers, I get the following error message: quote: Fit did not converge - mutual dependency exists between parameters. You may have overparameterized the fitting function. Fixing one of them may eliminate this problem.
I tried using Analysis>Peaks and Baseline>Multiple Peak Fit menu for one of my graphs. Here, I could select all peak centers and it showed no problem at all, so I can't understand why it does if I do it manually.
I realized that the message doesn't pop up if I change the parameters to a different but similar number.
What could be the cause? |
Edited by - Clairekun on 04/02/2013 06:33:03 AM |
|
|
easwar
USA
1964 Posts |
Posted - 03/22/2013 : 3:57:25 PM
|
Hi,
Hard to tell without seeing your data....please send your data/opj along with the script you used, to tech. You can use the "Send File to Tech support" link at the top right of this page. Then in your e-mail, please refer to this thread.
Easwar OriginLab |
|
|
Clairekun
Germany
175 Posts |
Posted - 04/04/2013 : 03:42:32 AM
|
While I was preparing a project with several graphs explaining what was wrong, in order to send it to tech support, I noticed that fitting them with the tool may also encounter the same errors about not converging and finding peaks wrongly.
I have reached a conclusion: peaks are apparently correct (I hadn't fully understood the concept), and certain peak centers have X values which aren't suitable for that function. I will have to find proper values first before fitting the whole worksheet.
Now that I have my fitted plots, is there any way to rename results tables to graph names, so that I know where they come from? I have been browsing the forum and the wiki, but all I can find is how to rename graphs to worksheets and not the other way around.
I renamed my graphs to column comments with the following code:
doc -ef P{
page.label$=%(1Y,@LC);
string str$ = page.label$;
} This doesn't work for result tables because (I assume) they are not referred to my worksheet but to graphs, and I can't find an @option to specify graph name. I guess I could address the code to a specific worksheet, but I cannot find how. I know that, if I were to use a code like the one above but for all worksheets in folder, I would have to move my data worksheet elsewere. |
Edited by - Clairekun on 04/04/2013 04:09:32 AM |
|
|
cdrozdowski111
USA
247 Posts |
Posted - 04/04/2013 : 06:44:15 AM
|
If you are referring to the name of the actual graph, then there are two properties of the page object:
page.name$ - which is a unique short name generally automatically assigned (e.g. Graph1). You can change the automatically assigned short name via page.name$=whatever. But it has to meet the rules set up for short names.
page.longname$ which is the name you can give a graph or workbook that is more descriptive than the short name. It doesn't have to be unique.
page.label$ is apparently deprecated. |
|
|
Clairekun
Germany
175 Posts |
Posted - 04/04/2013 : 07:05:52 AM
|
I have read about those properties, but I don't know how to proceed so that, in the end, I have the same name for a graph and its result table after fitting. For example:
Before editing:
Graph name - W406nm Results table name - Table1
After editing:
Graph name - W406nm Results table name - W406nm
And for all tables in the folder, so the code would be:
doc -ef W{
//Here lies the problem
} |
Edited by - Clairekun on 04/04/2013 07:13:22 AM |
|
|
|
Topic |
|