IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 5, 2009, 4:31:25 PM (17 years ago)
Author:
Paul Price
Message:

Merging pap_branch_20090128. Resolved a small number of conflicts. Compiles, but not tested in detail.

File:
1 edited

Legend:

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

    r20561 r21363  
    2424static inline double calculateSumProduct(const psKernel *image1, // First image in multiplication
    2525                                         const psKernel *image2, // Second image in multiplication
    26                                          const psKernel *weight, // Weight image
     26                                         const psKernel *variance, // Variance image
    2727                                         int footprint // (Half-)Size of stamp
    2828    )
     
    3131    for (int y = - footprint; y <= footprint; y++) {
    3232        for (int x = - footprint; x <= footprint; x++) {
    33             sum += image1->kernel[y][x] * image2->kernel[y][x] / 1.0; // weight->kernel[y][x];
     33            sum += image1->kernel[y][x] * image2->kernel[y][x] / 1.0; // variance->kernel[y][x];
    3434        }
    3535    }
     
    4242                                           const psKernel *image1, // First image in multiplication
    4343                                           const psKernel *image2, // Second image in multiplication
    44                                            const psKernel *weight, // Weight image
     44                                           const psKernel *variance, // Variance image
    4545                                           const psImage *polyValues, // Spatial polynomial values
    4646                                           int numKernels, // Number of kernel basis functions
     
    5050    )
    5151{
    52     double sum = calculateSumProduct(image1, image2, weight, footprint); // Sum of the image products
     52    double sum = calculateSumProduct(image1, image2, variance, footprint); // Sum of the image products
    5353    if (!isfinite(sum)) {
    5454        return false;
     
    7979                                           const psKernel *image1, // First image in multiplication
    8080                                           const psKernel *image2, // Second image in multiplication
    81                                            const psKernel *weight, // Weight image
     81                                           const psKernel *variance, // Variance image
    8282                                           const psImage *polyValues, // Spatial polynomial values
    8383                                           int numKernels, // Number of kernel basis functions
     
    8787    )
    8888{
    89     double sum = calculateSumProduct(image1, image2, weight, footprint); // Sum of the image products
     89    double sum = calculateSumProduct(image1, image2, variance, footprint); // Sum of the image products
    9090    if (!isfinite(sum)) {
    9191        return false;
     
    120120                                  const psArray *convolutions1, // Convolutions for element 1
    121121                                  const psArray *convolutions2, // Convolutions for element 2
    122                                   const psKernel *weight, // Weight image
     122                                  const psKernel *variance, // Variance image
    123123                                  const psImage *polyValues, // Polynomial values
    124124                                  int numKernels, // Number of kernel basis functions
     
    135135            psKernel *jConv = convolutions2->data[j]; // Convolution for j-th element
    136136
    137             if (!calculateMatrixElement2(matrix, i, j, iConv, jConv, weight, polyValues, numKernels,
     137            if (!calculateMatrixElement2(matrix, i, j, iConv, jConv, variance, polyValues, numKernels,
    138138                                         footprint, spatialOrder, symmetric)) {
    139139                psTrace("psModules.imcombine", 2, "Bad sumCC at %d, %d", i, j);
     
    151151                            const psArray *convolutions, // Convolutions of source with kernels
    152152                            const psKernel *input, // Input stamp, or NULL
    153                             const psKernel *weight, // Weight stamp
     153                            const psKernel *variance, // Variance stamp
    154154                            const psImage *polyValues, // Spatial polynomial values
    155155                            int footprint, // (Half-)Size of stamp
     
    171171
    172172    // Square part of the matrix (convolution-convolution products)
    173     if (!calculateMatrixSquare(matrix, convolutions, convolutions, weight, polyValues, numKernels,
     173    if (!calculateMatrixSquare(matrix, convolutions, convolutions, variance, polyValues, numKernels,
    174174                               spatialOrder, footprint)) {
    175175        return false;
     
    185185
    186186            // Normalisation-convolution terms
    187             if (!calculateMatrixElement1(matrix, i, normIndex, conv, input, weight, polyValues, numKernels,
     187            if (!calculateMatrixElement1(matrix, i, normIndex, conv, input, variance, polyValues, numKernels,
    188188                                         footprint, spatialOrder, true)) {
    189189                psTrace("psModules.imcombine", 2, "Bad sumIC at %d", i);
     
    195195            for (int y = - footprint; y <= footprint; y++) {
    196196                for (int x = - footprint; x <= footprint; x++) {
    197                     sumC += conv->kernel[y][x] / 1.0; // weight->kernel[y][x];
     197                    sumC += conv->kernel[y][x] / 1.0; // variance->kernel[y][x];
    198198                }
    199199            }
     
    218218        for (int y = - footprint; y <= footprint; y++) {
    219219            for (int x = - footprint; x <= footprint; x++) {
    220                 double invNoise2 = 1.0 / 1.0; // weight->kernel[y][x];
     220                double invNoise2 = 1.0 / 1.0; // variance->kernel[y][x];
    221221                double value = input->kernel[y][x] * invNoise2;
    222222                sumI += value;
     
    253253                            const psKernel *input, // Input stamp, or NULL if !normAndBG
    254254                            const psKernel *target, // Target stamp
    255                             const psKernel *weight, // Weight stamp
     255                            const psKernel *variance, // Variance stamp
    256256                            const psImage *polyValues, // Spatial polynomial values
    257257                            int footprint, // (Half-)Size of stamp
     
    277277        for (int y = - footprint; y <= footprint; y++) {
    278278            for (int x = - footprint; x <= footprint; x++) {
    279                 sumTC += target->kernel[y][x] * conv->kernel[y][x] / 1.0; // weight->kernel[y][x];
     279                sumTC += target->kernel[y][x] * conv->kernel[y][x] / 1.0; // variance->kernel[y][x];
    280280            }
    281281        }
     
    297297        for (int y = - footprint; y <= footprint; y++) {
    298298            for (int x = - footprint; x <= footprint; x++) {
    299                 float value = target->kernel[y][x] / 1.0; // weight->kernel[y][x];
     299                float value = target->kernel[y][x] / 1.0; // variance->kernel[y][x];
    300300                sumIT += value * input->kernel[y][x];
    301301                sumT += value;
     
    329329                                 const psArray *convolutions2, // Convolutions of image 2
    330330                                 const psKernel *image1, // Image 1 stamp
    331                                  const psKernel *weight, // Weight stamp
     331                                 const psKernel *variance, // Variance stamp
    332332                                 const psImage *polyValues, // Spatial polynomial values
    333333                                 int footprint // (Half-)Size of stamp
     
    348348    PM_SUBTRACTION_INDICES(normIndex, bgIndex, kernels);
    349349
    350     if (!calculateMatrixSquare(matrix, convolutions1, convolutions2, weight, polyValues, numKernels,
     350    if (!calculateMatrixSquare(matrix, convolutions1, convolutions2, variance, polyValues, numKernels,
    351351                               spatialOrder, footprint)) {
    352352        return false;
     
    356356        // Normalisation
    357357        psKernel *conv = convolutions2->data[i]; // Convolution
    358         if (!calculateMatrixElement1(matrix, i, normIndex, conv, image1, weight, polyValues, numKernels,
     358        if (!calculateMatrixElement1(matrix, i, normIndex, conv, image1, variance, polyValues, numKernels,
    359359                                     footprint, spatialOrder, false)) {
    360360            psTrace("psModules.imcombine", 2, "Bad sumIC at %d", i);
     
    366366        for (int y = - footprint; y <= footprint; y++) {
    367367            for (int x = - footprint; x <= footprint; x++) {
    368                 sumC += conv->kernel[y][x] / 1.0; // weight->kernel[y][x];
     368                sumC += conv->kernel[y][x] / 1.0; // variance->kernel[y][x];
    369369            }
    370370        }
     
    559559      case PM_SUBTRACTION_MODE_1:
    560560        status = calculateMatrix(stamp->matrix1, kernels, stamp->convolutions1, stamp->image1,
    561                                  stamp->weight, polyValues, footprint, true);
     561                                 stamp->variance, polyValues, footprint, true);
    562562        status &= calculateVector(stamp->vector1, kernels, stamp->convolutions1, stamp->image1,
    563                                   stamp->image2, stamp->weight, polyValues, footprint, true);
     563                                  stamp->image2, stamp->variance, polyValues, footprint, true);
    564564        break;
    565565      case PM_SUBTRACTION_MODE_2:
    566566        status = calculateMatrix(stamp->matrix1, kernels, stamp->convolutions2, stamp->image2,
    567                                  stamp->weight, polyValues, footprint, true);
     567                                 stamp->variance, polyValues, footprint, true);
    568568        status &= calculateVector(stamp->vector1, kernels, stamp->convolutions2, stamp->image2,
    569                                   stamp->image1, stamp->weight, polyValues, footprint, true);
     569                                  stamp->image1, stamp->variance, polyValues, footprint, true);
    570570        break;
    571571      case PM_SUBTRACTION_MODE_DUAL:
     
    581581#endif
    582582        status  = calculateMatrix(stamp->matrix1, kernels, stamp->convolutions1, stamp->image1,
    583                                   stamp->weight, polyValues, footprint, true);
     583                                  stamp->variance, polyValues, footprint, true);
    584584        status &= calculateMatrix(stamp->matrix2, kernels, stamp->convolutions2, NULL,
    585                                   stamp->weight, polyValues, footprint, false);
     585                                  stamp->variance, polyValues, footprint, false);
    586586        status &= calculateMatrixCross(stamp->matrixX, kernels, stamp->convolutions1,
    587                                        stamp->convolutions2, stamp->image1, stamp->weight, polyValues,
     587                                       stamp->convolutions2, stamp->image1, stamp->variance, polyValues,
    588588                                       footprint);
    589589        status &= calculateVector(stamp->vector1, kernels, stamp->convolutions1, stamp->image1,
    590                                   stamp->image2, stamp->weight, polyValues, footprint, true);
     590                                  stamp->image2, stamp->variance, polyValues, footprint, true);
    591591        status &= calculateVector(stamp->vector2, kernels, stamp->convolutions2, NULL,
    592                                   stamp->image2, stamp->weight, polyValues, footprint, false);
     592                                  stamp->image2, stamp->variance, polyValues, footprint, false);
    593593        break;
    594594      default:
     
    10331033
    10341034        // Calculate residuals
    1035         psKernel *weight = stamp->weight; // Weight postage stamp
     1035        psKernel *variance = stamp->variance; // Variance postage stamp
    10361036        psImageInit(residual->image, 0.0);
    10371037        if (kernels->mode != PM_SUBTRACTION_MODE_DUAL) {
     
    10981098        for (int y = - footprint; y <= footprint; y++) {
    10991099            for (int x = - footprint; x <= footprint; x++) {
    1100                 double dev = PS_SQR(residual->kernel[y][x]) / weight->kernel[y][x];
     1100                double dev = PS_SQR(residual->kernel[y][x]) / variance->kernel[y][x];
    11011101                deviation += dev;
    11021102#ifdef TESTING
     
    11411141            psFitsClose(fits);
    11421142        }
    1143         if (stamp->weight) {
     1143        if (stamp->variance) {
    11441144            psString filename = NULL;
    1145             psStringAppend(&filename, "stamp_weight_%03d.fits", i);
     1145            psStringAppend(&filename, "stamp_variance_%03d.fits", i);
    11461146            psFits *fits = psFitsOpen(filename, "w");
    11471147            psFree(filename);
    1148             psFitsWriteImage(fits, NULL, stamp->weight->image, 0, NULL);
     1148            psFitsWriteImage(fits, NULL, stamp->variance->image, 0, NULL);
    11491149            psFitsClose(fits);
    11501150        }
Note: See TracChangeset for help on using the changeset viewer.