IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 21, 2006, 5:20:08 PM (20 years ago)
Author:
Paul Price
Message:

Fixing pmFPAfileDefineFromConf to allow interpolation on filenames. Most of the code wasn't required, since it is in pmFPAfileOpen (I think Gene said pmFPAfileDefineFromConf was coded early on, before everything got settled) --- just had to set found to true, and return a pmFPAfile. To get this change to work, added a check in pmFPAfileRead to see if the file is open (it doesn't know the file level a-priori).

File:
1 edited

Legend:

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

    r8848 r8879  
    531531pmFPAfile *pmFPAfileDefineFromConf (bool *found, pmConfig *config, char *filename)
    532532{
    533     bool status;
    534 
    535533    PS_ASSERT_PTR_NON_NULL(config, false);
    536534    PS_ASSERT_PTR_NON_NULL(filename, false);
     
    563561    }
    564562
     563
    565564    // image names may not come from file->names
    566565    if (!strcasecmp (file->filerule, "@FILES")) {
     
    581580    }
    582581
    583     // use the supplied filename
    584     char *infile = psStringCopy (file->filerule);
    585 
    586     // load the header of the first image
    587     psFits *fits = psFitsOpen (infile, "r");
    588     psMetadata *phu = psFitsReadHeader (NULL, fits);
    589     psFitsClose (fits);
    590 
    591     // determine the current format from the header
    592     // determine camera if not specified already
    593     file->format = pmConfigCameraFormatFromHeader (config, phu);
    594     if (!file->format) {
    595         psError(PS_ERR_IO, false, "Failed to read CCD format from %s\n", infile);
    596         psFree(phu);
    597         psFree(fpa);
    598         psFree(file);
    599         psFree(infile);
    600         return NULL;
    601     }
    602 
    603     // set the view to the corresponding entry for this phu
    604     pmFPAview *view = pmFPAAddSourceFromHeader (fpa, phu, file->format);
    605     if (!view) {
    606         psError(PS_ERR_IO, false, "Unable to determine source for %s (%s)", file->name, infile);
    607         psFree(phu);
    608         psFree(fpa);
    609         psFree(file);
    610         psFree(infile);
    611         return NULL;
    612     }
    613 
    614     // adjust the rules to identify these files in the file->names data
    615     psFree (file->filerule);
    616     psFree (file->filextra);
    617     file->filerule = psStringCopy ("@FILES");
    618     file->filextra = psStringCopy ("{CHIP.NAME}.{CELL.NAME}");
    619 
    620     // find the matching fileLevel
    621     psMetadata *filemenu = psMetadataLookupPtr (&status, file->format, "FILE");
    622     if (!filemenu) {
    623         psError (PS_ERR_IO, true, "missing FILE in FORMAT");
    624         psFree(phu);
    625         psFree(fpa);
    626         psFree(file);
    627         psFree(view);
    628         psFree(infile);
    629         return NULL;
    630     }
    631     char *levelName = psMetadataLookupStr (&status, filemenu, "PHU");
    632     if (!levelName) {
    633         psError (PS_ERR_IO, true, "missing PHU in FILE in FORMAT");
    634         return NULL;
    635     }
    636     file->fileLevel = pmFPALevelFromName (levelName);
    637     if (file->fileLevel == PM_FPA_LEVEL_NONE) {
    638         psError (PS_ERR_IO, true, "unknown level");
    639         return NULL;
    640     }
    641 
    642     // associate the filename with the FPA element
    643     char *name = pmFPAfileNameFromRule (file->filextra, file, view);
    644 
    645     // save the name association in the pmFPAfile structure
    646     psMetadataAddStr (file->names, PS_LIST_TAIL, name, 0, "", infile);
    647 
    648     psFree (phu);
     582    if (found) {
     583        *found = true;
     584    }
    649585    psFree (fpa);
    650     psFree (view);
    651     psFree (name);
    652     psFree (infile);
    653 
    654     *found = true;
    655586    return file;
    656587}
Note: See TracChangeset for help on using the changeset viewer.