1. UALPython actor

UALPython actor allows to execute Python code inside Kepler. It enables manipulation of CPOs 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 CPO 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 CPOs).

1.1. 1. The actor can be used in two ways

1.1.1. 1.1 User's script can be provided as input to actor

1.1.2. 1.2 User's script can be passed as argument inside actor's properties (double-click actor)


1.2. 2. Passing CPO as argument

The actor get CPO data automatically into a cponameX variable (always an array, that will contain only 1 element in slice mode), where cponame is the type of the CPO (e.g.: equilibrium, coreprof, mhd, etc.) and X is a number representing the position of the CPO amongst all inputs of the same type. For instance if there are 3 input CPOs in the order:

  • equilibrium
  • coreprof
  • equilibrium

the associated python variables will be named respectively equilibrium0, coreprof0 and equilibrium1.

1.3. 3. Available packages

Some python packages are already imported and ready to be used. Here is the list:

  • pylab
  • ual
  • numpy
  • sys
  • copy

For instance, for plotting with matplotlib you can call

pylab.plot(some_data)
pylab.show()

1.4. 4. Additional variables available inside script

A dictionary cpo_in has been added for easy manipulation of all input CPOs of a given type. You can access them by calling: cpo_in['equilibrium']. This code will return all equilibrium variables read from input ports.

You can also add output port for CPOs by respecting strictly the following naming convention:

  • the port should be named by the name of the CPO variable in python
    • for writting a CPO present as input, simply put the name of the corresponding python variable (defined as explained previously),
    • if CPO has to be written into an occurrence different than the default one, then add /Y as to be concatenated to the name of the variable (e.g. equilibrium0/1),
    • in time slice mode of output CPOs, all CPOs are written at the time specified in the time_in input port.

1.5. 5. Synchronization

Python process is asynchronous! - actor will not wait for it by default. If you have CPO as output of the actor you should set UALPython in synchronous mode (take a look at the picture above).

1.6. 6. Data output

All output CPOs are written in the same pulsefile/database. It is read from the very first input CPO.

1.7. 7. Storing new CPO inside DB


If you want to store CPOs that are NOT present as input (it can be another type of CPO, or another instance of a type already present as input), please follow the same rules for naming the python variable (type of the CPO + a number) as for input CPOs, 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 CPO
  • new mhd CPO can be stored by specifying, for instance, mhd0/1 as the name of the output port for this CPO
  • If you specify the name of variable, it implies that you have created mhd0 variable inside Python script and is filled with proper data
    • mhd0 = ual.mhd.mhdArray()
      mhd0.resize(desired_nb_of_slices)

1.8. 8. Passing workflow's parameters into script

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 (inside python) is parameters. Note! If you specify wrong name of the parameter, it will not occur in script. To pass parameters, pass them embedded inside quotation marks

"string_parameter, another_parameter"



  • No labels