next up previous
Next: Creating a FitsChan
Up: Storing AST Objects in FITS Headers (FitsChans)
Previous: The Native FITS Encoding

The FitsChan Model

I/O between AST Objects and FITS headers is supported by a specialised form of Channel called a FitsChan. A FitsChan contains a buffer which may hold any number, including zero, of FITS header cards. This buffer forms a workspace in which you can assemble FITS cards and manipulate them before writing them out to a FITS file.

By default, when a FitsChan is first created, it contains no cards and there are three ways of inserting cards into it:

1.
You may add cards yourself, one at a time, using AST_PUTFITS ([*]).
2.
You may write an AST Object to the FitsChan (using AST_WRITE), which will have the effect of creating new cards within the FitsChan which describe the Object ([*]).

3.
You may specify a source routine which reads data from some external store of FITS cards, just like the source associated with a basic Channel ([*]). If you supply a source routine, it will be called when the FitsChan is created in order to fill it with an initial set of cards ([*]).

There are also three ways of removing cards from a FitsChan:

1.
You may delete cards yourself, one at a time, using AST_DELFITS ([*]).
2.
You may read an AST Object from the FitsChan (using AST_READ), which will have the effect of removing those cards from the FitsChan which describe the Object ([*]).

3.
You may specify a sink routine which writes data to some external store of FITS cards, just like the sink associated with a basic Channel ([*]). If you supply a sink routine, it will be called when the FitsChan is deleted in order to write out any FITS cards that remain in it ([*]).

Note, in particular, that reading an AST Object from a FitsChan is destructive. That is, it deletes the FITS cards that describe the Object. The reason for this is explained in [*].

In addition to the above, you may also read individual cards from a FitsChan using the function AST_FINDFITS (which is not destructive). This is the main means of writing out FITS cards if you have not supplied a sink routine. AST_FINDFITS also provides a means of searching for particular FITS cards (by keyword, for example) and there are other facilities for overwriting cards when required ([*]).



next up previous
Next: Creating a FitsChan
Up: Storing AST Objects in FITS Headers (FitsChans)
Previous: The Native FITS Encoding

AST A Library for Handling World Coordinate Systems in Astronomy
Starlink User Note 210
R.F. Warren-Smith & D.S. Berry
30th April 2003
E-mail:ussc@star.rl.ac.uk

Copyright (C) 2003 Central Laboratory of the Research Councils