Charming users into scripting CIAO with Python - the ciao_contrib.runtool module
The CIAO (Chandra Interactive Analysis of Observations) package for X-ray data analysis supports Python as a scripting language. This includes interfaces to the modeling and fitting engine (Sherpa) and plotting package (ChIPS) as well as a number of modules that interface to CIAO libraries. Additional support for Python users is provided by the contributed-scripts package - which was originally a set of shell scripts but has since been enhanced to include Python modules and executables - written by members of the Science Data Systems group of the Chandra X-ray Center. While developing these scripts, and from discussions with CIAO users, it became clear that users needed the ability to easily call CIAO command-line tools from Python code.
Rather than use the venerable system call, or the newer Python subprocess module, users call functions with the same name as the tool. The parameters for the tools can be given either as arguments when the function is called or beforehand, as fields of the object. Although missing the full functionality of the subprocess module, users are provided with both a more declarative interface and one with additional compile-time and run-time checks. As a bonus, Python scoping rules make it easier to run multiple copies of a tool compared to a shell script.
In this poster we shall describe the design and implementation of the module, highlight the implementation trade-offs that lead to the current design, and discuss planned improvements. We finish with a discussion of the coding guidelines that have been developed for Data Aides working on the contributed-scripts package.
Support for this work is provided by National Aeronautics and Space Administration through the Chandra X-ray Center, which is operated by the Smithsonian Astrophysical Observatory for and on behalf of the National Aeronautics and Space Administration under contract NAS8-03060.
Return to poster list