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
 Origin Forum
 interpolate onto irregular x-axis?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

ehudson

USA
3 Posts

Posted - 11/26/2001 :  2:34:03 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I would like to interpolate a dataset defined on one irregularly spaced x-axis onto a different set of x-values. The new x values are all within the range of the original x values, so there is no extrapolation. Is there a simple way to do this?

This problem arises in the more general challenge of fitting spectra using a linear combination of empirical data. Please let me know if there are any tools available for this, also. (It is ok to use scripts to do this since I need to automate it anyhow.)

Thanks

rtoomey

USA
184 Posts

Posted - 11/27/2001 :  11:47:02 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
An interpolate/extrapolate feature is already built into Origin. With a graph active, select Analysis | Interpolate/Extrapolate (or in earlier versions... Analysis | Inter/Extrapolate). To see the LabTalk code used, look at the [Interpolate] section in GRANALY.OGS. This file can be found by navigating to your Origin installation folder through Windows Explorer. Please note that several additional sections are called within the [Interpolate] section. You might need to look at them as well. Most are located in the same file.

Hope this helps!

- rtoomey

Go to Top of Page

marko

Germany
112 Posts

Posted - 11/27/2001 :  12:04:02 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
This way you get by default a linear interpolation.

If you want to achieve some spline interpolation instead one has to set the line type of the displayed curve to spline. This might be helpful as well for you.

On the other hand, a question to the ORIGIN team: Is there a way to get the same functionality just for the worksheet? I need interpolation myself, from time to time, so is there a way to avoid making a graph and only then being able to select the appropriate Analysis/Interpolate menu point???

Regards,
Marko

Go to Top of Page

asp001

Russia
9 Posts

Posted - 11/28/2001 :  08:02:06 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I'm not from OT, but it might help you (linear interpolation using wks only)

http://www.originlab.com/www/support/resultstech.asp?ItemID=697&VersionID=All&TitleID=How+to+create+an+interpolated+dataset&CatID=Analysis&TypeID=Script

By the way Origin Knowledge base is very helpfull sometime.
Regards,
SVB
Go to Top of Page

marko

Germany
112 Posts

Posted - 11/29/2001 :  02:58:26 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks for that link. Quite complicated though, compared to the rather simple approach with a graph open. But, OK.

Well, but the Question is still: HOW can I switch to another interpolation type, like spline or bezier???

Regards,
Marko

Go to Top of Page

rtoomey

USA
184 Posts

Posted - 11/29/2001 :  09:18:22 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
A graph is required to perform any sort of interpolation when the Line Connection type is not Straight.

Although this is somewhat of a limitation, there are ways to open a graph and then destroy it afterwards.

For instance, you could open the graph using the window -t command option and then close it using the window -c command option.

Ryan Toomey
Technical Support
OriginLab Corp.

Go to Top of Page

ehudson

USA
3 Posts

Posted - 12/10/2001 :  4:16:51 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:

An interpolate/extrapolate feature is already built into Origin. With a graph active, select Analysis | Interpolate/Extrapolate (or in earlier versions... Analysis | Inter/Extrapolate). To see the LabTalk code used, look at the [Interpolate] section in GRANALY.OGS. This file can be found by navigating to your Origin installation folder through Windows Explorer. Please note that several additional sections are called within the [Interpolate] section. You might need to look at them as well. Most are located in the same file.

Hope this helps!

- rtoomey





This approach will interpolate onto a regularly-spaced set of x-values. But my
question is how to interpolate onto arbitrary x-values which are not equally spaced.
Since I posted, I discovered I can use a functional form like this:
Newdata_b=Oldata_b(newdata_a)
where columns a and b are x and y respectively. Is this best way? I want to put it into a NLSF function, so I am concerned that it may be slow.


Thanks
-Eric
Go to Top of Page

rtoomey

USA
184 Posts

Posted - 12/12/2001 :  11:48:31 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I believe the method you are using

Newdata_b=Oldata_b(newdata_a)

is the best approach (at least that I can think of right now). Furthermore, since this type of operation can be performed on vectors (i.e. entire datasets), it is inherently fast. In other words, when you perform an operation such as:

data1_d=data1_b(data1_c)

where data1_b is the original Y data, data1_c is a new set of X data, and data1_d is the location of the new Y data, the operation occurs very quickly since it is operating on the entire dataset.

As long as your datasets aren't huge, this shouldn't take very long in the fitter.

Hope this helps.

- rtoomey

Go to Top of Page

H.Steen

Norway
12 Posts

Posted - 12/21/2001 :  05:14:39 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Interpolation failure with %H_D=%H_B(%H_C) syntax. (%H=Active dataset name)

If the above code is executed in the worksheet script the result is wrong if col. B contains a non numeric data at the end. See result below.

A B C D
1 1 1.4 2.2
2 4 1.9 3.7
3 9 2.4 5.2
4 16 3 7
-
(The - should show up on col. B as last row, the forum system don't want to display it like this)

When the non-numeric value is removed it is OK:

A B C D
1 1 1.4 2.2
2 4 1.9 3.7
3 9 2.4 6
4 16 3 9

A bug fix is recommended.

Helge Steen

Edited by - H.Steen on 12/21/2001 05:16:58
Go to Top of Page

rtoomey

USA
184 Posts

Posted - 12/21/2001 :  09:15:50 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply

Helge,



If I understand you correctly you have your data organized similar to the following.



A(X)B(Y)C(Y)
row 1111.4
row 2241.9
row 3392.4
row 44163
row 5 text 


If you then add another column and execute an interpolation as follows...



%H_D=%H_B(%H_C) where %H is the active window title



...you get a dash in the place of the word "text" in column B. Is that true?



I tried this in the latest 7.0 build, 6.1 SR4 (6.1113), and 6.0 Release (6.0211). In the latest 7.0 build and 6.0 Release, the result was exactly as you see it below:







A(X)B(Y)C(Y)D(Y)
row 1111.42.2
row 2241.93.7
row 3392.45.2
row 441637
row 5 text  


In 6.1 SR4, the result was as follows:







A(X)B(Y)C(Y)D(Y)
row 1111.42.2
row 2241.93.7
row 3392.45.2
row 441637
row 5 text -


As you can see, the dash appears in column D for me. Is this what you meant? If so, it should be corrected when the new version comes out. If not please explain how I can reproduce the problem.



Sincerely,
Ryan Toomey
OriginLab Technical Support


Go to Top of Page

H.Steen

Norway
12 Posts

Posted - 12/21/2001 :  10:11:55 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
OK, I understand that my description is not clear enough:

The problem is NOT related to the result in row 5 (where the non numeric value is in col. B), it is related to the fact that the data in Col D is NOT correct ! Take a look again in my previous reply, the values are different in row 3&4 (sorry for not providing them as clear as your table), and if you plot them you will see that row 3&4 values are wrong, i.e. Col D. is not a interpolation version of Col. B !
(it is easy to see, look at the value in Col B for x value (Col A) = 3, The value is indeed 9 and not 7)

I had a division with zero on Col(B) in the beginning so that was the origin of my non numeric value.

As far as I understand you have shown that the bug is reproduced in all version (As you can see all your col D are wrong in row 3&4).

In your examples I normally prefer to Define Col C as an X-value (showing Col A as X1, and Col. C as X2) it is then a little more easy to understand the result of the syntax %H_D=%H_B(%H_C).

To be able to get it correctly I had to select all rows below row 4 and select Delete from the Edit menu, (all “garbage” is removed below line 4) and the script works OK !

I hope this makes it a little clearer and look forward to your reply.

My Origin version is V6.1052.

Helge


Go to Top of Page

rtoomey

USA
184 Posts

Posted - 12/28/2001 :  2:09:21 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Helge,

OK. Now I understand what the problem is. I really should have looked at your data more closely.

The interpolation of your data with the non-numeric (a.k.a. a missing value) included will proceed correctly if the interpolation is performed on the plot of column B(Y) (instead of the worksheet). This is because our interpolation was designed to work from the graph only. If you don't believe me, compare the Analysis menu when a worksheet is active to the Analysis menu when a graph is active. Only one contains interpolation.

So my suggestion would be to plot the data first, perform the interpolation, and then destroy the graph (if you don't want it that is). All of this can be done through LabTalk Script if you want. For instance, execute the following script on the worksheet:


%B=%H; // store name of active window
work -s 2 0 2 0; // select column 2
work -p 200 Origin; // plot column 2 as a line plot
%B_D=%C(%B_C); // perform interpolation where %C=active dataset
win -c %H; // close graph window
win -a %B; // activate original worksheet


I hope this makes sense. Please also keep in mind that the interpolation is affected by the line connection type. Therefore, if you connect the points of your plot using a Spline connection, you'll get different values.

Sincerely,
Ryan Toomey
OriginLab Technical Support


Go to Top of Page

rtoomey

USA
184 Posts

Posted - 01/03/2002 :  09:15:21 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Helge,

I added a suggestion in our database which would create an interpolate dialog for worksheets. If implemented, I thought the following controls would be appropriate:

1. Range FROM and TO text boxes.
2. Number of POINTS text box.
3. TYPE of interpolation drop-down list. This would include things like: Linear, Spline, etc.
4. DATASET to interpolate drop-down list. This would be set to the active dataset if one is selected.

The item can be referred to by mentioning the tracking ID, "AFO 31". If you have any additional input please let us know and we'll add it to the suggestion.

Thank you,
Ryan Toomey
OriginLab Technical Support

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