Next Previous Contents

2. Introduction

SLxpa binds the XPA library to the S-Lang language. It provides an importable module and associated .sl script which make XPA callable directly from S-Lang scripts. The S-Lang interpreter is part of the widely-used, open-source library of the same name, and provides a scripting environment well-suited for scientific and engineering tasks, due to the powerful, compact, fast, and robust multidimensional numerical capabilities that are native to the language.

XPA is a set of libraries (ANSI C, Tcl/Tk) and commandline tools, written at the Smithsonian Astrophysical Observatory, which provide a clean and simple IPC (inter-process communication) mechanism that is also surprisingly powerful. It can be used to build loosely-coupled client/server programs that interact either on a single machine or across local and wide-area networks; we have also found it useful for automated regression testing, especially for GUIs that are traditionally difficult to test in this manner. The XPA library provides much of the functionality of more well-known mechanisms like CORBA, Java RMI, and the now-defunct ToolTalk, but is much smaller and, we feel, can be easier to learn, embed, deploy, and utilize.

The SAOds9 image display and analysis tool is perhaps the most well-known XPA command server. Also written at the Smithsonian Astrophysical Observatory, SAOds9 is one of the single most widely used programs in observational astronomy. CIAO, a software system created to assist in the analysis of data generated by the Chandra X-Ray Telescope, provides a number of programs (e.g. ChIPS and Prism) that function both as XPA clients (by interacting with DS9 and each other) and servers (by providing XPA access points of their own). Other software employing XPA includes fv and POW (a FITS file viewer and plotting tool, respectively, available within both the FTOOLS and HEASOFT astronomy software suites), as well as the SAS package created for the XMM-Newton X-Ray Telescope. A set of Perl bindings to XPA also exists in CPAN.

2.1 Brief History

S-Lang bindings for XPA were originally developed at the Smithsonian Astrophysical Observatory in 2002, as part of CIAO, an analysis software package developed in part to support the Chandra X-Ray Telescope. The SLxpa package, created at the MIT Center for Space Research between 2003 and 2004, adds significant enhancements to the original bindings, in order to:

Moreover, SLxpa extends their scope of potential use to a considerably wider audience, in that the package may be obtained independently of CIAO, allowing developers to avoid downloading hundreds of megabytes of astronomical software and data just to obtain a 100 Kb module.

2.2 Backwards Compatibility

As noted in the respective function descriptions, some of the SLxpa enhancements described above change the semantics of the XPA bindings as originally developed within CIAO. However, SLxpa may still be used as a drop-in replacement for those bindings, simply by declaring the variable _CIAO3_XPA_COMPAT_ in the Global namespace prior to loading the package, e.g. as

                public variable _CIAO3_XPA_COMPAT_;
The variable need not be initialized to any particular value.

2.3 Using the XPA Module


SLxpa ships with a configure script generated by autoconf, and in most cases can be built by issuing the following standard commands within a UNIX-like (e.g. Linux or Cygwin) environment:

      ./configure [options]
      make install
The third step is optional, but recommended. Version 2.1.4 or later of XPA is recommended. Versions of SLxpa prior to 0.5 were compatible with S-Lang 1, but SLxpa versions 0.5 and later require S-Lang 2.1 or later (e.g. to support the use of named qualifers in function calls). The ./configure --help command will display all available configure options.


To use the XPA module in a S-Lang script it is first necessary to make the functions in the package known to the interpreter, via

        () = evalfile ("xpa");
or, if the application embedding the interpreter supports the require function,
        require ("xpa");
may be used. You may also load the package into a namespace, such as
        () = evalfile ("xpa", "xpans");
This would place the XPA symbols into the xpans namespace (creating it, if necessary). Once the package has been loaded functions and variables defined within may be used in the usual way, e.g.
        require ("xpa");
        () = xpaset("ds9","quit");
Finally, recall that the S-Lang autoload function may be used to avoid explicitly evalfile-ing or require-ing the package prior to using the functions defined within.

The remainder of this document assumes the reader is familiar with the XPA suite of command line tools and/or the XPA application programming interface (api). For more information consult the XPA website.

2.4 A Word About Examples

To make the most of the examples given below it is encouraged that you run them and experiment. In support of that you should first:

The examples reference programs mentioned in the introduction with which you may not be familiar. Do not fret, as you need not actually run an example within the given application for it to still serve most of its didactic purpose, because what's being shown are not specific features of the application, per se, but rather how XPA function calls may be made through the S-Lang interpreter. The XPA functions may be called in the exact same manner from any application which embeds the S-Lang interpreter and supports module importation. In fact, most of the examples can be cut and pasted into a S-Lang script and then invoked from within the S-Lang shell (slsh, distributed with the S-Lang library, and assumed to be installed on your system).

2.5 Interactive Image Analysis with SAOds9

As described in chapter DS9_Package, SLxpa also bundles a script which streamlines interactions with the SAOds9 image display and analysis tool.

By augmenting the numerical strength and modular extensibility of the S-Lang platform with the imaging capabilities of SAOds9, the DS9 script can make a powerful addition to your image analysis toolset.

Next Previous Contents