IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 18, 2010, 2:34:09 PM (16 years ago)
Author:
eugene
Message:

merging changes from PAP branch with modifications to the covariance matrix calculation

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/ppSub/src/ppSubReadoutSubtract.c

    r26982 r28006  
    4848    pmReadout *outRO = pmFPAfileThisReadout(config->files, view, "PPSUB.OUTPUT");
    4949    outRO->image = (psImage*)psBinaryOp(outRO->image, minuend->image, "-", subtrahend->image);
    50     if (minuend->variance && subtrahend->variance) {
    51         outRO->variance = (psImage*)psBinaryOp(outRO->variance, minuend->variance, "+", subtrahend->variance);
    52     }
    5350    outRO->mask = (psImage*)psBinaryOp(outRO->mask, minuend->mask, "|", subtrahend->mask);
     51    outRO->variance = (psImage*)psBinaryOp(outRO->variance, minuend->variance, "+", subtrahend->variance);
    5452
     53    // Measure the variance scales
     54    psStats *varStats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN); // Statistics for variance images
     55    psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS);           // Random number generator
     56    psImageMaskType maskVal = pmConfigMaskGet("MASK.VALUE", config) |
     57        pmConfigMaskGet("BLANK", config); // Bits to mask in inputs
     58    psImageBackground(varStats, NULL, minuend->variance, minuend->mask, maskVal, rng);
     59    float minuendVar = varStats->robustMedian; // Mean variance for minuend
     60    psImageBackground(varStats, NULL, subtrahend->variance, subtrahend->mask, maskVal, rng);
     61    float subtrahendVar = varStats->robustMedian; // Mean variance for subtrahend
     62    psFree(varStats);
     63    psFree(rng);
     64
     65    // Combine the covariances
     66    // These are weighted by the appropriate mean variance.  This is probably not perfectly correct, but it
     67    // does seem to reproduce the correct magnitude limit in psphot.
    5568    psArray *covars = psArrayAlloc(2);  // Covariance pseudo-matrices
     69    psVector *covarWeights = psVectorAlloc(2, PS_TYPE_F32); // Weights for covariances
    5670    covars->data[0] = psMemIncrRefCounter(minuend->covariance);
    5771    covars->data[1] = psMemIncrRefCounter(subtrahend->covariance);
    58     outRO->covariance = psImageCovarianceAverage(covars);
     72    covarWeights->data.F32[0] = minuendVar;
     73    covarWeights->data.F32[1] = subtrahendVar;
     74    outRO->covariance = psImageCovarianceAverageWeighted(covars, covarWeights);
    5975    psFree(covars);
     76    psFree(covarWeights);
     77
     78    psImageCovarianceTransfer(outRO->variance, outRO->covariance);
    6079
    6180    outRO->data_exists = true;
Note: See TracChangeset for help on using the changeset viewer.