IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 13, 2021, 6:44:06 AM (5 years ago)
Author:
eugene
Message:

some tests of pattern.row implementation

File:
1 edited

Legend:

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

    r41806 r41808  
    139139// Measurement and application
    140140//////////////////////////////////////////////////////////////////////////////////////////////////////////////
     141
     142// USE_BACKGROUND_STDEV: if true, the analysis will use the measured robust stdev to clip the out-of-range pixles
     143// if false, the stdev will be estimated based on the Poisson statistics of the median (sky level).
     144# define USE_BACKGROUND_STDEV 0
    141145
    142146bool pmPatternRow(pmReadout *ro, int order, int iter, float rej, float thresh,
     
    172176    }
    173177
    174 # if (0)
     178# if (USE_BACKGROUND_STDEV)
    175179    float lower = stats->robustMedian - thresh * stats->robustStdev; // Lower bound for data
    176180    float upper = stats->robustMedian + thresh * stats->robustStdev; // Upper bound for data
    177181    float background = stats->robustMedian;
    178182# else
    179 
    180183    // the signal we are looking for is a small variation on top of the background.  if
    181184    // the background is uniform with only read noise + sky noise, then the pixel-to-pixel
     
    201204# endif   
    202205   
    203     // the expected amplitude of the 2nd order term is
    204     // if the predicted sky poisson signal is larger than
    205 
    206     // I want to add a constraint to the fit so the amplitude or coeffs are |value| < x
     206    pmCell *cell = ro->parent;
     207    const char *cellName = psMetadataLookupStr(NULL, cell->concepts, "CELL.NAME"); // Name of cell
     208    fprintf (stderr, "pattern row background %s: %f - %f - %f\n", cellName,lower, background, upper);
     209
     210
     211    // XXX add code to skip fit if background stdev is large compared to expected signal
     212    // XXX add a constraint to the fit so the |amplitude| < x (x ~ 20 - 25)
    207213
    208214    psFree(stats);
     
    217223
    218224    psStats *clip = psStatsAlloc(clipMean | clipStdev); // Clipping statistics
    219     clip->clipIter = iter;
     225    // XXX clip->clipIter = iter;
     226    clip->clipIter = 1; // XXX skip iteration for a test
    220227    clip->clipSigma = rej;
    221228    psVector *clipMask = psVectorAlloc(numCols, PS_TYPE_VECTOR_MASK); // Mask for clipping
     
    259266        float validXmax = -1;
    260267
     268        // XXX can we do just as well fitting 1/3 of the pixels? (NOT REALLY)
     269        // (x % 3) ||
    261270        for (int x = 0; x < numCols; x++) {
    262             if ((mask && mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) ||
    263                 data->data.F32[x] < lower || data->data.F32[x] > upper) {
    264                 clipMask->data.PS_TYPE_VECTOR_MASK_DATA[x] = 0xFF;
     271            if ((mask && mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) ||
     272                data->data.F32[x] < lower || data->data.F32[x] > upper) {
     273                clipMask->data.PS_TYPE_VECTOR_MASK_DATA[x] = 0xFF;
    265274            } else {
    266275                clipMask->data.PS_TYPE_VECTOR_MASK_DATA[x] = 0;
     
    271280        }
    272281
     282        // XXX how much time is spent in the fitting
    273283        if (num < validNmin) {
    274284            // Not enough points to fit
Note: See TracChangeset for help on using the changeset viewer.