5871

Programming in Origin and OriginPro

Origin and OriginPro provide a number of tools to import, analyze, plot, represent, and export data. The more familiar you get with Origin, the more you might want to create customized programs in Origin, using these options.

LabTalk

LabTalk is a scripting language native to Origin. For simple operations such as manipulating data and automating tasks, LabTalk is a good place to start. You can access a rich set of script commands and functions, including a large collection of X-Functions, to create scripts for your specific needs. Your custom script code can be easily assigned to buttons on graphs or worksheets, new toolbar buttons or custom menu items.

The Classic Script Window in Origin can be used to execute Labtalk script. The same window can also be used to execute Python code.
The Classic Script Window in Origin can be used to execute Labtalk script. The same window can also be used to execute Python code.
LabTalk script can be stored in OGS files, and organized by 'sections'. Scripts can be executed in many ways in Origin, including from button objects added to graphs and worksheet windows.
LabTalk script can be stored in OGS files, and organized by "sections". Scripts can be executed in many ways in Origin, including from button objects added to graphs and worksheet windows.

Origin C

This image shows an Origin C workspace in Code Builder, the integrated development environment
This image shows an Origin C workspace in Code Builder, the integrated development environment

Origin C is a programming language based on ANSI C, including additional support for C++ and C# features.

With Origin C, you can:

  • Create and access properties of all Origin objects such as worksheets, matrices and graphs
  • Automate your data analysis and graphing tasks
  • Build HTML Dialog with Java Script
  • Link to external dynamic link libraries (DLL)
  • Call C or Fortran library routines, such as the NAG library functions included with Origin, or other public-domain libraries

Origin provides a state-of-the-art integrated development environment called Code Builder for managing your Origin C projects.

This image shows an Origin C workspace in Code Builder, the integrated development environment
This image shows an Origin C workspace in Code Builder, the integrated development environment

Developer Kit

Dialog with National Instruments™ ActiveX Controls
Dialog with National Instruments™ ActiveX Controls

The Developer Kit is a utility that allows users to build complex dialog boxes, floating tools, and wizards and access them from Origin C. Dialogs created using the Developer Kit can contain embedded Origin graphs and other third party components.

Dialog with National Instruments™ ActiveX Controls
Dialog with National Instruments™ ActiveX Controls

X-Functions

Visually creating an X-Function with preview panel in X-Function Builder.
Visually creating an X-Function with preview panel in X-Function Builder.

X-Functions provide a framework for building custom tools in Origin. Simply define what controls you want in your dialog and Origin will generate the dialog from your definition. Once an X-Function is created, it can be placed in the Origin menu, accessed from LabTalk script, and shared with other Origin users.

Visually creating an X-Function with preview panel in X-Function Builder.
Visually creating an X-Function with preview panel in X-Function Builder.

Python

Set Column Values is one of several places where Python functions can be used to perform calculations and data transforms. The Python function, Before Formula Script, and the expression can all be saved together as a formula for future use.
Set Column Values is one of several places where Python functions can be used to perform calculations and data transforms. The Python function, Before Formula Script, and the expression can all be saved together as a formula for future use.

Origin provides an embedded Python environment so that you can run Python code in Origin.

  • A originpro package with easy, high-level access to Origin objects and data from Python
  • Intellisense support in Python Console
  • Use Python functions in Set Column Values
  • Define nonlinear fitting functions using Python
  • Define Python functions in Fitting Function Builder and Peak Analyzer
  • Support for Python code in the Import Wizard
  • Support for Python script in Buttons
  • Access to Python functions from LabTalk and Origin C
  • Several sample projects and workbook templates using Python, plus extended collection of code samples
Set Column Values is one of several places where Python functions can be used to perform calculations and data transforms. The Python function, Before Formula Script, and the expression can all be saved together as a formula for future use.
Set Column Values is one of several places where Python functions can be used to perform calculations and data transforms. The Python function, Before Formula Script, and the expression can all be saved together as a formula for future use.

R

This example shows simulation of a random walk in a 2D lattice computed in R, with the route displayed as an Origin line plot. The step number has been used a modifier for the line color.
This example shows simulation of a random walk in a 2D lattice computed in R, with the route displayed as an Origin line plot. The step number has been used a modifier for the line color.

Origin provides access to an R console and support for Rserve to exchange data between Origin and R. R commands can be issued from within Origin.

This example shows simulation of a random walk in a 2D lattice computed in R, with the route displayed as an Origin line plot. The step number has been used a modifier for the line color.
This example shows simulation of a random walk in a 2D lattice computed in R, with the route displayed as an Origin line plot. The step number has been used a modifier for the line color.
NAG Logo

NAG Library

Origin includes, and Origin C has full access to, the entire Mark 26.1 Library from the Numerical Algorithms Group, Inc. (NAG). Having NAG functions accessible from Origin C allows you to develop custom applications that require advanced numerical computation.

  • Complex Arithmetic
  • Zeros of Polynomials
  • Roots of One or More Transcendental Equations
  • Fourier Transforms
  • Wavelet Transforms
  • Quadrature
  • Ordinary Differential Equations
  • Partial Differential Equations
  • Mesh Generation
  • Interpolation
  • Curve and Surface Fitting
  • Minimizing or Maximizing a Function
  • Global Optimization of a Function
  • Linear Algebra
  • Matrix Factorizations
  • Eigenvalues and Eigenvectors
  • Determinants
  • Simultaneous Linear Equations
  • Linear Algebra Support Functions
  • Linear Equations (LAPACK)
  • Least-squares and Eigenvalue Problems (LAPACK)
  • Large Scale Linear Systems
  • Large Scale Eigenproblems
  • NAG Interface to BLAS
  • Simple Calculations on Statistical Data
  • Correlation and Regression Analysis
  • Multivariate Methods
  • Analysis of Variance
  • Random Number Generators
  • Univariate Estimation
  • Nonparametric Statistics
  • Smoothing in Statistics
  • Contingency Table Analysis
  • Survival Analysis
  • Time Series Analysis
  • Operations Research
  • Sorting and Searching
  • Approximations of Special Functions
  • Mathematical Constants
  • Machine Constants
  • Input/Output Utilities

Support for the NAG Library is available with ADDITIVE Professional Service.

Automation Server

Excel calling Origin
Excel calling Origin

Origin can be accessed as an automation server from client applications such as Excel, LabVIEW, MATLAB, or custom tools built using Visual Basic® or Visual C++ .NET. Data can be streamed into Origin and graphed, and tools in Origin such as Gadgets can be used to perform analysis on the incoming data. Post analysis of data can also be performed by pushing data into Analysis Templates™.

A typical client application may involve some, or many, of the following steps:

  1. Launching the Origin application.
  2. Opening a previously customized Origin project or preparing the default project to receive data from the client application.
  3. Sending data (collected from hardware) to Origin workbooks and matrices.
  4. Sending commands to Origin to process the data or have Origin update result columns using the recalculate analysis feature.
  5. Getting results back from Origin worksheets and matrices.
  6. Getting images of graphs and layout pages back from Origin.
  7. Saving the Origin project.
  8. Closing the Origin application.

Once the client closes the connection, the user could later launch Origin and just re-open the saved project for further processing.

A network (server/client) installation of Origin is ideal for taking advantage of this feature. Origin gets installed as a server on one computer and as a client on multiple computers, using a FlexLM license manager. Then, any technician who uses a client machine can be provided with a simple interface, such as an Excel worksheet or in-house Visual Basic application, by the company. These simple interfaces can then use the Origin client installation on their local machine to call the Origin server. In doing so, the technician does not have to learn how to use Origin itself, since all required controls would be on the customized interface.

OriginPro provides additional methods to handle multiple client applications.

Excel calling Origin
Excel calling Origin