Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Description

The UALPython enables manipulation of IDSs with the Python UAL interface. It also provides Matplotlib plotting capabilities by using a standard Python shell for interpretation of Python commands and scripts. Note that the manipulated IDS should be given into a new input port, it is up to the user to add this port (there are no restrictions to input port names for IDSs).

The actor can be used in two ways:
- the user provides a Python script written in a file as input. For this mode, connect a FileReader actor at the inputScript port of the UALPython.
- the user writes Python commands direclty in parameters of the UALPython. Double-click on the actor (or right-click on it and select Configure Actor) to access the text box where you can write the Python commands.

Info
title***** Note about how to program in python from the UALPython actor *****

The actor get IDS data automatically into a "idsnameX" variable (always an array, that will contain only 1 element in slice mode), where "idsname" is the type of the IDS (equilibrium, coreprof, mhd, etc...) and "X" is a number representing the position of the IDS amongst all inputs of the same type. For instance if there are 3 input IDSs in the order equilibrium, coreprof, equilibrium, the associated python variables will be named respectively "equilibrium0", "coreprof0" and "equilibrium1".
Some python packages are already imported and ready to be used. Here is the list: "import pylab", "import ual", "from numpy import *", "import sys", "import copy". For instance, for plotting with matplotlib you can call "pylab.plot(some_data)" and "pylab.show()".


A dictionary "ids_in" has been added for easy manipulation of all input IDSs of a given type: "ids_in['equilibrium']" contains the list of all equilibrium variables got from input ports.
You can also add output port for IDSs by respecting strictly the following naming convention: the port should be named by the name of the IDS variable in python. For writting a IDS present as input, simply put the name of the corresponding python variable (defined as explained previously). When the IDS has to be written into an occurrence different than the default one, then "/Y" as to be concatenated to the name of the variable (where "Y" is the occurrence number). In time slice mode of output IDSs, all IDSs are written at the time specified in the "time_in" input port (similar to FC2K).

Warning
titleIMPORTANT NOTE 1

...

python process is asynchronous with the actor, so if you have IDS as output of the actor you should set UALPython in synchronous mode.

Warning
title IMPORTANT NOTE 2

...

as for FC2K actors, all output IDSs are written in the same pulsefile/database, this one is given by the very first input IDS.

Info
titleADVANCED USERS

...

for writting IDSs that are NOT present as input (it can be another type of IDS, or another instance of a type already present as input), please follow the same rules for naming the python variable (type of the IDS + a number) as for input IDSs, but with a different number. Here is an example based of the inputs stated above: having "equilibrium0", "coreprof0" and "equilibrium1" as input variables, the first additional output port can be named "equilibrium1/1" to specify writting in the same pulsefile as the second equilibrium input and in occurrence 1 for this IDS. Then a new mhd IDS can be outputed by specifying for instance "mhd0/1" as the name of the output port for this IDS. This implies that the mhd0 variable exists in python and as been set and filled by the developer of the script. This can be done as the following: "mhd0 = ual.mhd.mhdArray()" and then "mhd0.resize(desired_nb_of_slices)".


Passing workflow's parameters valuse to Python script is possible via parameters property. This list can contain parameters that are defined on the workflow. List of parameters should be specified as comma separated list of parametes names. Each parameter is retrieved from the workflow and it's name and value is passed inside dictionary withing python script. The name of the dictionary is 'parameters'. Note! If you specify wrong name of the parameter, it will not occur in script.
For more information on usage of the Python UAL interface, please refer to its manual in the Python Visualization project under ITM gforge (http://portal.iter.org/gf/download/docmanfileversion/108/911/ual-python-doc.pdf).

...

port namepurposeIcon
inputScriptFile containing the Python script (for example given by a FileReader actor).

time_inTime at which the input IDSs are read, when slice mode is used.
iter_in

Only used when output IDSs are written in slice mode. If the passed value is 1 (one), it writes first the non-timed values of the IDS (this will erase previous data for this IDS). Else it just writes the time-dependent values. This is similar to FC2K actors.

Outputs

 

...

port namepurpose
time_out

Output time value is equal to input time value. This is similar to FC2K actors.

outputError

Error stream, used only in debug mode: returns standard output and error from the Python process, and gives the actual executed script (be aware that the actor is blocking when in debug mode).

Configuration

Image Added

option namedescription
Python commands or scriptCommands or script written in Python

 

Slice mode for all input IDSsIf this option is enabled, all input IDSs are read in slice mode, at the time given through the time_in port.
Slice mode for all output IDSsIf this option is enabled, all output IDSs are written in slice mode. In case the associated python variable contains several slices, the first one is written.
Synchronized modeSwitch on the synchronized mode: wait for python process to terminate, mandatory when outputs contain IDSs.
Debugging modeSwitch on the debug mode (implies sync mode): print python standard output and the actual python script which has been executed.
Workflow waits PythonSwitch off to allow killing python running process (e.g matplotlib window before it is closed) automatically at the end of the workflow.
parameters (comma separated)This list can contain parameters that are defined on the workflow. List of parameters should be specified as comma separated list of parametes names. Each parameter is retrieved from the workflow and it's name and value is passed inside dictionary withing python script. The name of the dictionary is 'parameters'. Note! If you specify wrong name of the parameter, it will not occur in script.

Image Removed 

Version history

versiondescription
3.0.4