Tellurium Plugins
Python Wrapper for Tellurium Plugins
|
The plugin API allows users to easily access roadrunner plugins. Only three concepts need to be understood:
Before using the plugin system the plugin library must be imported using the line:
To load a plugin called "tel_add_noise" use the Python command:
The variable p now represents the plugin. Plugins expose a number of properties, these are variables that can be inspected or set. For example the add noise plugin has a property called Sigma. To set this to a particular value we would use:
Likewise, properties can be inspected:
To list all propreties in a plugin use the method listOfProperties. The following uses call together with pprint to make the output more understandable:
To run a plugin so that it carries out its function, use the execute method:
The results from an execute call will either be saved to a file or more likely via properties of the plugin. As a trivial example, consider a plugin called "add" that has three properties, x, y and z. When the execute() method is called the plugin will take the values stored in x and y, add them together and store the result in z. The following script illustrates how the plugin would be used from Python:
The following script illustrates a more substantial example using the add_noise plugin
The plugin system supports a special data type called a Data Series. This is a convenient way to represent rows and colums of data. The data type also has the ability to label columns with a text string and to associate each value in the data series with an additional value called a weight. In practice the data series will usually store experimental data and the weights will represent a measure of undertaintly, perhaps a standard deviation, of the data point. A Data Series can be created using the call:
Data can be entered into a data series either by loading the data from a specially formated file or from a Python NumPy array. For example:
To read numpy arrays into a data series use the code:
The number of rows and columns in a Data Series can be obtained using:
Currently individual values in a data series can be accessed using the set and get methods:
Data series can be plotted using the plot method:
The following script is an example of using the add_noise plugin. This plugin takes a data series and add a given amount of Guassian noise to all data except the data in the first column.
Plugin objects are instanciated using Plugin class. For example to instanciate a plugin called myplugin, we would use the code:
All interactions with plugins are via plugin properties. Values can be set and retrieved via plugin properties. For example, if a plugin has a property sigma, we can assign or access the value using the code:
Plugins have a single method that can be used to excecute the plugin's functionality:
Once a plugin has been executed, any output from the plugin can be retrieved via properties. Let's suppose for example there is a plugin all add, which has three properties called, x, y and result. When executed the plugin will take the values in x and y, compute the sum and assign it to result. The plugin can therefore be used as follows: