IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 8, 2008, 6:10:14 PM (18 years ago)
Author:
Paul Price
Message:

Discovered a problem with threaded implementation of pmDarkApply --- the polynomial is altered within pmDarkApplyScan, so it should not be global across threads. Checked and cleaned up the other threaded detrending functions.

File:
1 edited

Legend:

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

    r19299 r19432  
    661661
    662662    psImage *image        = job->args->data[0];
    663     psImage *shutterImage = job->args->data[1];
     663    const psImage *shutterImage = job->args->data[1];
    664664    psImage *mask         = job->args->data[2];
    665665
     
    668668    int rowStart     = PS_SCALAR_VALUE(job->args->data[5],S32);
    669669    int rowStop      = PS_SCALAR_VALUE(job->args->data[6],S32);
    670     bool status = pmShutterCorrectionApplyScan (image, shutterImage, mask, exptime, blank, rowStart, rowStop);
    671     return status;
    672 }
    673 
    674 bool pmShutterCorrectionApplyScan(psImage *image, psImage *shutterImage, psImage *mask, float exptime, psMaskType blank, int rowStart, int rowStop)
     670    return pmShutterCorrectionApplyScan (image, shutterImage, mask, exptime, blank, rowStart, rowStop);
     671}
     672
     673bool pmShutterCorrectionApplyScan(psImage *image, const psImage *shutterImage, psImage *mask, float exptime,
     674                                  psMaskType blank, int rowStart, int rowStop)
    675675{
    676676    for (int y = rowStart; y < rowStop; y++) {
     
    753753            }
    754754        }
    755         psMetadataAddF32 (cell->concepts, PS_LIST_TAIL, "CELL.EXPOSURE", PS_META_REPLACE, "exposure time re-normalized to 1.0", 1.0); // Exposure time
     755        psMetadataAddF32(cell->concepts, PS_LIST_TAIL, "CELL.EXPOSURE", PS_META_REPLACE,
     756                         "exposure time re-normalized to 1.0", 1.0); // Exposure time
    756757        psString line = NULL;
    757         psStringAppend (&line, "extreme exposure time %f, re-normalized to 1.0", exptime);
     758        psStringAppend(&line, "extreme exposure time %f, re-normalized to 1.0", exptime);
    758759        psMetadataAddStr(hdu->header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, line, "");
    759         psFree (line);
     760        psFree(line);
    760761    } else {
    761762        for (int rowStart = 0; rowStart < image->numRows; rowStart += scanRows) {
     
    764765            if (threaded) {
    765766                // allocate a job, construct the arguments for this job
    766                 psThreadJob *job = psThreadJobAlloc ("PSMODULES_DETREND_SHUTTER");
    767                 psArrayAdd (job->args, 1, image);
    768                 psArrayAdd (job->args, 1, shutterImage);
    769                 psArrayAdd (job->args, 1, mask);
    770                 PS_ARRAY_ADD_SCALAR (job->args, exptime, PS_TYPE_F32);
    771                 PS_ARRAY_ADD_SCALAR (job->args, blank, PS_TYPE_MASK);
    772                 PS_ARRAY_ADD_SCALAR (job->args, rowStart, PS_TYPE_S32);
    773                 PS_ARRAY_ADD_SCALAR (job->args, rowStop, PS_TYPE_S32);
    774 
    775                 // ppImageDetrendReadout(config, options, view)
    776                 if (!psThreadJobAddPending (job)) {
     767                psThreadJob *job = psThreadJobAlloc("PSMODULES_DETREND_SHUTTER");
     768                psArrayAdd(job->args, 1, image);
     769                psArrayAdd(job->args, 1, shutterImage);
     770                psArrayAdd(job->args, 1, mask);
     771                PS_ARRAY_ADD_SCALAR(job->args, exptime, PS_TYPE_F32);
     772                PS_ARRAY_ADD_SCALAR(job->args, blank, PS_TYPE_MASK);
     773                PS_ARRAY_ADD_SCALAR(job->args, rowStart, PS_TYPE_S32);
     774                PS_ARRAY_ADD_SCALAR(job->args, rowStop, PS_TYPE_S32);
     775
     776                if (!psThreadJobAddPending(job)) {
    777777                    psFree(job);
    778778                    return false;
    779779                }
    780780                psFree(job);
    781             } else {
    782                 pmShutterCorrectionApplyScan (image, shutterImage, mask, exptime, blank, rowStart, rowStop);
     781            } else if (!pmShutterCorrectionApplyScan(image, shutterImage, mask, exptime, blank,
     782                                                     rowStart, rowStop)) {
     783                psError(PS_ERR_UNKNOWN, false, "Unable to apply shutter correction.");
     784                psFree(shutterImage);
     785                return false;
    783786            }
    784787        }
    785788        if (threaded) {
    786789            // wait here for the threaded jobs to finish
    787             if (!psThreadPoolWait(false)) {
    788                 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image.");
     790            if (!psThreadPoolWait(true)) {
     791                psError(PS_ERR_UNKNOWN, false, "Unable to apply shutter correction.");
     792                psFree(shutterImage);
    789793                return false;
    790             }
    791             fprintf (stderr, "success for threaded jobs\n");
    792 
    793             // free the done jobs
    794             psThreadJob *job = NULL;
    795             while ((job = psThreadJobGetDone()) != NULL) {
    796                 psFree (job);
    797794            }
    798795        }
     
    10241021}
    10251022
    1026 bool pmShutterCorrectionGeneratePrepare(pmReadout *shutter, pmReadout *pattern, const psArray *inputs, psMaskType maskVal)
     1023bool pmShutterCorrectionGeneratePrepare(pmReadout *shutter, pmReadout *pattern, const psArray *inputs,
     1024                                        psMaskType maskVal)
    10271025{
    10281026    PS_ASSERT_PTR_NON_NULL(shutter, false);
     
    10431041    }
    10441042
    1045     psImage *nums = pmReadoutSetAnalysisImage(shutter, PM_READOUT_STACK_ANALYSIS_COUNT, numCols, numRows, PS_TYPE_U16, 0); // Image with number fitted per pixel
     1043    psImage *nums = pmReadoutSetAnalysisImage(shutter, PM_READOUT_STACK_ANALYSIS_COUNT, numCols, numRows,
     1044                                              PS_TYPE_U16, 0); // Image with number fitted per pixel
    10461045    if (!nums) {
    10471046        return false;
    10481047    }
    1049     psImage *sigma = pmReadoutSetAnalysisImage(shutter, PM_READOUT_STACK_ANALYSIS_SIGMA, numCols, numRows, PS_TYPE_F32, NAN); // Image with stdev per pixel
     1048    psImage *sigma = pmReadoutSetAnalysisImage(shutter, PM_READOUT_STACK_ANALYSIS_SIGMA, numCols, numRows,
     1049                                               PS_TYPE_F32, NAN); // Image with stdev per pixel
    10501050    if (!sigma) {
    10511051        return false;
Note: See TracChangeset for help on using the changeset viewer.