IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 12, 2021, 7:09:14 AM (5 years ago)
Author:
eugene
Message:

prep for background-based activation of pattern correction

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-dev-20210817/psModules/src/detrend/pmPattern.c

    r41817 r41838  
    164164                  psImageMaskType maskVal, psImageMaskType maskBad) {
    165165
    166 //  bool status = pmPatternRowBinned(ro, order, iter, rej, thresh, clipMean, clipStdev, maskVal, maskBad);
    167     bool status = pmPatternRowUnbinned(ro, order, iter, rej, thresh, clipMean, clipStdev, maskVal, maskBad);
     166  bool status = pmPatternRowBinned(ro, order, iter, rej, thresh, clipMean, clipStdev, maskVal, maskBad);
     167  // bool status = pmPatternRowUnbinned(ro, order, iter, rej, thresh, clipMean, clipStdev, maskVal, maskBad);
    168168    return status;
    169169}
     
    480480    psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator
    481481    if (!psImageBackground(stats, NULL, ro->image, ro->mask, maskVal, rng)) {
    482         psWarning("Unable to calculate statistics on readout; masking entire readout.");
     482        psWarning("Unable to calculate statistics on readout; skipping pattern correction.");
    483483        psErrorClear();
    484484        psFree(stats);
    485485        psFree(rng);
    486         psImageInit(image, NAN);
    487         if (mask) {
    488             psBinaryOp(mask, mask, "|", psScalarAlloc(maskBad, PS_TYPE_IMAGE_MASK));
    489         }
    490         if (ro->variance) {
    491             psImageInit(image, NAN);
    492         }
     486       
     487        // EAM 20211011 : we used to mask cells which fail the above, but this seems excessive
     488        // psImageInit(image, NAN);
     489        // if (mask) {
     490        //     psBinaryOp(mask, mask, "|", psScalarAlloc(maskBad, PS_TYPE_IMAGE_MASK));
     491        // }
     492        // if (ro->variance) {
     493        //     psImageInit(image, NAN);
     494        // }
    493495        return true;
    494496    }
     
    520522    // so smaller by a factor of 1.4 than what we predict, which is not very large
    521523
    522     # define READNOISE 10
     524    // retrieve noise and gain from 'concepts' if possible
     525# define READNOISE 10 /* arbitrary number */
    523526    float sigma = sqrt(stats->robustMedian + PS_SQR(READNOISE));
    524     float delta = PS_MIN (thresh * sigma, 40);
     527    float delta = PS_MIN (thresh * sigma, 40); // XXX EAM : arbitrary number
    525528    float lower = stats->robustMedian - delta; // Lower bound for data
    526529    float upper = stats->robustMedian + delta; // Upper bound for data
    527530    float background = stats->robustMedian;
    528 # endif   
     531
     532    // find the nominal signal amplitude (check the ghost and/or crosstalk recipe file)
     533    float nominalAmplitude = 20; // XXX EAM : arbitrary number
     534
     535    // if the noise from the background is too large
     536    float significance = nominalAmplitude / sigma;
     537    if (significance < 0.5) return true; // XXX EAM : arbitrary number
    529538   
    530539    pmCell *cell = ro->parent;
    531540    const char *cellName = psMetadataLookupStr(NULL, cell->concepts, "CELL.NAME"); // Name of cell
    532     fprintf (stderr, "pattern row background %s: %f - %f - %f\n", cellName,lower, background, upper);
    533 
    534 
    535     // XXX add code to skip fit if background stdev is large compared to expected signal
    536     // XXX add a constraint to the fit so the |amplitude| < x (x ~ 20 - 25)
     541    fprintf (stderr, "pattern row background %s: %f - %f - %f\n", cellName, lower, background, upper);
     542# endif   
    537543
    538544    psFree(stats);
     
    637643        if (num < validNmin) {
    638644            // Not enough points to fit
    639             patternMaskRow(ro, y, maskBad);
     645            // EAM 20211011 : we used to mask rows which could not be fit, but this is excessive.  just skip.
     646            // patternMaskRow(ro, y, maskBad);
    640647            // Ignore this row in our subsequent fits, because the fit failed.
    641648            yaxisMask->data.PS_TYPE_VECTOR_MASK_DATA[y] = 0xFF;
     
    646653            psWarning("Unable to fit polynomial to row %d", y);
    647654            psErrorClear();
    648             patternMaskRow(ro, y, maskBad);
     655            // EAM 20211011 : we used to mask rows which could not be fit, but this is excessive.  just skip.
     656            // patternMaskRow(ro, y, maskBad);
    649657            // Ignore this row in our subsequent fits, because the fit failed.
    650658            yaxisMask->data.PS_TYPE_VECTOR_MASK_DATA[y] = 0xFF;
     
    661669            psWarning("Unable to evaluate polynomial for row %d", y);
    662670            psErrorClear();
    663             patternMaskRow(ro, y, maskBad);
     671            // EAM 20211011 : we used to mask rows which could not be fit, but this is excessive.  just skip.
     672            // patternMaskRow(ro, y, maskBad);
    664673            yaxisMask->data.PS_TYPE_VECTOR_MASK_DATA[y] = 0xFF;
    665674            continue;
Note: See TracChangeset for help on using the changeset viewer.