Logo Search packages:      
Sourcecode: qfits version File versions  Download package

int qfits_query_nplanes ( const char *  filename,
int  extnum 
)

Counts the number of planes in a FITS extension.

Parameters:
filename Name of the FITS file to browse.
extnum Extensin number
Returns:
int Counts how many planes are in the extension. Returns 0 if no plane is found, and -1 if an error occurred.

Definition at line 241 of file qfits_tools.c.

References qfits_query_ext(), and qfits_query_n_ext().

{
    char    *    sval ;
    int            next ;
    int            naxes ;
    int            nplanes ;

    /* Check file existence */
    if (filename == NULL) return -1 ;
    /* Check validity of extnum */
    next = qfits_query_n_ext(filename) ;
    if (extnum>next) {
        qfits_error("invalid extension specified") ;
        return -1 ;
    }

    /* Find the number of axes  */
    naxes = 0 ;
    if ((sval = qfits_query_ext(filename, "NAXIS", extnum)) == NULL) {
        qfits_error("missing key in header: NAXIS");
        return -1 ;
    }
    naxes = atoi(sval) ;

    /* Check validity of naxes */
    if ((naxes < 2) || (naxes > 3)) return -1 ;

    /* Two dimensions cube */
    if (naxes == 2) nplanes = 1 ;
    else {
        /* For 3D cubes, get the third dimension size   */
        if ((sval = qfits_query_ext(filename, "NAXIS3", extnum))==NULL) {
            qfits_error("missing key in header: NAXIS3");
            return -1 ;
        }
        nplanes = atoi(sval);
        if (nplanes < 1) nplanes = 0 ;
    }
    return nplanes ;
}


Generated by  Doxygen 1.6.0   Back to index