void PlotHeader( int nc, char cards[][81], char *name, char *settings ){
/*
* This function draws annotated coordinate axes for a FITS-WCS header.
* Parameters:
* nc
* The number of header cards supplied in "cards".
* cards
* An array of FITS header cards (any non-WCS cards are ignored).
* name
* The WCSNAME keyword value defining the coordinate system to be
* plotted.
* settings
* A comma-separated list of "keyword=value" pairs which specify the
* required appearance of the grid.
*/
AstFitsChan *header;
AstFrame *template;
AstFrameSet *fs;
AstPlot *plot;
char card1[81], card2[81];
double pixel_limits[4];
float screen_limits[4];
int i, npix, naxis1, naxis2;
/* Put the header cards into a FitsChan object, and then read a FrameSet from
the FitsChan. */
header = astFitsChan( NULL, NULL, "" );
for( i = 0; i < nc; i++ ) astPutFits( header, cards[i], 0 );
fs = astRead( header );
/* Search the FrameSet for a coordinate frame with the given name and make
it the current Frame within the FrameSet. */
if( name && strlen( name ) > 0 ) {
template = astFrame( 1, "MinAxes=1,MaxAxes=99" );
astSetC( template, "Domain", name );
astFindFrame( fs, template, "" );
}
/* Get the NAXIS1 and NAXIS2 cards from the FitsChan, and extract the keyword
values form the cards. Only proceed if successful. */
astClear( header, "Card" );
astFindFits( header, "NAXIS1", card1, 0 );
astClear( header, "Card" );
astFindFits( header, "NAXIS2", card2, 0 );
if( scanf( "NAXIS1 = %d", &naxis1 ) == 1 &&
scanf( "NAXIS2 = %d", &naxis2 ) == 1 ) {
/* Set the pixel limits of the plot to be the smallest square enclosing the
whole image. */
npix = ( naxis1 > naxis2 ) ? naxis1 : naxis2;
pixel_limits[ 0 ] = pixel_limits[ 1 ] = 0.5;
pixel_limits[ 2 ] = pixel_limits[ 3 ] = npix + 0.5;
/* Set the screen limits of the plot to be a unit square (this assumes the
graphics system uses a coordinate system in which a unit square spans its
shortest axis). */
screen_limits[ 0 ] = screen_limits[ 1 ] = 0.0;
screen_limits[ 2 ] = screen_limits[ 3 ] = 1.0;
/* Create an AST Plot, an object representing an area of the graphics screen with
the screen and pixel limits set up above. Use any attribute settings supplied by
the caller to determine the appearance of the plot. */
plot = astPlot( fs, screen_limits, pixel_limits, settings );
/* Finally draw the complete annotated coordinate grid. */
astGrid( plot );
}
}