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 Python
 xfunction in Python

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
Pascal_S Posted - 07/25/2023 : 08:11:11 AM
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
7   L A T E S T    R E P L I E S    (Newest First)
YimingChen Posted - 12/08/2023 : 11:37:19 AM
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
YimingChen Posted - 08/02/2023 : 09:59:52 AM
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

Pascal_S Posted - 08/02/2023 : 07:56:53 AM
Hey,

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

Lg Pascal
YimingChen Posted - 07/27/2023 : 2:44:49 PM
Hi,

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

James
YimingChen Posted - 07/27/2023 : 09:17:44 AM
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

Pascal_S Posted - 07/26/2023 : 4:29:56 PM
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
YimingChen Posted - 07/25/2023 : 11:45:55 AM
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

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