IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 10, 2007, 2:57:23 PM (19 years ago)
Author:
Paul Price
Message:

An assertion isn't appropriate.

File:
1 edited

Legend:

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

    r12696 r12791  
    5151
    5252    if (*target) {
    53         psFree(*target);
     53        psFree(*target);
    5454    }
    5555    if (pixels) {
    56         *target = psImageFlip(NULL, source, xFlip, yFlip);
    57         return;
    58     } 
     56        *target = psImageFlip(NULL, source, xFlip, yFlip);
     57        return;
     58    }
    5959
    6060    // I have the fine image size, I know the binning factor, determine the ruff image size
     
    108108    int xParitySource = psMetadataLookupS32(&mdokS, source->concepts, "CELL.XPARITY"); // Source parity
    109109    int xParityTarget = psMetadataLookupS32(&mdokT, target->concepts, "CELL.XPARITY"); // Target x parity
    110     assert (mdokS && mdokT);
    111     assert (abs(xParitySource) == 1);
    112     assert (abs(xParityTarget) == 1);
     110    assert(mdokS && mdokT);
     111    if (abs(xParitySource) != 1 || abs(xParityTarget) != 1) {
     112        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     113                "CELL.XPARITY is not set for both source (%d) and target (%d)",
     114                xParitySource, xParityTarget);
     115        psFree(binning);
     116        return false;
     117    }
    113118    if (xParityTarget != xParitySource) {
    114         xFlip = true;
     119        xFlip = true;
    115120    } else {
    116         // Use the source parity
    117         COPY_CONCEPT(target->concepts, source->concepts, "CELL.XPARITY", S32);
     121        // Use the source parity
     122        COPY_CONCEPT(target->concepts, source->concepts, "CELL.XPARITY", S32);
    118123    }
    119124
    120125    int yParityTarget = psMetadataLookupS32(&mdokT, target->concepts, "CELL.YPARITY"); // Target y parity
    121126    int yParitySource = psMetadataLookupS32(&mdokS, source->concepts, "CELL.YPARITY"); // Source parity
    122     assert (mdokS && mdokT);
    123     assert (abs(yParitySource) == 1);
    124     assert (abs(yParityTarget) == 1);
     127    assert(mdokS && mdokT);
     128    if (abs(yParitySource) != 1 || abs(yParityTarget) != 1) {
     129        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     130                "CELL.YPARITY is not set for both source (%d) and target (%d)",
     131                yParitySource, yParityTarget);
     132        psFree(binning);
     133        return false;
     134    }
    125135    if (yParityTarget != yParitySource) {
    126         yFlip = true;
     136        yFlip = true;
    127137    } else {
    128         // Use the source parity
    129         COPY_CONCEPT(target->concepts, source->concepts, "CELL.YPARITY", S32);
     138        // Use the source parity
     139        COPY_CONCEPT(target->concepts, source->concepts, "CELL.YPARITY", S32);
    130140    }
    131141    psTrace("psModules.camera", 3, "xFlip: %d; yFlip: %d\n", xFlip, yFlip);
     
    140150
    141151        // Copy attributes
    142         // XXX is this correct under binning?
     152        // XXX is this correct under binning?
    143153        targetReadout->col0 = sourceReadout->col0;
    144154        targetReadout->row0 = sourceReadout->row0;
     
    148158
    149159        // Copy all three image components (image, mask, weight)
    150         readoutCopyComponent (&targetReadout->image,  sourceReadout->image,  binning, xFlip, yFlip, pixels);
    151         readoutCopyComponent (&targetReadout->mask,   sourceReadout->mask,   binning, xFlip, yFlip, pixels);
    152         readoutCopyComponent (&targetReadout->weight, sourceReadout->weight, binning, xFlip, yFlip, pixels);
     160        readoutCopyComponent (&targetReadout->image,  sourceReadout->image,  binning, xFlip, yFlip, pixels);
     161        readoutCopyComponent (&targetReadout->mask,   sourceReadout->mask,   binning, xFlip, yFlip, pixels);
     162        readoutCopyComponent (&targetReadout->weight, sourceReadout->weight, binning, xFlip, yFlip, pixels);
    153163
    154164        // Copy bias
     
    162172        while ((bias = psListGetAndIncrement(biasIter))) {
    163173            psImage *biasCopy = NULL;          // Copy of the bias
    164             readoutCopyComponent (&biasCopy, bias, binning, xFlip, yFlip, pixels);
     174            readoutCopyComponent (&biasCopy, bias, binning, xFlip, yFlip, pixels);
    165175            psListAdd(targetReadout->bias, PS_LIST_TAIL, biasCopy);
    166176            psFree(biasCopy);           // Drop reference
     
    181191        psString name = conceptItem->name; // Name of concept
    182192        if (!strcmp(name, "CELL.TRIMSEC")) continue;
    183         if (!strcmp(name, "CELL.BIASSEC")) continue;
    184         if (!strcmp(name, "CELL.XPARITY")) continue;
    185         if (!strcmp(name, "CELL.YPARITY")) continue;
    186         if (!strcmp(name, "CELL.X0")) continue;
    187         if (!strcmp(name, "CELL.Y0")) continue;
    188 
    189         psMetadataItem *copy = psMetadataItemCopy(conceptItem); // Copy of the concept
    190         psMetadataAddItem(target->concepts, copy, PS_LIST_TAIL, PS_META_REPLACE);
    191         psFree(copy);               // Drop reference
     193        if (!strcmp(name, "CELL.BIASSEC")) continue;
     194        if (!strcmp(name, "CELL.XPARITY")) continue;
     195        if (!strcmp(name, "CELL.YPARITY")) continue;
     196        if (!strcmp(name, "CELL.X0")) continue;
     197        if (!strcmp(name, "CELL.Y0")) continue;
     198
     199        psMetadataItem *copy = psMetadataItemCopy(conceptItem); // Copy of the concept
     200        psMetadataAddItem(target->concepts, copy, PS_LIST_TAIL, PS_META_REPLACE);
     201        psFree(copy);               // Drop reference
    192202    }
    193203    psFree(conceptsIter);
     
    196206    // XXX this code seems to be very similar to pmConceptsUpdate
    197207    if ((binning->nXbin != 1) || (binning->nYbin != 1)) {
    198         bool mdok = false;
     208        bool mdok = false;
    199209        psRegion *trimsec = psMetadataLookupPtr(&mdok, target->concepts, "CELL.TRIMSEC"); // The trim section
    200210        if (mdok && trimsec && !psRegionIsNaN(*trimsec)) {
     
    227237        }
    228238
    229         // XXX make sure this is consistent with the psImageBinning
     239        // XXX make sure this is consistent with the psImageBinning
    230240        psTrace("psModules.camera", 3, "CELL.X0: Before: %d After: %d\n", xZero, xZero + (xSize - 1) * xParity * sourceBin);
    231241        psTrace("psModules.camera", 9, "(xParity: %d xBin: %d numCols: %d)\n", xParity, sourceBin, xSize);
     
    284294    pmHDU *targetPHU = findBlankPHU(target); // The target PHU
    285295    if (targetPHU && targetPHU != targetHDU) {
    286         // pmHDU *sourcePHU = pmHDUGetHighest(source->parent->parent, source->parent, source); // A source HDU
     296        // pmHDU *sourcePHU = pmHDUGetHighest(source->parent->parent, source->parent, source); // A source HDU
    287297        pmHDU *sourcePHU = findBlankPHU(source); // The target PHU
    288298        if (sourcePHU && sourcePHU->header) {
Note: See TracChangeset for help on using the changeset viewer.