AAOGlimpse 'Plug-out' programs
'Plug-outs' are small separate
utility programs that can be used with AAOGlimpse. When
AAOGlimpse starts up, it looks for a 'Glimpse' subdirectory in
the user's home directory, and if that exists it looks in there
for any executable files with a '.glimpse' extension. Each such
file will appear in the 'Plug-outs' menu, and can be run by
selecting it from this menu. Most useful plug-out programs will
interact with AAOGlimpse through its socket interface.
Such a program could be run equally well from the command line directly, and most will be developed in this way at first. However, having them available as AAOGlimpse menu items makes it much easier to run them, and makes the whole thing seem rather more elegant, particularly for users who did not write the programs themselves.
The programs themselves can be written in any way you like. They can be Python programs, C/C++ programs, F90 programs, shell scripts, anything that can be run from the command line. The original one developed at AAO was one that fitted ellipses to out-of-focus camera images taken as part of the HERMES spectrograph testing. This was something of a lash-up, and as such it gives the flavour of what can be done. It consisted of a Python script which did the following:
There are some things to note when writing such plug-in programs:
Such a program could be run equally well from the command line directly, and most will be developed in this way at first. However, having them available as AAOGlimpse menu items makes it much easier to run them, and makes the whole thing seem rather more elegant, particularly for users who did not write the programs themselves.
The programs themselves can be written in any way you like. They can be Python programs, C/C++ programs, F90 programs, shell scripts, anything that can be run from the command line. The original one developed at AAO was one that fitted ellipses to out-of-focus camera images taken as part of the HERMES spectrograph testing. This was something of a lash-up, and as such it gives the flavour of what can be done. It consisted of a Python script which did the following:
- It asked AAOGlimpse if the file displayed was available as a FITS file (usually it wasn't, as these were JPEG images).
- If the file wasn't available already in FITS format, it asked AAOGLimpse to write out a FITS copy.
- It asked AAOGlimpse if there was a subset of the area selected, and if what its limits were.
- It then ran a crude edge detection algorithm on the subset of the image, and wrote a temporary disk file with the set of points it had found. These were what we wanted to fit the ellipse to.
- The python script then ran a Fortran 90 program that ran a minimisation code to fit the points to an ellipse, and read the output of the F90 program (by swallowing its standard output - it used os.popen()) and parsed it to get the fitted parameters.
- It then asked AAOGlimpse to display an ellipse with the parameters obtained from the F90 program.
There are some things to note when writing such plug-in programs:
- The default directory for the plug-out when started will be the ~/Glimpse directory that the program is being run from. This may not be writeable, and even if it is, writing to it may not be a good idea. Temporary files are probably best written to /tmp.
- The default directory used by AAOGlimpse is not this
~/Glimpse directory, and any file specifications passed to
AAOGlimpse by a plug-out must use absolute paths or
AAOGlimpse will not find the files.
- The program is run with no addiitonal arguments.
- The standard and error outputs for the program are both read by AAOGlimpse, and are simply logged on the console - which most users will not have open. There is no way at present to interact with the user, or even to signal an error. (This is the most glaring shortcoming of the scheme as implemented at present, and something will be done to improve it. Eventually.)
- Programs run completely asynchronously. AAOGlimpse does not wait for them to finish (although at present it can only have one plug-out running at a time), so things may change underneath the plug-out - the highlit area may be changed by the user, for example, or even a new file read in.