IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 17, 2021, 1:29:19 PM (5 years ago)
Author:
eugene
Message:

trap stacking failures without hanging forever

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ppStack.20211015/src/ppStackReadout.c

    r41842 r41845  
    1919                                         weightings, exposures, addVariance);
    2020    thread->busy = false;
     21
     22    thread->status = job->results ? PPSTACK_THREAD_SUCCESS : PPSTACK_THREAD_FAILURE;
     23
     24    psAssert(job->results, "Stacking failed.");
    2125
    2226    return job->results ? true : false;
     
    4852    thread->busy = false;
    4953
     54    thread->status = status ? PPSTACK_THREAD_SUCCESS : PPSTACK_THREAD_FAILURE;
     55
    5056    psAssert(status, "Stacking failed.");
    5157
     
    6874    psVector *addVariance = options->matchChi2; // Additional variance when rejecting
    6975
    70     job->results = ppStackReadoutInitial(config, outRO, thread->readouts, mask, weightings, exposures, addVariance);
     76    // fprintf (stderr, "start thread %d : scan range %d - %d\n", thread->entry, thread->firstScan, thread->lastScan);
     77
     78    bool status = ppStackReadoutPercent(config, outRO, thread->readouts, mask, weightings, exposures, addVariance);
     79
    7180    thread->busy = false;
    7281
    73     return job->results ? true : false;
     82    thread->status = status ? PPSTACK_THREAD_SUCCESS : PPSTACK_THREAD_FAILURE;
     83
     84    // fprintf (stderr, "finished thread %d, status %d : scan range %d - %d\n", thread->entry, thread->status, thread->firstScan, thread->lastScan);
     85
     86    psAssert(status, "Stacking failed.");
     87
     88    return status;
    7489}
    7590
     
    167182
    168183    int num = readouts->n;              // Number of inputs
    169     psArray *stack = psArrayAlloc(num); // Array for stacking
     184    psArray *stackData = psArrayAlloc(num); // Array of data to be stacked
    170185
    171186    for (int i = 0; i < num; i++) {
     
    182197        }
    183198
    184         stack->data[i] = pmStackDataAlloc(ro, weightings->data.F32[i], exposures->data.F32[i],
     199        // stackData is an array of pmStackData structures
     200        stackData->data[i] = pmStackDataAlloc(ro, weightings->data.F32[i], exposures->data.F32[i],
    185201                                          addVariance->data.F32[i]);
    186202    }
    187203
    188     if (!pmStackCombine(outRO, NULL, stack, maskBad, maskSuspect, maskBlank, kernelSize, iter,
     204    if (!pmStackCombine(outRO, NULL, stackData, maskBad, maskSuspect, maskBlank, kernelSize, iter,
    189205                        combineRej, combineSys, combineDiscard, useVariance, safe, nminpix, false)) {
    190206        psError(PS_ERR_UNKNOWN, false, "Unable to combine input readouts with rejection.");
    191         psFree(stack);
     207        psFree(stackData);
     208       
     209        // XXX EAM : if pmStackCombine fails above this return will cause the thread to block.
     210        // The failure status results in a psThread.fault.  the psThreadLauncher function, which
     211        // each background thread runs as a loop, will sleep until the fault is cleared externally
     212        // by the handler.  psThreadPoolWait() catches, counts, and clears these faults, but
     213        // ppStackThreadRead does not. 
    192214        return false;
    193215    }
     
    197219    psArray *reject = psArrayAlloc(num);  // List of pixels rejected
    198220    for (int i = 0; i < num; i++) {
    199         pmStackData *data = stack->data[i]; // Data for this image
     221        pmStackData *data = stackData->data[i]; // Data for this image
    200222        if (!data) {
    201223            continue;
     
    208230        reject->data[i] = psMemIncrRefCounter(data->reject);
    209231    }
    210     psFree(stack);
     232    psFree(stackData);
    211233
    212234    //MEH change to trace
     
    269291
    270292    int num = readouts->n;              // Number of inputs
    271     psArray *stack = psArrayAlloc(num); // Array for stacking
     293    psArray *stackData = psArrayAlloc(num); // Array of data to be stacked
    272294
    273295    // We have rejection from a previous combination: combine without flagging pixels to inspect
     
    294316                                             addVariance ? addVariance->data.F32[i] : NAN);
    295317        data->reject = rejected ? psMemIncrRefCounter(rejected->data[i]) : NULL;
    296         stack->data[i] = data;
     318        stackData->data[i] = data;
    297319
    298320        //MEH -- apply bscale offset before norm   
     
    310332    }
    311333
    312     if (!pmStackCombine(outRO, expRO, stack, maskBad, maskSuspect, maskBlank, 0, iter, combineRej,
     334    if (!pmStackCombine(outRO, expRO, stackData, maskBad, maskSuspect, maskBlank, 0, iter, combineRej,
    313335                        combineSys, combineDiscard, useVariance, safe, nminpix, rejected)) {
    314336        psError(PS_ERR_UNKNOWN, false, "Unable to combine input readouts.");
    315         psFree(stack);
     337        psFree(stackData);
    316338        return false;
    317339    }
     
    329351    expChip->data_exists = true;
    330352
    331     psFree(stack);
     353    psFree(stackData);
    332354
    333355    //MEH change to trace
     
    338360    return true;
    339361}
    340 
    341 bool pmStackCombineByPercentile(pmReadout *outRO, psArray *stack, float minRange, float maxRange, psImageMaskType maskBad, psImageMaskType maskSuspect, psImageMaskType maskBlank);
    342362
    343363bool ppStackReadoutPercent(const pmConfig *config, pmReadout *outRO, const psArray *readouts,
     
    353373    static int sectionNum = 0;          // Section number; for debugging outputs
    354374
     375    // fprintf (stderr, "starting ReadoutPercent, %d\n", sectionNum);
     376
    355377    // Get the recipe values
    356378    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // ppStack recipe
     
    358380
    359381    bool mdok;                          // Status of MD lookup
    360     float minRange = psMetadataLookupF32(&mdok, recipe, "COMBINE.MIN.RANGE"); // Combination threshold
    361     float maxRange = psMetadataLookupF32(&mdok, recipe, "COMBINE.MAX.RANGE"); // Combination threshold
     382    psF64 minRange = psMetadataLookupF32(&mdok, recipe, "COMBINE.MIN.RANGE"); // Combination threshold
     383    psF64 maxRange = psMetadataLookupF32(&mdok, recipe, "COMBINE.MAX.RANGE"); // Combination threshold
    362384
    363385    char defaultBlankStr[16] = "BLANK";
     
    378400
    379401    int num = readouts->n;              // Number of inputs
    380     psArray *stack = psArrayAlloc(num); // Array for stacking
     402    psArray *stackData = psArrayAlloc(num); // Array of data to be stacked
    381403
    382404    for (int i = 0; i < num; i++) {
     
    393415        }
    394416
    395         stack->data[i] = pmStackDataAlloc(ro, weightings->data.F32[i], exposures->data.F32[i],
    396                                           addVariance->data.F32[i]);
    397     }
    398 
    399     if (!pmStackCombineByPercentile(outRO, stack, minRange, maxRange, maskBad, maskSuspect, maskBlank)) {
     417        stackData->data[i] = pmStackDataAlloc(ro, weightings->data.F32[i], exposures->data.F32[i],
     418                                              addVariance->data.F32[i]);
     419    }
     420
     421    if (!pmStackCombineByPercentile(outRO, stackData, minRange, maxRange, maskBad, maskSuspect, maskBlank)) {
    400422        psError(PS_ERR_UNKNOWN, false, "Unable to combine input readouts with rejection.");
    401         psFree(stack);
     423        psFree(stackData);
    402424        return false;
    403425    }
    404426
     427    outRO->data_exists = true; // output readout
     428    outRO->parent->data_exists = true; // output cell
     429    outRO->parent->parent->data_exists = true; // output chip
     430
     431# if 0
     432      pmCell *expCell = expRO->parent;    // Exposure cell
     433      pmChip *expChip = expCell->parent;  // Exposure chip
     434      expRO->data_exists = true;
     435      expCell->data_exists = true;
     436      expChip->data_exists = true;
     437# endif
     438
     439    psFree(stackData);
    405440    sectionNum++;
    406441
Note: See TracChangeset for help on using the changeset viewer.