##
Reading Foreign WCS Information from a FITS Header

Having stored a set of FITS header cards in a FitsChanFitsChan and determined how the WCS information is encoded (§17.3), the next step is to read an AST ObjectObject from the FitsChan using astReadastRead. We must also remember to rewind the FitsChan first, if necessary, such as by clearing its CardCard attribute, which defaults to 1:

270#270

If the pointer returned by astRead is not equal to AST__NULL, then an Object has been read successfully. Otherwise, there was either no information to read or the choice of FITS encoding (§17.3) was inappropriate.

At this point you might like to indulge in a little data validation along the lines described in §15.6, for example:

271#271

If a foreign encoding has definitely been used, then the Object will automatically be a FrameSetFrameSet (§17.2), so this stage can be omitted. However, if the native encoding (§16.1) might have been employed, which is a possibility if you accept the FitsChan's default EncodingEncoding value, then any class of Object might have been read and a quick check would be worthwhile.

If you used astShowastShow (§4.4) to examine the FrameSet which results from reading our example FITS header (§17.3), you would find that its base FrameFrame describes the image's pixel coordinate system and that its current Frame is a SkyFrameSkyFrame representing galactic coordinates. These two Frames are inter-related by a MappingMapping (actually a CmpMapCmpMap) which incorporates the effects of various rotations, scalings and a “zenithal equal area” sky projection, so that each pixel of the FITS image is mapped on to a corresponding sky position in galactic coordinates.

Because this FrameSet may be used both as a Mapping (§13.6) and as a Frame (§13.8), it may be employed directly to perform many useful operations without any need to decompose it into its component parts. These include:

- Transforming data grid (FITS pixel) coordinates into galactic coordinates and vice versa (§13.6).

- Formatting coordinate values (either pixel or galactic coordinates) ready for display to a user (§7.6 and §7.7).

- Enquiring about axis labels (or other axis information—§7.5) which might be used, for example, to label columns of coordinates in a table (§7.4).

- Aligning the image with another image from which a similar FrameSet has been obtained (§14.3).

- Creating a PlotPlot (§21), which can be used to overlay a variety of graphical information (including a coordinate grid—Figure 8) on the displayed image.

- Generating a new FrameSet which reflects any geometrical processing you perform on the associated image data (§14.5). This new FrameSet could then be written out as FITS headers to describe the modified image (§17.7).

If the FrameSet contains other Frames (apart from the base and current Frames), then you would also have access to information about other coordinate systems associated with the image.