IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 4, 2010, 10:06:09 AM (17 years ago)
Author:
eugene
Message:

add skyErr, a way of increasing the constant portion of the variance in the kernel analysis: var = (readNoise2 + skyErr + gain*flux + sysErr*flux2); clean up testing verbosity; temporary dump residuals and quit in visualization code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20091201/psModules/src/imcombine/pmSubtractionStamps.c

    r26502 r26505  
    181181
    182182pmSubtractionStampList *pmSubtractionStampListAlloc(int numCols, int numRows, const psRegion *region,
    183                                                     int footprint, float spacing, float sysErr)
     183                                                    int footprint, float spacing, float sysErr, float skyErr)
    184184{
    185185    pmSubtractionStampList *list = psAlloc(sizeof(pmSubtractionStampList)); // Stamp list to return
     
    224224    list->footprint = footprint;
    225225    list->sysErr = sysErr;
     226    list->skyErr = skyErr;
    226227
    227228    return list;
     
    326327                                                const psImage *image2, const psImage *subMask,
    327328                                                const psRegion *region, float thresh1, float thresh2,
    328                                                 int size, int footprint, float spacing, float sysErr,
     329                                                int size, int footprint, float spacing, float sysErr, float skyErr,
    329330                                                pmSubtractionMode mode)
    330331{
     
    383384
    384385    if (!stamps) {
    385         stamps = pmSubtractionStampListAlloc(numCols, numRows, region, footprint, spacing, sysErr);
     386        stamps = pmSubtractionStampListAlloc(numCols, numRows, region, footprint, spacing, sysErr, skyErr);
    386387    }
    387388
     
    441442                    xStamp = xList->data.F32[j];
    442443                    yStamp = yList->data.F32[j];
    443                     fprintf (stderr, "find: %d %d ==> %5.1f %5.1f\n", xCentre, yCentre, xStamp, yStamp);
     444                    // fprintf (stderr, "find: %d %d ==> %5.1f %5.1f\n", xCentre, yCentre, xStamp, yStamp);
    444445                }
    445446            } else {
     
    496497                                               const psImage *image, const psImage *subMask,
    497498                                               const psRegion *region, int size, int footprint,
    498                                                float spacing, float sysErr, pmSubtractionMode mode)
     499                                               float spacing, float sysErr, float skyErr, pmSubtractionMode mode)
    499500
    500501{
     
    517518    pmSubtractionStampList *stamps = pmSubtractionStampListAlloc(subMask->numCols, subMask->numRows,
    518519                                                                 region, footprint, spacing,
    519                                                                  sysErr); // Stamp list
     520                                                                 sysErr, skyErr); // Stamp list
    520521    int numStamps = stamps->num;        // Number of stamps
    521522
     
    548549        }
    549550
    550         fprintf (stderr, "stamp: %5.1f %5.1f == %d %d\n", xStamp, yStamp, xPix, yPix);
     551        // fprintf (stderr, "stamp: %5.1f %5.1f == %d %d\n", xStamp, yStamp, xPix, yPix);
    551552
    552553        bool found = false;
     
    742743            return false;
    743744        }
    744         fprintf (stderr, "stamp: %5.1f %5.1f == %d %d\n", stamp->x, stamp->y, x, y);
     745        // fprintf (stderr, "stamp: %5.1f %5.1f == %d %d\n", stamp->x, stamp->y, x, y);
    745746
    746747        // Catch memory leaks --- these should have been freed and NULLed before
     
    765766            psImage *varSub = psImageSubset(variance, region); // Subimage with stamp
    766767            psKernel *var = psKernelAllocFromImage(varSub, size, size); // Variance postage stamp
    767             if (isfinite(stamps->sysErr) && stamps->sysErr > 0) {
     768
     769            if ((isfinite(stamps->skyErr) && (stamps->skyErr > 0)) ||
     770                (isfinite(stamps->sysErr) && (stamps->sysErr > 0))) {
    768771                float sysErr = 0.25 * PS_SQR(stamps->sysErr); // Systematic error
     772                float skyErr = stamps->skyErr;
    769773                psKernel *image1 = stamp->image1, *image2 = stamp->image2; // Input images
    770774                for (int y = -size; y <= size; y++) {
    771775                    for (int x = -size; x <= size; x++) {
    772776                        float additional = image1->kernel[y][x] + image2->kernel[y][x];
    773                         weight->kernel[y][x] = 1.0 / (var->kernel[y][x] + sysErr * PS_SQR(additional));
     777                        weight->kernel[y][x] = 1.0 / (skyErr + var->kernel[y][x] + sysErr * PS_SQR(additional));
    774778                    }
    775779                }
     
    795799pmSubtractionStampList *pmSubtractionStampsSetFromSources(const psArray *sources, const psImage *image,
    796800                                                          const psImage *subMask, const psRegion *region,
    797                                                           int size, int footprint, float spacing, float sysErr,
     801                                                          int size, int footprint, float spacing, float sysErr, float skyErr,
    798802                                                          pmSubtractionMode mode)
    799803{
     
    819823            y->data.F32[numOut] = source->peak->yf;
    820824        }
    821         fprintf (stderr, "stamp: %5.1f %5.1f\n", x->data.F32[numOut], y->data.F32[numOut]);
     825        // fprintf (stderr, "stamp: %5.1f %5.1f\n", x->data.F32[numOut], y->data.F32[numOut]);
    822826        numOut++;
    823827    }
     
    826830
    827831    pmSubtractionStampList *stamps = pmSubtractionStampsSet(x, y, image, subMask, region, size,
    828                                                             footprint, spacing, sysErr, mode); // Stamps
     832                                                            footprint, spacing, sysErr, skyErr, mode); // Stamps
    829833    psFree(x);
    830834    psFree(y);
     
    840844pmSubtractionStampList *pmSubtractionStampsSetFromFile(const char *filename, const psImage *image,
    841845                                                       const psImage *subMask, const psRegion *region,
    842                                                        int size, int footprint, float spacing, float sysErr,
     846                                                       int size, int footprint, float spacing, float sysErr, float skyErr,
    843847                                                       pmSubtractionMode mode)
    844848{
     
    858862
    859863    pmSubtractionStampList *stamps = pmSubtractionStampsSet(x, y, image, subMask, region, size, footprint,
    860                                                             spacing, sysErr, mode);
     864                                                            spacing, sysErr, skyErr, mode);
    861865    psFree(data);
    862866
Note: See TracChangeset for help on using the changeset viewer.