### 1 Introduction

Welcome to the AST library. If you are writing software for astronomy and need to use celestial coordinates (e.g. RA and Dec), spectral coordinates (e.g. wavelength, frequency, etc.), or other coordinate system information, then this library should be of interest. It provides solutions for most of the problems you will meet and allows you to write robust and flexible software. It is able to read and write WCS information in a variety of formats, including FITS-WCS.

#### 1.1 What Problems Does AST Tackle?

Here are some of the main problems you may face when handling world coordinate system (WCS) information and the solutions that AST provides:

1. The Variety of Coordinate Systems

Astronomers use a wide range of differing coordinate systems to describe positions within a variety of physical domains. For instance, there are a large number of celestial coordinate systems in use within astronomy to describe positions on the sky. Understanding these, and knowing how to convert coordinates between them, can require considerable expertise. It can also be difficult to decide which of them your software should support. The same applies to coordinate systems describing other domains, such as position within an electro-magnetic spectrum.

Solution. AST has built-in knowledge of many coordinate systems and allows you to convert freely between them without specialist knowledge. This avoids the need to embed details of specific coordinate systems in your software. You also benefit automatically when new coordinate systems are added to AST.

2. Storing and Retrieving WCS Information

Storing coordinate system information in astronomical datasets and retrieving it later can present a considerable challenge. Typically, it requires knowledge of rather complex conventions (e.g. FITS) which are low-level, often mis-interpreted and may be subject to change. Exchanging information with other software systems is further complicated by the number of different conventions in use.

Solution. AST combines a unifying high-level description of WCS information with the ability to save and restore this using a variety of formats. Details of the formats, which include FITS, are handled internally by AST. This frees you from the need to understand them or embed the details in your software. Again, you benefit automatically when new formats are added to AST.

3. Generating Graphical Output

Producing graphical displays involving curvilinear coordinate systems, such as celestial coordinate grids, can be complicated. Particular difficulties arise when handling large areas of sky, the polar regions and discontinuous (e.g. segmented) sky projections. Even just numbering and labelling curvilinear axes is rarely straightforward.

Solution. AST provides plotting facilities especially designed for use with curvilinear coordinate systems. These include the plotting of axes and complete labelled coordinate grids. A large number of options are provided for tailoring the output to your specific needs. Three dimensional coordinate grids can also be produced.

4. Aligning Data from Different Sources

One of the main uses of coordinate systems is to facilitate the inter-comparison of data from different sources. A typical use might be to plot (say) radio contours over an optical image. In practice, however, different celestial coordinate systems may have been used, making accurate alignment far from simple.

Solution AST provides a one-step method of aligning datasets, searching for all possible intermediate coordinate systems. This makes it simple to directly inter-relate the pixel coordinates of different datasets.

5. Handling Different Types of Coordinate System

Not all coordinate systems used in astronomy are celestial ones, so if you are writing general-purpose software such as (say) a display tool, you may also need to handle axes representing wavelength, distance, time or whatever else comes along. Obviously, you would prefer not to handle each one as a special case.

Solution AST uses the same flexible high-level model to describe all types of coordinate system. This allows you to write software that handles different kinds of coordinate axis without introducing special cases.

#### 1.2 Other Design Objectives

As well as its scientific objectives, the AST library’s design includes a number of technical criteria intended to make it applicable to as wide a range of projects as possible. The main considerations are described here:

(1)
Minimum Software Dependencies. The AST library depends on no other other software1.
(2)
Environment Independence. AST is designed so that it can operate in a variety of “programming environments” and is not tied to any particular one. To allow this, it uses simple, flexible interfaces to obtain the following services:
• Data Storage. Data I/O operations are based on text and/or FITS headers. This makes it easy to interface to a wide variety of astronomical data formats in a machine-independent way.
• Graphics. Graphical output is produced via a simple generic graphics interface, which may easily be re-implemented over different graphics systems. AST provides a default implementation based on the widely-used PGPLOT graphics system (SUN/15).
• Error Handling. Error messages are written to standard error by default, but go through a simple generic interface similar to that used for graphics (above). This permits error message delivery via other routes when necessary (e.g. in a graphical interface).
(3)
Multiple Language Support. AST has been designed to be called from more than one language. Both C and Fortran interfaces are available (see SUN/210 for the Fortran version) and use from C$++$ is also straightforward if the C interface is included using:

extern "C" {
#include "star/ast.h"
}

A JNI interface (known as “JNIAST” - see http://www.starlink.ac.uk/jniast/) has also been developed by Starlink which allows AST to be used from Java.

(4)
Object Oriented Design. AST uses “object oriented” techniques internally in order to provide a flexible and easily-extended programming model. A fairly traditional calling interface is provided, however, so that the library’s facilities are easily accessible to programmers using C and Fortran.
(5)
Portability. AST is implemented entirely in ANSI standard C and, when called via its C interface, makes no explicit use of any machine-dependent facilities.

The Fortran interface is, unavoidably, machine dependent. However, the potential for problems has been minimised by encapsulating the interface layer in a compact set of C macros which facilitate its transfer to other platforms. No Fortran compiler is needed to build the library.

Currently, AST is supported by Starlink on PC Linux, Sun Solaris and Tru64 Unix (formerly DEC UNIX) platforms.

#### 1.3 What Does “AST” Stand For?

The library name “AST” stands for “ASTrometry Library”. The name arose when it was thought that knowledge of “astrometry” (i.e. celestial coordinate systems) would form the bulk of the library. In fact, it turns out that astrometry forms only a minor component, but the name AST has stuck.

1It comes with bundled copies of the ERFA and Starlink PAL libraries which are built at the same time as the other AST internal libraries. Alternatively, external PAL and ERFA libraries may be used by specifying the “–with-external_pal” option when configuring AST