IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28011


Ignore:
Timestamp:
May 18, 2010, 3:49:34 PM (16 years ago)
Author:
eugene
Message:

updates from trunk

Location:
branches/eam_branches/psModules.20100506
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/psModules.20100506

  • branches/eam_branches/psModules.20100506/src/camera/pmFPAConstruct.c

    r27762 r28011  
    100100
    101101    return num;
    102 }
    103 
    104 // Get the name of a PHU chip or cell from the header
    105 static psString phuNameFromHeader(const char *name, // The name to lookup: "CELL.NAME" or "CHIP.NAME"
    106                                   const psMetadata *fileInfo, // FILE within the camera format description
    107                                   const psMetadata *header // Primary header
    108                                  )
    109 {
    110     assert(name && strlen(name) > 0);
    111     assert(fileInfo);
    112     assert(header);
    113 
    114     bool mdok = true;                   // Result of MD lookup
    115     psString keyword = psMetadataLookupStr(&mdok, fileInfo, name);
    116     if (!mdok || strlen(keyword) == 0) {
    117         return false;
    118     }
    119     psMetadataItem *resultItem = psMetadataLookup(header, keyword);
    120     if (!resultItem) {
    121         psError(PS_ERR_IO, true, "Unable to find %s in primary header to identify %s.\n", keyword, name);
    122         return NULL;
    123     }
    124     return psMetadataItemParseString(resultItem);
    125102}
    126103
     
    11021079// It returns a view corresponding to the PHU
    11031080static pmFPAview *addSource(pmFPA *fpa,       // The FPA
    1104                             const char *fpaObs, // The desired FPA observation name
    11051081                            const pmFPAview *phuView, // The view corresponding to the PHU, or NULL
    11061082                            const psMetadata *header, // The PHU header, or NULL
     
    11141090
    11151091    bool mdok;                          // Status of MD lookup
    1116 
    1117     // If FPA.OBS is already defined, new name must match it; otherwise, warn the user that something
    1118     // potentially bad is happening.
    1119     if (fpaObs && install) {
    1120         const char *currentName = psMetadataLookupStr(&mdok, fpa->concepts, "FPA.OBS"); // Current name
    1121         if (mdok && currentName && strlen(currentName) > 0 && strcmp(currentName, fpaObs) != 0) {
    1122             psWarning("FPA.OBS for new source (%s) doesn't match FPA.OBS for current fpa (%s).",
    1123                       fpaObs, currentName);
    1124         }
    1125         psMetadataAddStr(fpa->concepts, PS_LIST_HEAD, "FPA.OBS", PS_META_REPLACE, "Observation identifier",
    1126                          fpaObs);
    1127     } else if (!psMetadataLookup(fpa->concepts, "FPA.OBS")) {
    1128         // Make sure there is an FPA.OBS
    1129         psMetadataAddStr(fpa->concepts, PS_LIST_HEAD, "FPA.OBS", 0, "Observation identifier", "UNKNOWN");
    1130     }
    11311092
    11321093    psMetadata *fileInfo = psMetadataLookupMetadata(&mdok, format, "FILE"); // The file information
     
    13501311}
    13511312
    1352 bool pmFPAAddSourceFromFormat(pmFPA *fpa, const char *fpaObs, const psMetadata *format)
     1313bool pmFPAAddSourceFromFormat(pmFPA *fpa, const psMetadata *format)
    13531314{
    13541315    PS_ASSERT_PTR_NON_NULL(fpa, false);
     
    13591320    pmFPAview *view = pmFPAviewAlloc(0);// View for current level
    13601321    if (phuLevel == PM_FPA_LEVEL_FPA) {
    1361         if (!pmFPAAddSourceFromView(fpa, fpaObs, view, format)) {
     1322        if (!pmFPAAddSourceFromView(fpa, view, format)) {
    13621323            psError(PS_ERR_UNKNOWN, false, "Unable to add PHU to FPA.");
    13631324            psFree(view);
     
    13681329        while ((chip = pmFPAviewNextChip(view, fpa, 1))) {
    13691330            if (phuLevel == PM_FPA_LEVEL_CHIP) {
    1370                 if (!pmFPAAddSourceFromView(fpa, fpaObs, view, format)) {
     1331                if (!pmFPAAddSourceFromView(fpa, view, format)) {
    13711332                    psError(PS_ERR_UNKNOWN, false, "Unable to add PHU to FPA.");
    13721333                    psFree(view);
     
    13771338                while ((cell = pmFPAviewNextCell(view, fpa, 1))) {
    13781339                    if (phuLevel == PM_FPA_LEVEL_CELL) {
    1379                         if (!pmFPAAddSourceFromView(fpa, fpaObs, view, format)) {
     1340                        if (!pmFPAAddSourceFromView(fpa, view, format)) {
    13801341                            psError(PS_ERR_UNKNOWN, false, "Unable to add PHU to FPA.");
    13811342                            psFree(view);
     
    13921353}
    13931354
    1394 bool pmFPAAddSourceFromView(pmFPA *fpa, const char *fpaObs, const pmFPAview *phuView,
     1355bool pmFPAAddSourceFromView(pmFPA *fpa, const pmFPAview *phuView,
    13951356                            const psMetadata *format)
    13961357{
     
    13991360    PS_ASSERT_PTR_NON_NULL(format, false);
    14001361
    1401     pmFPAview *view = addSource(fpa, fpaObs, phuView, NULL, format, true);
     1362    pmFPAview *view = addSource(fpa, phuView, NULL, format, true);
    14021363    bool status = (view != NULL);
    14031364    psFree(view);
     
    14181379    }
    14191380
    1420     // Check the name of the FPA
    1421     psString fpaObs = phuNameFromHeader("FPA.OBS", fileInfo, phu); // New observation name for the FPA
    1422     if (!fpaObs || strlen(fpaObs) == 0) {
    1423         psWarning("Unable to determine FPA.OBS: check for FPA.OBS in FILE in camera format");
    1424     }
    1425 
    1426     pmFPAview *view = addSource(fpa, fpaObs, NULL, phu, format, true); // View of PHU, to return
    1427     psFree(fpaObs);
     1381    pmFPAview *view = addSource(fpa, NULL, phu, format, true); // View of PHU, to return
    14281382
    14291383    return view;
     
    14371391    PS_ASSERT_PTR_NON_NULL(format, NULL);
    14381392
    1439     return addSource(fpa, NULL, NULL, phu, format, false);
     1393    return addSource(fpa, NULL, phu, format, false);
    14401394}
    14411395
  • branches/eam_branches/psModules.20100506/src/camera/pmFPAConstruct.h

    r17911 r28011  
    2929/// This is suitable for generating an output FPA given the desired format.
    3030bool pmFPAAddSourceFromFormat(pmFPA *fpa, ///< The FPA
    31                               const char *fpaObs, ///< FPA.NAME for the source
    3231                              const psMetadata *format ///< Format of file
    3332    );
     
    3837/// configuration is required in order to describe how the FPA is laid out in terms of disk files.
    3938bool pmFPAAddSourceFromView(pmFPA *fpa,   ///< The FPA
    40                             const char *fpaObs, ///< FPA.NAME for the source
    4139                            const pmFPAview *phuView, ///< The view, corresponding to the PHU
    4240                            const psMetadata *format ///< Format of file
  • branches/eam_branches/psModules.20100506/src/camera/pmFPAWrite.c

    r25881 r28011  
    165165    // generate the HDU, but only copies the structure.
    166166    if (!blank && !hdu->blankPHU && !*imageArray) {
    167         if (!pmHDUGenerateForCell(cell)) {
    168             psError(PS_ERR_UNKNOWN, false, "Unable to generate HDU for cell --- likely programming error.");
    169             return false;
    170         }
    171         if (!*imageArray) {
    172             if (type == FPA_WRITE_TYPE_IMAGE) {
    173                 psError(PS_ERR_UNKNOWN, false, "Expected to write an image, but it is missing...programming error?.");
    174                 return false;
    175             }
    176             if (type == FPA_WRITE_TYPE_MASK) {
    177                 psWarning("No mask image for this cell; skipping");
    178             }
    179             if (type == FPA_WRITE_TYPE_VARIANCE) {
    180                 psWarning("No variance image for this cell; skipping");
    181             }
    182             return true;
    183         }
     167        if (!pmHDUGenerateForCell(cell)) {
     168            psError(PS_ERR_UNKNOWN, false, "Unable to generate HDU for cell --- likely programming error.");
     169            return false;
     170        }
     171        if (!*imageArray) {
     172            if (type == FPA_WRITE_TYPE_IMAGE) {
     173                psError(PS_ERR_UNKNOWN, false, "Expected to write an image, but it is missing...programming error?.");
     174                return false;
     175            }
     176            if (type == FPA_WRITE_TYPE_MASK) {
     177                psWarning("No mask image for this cell; skipping");
     178            }
     179            if (type == FPA_WRITE_TYPE_VARIANCE) {
     180                psWarning("No variance image for this cell; skipping");
     181            }
     182            return true;
     183        }
    184184    }
    185185
     
    307307
    308308        if (writeBlank || writeImage) {
    309             if (!pmConceptsWriteFPA(fpa, true, config)) {
     309            if (!pmConceptsWriteFPA(fpa, true, config)) {
    310310                psError(PS_ERR_IO, false, "Unable to write concepts for FPA.\n");
    311311                return false;
     
    341341//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    342342
    343 // Update the FPA.OBS, CHIP.NAME and CELL.NAME in the FITS header, if required
     343// Update the CHIP.NAME and CELL.NAME in the FITS header, if required
    344344bool pmFPAUpdateNames(pmFPA *fpa, pmChip *chip, pmCell *cell, psS64 imageId, psS64 sourceId)
    345345{
     
    375375        psError(PS_ERR_UNKNOWN, true, "Unable to find FILE information in camera format.\n");
    376376        return false;
    377     }
    378     if (fpa) {
    379         const char *fpaObsHdr = psMetadataLookupStr(&mdok, fileData, "FPA.OBS");
    380         if (mdok && fpaObsHdr && strlen(fpaObsHdr) > 0) {
    381             const char *fpaObs = psMetadataLookupStr(NULL, fpa->concepts, "FPA.OBS");
    382             psMetadataAddStr(hduHigh->header, PS_LIST_TAIL, fpaObsHdr, PS_META_REPLACE,
    383                              "Observation identifier", fpaObs);
    384         }
    385377    }
    386378
  • branches/eam_branches/psModules.20100506/src/camera/pmFPAfileFitsIO.c

    r25878 r28011  
    7575    }
    7676
    77     pmFPA *nameSource = file->src; // Source of FPA.OBS
    78     if (!nameSource) {
    79         nameSource = file->fpa;
    80     }
    81     bool mdok;                  // Status of MD lookup
    82     const char *fpaObs = psMetadataLookupStr(&mdok, nameSource->concepts, "FPA.OBS"); // Observation id
    83 
    8477    pmFPA *copy = pmFPAConstruct(file->camera, file->cameraName);  // FPA to return
    85     if (!pmFPAAddSourceFromView(copy, fpaObs, phuView, file->format)) {
     78    if (!pmFPAAddSourceFromView(copy, phuView, file->format)) {
    8679        psError(PS_ERR_UNKNOWN, false, "Unable to insert HDU into FPA for writing.\n");
    8780        psFree(copy);
  • branches/eam_branches/psModules.20100506/src/camera/pmFPAfileIO.c

    r26893 r28011  
    286286            }
    287287
    288             pmFPA *nameSource = file->src; // Source of FPA.OBS
    289             if (!nameSource) {
    290                 nameSource = file->fpa;
    291             }
    292             bool mdok;                  // Status of MD lookup
    293             const char *fpaObs = psMetadataLookupStr(&mdok, nameSource->concepts, "FPA.OBS"); // Obs. id
    294 
    295             pmFPAAddSourceFromView(file->fpa, fpaObs, view, format);
     288            pmFPAAddSourceFromView(file->fpa, view, format);
    296289            psTrace ("psModules.camera", 5, "created fpa data elements for %s (%s) (%d:%d:%d)\n",
    297290                     file->name, file->name, view->chip, view->cell, view->readout);
Note: See TracChangeset for help on using the changeset viewer.