IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 17989 for trunk/psModules


Ignore:
Timestamp:
Jun 8, 2008, 2:35:44 PM (18 years ago)
Author:
eugene
Message:

update to new API for pmConfigCameraFormatFromHeader

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmFPAfileIO.c

    r17911 r17989  
    629629      case PM_FPA_FILE_ASTROM_MODEL:
    630630      case PM_FPA_FILE_ASTROM_REFSTARS:
    631         psTrace ("psModules.camera", 5, "NOT freeing %s (%s) : save for further analysis\n", file->filename, file->name);
     631        psTrace ("psModules.camera", 6, "NOT freeing %s (%s) : save for further analysis\n", file->filename, file->name);
    632632        return true;
    633633      case PM_FPA_FILE_JPEG:
     
    779779        file->fits->options = psMemIncrRefCounter(file->options);
    780780
    781         // in most cases, we have already open and read the phu and determined the format.
    782         // in some cases, (eg DetDB images), we have only just determined the filename.
    783         // we need to check the file format before we can work with the file
    784         if (!file->format) {
    785           psMetadata *phu = psFitsReadHeader (NULL, file->fits);
    786           if (!phu) {
    787             psError(PS_ERR_IO, false, "Failed to read file header %s\n", file->filename);
    788             return false;
    789           }
    790 
    791           // determine the current format from the header
    792           // determine camera if not specified already
    793           file->format = pmConfigCameraFormatFromHeader (config, phu, true);
    794           if (!file->format) {
    795             psError(PS_ERR_IO, false, "Failed to read CCD format from %s\n", file->filename);
    796             psFree(phu);
    797             return false;
    798           }
    799           psFree(phu);
    800         }
    801 
    802         // if needed, set the optional EXTWORD field based on the camera value
    803         psMetadata *fileMenu = psMetadataLookupMetadata (NULL, file->format, "FILE");
    804         if (!fileMenu) {
    805           psError (PS_ERR_IO, true, "FILE METADATA missing from camera format %s\n",
    806                    config->formatName);
    807           return false;
    808         }
    809         char *extword = psMetadataLookupStr (&status, fileMenu, "EXTWORD");
    810         if (status) {
    811           psFitsSetExtnameWord (file->fits, extword);
    812         }
     781        // in most cases, we have already open and read the phu and determined the format.
     782        // in some cases, (eg DetDB images), we have only just determined the filename.
     783        // we need to check the file format before we can work with the file
     784        if (!file->format) {
     785          psMetadata *phu = psFitsReadHeader (NULL, file->fits);
     786          if (!phu) {
     787            psError(PS_ERR_IO, false, "Failed to read file header %s\n", file->filename);
     788            return false;
     789          }
     790
     791          // determine the current format from the header
     792          // determine camera if not specified already
     793          // XXX can I actually reach this with camera not specified??
     794          file->format = pmConfigCameraFormatFromHeader (NULL, NULL, config, phu, true);
     795          if (!file->format) {
     796            psError(PS_ERR_IO, false, "Failed to read CCD format from %s\n", file->filename);
     797            psFree(phu);
     798            return false;
     799          }
     800          psFree(phu);
     801        }
     802
     803        // if needed, set the optional EXTWORD field based on the camera value
     804        psMetadata *fileMenu = psMetadataLookupMetadata (NULL, file->format, "FILE");
     805        if (!fileMenu) {
     806          psError (PS_ERR_IO, true, "FILE METADATA missing from camera format %s\n",
     807                   config->formatName);
     808          return false;
     809        }
     810        char *extword = psMetadataLookupStr (&status, fileMenu, "EXTWORD");
     811        if (status) {
     812          psFitsSetExtnameWord (file->fits, extword);
     813        }
    813814
    814815        // XXX these are probably only needed for WRITE files
     
    849850
    850851// for this file and view, if we need to read a PHU, read it.  return true for any non-error
    851 // condition. this function should be called by pmFPAfileOpen.
     852// condition. this function should be called by pmFPAfileOpen.  this function is only called
     853// for files for which the PHU is not already loaded (files passed via the db or files after
     854// the first in a multifile dataset)
    852855bool pmFPAfileReadPHU (pmFPAfile *file, const pmFPAview *view, pmConfig *config)
    853856{
     
    885888    psMetadata *phu = psFitsReadHeader (NULL, file->fits);
    886889    if (!file->format) {
    887         // XXX do we need to read the recipe here?  these files are supplemental, and probably
    888         // do not need to re-load the recipes
    889         file->format = pmConfigCameraFormatFromHeader (config, phu, false);
     890        // determine the format (camera is already known); do not load the recipe
     891        file->format = pmConfigCameraFormatFromHeader (NULL, &file->formatName, config, phu, false);
    890892        if (!file->format) {
    891893            psError(PS_ERR_IO, false, "Failed to read CCD format from %s\n", file->filename);
     
    893895            return false;
    894896        }
    895         file->formatName = psStringCopy(config->formatName);
    896 
    897897    } else {
    898898        bool valid;
Note: See TracChangeset for help on using the changeset viewer.