next up previous 264
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 four ways of inserting cards into it:

  1. You may add cards yourself, one at a time, using astPutFits ([*]).

  2. You may add cards yourself, supplying all cards concatenated into a single string, using astPutCards ([*]).

  3. You may write an AST Object to the FitsChan (using astWrite), which will have the effect of creating new cards within the FitsChan which describe the Object ([*]).

  4. You may specify a source function which reads data from some external store of FITS cards, just like the source associated with a basic Channel ([*]). If you supply a source function, 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 astDelFits ([*]).

  2. You may read an AST Object from the FitsChan (using astRead), which will have the effect of removing those cards from the FitsChan which describe the Object ([*]).

  3. You may specify a sink function which writes data to some external store of FITS cards, just like the sink associated with a basic Channel ([*]). If you supply a sink function, 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 astFindFits (which is not destructive). This is the main means of writing out FITS cards if you have not supplied a sink function. astFindFits 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 264
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 211
R.F. Warren-Smith & D.S. Berry
24th May 2011
E-mail:ussc@star.rl.ac.uk

Copyright (C) 2009 Science \& Technology Facilities Council