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
 Forum for Python
 xfunction in Python
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Pascal_S

Germany
4 Posts

Posted - 07/25/2023 :  08:11:11 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hello,

I currently need to evaluate some spectra and would like to simplify this process using Origin Python. To do this, I read the raw data into Origin, run a filter over the data and create the graph including the plot and output it. In the following, I would like to use the x-function pa to run a pre-built theme over the data. The code snippet looks like this:


#MyTheme = op.path('p') + "Themes\Spectraanalyisis.ois" #Read the theme Spectraanalyisis
#MyTheme = op.path('p') + "Themes\Peakfinder.ois" #reading the Peakfinder theme
#wks.lt_exec('pa iy:=col(B) smode:=1 theme:=MyTheme') #does not work like this
wks.lt_exec('pa iy:=col(B) smode:=1 theme:=Peakfinder') #Calling the theme

As you can see, I'm trying to do the whole thing with a LabTalk function. The Peakfinder theme stores the correct x-coordinates and y-coordinates of the peaks and puts them in a new sheet. The Spectraanalyisis theme retrieves the peak analyzer (pro) and creates the corresponding Plot_Data, Integration_Result, etc. sheets. Unfortunately, however, it does not create the additional graphs as it does when run manually.
Several questions arise for me:

Is it possible to get the generated data processed as after manual execution without running new fit functions etc. over it? (Peakfinder - x-coordinate as label at the peak in the graph, peak analyzer (pro) with Gaussfits graph etc.).
Can I also access the x functions directly with python?
Can I assign the themes to a variable as in the comment out attempt and then retrieve it later? (Like MyTheme)

My Origin Version is OriginPro 2023 (64-bit) 10.0.0.154.

Thanks for your help.

Lg Pascal

YimingChen

1609 Posts

Posted - 07/25/2023 :  11:45:55 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You could call X-function from Python the same way as it does in LabTalk. Try the script below:

import originpro as op

f = op.path('e')+r'Samples\Curve Fitting\Multiple Peaks.dat'
wks = op.new_sheet()
wks.from_file(f)
wks.lt_exec('pa iy:=(1,2) smode:=1 theme:=myTheme')


You can manually run the PA and save the theme as myTheme before running the code above.

James
Go to Top of Page

Pascal_S

Germany
4 Posts

Posted - 07/26/2023 :  4:29:56 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you for your help.
I looked at the wks.lt_exec('pa iy:=(1,2) smode:=1 theme:=myTheme') again and found that I made a fault at the themes Name. After I changed it, it worked pretty much as intended.

In the Origin folder the themes are saved as 0-xFunctionName-ThemeName.osi. I changed the name in just ThemeName.osi which somehow crashed the retrieval of the pa-xFunction. It needs to be in the original order 0-xFunctionName-ThemeName.osi. Futhermore you can't use theme:=0-xFunctionName-ThemeName.osi as well. It needs to be the name you saved it with.

The part I could not solve is to save the theme in the projectfolder itself. I need the program on a USB to just plug it in and starting the programm. Is it somehow possible to retrieve the theme from another folder then the default one?


Lg Pascal
Go to Top of Page

YimingChen

1609 Posts

Posted - 07/27/2023 :  09:17:44 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Right now it is not possible to load the theme by its file path. You have to drag the theme file to the Origin workspace to install it first. I have created a ticket (ORG-27498) to report this request, and we will see if any improvements are needed.

quote:
Originally posted by Pascal_S

Thank you for your help.
I looked at the wks.lt_exec('pa iy:=(1,2) smode:=1 theme:=myTheme') again and found that I made a fault at the themes Name. After I changed it, it worked pretty much as intended.

In the Origin folder the themes are saved as 0-xFunctionName-ThemeName.osi. I changed the name in just ThemeName.osi which somehow crashed the retrieval of the pa-xFunction. It needs to be in the original order 0-xFunctionName-ThemeName.osi. Futhermore you can't use theme:=0-xFunctionName-ThemeName.osi as well. It needs to be the name you saved it with.

The part I could not solve is to save the theme in the projectfolder itself. I need the program on a USB to just plug it in and starting the programm. Is it somehow possible to retrieve the theme from another folder then the default one?


Lg Pascal

Go to Top of Page

YimingChen

1609 Posts

Posted - 07/27/2023 :  2:44:49 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

should it be good enough to support checking theme from the current project path?

James
Go to Top of Page

Pascal_S

Germany
4 Posts

Posted - 08/02/2023 :  07:56:53 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hey,

sorry for the late answer. It would fit to just access it from the project folder.

Lg Pascal
Go to Top of Page

YimingChen

1609 Posts

Posted - 08/02/2023 :  09:59:52 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you!

quote:
Originally posted by Pascal_S

Hey,

sorry for the late answer. It would fit to just access it from the project folder.

Lg Pascal

Go to Top of Page

YimingChen

1609 Posts

Posted - 12/08/2023 :  11:37:19 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

Just to let you know that in Origin 2024, we have made the improvement that you can load the X-function dlg theme from a theme file. Thank you.

James
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