HEAdas Developers Guide

Introduction

HEAdas refers to a new component in HEASoft, the LHEA software suite which currently encompasses FTOOLS and XANADU (ie, XSPEC, XRONOS, and XIMAGE). HEAdas tasks are virtually identical in look-and-feel to FTOOLS from a user's perspective but are, in fact, built around a completely distinct core (with the exception of the CFITSIO library). This new package is intended to be simpler and leaner than FTOOLS, as well as more portable, stable and extensible.

HEAdas is composed of two basic parts: a mission-independent set of general FITS utilities (HEAtools) which is being developed within the HEASARC, as well as a set of mission-specific packages developed and maintained (in whole or in part) by outside groups. The HEAdas core (including the HEAtools) is written entirely in ANSI C for maximum portability. Missions are, however, free to use any language they wish within their own package, bearing in mind that certain choices may limit the platforms and/or compilers on which their tasks will build and run.

Until HEAdas has fully matured it is likely that tasks (eg, Perl scripts) in the mission-specific packages will call tasks which still reside in the FTOOLS portion of HEASoft and software distributions by the HEASARC will generally include all necessary components in a single tar file to make things as easy for users as possible. However, in keeping with a modular approach (as well as to avoid incompatibility due to different release schedules) it is important that mission-specific tasks not link against FTOOLS libraries (eg, xanlib). If mission developers find that they require those subroutines in their tasks then they should be migrated to the appropriate HEAdas library. Whether that would be more appropriate to a core library versus a mission-specific library may require coordination and/or consultation with the HEASARC programming staff.

Configuration Management and HEADAS setup

All infrastructure and configuration management of HEAdas is handled by the HEASARC, including such things as Makefiles and configure scripts. Code revision control is handled via a central CVS repository resident on a HEASARC server. Developers of mission-specific software only have write access in the relevant portions of the repository but have read access to the entire package so that they can check-out as much of it as they wish for local testing. However, a limited number of HEASARC programmers have global write access to enable necessary configuration modifications. CVS includes automatic email notification of new check-ins so that developers will be informed of any changes to their portion of the repository as they occur.

The directory structure for any given subpackage is reasonably flexible so that mission software developers can arrange things to suit their own needs and/or preferences. Certain constraints may, however, be required to accomodate the overall HEAdas build paradigm.

Full, top-down builds are started from the headas/BUILD_DIR directory using the typical steps of ./configure followed by make and then finally make install. Unit test scripts may optionally be installed via a parallel make test and make install-test sequence. Internally, however, builds are managed by hmake, exactly as in the current FTOOLS package. This utility is designed to also make it easy to build all or part of the distribution on any supported platform without having to make modifications by hand specifying the location and/or names of necessary flags and libraries. That is, once a full build and install have been performed, a developer may simply checkout a copy of a particular tool and build it via the command hmake. Before using hmake one simply needs to be pointing at a completed HEAdas installation by setting the HEADAS environment variable and running the appropriate initialization script (eg, (assuming a cshell environment) source $HEADAS/headas-init.csh). The hmake utility should then be able to build any tool or library, automatically linking as needed against the libraries in the pointed-to installation and using the flags appropriate to that installation.

Input/Output

INPUT

All input to HEAdas tasks is controlled by the Parameter Interface Library (PIL) which is developed and maintained by the INTEGRAL Science Data Center. PIL has a very similar look and feel to XPI (the parameter interface used in FTOOLS) but includes such additional features as enumerated values, minimum-maximum range checking, the ability to use environment variables in parameters and a dedicated "filename" type. PIL is callable by C, C++, f77 and f90 tasks. Full documentation for PIL is available in the source tree under headas/heacore/pil/doc.

There are three commonly-used parameters which are handled intrinsically by the internal HEAdas initialization routines and thus developers do not need to explicitly read them at the individual task level. (A fourth parameter, "mode", is a PIL internal and operates exactly as in XPI). The standard HEAdas parameters are:

OUTPUT

Diagnostic output and other text messages must be able to be separated from the standard output stream to enable, eg, piping FITS files between tasks. Developers should never write directly to stdout but should instead funnel screen output through the dedicated HEAdas streams. These streams are set up during task initialization and are controlled by environment variables. Task developers should never have to read or otherwise deal with these variables. The following methods for diagnostic output are currently available to developers writing tasks in C:

Fortran tasks should use the dedicated routines hdecho() and hdchat(). The former is exactly equivalent to the fcecho() routine in the FTOOLS package while the latter adds the chatter threshold argument as in headas_chat() above. Note that unlike the C versions above, formatting of the output strings must be done prior to calling hdecho()/hdchat(), eg, via an internal write.

Future GUI development and/or other enhancements to HEAdas will likely require that the standard error stream and parameter prompts be monitored and/or redirected as well. The environment variables HEADASERROR and HEADASPROMPT, respectively, control these but developers should not need to deal with them directly. C tasks may simply use fprintf(stderr, ...) to print error messages as usual, while Fortran tasks should use hderr() (which is exactly like the FTOOLS fcerr() routine). As with hdecho(), the output error message must be constructed internally prior to calling hderr().

General Notes

All tasks should:

Task Name/Version

Every HEAdas task should register its name and version number so that the information is available to other routines which may need it. A set of routines in the heautils library (see headas_toolname.c in the library inventory section, below) has been provided for this purpose. Each task should call set_toolname() and set_toolversion() to record the information and developers may retrieve the information via get_toolname()/get_toolversion() or by the simpler get_toolnamev() which returns both in a single string with name and version joined with an underscore. The Fortran equivalents are hdnameset(), hdverset(), hdnameget(), hdverget() and hdnamevget(). Note that a default name is recorded during task initialization based on the executable name. A default version number of "0.0" will likewise be used. These defaults will be superceded via calls at the task level to set_toolname() and set_toolversion().

CALDB Access

The HEASARC Calibration Database (CALDB) will be accessible to HEAdas tasks exactly as it is to FTOOLS and missions choosing to use HEAdas should plan on submitting their FITS calibration files for inclusion in the CALDB. However, because the main CALDB access routine, gtcalf(), is written in f77, however, it is being rewritten in ANSI C in keeping with the requirements of the HEAdas core. The method in which it is used will be exactly the same, making code migration from the FTOOLS system trivial. As in most of the routines discussed here, a Fortran wrapper will be provided so that they may be called from Fortran tasks too.

Scripting

All scripting should be done using Perl5. The HEASARC will provide Perl utilities to make it easy and convenient for scripts to call HEAdas and/or FTOOLS tasks, for example, to trap any runtime errors which may occur. We also expect to include the CFITSIO Perl module (CFITSIO.pm) in the distribution to allow for Perl scripts to directly call CFITSIO routines as well.

Expected Enhancements

In addition to the components already mentioned, the following are being evaluated for inclusion with the HEAdas package:

Library Inventory

The "heacore" directory contains source code for a number of libraries which are expected to be generally useful and mission-independent. These core libraries will automatically be built and available for linking by any or all of the tool packages (eg, heatools, swift) via the normal hmake build process.

The components of the directory "heacore" are:


Michael Tripicco
Last modified: Fri Apr 4 10:07:19 EST 2003