IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 22, 2009, 3:12:36 PM (17 years ago)
Author:
Paul Price
Message:

Mask row if we can't fit it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/detrend/pmPattern.c

    r24891 r24899  
    77
    88
     9// Mask a row as bad
     10static void patternMaskRow(pmReadout *ro, // Readout to mask
     11                           int y,         // Row to mask
     12                           psImageMaskType bad // Mask value to give
     13                           )
     14{
     15    psImage *image = ro->image;         // Image to mask
     16    psAssert(image, "Require image");
     17    psAssert(y < image->numRows, "Row not in image");
     18
     19    int numCols = image->numCols;       // Size of image
     20    for (int x = 0; x < numCols; x++) {
     21        image->data.F32[y][x] = NAN;
     22    }
     23    if (ro->mask) {
     24        psImage *mask = ro->mask;       // Mask image to mask
     25        for (int x = 0; x < numCols; x++) {
     26            mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= bad;
     27        }
     28    }
     29    return;
     30}
     31
    932bool pmPatternRow(pmReadout *ro, int order, int iter, float rej,
    10                   psStatsOptions clipMean, psStatsOptions clipStdev)
     33                  psStatsOptions clipMean, psStatsOptions clipStdev,
     34                  psImageMaskType maskBad)
    1135{
    1236    PM_ASSERT_READOUT_NON_NULL(ro, false);
     
    4771        if (num < order + 1) {
    4872            // Not enough points to fit
     73            patternMaskRow(ro, y, maskBad);
    4974            continue;
    5075        }
    5176        if (!psVectorClipFitPolynomial1D(poly, clip, mask, 0xFF, data, NULL, indices)) {
    52             psError(PS_ERR_UNKNOWN, false, "Unable to fit polynomial to row %d", y);
    53             psFree(indices);
    54             psFree(clip);
    55             psFree(mask);
    56             psFree(poly);
    57             psFree(data);
    58             return false;
     77            psWarning("Unable to fit polynomial to row %d", y);
     78            psErrorClear();
     79            patternMaskRow(ro, y, maskBad);
     80            continue;
    5981        }
    6082        psVector *solution = psPolynomial1DEvalVector(poly, indices); // Solution vector
    6183        if (!solution) {
    62             psError(PS_ERR_UNKNOWN, false, "Unable to evaluate polynomial for row %d", y);
    63             psFree(indices);
    64             psFree(clip);
    65             psFree(mask);
    66             psFree(poly);
    67             psFree(data);
    68             return false;
     84            psWarning("Unable to evaluate polynomial for row %d", y);
     85            psErrorClear();
     86            patternMaskRow(ro, y, maskBad);
     87            continue;
    6988        }
    7089
Note: See TracChangeset for help on using the changeset viewer.