IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 25326


Ignore:
Timestamp:
Sep 10, 2009, 3:34:32 PM (17 years ago)
Author:
Paul Price
Message:

Adding function to move to a FITS extension quietly (don't generate an error if we can't find the extension)

Location:
branches/pap/psLib/src/fits
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/pap/psLib/src/fits/psFits.c

    r25049 r25326  
    344344// Therefore, we implement our own version of moving to an extension specified by name.  The pure cfitsio
    345345// version is used if "conventions.compression" handling is turned off in the psFits structure.
    346 bool psFitsMoveExtName(const psFits* fits,
    347                        const char* extname)
     346static bool fitsMoveExtName(const psFits* fits, // FITS file
     347                            const char* extname, // Extension name
     348                            bool errors // Generate errors?
     349    )
    348350{
    349351    PS_ASSERT_FITS_NON_NULL(fits, false);
     
    356358        // User wants to use cfitsio.  Good luck to them!
    357359        if (fits_movnam_hdu(fits->fd, ANY_HDU, (char*)extname, 0, &status) != 0) {
    358             psFitsError(status, true, _("Could not find HDU '%s'"), extname);
     360            if (errors) {
     361                psFitsError(status, true, _("Could not find HDU '%s'"), extname);
     362            }
    359363            return false;
    360364        }
     
    378382        if (fits_movabs_hdu(fits->fd, i, &hdutype, &status)) {
    379383            // We've run off the end
    380             psFitsError(status, true, _("Could not find HDU with %s = '%s'"), extword, extname);
     384            if (errors) {
     385                psFitsError(status, true, _("Could not find HDU with %s = '%s'"), extword, extname);
     386            }
    381387            return false;
    382388        }
     
    406412    }
    407413    psAbort("Should never reach here.");
     414}
     415
     416
     417bool psFitsMoveExtName(const psFits* fits, const char* extname)
     418{
     419    return fitsMoveExtName(fits, extname, true);
     420}
     421
     422bool psFitsMoveExtNameClean(const psFits* fits, const char* extname)
     423{
     424    return fitsMoveExtName(fits, extname, false);
    408425}
    409426
  • branches/pap/psLib/src/fits/psFits.h

    r19035 r25326  
    245245);
    246246
     247/** Moves the FITS HDU to the specified extension name without generating errors.
     248 *
     249 *  @return bool        TRUE if the extension name was found and move was
     250 *                      successful, otherwise FALSE
     251 */
     252bool psFitsMoveExtNameClean(
     253    const psFits* fits,                ///< the psFits object to move
     254    const char* extname                ///< the extension name
     255);
     256
    247257/** Moves the FITS HDU to the specified extension number
    248258 *
Note: See TracChangeset for help on using the changeset viewer.