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.
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
and ReflexOutput
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 mimetypeThese two classes contain also methods for setting and reading these parameters.
setMimeType(mimeType)
sets the mime type of the port, mimeType
is String
setName(name)
sets the name of the port, name
is String
setValue(value)
sets the location of the port, value
is e.g. "/home/tester/rectified_lamp_mxu.fits"
printValues()
prints port name
, mimeType
and value
getName()
returns port name
getMimeType()
returns port mimeType
getValue()
returns port value
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 parametersIn 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.