IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 20488


Ignore:
Timestamp:
Oct 31, 2008, 2:15:50 PM (18 years ago)
Author:
Paul Price
Message:

Making things a bit clearer. Had ratio around the wrong way.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmFPAMaskWeight.c

    r20486 r20488  
    414414    for (int i = 0; i < num; i++) {
    415415        // Coordinates of interest
    416         int xPix = psRandomUniform(rng) * xSize + xOffset;
    417         int yPix = psRandomUniform(rng) * ySize + yOffset;
     416        int xPix = psRandomUniform(rng) * xSize + xOffset + 0.5;
     417        int yPix = psRandomUniform(rng) * ySize + yOffset + 0.5;
    418418        psAssert(xPix - size >= 0 && xPix + size < numCols &&
    419                  yPix - size >= 0 && yPix + size > numRows,
    420                  "Bad pixel position");
     419                 yPix - size >= 0 && yPix + size < numRows,
     420                 "Bad pixel position: %d,%d", xPix, yPix);
    421421
    422422        // Weighted aperture photometry
     
    431431            float xSumWeight = 0.0; // Sum for weight measurement in x
    432432            float xSumGauss = 0.0, xSumGauss2 = 0.0; // Sums of Gaussian kernels in x
    433             float yGauss = peakFlux * gauss->data.F32[v]; // Value of Gaussian in y
     433            float yGauss = gauss->data.F32[v]; // Value of Gaussian in y
    434434            for (int u = 0, x = xPix - size; u < fullSize; u++, x++) {
    435435                if (mask && mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal) {
     
    440440                float xGauss2 = gauss2->data.F32[u]; // Value of Gaussian^2 in x
    441441                xSumNoise += value * xGauss;
    442                 xSumSource += (value + xGauss * yGauss) * xGauss;
     442                xSumSource += (value + peakFlux * xGauss * yGauss) * xGauss;
    443443                xSumWeight += weight->data.F32[y][x] * xGauss2;
    444444                xSumGauss += xGauss;
     
    453453        }
    454454
    455         float weightValue = sumWeight / sumGauss2; // Value of convolved weight
    456455        photMask->data.PS_TYPE_MASK_DATA[i] = ((isfinite(sumNoise) && isfinite(sumSource) &&
    457                                                 isfinite(weightValue) && sumGauss > 0 && sumGauss2 > 0) ?
     456                                                isfinite(sumWeight) && sumGauss > 0 && sumGauss2 > 0) ?
    458457                                               0 : 0xFF);
    459458
    460         noise->data.F32[i] = sumNoise / sumGauss;
    461         source->data.F32[i] = sumSource / sumGauss;
    462         guess->data.F32[i] = (sumSource > 0) ? sigFactor * PS_SQR(sumSource) / sumWeight * sumGauss2 : 0.0;
     459        float smoothImageNoise = sumNoise / sumGauss; // Value of smoothed image pixel for noise
     460        float smoothImageSource = sumSource / sumGauss; // Value of smoothed image pixel for source
     461        float smoothWeight = sumWeight / sumGauss2; // Value of smoothed weight pixel
     462
     463        noise->data.F32[i] = smoothImageNoise;
     464        source->data.F32[i] = smoothImageSource;
     465        guess->data.F32[i] = (sumSource > 0) ? sigFactor * PS_SQR(smoothImageSource) / smoothWeight : 0.0;
    463466        psTrace("psModules.camera", 10, "Flux %d (%d,%d): %f, %f, %f\n",
    464                 i, xPix, yPix, source->data.F32[i], noise->data.F32[i], guess->data.F32[i]);
     467                i, xPix, yPix, smoothImageNoise, smoothImageSource, smoothWeight);
    465468    }
    466469    psFree(gauss);
     
    491494            photMask->data.PS_TYPE_MASK_DATA[i] = 0xFF;
    492495        }
    493         ratio->data.F32[i] = measuredSig / guess->data.F32[i];
     496        ratio->data.F32[i] = guess->data.F32[i] / measuredSig;
     497        psTrace("psModules.camera", 9, "Ratio %d: %f, %f, %f\n",
     498                i, guess->data.F32[i], measuredSig, ratio->data.F32[i]);
    494499    }
    495500    psFree(source);
Note: See TracChangeset for help on using the changeset viewer.