IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 8, 2008, 8:09:07 AM (18 years ago)
Author:
Paul Price
Message:

Fixing to match slight differences in psThread

File:
1 edited

Legend:

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

    r18893 r18960  
    102102bool pmDarkCombinePrepare(pmCell *output, const psArray *inputs, psArray *ordinates, const char *normConcept)
    103103{
    104     psArray *values = psArrayAlloc(inputs->n); 
     104    psArray *values = psArrayAlloc(inputs->n);
    105105    psVector *roMask = psVectorAlloc(inputs->n, PS_TYPE_U8); // Mask for bad readouts
    106106    psVector *norm = normConcept ? psVectorAlloc(inputs->n, PS_TYPE_F32) : NULL; // Normalizations for each
     
    117117        if (!norm) continue;
    118118
    119         pmReadout *readout = inputs->data[i]; // Readout of interest
    120         float normValue;            // Normalisation value
    121         if (!ordinateLookup(&normValue, &inRange, normConcept, false, NAN, NAN, readout)) {
    122             psWarning("Unable to find value of %s for readout %d", normConcept, i);
    123             roMask->data.U8[i] = 0xff;
    124             norm->data.F32[i] = NAN;
    125             numBadInputs++;
    126             continue;
    127         }
    128         if (normValue == 0.0) {
    129             psWarning("Normalisation value (%s) for readout %d is zero", normConcept, i);
    130             roMask->data.U8[i] = 0xff;
    131             norm->data.F32[i] = NAN;
    132             numBadInputs++;
    133             continue;
    134         }
    135         norm->data.F32[i] = 1.0 / normValue;
     119        pmReadout *readout = inputs->data[i]; // Readout of interest
     120        float normValue;            // Normalisation value
     121        if (!ordinateLookup(&normValue, &inRange, normConcept, false, NAN, NAN, readout)) {
     122            psWarning("Unable to find value of %s for readout %d", normConcept, i);
     123            roMask->data.U8[i] = 0xff;
     124            norm->data.F32[i] = NAN;
     125            numBadInputs++;
     126            continue;
     127        }
     128        if (normValue == 0.0) {
     129            psWarning("Normalisation value (%s) for readout %d is zero", normConcept, i);
     130            roMask->data.U8[i] = 0xff;
     131            norm->data.F32[i] = NAN;
     132            numBadInputs++;
     133            continue;
     134        }
     135        norm->data.F32[i] = 1.0 / normValue;
    136136    }
    137137
     
    144144            psFree(roMask);
    145145            psFree(orders);
    146             psFree(norm);
     146            psFree(norm);
    147147            return false;
    148148        }
     
    215215        }
    216216
    217         pmReadoutStackDefineOutput(readout, col0, row0, numCols, numRows, false, false, 0);
    218         psTrace("psModules.imcombine", 7, "Output minimum: %d,%d\n", col0, row0);
     217        pmReadoutStackDefineOutput(readout, col0, row0, numCols, numRows, false, false, 0);
     218        psTrace("psModules.imcombine", 7, "Output minimum: %d,%d\n", col0, row0);
    219219    }
    220220
     
    269269    bool mdok = false;
    270270
    271     // retrieve the required parameter vectors 
    272     psArray *values      = psMetadataLookupPtr(&mdok, output->analysis, "DARK.VALUES");  psAssert (values, "values not supplied");
    273     psVector *roMask     = psMetadataLookupPtr(&mdok, output->analysis, "DARK.RO.MASK"); psAssert (roMask, "roMask not supplied");
     271    // retrieve the required parameter vectors
     272    psArray *values      = psMetadataLookupPtr(&mdok, output->analysis, "DARK.VALUES");  psAssert (values, "values not supplied");
     273    psVector *roMask     = psMetadataLookupPtr(&mdok, output->analysis, "DARK.RO.MASK"); psAssert (roMask, "roMask not supplied");
    274274    psPolynomialMD *poly = psMetadataLookupPtr(&mdok, output->analysis, "DARK.POLY");    psAssert (poly, "orders not supplied");
    275275
    276276    // retrieve the norm vector, if supplied
    277     psVector *norm       = psMetadataLookupPtr(&mdok, output->analysis, "DARK.NORM");   
     277    psVector *norm       = psMetadataLookupPtr(&mdok, output->analysis, "DARK.NORM");
    278278
    279279    // retrieve the 'counts' and 'sigma' images
     
    367367}
    368368
    369 bool pmDarkApplyScan_Threaded (psThreadJob *job) {
     369bool pmDarkApplyScan_Threaded(const psThreadJob *job)
     370{
     371    PS_ASSERT_THREAD_JOB_NON_NULL(job, false);
     372
    370373    pmReadout *readout   = job->args->data[0];
    371374    pmCell *dark         = job->args->data[1];
     
    478481    bool threaded = true;
    479482    int scanRows = pmDetrendGetScanRows();
    480     if (scanRows == 0) { 
    481         threaded = false;
    482         scanRows = readout->image->numRows;
     483    if (scanRows == 0) {
     484        threaded = false;
     485        scanRows = readout->image->numRows;
    483486    }
    484487
     
    486489      int rowStop = PS_MIN (rowStart + scanRows, readout->image->numRows);
    487490
    488 # define PS_ARRAY_ADD_SCALAR(ARRAY, VALUE, TYPE) { \
    489       psScalar *scalar = psScalarAlloc(VALUE, TYPE); \
    490       psArrayAdd(ARRAY, 1, scalar); \
    491       psFree (scalar); }
    492      
    493491      if (threaded) {
    494           // allocate a job, construct the arguments for this job
    495           psThreadJob *job = psThreadJobAlloc ("PSMODULES_DETREND_DARK");
    496           psArrayAdd (job->args, 1, readout);
    497           psArrayAdd (job->args, 1, dark);
    498           psArrayAdd (job->args, 1, poly);
    499           psArrayAdd (job->args, 1, values);
    500           PS_ARRAY_ADD_SCALAR (job->args, bad, PS_TYPE_MASK);
    501           PS_ARRAY_ADD_SCALAR (job->args, doNorm, PS_TYPE_U8);
    502           PS_ARRAY_ADD_SCALAR (job->args, norm, PS_TYPE_F32);
    503           PS_ARRAY_ADD_SCALAR (job->args, rowStart, PS_TYPE_S32);
    504           PS_ARRAY_ADD_SCALAR (job->args, rowStop, PS_TYPE_S32);
    505 
    506           // ppImageDetrendReadout(config, options, view)
    507           if (!psThreadJobAddPending (job)) {
    508               return false;
    509           }
     492          // allocate a job, construct the arguments for this job
     493          psThreadJob *job = psThreadJobAlloc ("PSMODULES_DETREND_DARK");
     494          psArrayAdd (job->args, 1, readout);
     495          psArrayAdd (job->args, 1, dark);
     496          psArrayAdd (job->args, 1, poly);
     497          psArrayAdd (job->args, 1, values);
     498          PS_ARRAY_ADD_SCALAR (job->args, bad, PS_TYPE_MASK);
     499          PS_ARRAY_ADD_SCALAR (job->args, doNorm, PS_TYPE_U8);
     500          PS_ARRAY_ADD_SCALAR (job->args, norm, PS_TYPE_F32);
     501          PS_ARRAY_ADD_SCALAR (job->args, rowStart, PS_TYPE_S32);
     502          PS_ARRAY_ADD_SCALAR (job->args, rowStop, PS_TYPE_S32);
     503
     504          // ppImageDetrendReadout(config, options, view)
     505          if (!psThreadJobAddPending (job)) {
     506              psFree(job);
     507              return false;
     508          }
     509          psFree(job);
    510510      } else {
    511           pmDarkApplyScan (readout, dark, poly, values, bad, doNorm, norm, rowStart, rowStop);
     511          pmDarkApplyScan (readout, dark, poly, values, bad, doNorm, norm, rowStart, rowStop);
    512512      }
    513513    }
    514514
    515515    if (threaded) {
    516         // wait here for the threaded jobs to finish
    517         if (!psThreadPoolWait ()) {
    518             psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image.");
    519             return false;
    520         }
    521         fprintf (stderr, "success for threaded jobs\n");
    522 
    523         // free the done jobs
    524         psThreadJob *job = NULL;
    525         while ((job = psThreadJobGetDone()) != NULL) {
    526             psFree (job);
    527         }
     516        // wait here for the threaded jobs to finish
     517        if (!psThreadPoolWait(false)) {
     518            psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image.");
     519            return false;
     520        }
     521        fprintf (stderr, "success for threaded jobs\n");
     522
     523        // free the done jobs
     524        psThreadJob *job = NULL;
     525        while ((job = psThreadJobGetDone()) != NULL) {
     526            psFree (job);
     527        }
    528528    }
    529529
Note: See TracChangeset for help on using the changeset viewer.