IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 17025


Ignore:
Timestamp:
Mar 17, 2008, 1:55:30 PM (18 years ago)
Author:
eugene
Message:

need to determine the format for files not already opened (eg, from DetDB)

File:
1 edited

Legend:

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

    r16841 r17025  
    761761        file->fits->options = psMemIncrRefCounter(file->options);
    762762
    763         // if needed, set the optional EXTWORD field based on the camera value
    764         if (file->format) {
    765             psMetadata *fileMenu = psMetadataLookupMetadata (NULL, file->format, "FILE");
    766             if (!fileMenu) {
    767                 psError (PS_ERR_IO, true, "FILE METADATA missing from camera format %s\n",
    768                          config->formatName);
    769                 return false;
    770             }
    771             char *extword = psMetadataLookupStr (&status, fileMenu, "EXTWORD");
    772             if (status) {
    773                 psFitsSetExtnameWord (file->fits, extword);
    774             }
    775         }
     763        // in most cases, we have already open and read the phu and determined the format.
     764        // in some cases, (eg DetDB images), we have only just determined the filename.
     765        // we need to check the file format before we can work with the file
     766        if (!file->format) {
     767          psMetadata *phu = psFitsReadHeader (NULL, file->fits);
     768          if (!phu) {
     769            psError(PS_ERR_IO, false, "Failed to read file header %s\n", file->filename);
     770            return false;
     771          }
     772
     773          // determine the current format from the header
     774          // determine camera if not specified already
     775          file->format = pmConfigCameraFormatFromHeader (config, phu, true);
     776          if (!file->format) {
     777            psError(PS_ERR_IO, false, "Failed to read CCD format from %s\n", file->filename);
     778            psFree(phu);
     779            return false;
     780          }
     781          psFree(phu);
     782        }
     783
     784        // if needed, set the optional EXTWORD field based on the camera value
     785        psMetadata *fileMenu = psMetadataLookupMetadata (NULL, file->format, "FILE");
     786        if (!fileMenu) {
     787          psError (PS_ERR_IO, true, "FILE METADATA missing from camera format %s\n",
     788                   config->formatName);
     789          return false;
     790        }
     791        char *extword = psMetadataLookupStr (&status, fileMenu, "EXTWORD");
     792        if (status) {
     793          psFitsSetExtnameWord (file->fits, extword);
     794        }
    776795
    777796        // XXX these are probably only needed for WRITE files
Note: See TracChangeset for help on using the changeset viewer.