The ESO Recipe Flexible Execution Workbench
Instructions for Python usage in ESO Reflex
At present astronmers are widely using Python as a scripting languague and therefore it is important to get
the flexibility and power of Python in use of ESO Reflex. This page includes instructions and examples with detailed description of the reflex.py
Python module which is required for the usage in ESO Reflex.
Python interface of Reflex
The reflex.py
Python module (download here) is the Python interface of Reflex. It is located under reflex/reflex-current/scripts/python
. It contains the following four classes for reading parametres from stdin and printing output parameters from stdout back to java.
ReflexExit
tells to Reflex we are exiting the Python script. When exiting the outputs are updated.ReflexInput
andReflexOutput
create the Reflex input and output ports with following three parameters:name
is an individual port identification name, e.g.dispCoeff
mimetype
tells to Reflex the data type of the input/output, most common values are'text/plain'
and'file/fits'
value
is a value for the input port or the result for the output port, value can be in any type but it must be identical with mimetype
These two classes contain also methods for setting and reading these parameters.
setMimeType(mimeType)
sets the mime type of the port,mimeType
isString
setName(name)
sets the name of the port,name
isString
setValue(value)
sets the location of the port,value
is e.g."/home/tester/rectified_lamp_mxu.fits"
printValues()
prints portname
,mimeType
andvalue
getName()
returns portname
getMimeType()
returns portmimeType
getValue()
returns portvalue
ReflexQuery
has three parameters-q
makes a Reflex query and displays Reflex ports with correct mimetypes and values-d
runs script with default values (god option with Python stand alone usage and for test purposes)-help
shows possible parameters
Python script editing window
In the figure below is the workflow pythonExample.xml
located under reflex/reflex-current/examples
.
Click on the Python processor Python_example
, and the window below will open.
Edit the script by adding the row input2 = ReflexInput(type="'file/fits'",name="output2",value="test2.fits")
under the row input1 = ReflexInput(type="'text/plain'",name="outputFilename",value="test.fits")
. Press "Save script changes", and you will see in the figure below a new entry in the Input ports window.
Make on purpose an error to the scripts. In the example below the word BUG is written on a line. Try pressing "Save script changes", and you will get the message below.