IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 25, 2008, 12:29:12 PM (18 years ago)
Author:
Paul Price
Message:

Always use the same name.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/imcombine/pmSubtractionIO.c

    r19535 r19758  
    3636#define NAME_NUMSTAMPS "NUMSTAMPS"      // Number of good stamps
    3737
    38 #define FALLBACK_EXTNAME "SUBTRACTION_KERNEL" // Fallback extension name
    39 
    40 // Generate an extension name for the subtraction kernel
    41 // In the case that there is no chip/cell (the readout is orphaned), the fallback extension name is used
    42 static psString subtractionKernelExtname(const pmReadout *ro // Readout containing kernel
    43                                          )
    44 {
    45     psAssert(ro, "Required parameter");
    46 
    47     psString extname = NULL;            // Name of FITS extension
    48     pmCell *cell = ro->parent;     // Parent cell
    49     if (cell && cell->parent) {
    50         pmChip *chip = cell->parent;        // Parent chip
    51         const char *chipName = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME"); // Name of chip
    52         const char *cellName = psMetadataLookupStr(NULL, cell->concepts, "CELL.NAME"); // Name of cell
    53         psAssert(chipName && cellName, "Chip and cell names should be defined in concepts.");
    54         int roNum = -1;                 // Index of readout
    55         for (int i = 0; i < cell->readouts->n && roNum == -1; i++) {
    56             if (cell->readouts->data[i] == ro) {
    57                 roNum = i;
    58             }
    59         }
    60         if (roNum != -1) {
    61             psStringAppend(&extname, "%s_%s_%d", chipName, cellName, roNum);
    62         } else {
    63             psWarning("Unable to find readout number");
    64         }
    65     }
    66 
    67     if (!extname) {
    68         extname = psStringCopy(FALLBACK_EXTNAME);
    69     }
    70 
    71     return extname;
    72 }
     38#define EXTNAME "SUBTRACTION_KERNEL"    // Extension name
    7339
    7440//////////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    173139    // CVS tags, used to identify the version of this file (in case incompatibilities are introduced)
    174140    psString cvsFile = psStringCopy("$RCSfile: pmSubtractionIO.c,v $");
    175     psString cvsRev  = psStringCopy("$Revision: 1.5 $");
    176     psString cvsDate = psStringCopy("$Date: 2008-09-12 19:01:46 $");
     141    psString cvsRev  = psStringCopy("$Revision: 1.6 $");
     142    psString cvsDate = psStringCopy("$Date: 2008-09-25 22:29:12 $");
    177143    psStringSubstitute(&cvsFile, NULL, "RCSfile: ");
    178144    psStringSubstitute(&cvsRev,  NULL, "Revision: ");
     
    188154    psFree(version);
    189155
    190     psString extname = subtractionKernelExtname(ro); // Extension name
    191 
    192     if (!psFitsWriteTable(fits, header, rows, extname)) {
     156    if (!psFitsWriteTable(fits, header, rows, EXTNAME)) {
    193157        psError(PS_ERR_IO, false, "Unable to write subtraction kernel to FITS table.");
    194158        psFree(header);
    195159        psFree(rows);
    196         psFree(extname);
    197160        return false;
    198161    }
     
    200163    psFree(header);
    201164    psFree(rows);
    202     psFree(extname);
    203165
    204166    return true;
     
    282244    PS_ASSERT_FITS_NON_NULL(fits, false);
    283245
    284     psString extname = subtractionKernelExtname(ro); // Extension name
    285     if (!psFitsMoveExtName(fits, extname)) {
    286         if (strcmp(extname, FALLBACK_EXTNAME) != 0) {
    287             psErrorClear();
    288             if (!psFitsMoveExtName(fits, FALLBACK_EXTNAME)) {
    289                 psError(PS_ERR_IO, false, "Unable to move to subtraction kernel table.");
    290                 psFree(extname);
    291                 return false;
    292             }
    293         } else {
    294             psError(PS_ERR_IO, false, "Unable to move to subtraction kernel table.");
    295             psFree(extname);
    296             return false;
    297         }
    298     }
    299     psFree(extname);
     246    if (!psFitsMoveExtName(fits, EXTNAME)) {
     247        psError(PS_ERR_IO, false, "Unable to move to subtraction kernel table.");
     248        return false;
     249    }
    300250
    301251    psArray *table = psFitsReadTable(fits); // Table of interest
Note: See TracChangeset for help on using the changeset viewer.