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.
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.
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:
headas_chat()/hdchat() in a task
having no chatter parameter will result in an error.
headas_clobberfile(filename)
which will delete the specified file if it exists and if the "clobber"
parameter was set to "yes". Note that an alternative to clobber exists
for FITS files since CFITSIO will clobber any file which begins with
the "!" character.
headas_parstamp() specifying
the desired FITS file and extension and, if the history
parameter value at runtime permits it, the HISTORY block will be
written. If the task has no history parameter then a call to
headas_parstamp() will return an error. Each
HISTORY keyword block will be clearly delimited and will include
the task name/version and a timestamp. Use of
headas_parstamp() is not required, but is
recommended both as a means of documenting the runtime
conditions and as input for a planned utility which can rerun
any task using the information recorded in the HISTORY block.
The headas_parstamp() utility now will also expand
any ascii file specified using the '@filename' convention and
will include the contents of that file in the HISTORY block.
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:
headas_printf(char *, ...)
Operates exactly like the stdio version of printf but the stream will
be directed to the location specified by the environment variable
HEADASOUTPUT (if present).
headas_chat(int, char *, ...)
Identical to headas_printf() except for an additional integer argument
which specifies the threshold "chatter" level below which the message
will be suppressed (depending on the runtime value of the chatter
parameter, see discussion of "chatter" above).
fprintf(heaout, char *, ...)
The "heaout" stream (which replaces
stdout in HEAdas) may be written to directly, as shown.
printf(char *, ...)
The usual stdio printf() routine can
still be used (eg, in legacy code) but
will be dynamically replaced by headas_printf() during compilation.
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().
#include "fitsio.h" /* assuming CFITSIO routines will be called */
#include "pil.h" /* assuming PIL routines will be called */
#include "headas.h"
#define TOOLSUB my_task_subroutine_name /* use actual subroutine name here */
#include "headas_main.c"
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().
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.
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.
In addition to the components already mentioned, the following are being evaluated for inclusion with the HEAdas package:
CCfits: an object-oriented interface to the
CFITSIO library designed to make the capabilities
of CFITSIO available to programmers working in
C++.The components of the directory "heacore" are:
int headas_init(int, char **)
int headas_close()
static void ReportError(int)
static int StandardPfile(int argc, char
*argv[])
int hd_pil_err_logger(char *s)main program unit for every task.
It calls headas_init() followed by the task subroutine
itself and then calls headas_close() after the task completes.
This main routine is not part of any library and
must be explicitly included
by all C tasks (via #include "headas_main.c"). For
f77 tasks it is automatically compiled and linked in by the Makefile.
int headas_printf(const char *, ...)printf() with identical arguments.
Text is written to the location specified by the HEADASOUTPUT
environment variable (if present) instead of to stdout.
int headas_chat(int, const char *, ...)headas_printf() but takes an integer argument
which specifies the threshold chatter level below which the text
will not be output.
int pil_printf(const char *, ...)printf()
for internal use by PIL only. Should not be called by tasks directly.
NOT CURRENTLY USED.
void headas_f77echo(const char *)headas_printf(). It is called
hdecho() from Fortran programs.
void headas_f77err(const char *)fprintf(stderr, ...).
Called hderr() from Fortran. This routine will write to
the stderr stream (which may have been redirected via the
HEADASERROR environment variable).
void headas_f77chat(int, const char *)headas_chat(). It is called
hdchat() from Fortran.
int headas_parstamp(fitsfile *, int)hdparstamp().
char *hdbasename(char *)basename() function (returns
the filename portion of an input pathname).
int headas_clobberfile(char *)hdclobber().
float hd_ran2(long *)ran2() from
Numerical Recipes in C, 2nd ed., p282. Returns a
uniform random deviate between 0.0 and 1.0 (exclusive of
the endpoint values). Call with a negative integer argument
to initialize.
Callable from Fortran as hd_ran2().
char **expand_item_list(char *, int *, char,
int, int, int, int *);
void set_toolname(const char *)hdnameset().
void get_toolname(char *)set_toolname()) a default name is
determined from the name of the executable file.
The Fortran version is hdnameget().
void set_toolversion(const char *)hdverset().
void get_toolversion(char *)set_toolversion())
a default version number string of "0.0" is returned.
The Fortran version is hdverget().
void get_toolnamev(char *)hdnamevget().
void get_history(int *)headas_parstamp().
Fortran version is hdghis().
void set_history(int)hdphis().