IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 10248


Ignore:
Timestamp:
Nov 28, 2006, 3:26:53 PM (19 years ago)
Author:
Paul Price
Message:

Adding weights/errors.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/imcombine/pmReadoutCombine.c

    r9730 r10248  
    3232    params->iter = 1;
    3333    params->rej = INFINITY;
     34    params->weights = false;
    3435
    3536    return params;
     
    7778    int xSize = 0, ySize = 0;           // The size of the output image
    7879
    79     bool haveWeights = false;           // Do we have weight images?
    8080    bool valid = false;                 // Do we have a single valid input?
    8181    for (long i = 0; i < inputs->n; i++) {
     
    9797        }
    9898
    99         if (readout->weight) {
    100             if (valid && !haveWeights) {
    101                 psLogMsg(__func__, PS_LOG_WARN, "Readout %ld has a weight map, but others don't --- "
    102                          "weights ignored.\n", i);
    103             } else {
    104                 haveWeights = true;
    105             }
    106         } else if (haveWeights) {
    107             psLogMsg(__func__, PS_LOG_WARN, "Readout %ld doesn't have a weight map, but others do --- "
    108                      "weights ignored.\n", i);
    109             haveWeights = false;
    110         }
     99        if (params->weights && !readout->weight) {
     100            psError(PS_ERR_UNEXPECTED_NULL, true,
     101                    "Rejection based on weights requested, but no weights supplied for image %ld.\n", i);
     102            return false;
     103        }
     104
    111105        valid = true;
    112106
     
    160154
    161155    psStatsOptions combineStdev = 0; // Statistics option for weights
    162     if (haveWeights) {
     156    if (params->weights) {
    163157
    164158        if (!output->weight) {
     
    207201
    208202    psVector *weights = NULL;           // Stack of weights
     203    psVector *errors = NULL;            // Stack of errors (sqrt of variance/weights), for psVectorStats
    209204    psF32 *weightsData = NULL;          // Dereference weights
    210     if (haveWeights) {
     205    if (params->weights) {
    211206        weights = psVectorAlloc(inputs->n, PS_TYPE_F32); // Stack of weights
    212207        weightsData = weights->data.F32;
     
    272267                #endif
    273268                pixelsData[r] = image->data.F32[yIn][xIn];
     269                if (params->weights) {
     270                    weightsData[r] = readout->weight->data.F32[yIn][xIn];
     271                }
     272
    274273                if (zero) {
    275274                    pixelsData[r] -= zero->data.F32[r];
     
    277276                if (scale) {
    278277                    pixelsData[r] *= invScale->data.F32[r];
     278                    if (params->weights) {
     279                        weightsData[r] *= invScale->data.F32[r] * invScale->data.F32[r];
     280                    }
    279281                }
    280282
     
    319321            }
    320322
     323            if (params->weights) {
     324                errors = (psVector*)psUnaryOp(errors, weights, "sqrt");
     325            }
     326
    321327            // Combination
    322             psVectorStats(stats, pixels, weights, mask, 1);
     328            psVectorStats(stats, pixels, errors, mask, 1);
    323329            outputImage[yOut][xOut] = psStatsGetValue(stats, params->combine);
    324             if (haveWeights) {
     330            if (params->weights) {
    325331                float stdev = psStatsGetValue(stats, combineStdev);
    326332                outputWeight[yOut][xOut] = PS_SQR(stdev); // Variance
     
    337343    psFree(mask);
    338344    psFree(weights);
     345    psFree(errors);
    339346    psFree(stats);
    340347    psFree(invScale);
Note: See TracChangeset for help on using the changeset viewer.