IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 6, 2021, 10:24:58 AM (5 years ago)
Author:
eugene
Message:

add threading to pattern detrending

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-dev-20210817/ppImage/src/ppImageDetrendPattern.c

    r41265 r41805  
    5252
    5353        pmFPAfile *input = psMetadataLookupPtr(&status, config->files, "PPIMAGE.INPUT");
     54
    5455        pmFPAview *view = pmFPAviewAlloc(0); // View for local processing
    5556        *view = *inputView;
     
    7980                ESCAPE(false, "Unable to determine whether row pattern matching should be applied.");
    8081            }
    81             //psWarning ("Row: %d\n", doPattern);
    8282            if (!doPattern) continue;
    8383
    84             // A very detailed log message.
    85             const char *chipName = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME");
    86             const char *cellName = psMetadataLookupStr(NULL, cell->concepts, "CELL.NAME");
    87             psLogMsg("ppImage", PS_LOG_INFO, "Performing row pattern correction for %s, %s\n", chipName, cellName);
    88 
    89             // process each of the readouts
    90             pmReadout *readout;         // Readout from cell
    91             while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) {
    92                 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
    93                     ESCAPE(false, "load failure for Readout");
    94                 }
    95                 if (!readout->data_exists) {
    96                     continue;
    97                 }
    98 
    99                 // Perform pattern correction
    100                 if (!pmPatternRow(readout, options->patternRowOrder, options->patternRowIter,
    101                                   options->patternRowRej, options->patternRowThresh, options->patternRowMean,
    102                                   options->patternRowStdev, options->maskValue, options->darkMask)) {
    103                     psFree(view);
    104                     return(false);
    105                 }
    106             }
    107 
    108         }
     84            // switch to test threaded version
     85            if (true) {
     86                // I need to allocate a view here to be freed by the
     87                // called function below. 
     88                pmFPAview *myView = pmFPAviewAlloc(0); // View for local processing
     89                *myView = *view;
     90
     91                // allocate a job, construct the arguments for this job
     92                psThreadJob *job = psThreadJobAlloc("PPIMAGE_PATTERN_ROW_CELL");
     93                psArrayAdd(job->args, 1, config);
     94                psArrayAdd(job->args, 1, input->fpa);
     95                psArrayAdd(job->args, 1, chip);
     96                psArrayAdd(job->args, 1, cell);
     97                psArrayAdd(job->args, 1, myView);
     98                psArrayAdd(job->args, 1, options);
     99                if (!psThreadJobAddPending(job)) {
     100                    return false;
     101                }
     102            } else {
     103                // bump the counter since it must be freed by the function below. 
     104                psMemIncrRefCounter (view); // View for local processing
     105                if (!ppImageDetrendPatternApplyCell (config, input->fpa, chip, cell, view, options)) {
     106                    return false;
     107                }
     108            }
     109
     110        }
     111
     112        // wait here for the threaded jobs to finish
     113        // if no threads are allocated, this
     114        if (!psThreadPoolWait(true, true)) {
     115            psError(PS_ERR_UNKNOWN, false, "Unable to apply bias correction.");
     116            return false;
     117        }
     118
    109119        psMetadataAddBool(hdu->header, PS_LIST_TAIL, "PTRN_ROW",PS_META_REPLACE,"PATTERN.ROW correction applied",true);
    110120        psFree(view);
     
    266276    return false;
    267277}
     278
     279bool ppImageDetrendPatternApplyCell (pmConfig *config, pmFPA *fpa, pmChip *chip, pmCell *cell, const pmFPAview *view, const ppImageOptions *options) {
     280 
     281    // A very detailed log message.
     282    const char *chipName = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME");
     283    const char *cellName = psMetadataLookupStr(NULL, cell->concepts, "CELL.NAME");
     284    psLogMsg("ppImage", PS_LOG_INFO, "Performing row pattern correction for %s, %s\n", chipName, cellName);
     285
     286    // process each of the readouts
     287    pmReadout *readout;         // Readout from cell
     288    while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) {
     289        if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
     290            ESCAPE(false, "load failure for Readout");
     291        }
     292        if (!readout->data_exists) {
     293            continue;
     294        }
     295
     296        // Perform pattern correction
     297        if (!pmPatternRow(readout, options->patternRowOrder, options->patternRowIter,
     298                          options->patternRowRej, options->patternRowThresh, options->patternRowMean,
     299                          options->patternRowStdev, options->maskValue, options->darkMask)) {
     300            psFree (view);
     301            return(false);
     302        }
     303    }
     304    psFree (view); // supplied view must be freeable
     305}
Note: See TracChangeset for help on using the changeset viewer.