next up previous 264
Next: Saving and Restoring Multiple Objects in a FitsChan
Up: Storing AST Objects in FITS Headers (FitsChans)
Previous: Adding Concatenated Cards to a FitsChan


Reading Native Objects From a FitsChan

Once you have stored a FITS header description of an Object in a FitsChan using the native encoding ([*]), you can read it back using astRead in much the same way as with a basic Channel ([*]). Similar comments about validating the Object you read also apply ([*]). If you have just written to the FitsChan, you must remember to rewind it first:

AstObject *object;

...

astClear( fitschan, "Card" );
object = astRead( fitschan );

An important feature of a FitsChan is that read operations are destructive. This means that if an Object description is found, it will be consumed by astRead which will remove all the cards involved, including associated COMMENT cards, from the FitsChan. Thus, if you write an Object to a FitsChan, rewind, and read the same Object back, you should end up with the original FitsChan contents. If you need to circumvent this behaviour for any reason, it is a simple matter to make a copy of a FitsChan using astCopy ([*]). If you then read from the copy, the original FitsChan will remain untouched.

After a read completes, the FitsChan's Card attribute identifies the card immediately following the last card read, or the end-of-file of there are no more cards.

Since the native encoding is being used, any long strings involved in the object description will have been split into two or more adjacent contuation cards when the Object was stored in the header using function astWrite. The astRead function reverses this process by concatenating any such adjacent continuation cards to re-create the original long string.



next up previous 264
Next: Saving and Restoring Multiple Objects in a FitsChan
Up: Storing AST Objects in FITS Headers (FitsChans)
Previous: Adding Concatenated Cards to a FitsChan

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