IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 29003


Ignore:
Timestamp:
Aug 20, 2010, 12:12:38 PM (16 years ago)
Author:
eugene
Message:

ensure masked pixels are NAN in output; flag detections with bright pos image neighbors

Location:
trunk/ppSub/src
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/ppSub/src/Makefile.am

    r28043 r29003  
    3939        ppSubDefineOutput.c             \
    4040        ppSubExtras.c                   \
     41        ppSubFlagNeighbors.c            \
    4142        ppSubMakePSF.c                  \
    4243        ppSubMatchPSFs.c                \
  • trunk/ppSub/src/ppSub.h

    r28121 r29003  
    175175    );
    176176
     177bool ppSubFlagNeighbors(pmConfig *config, pmFPAview *view, psArray *sources, bool matchRef);
     178bool ppSubMatchSources (psArray *objects, psArray *sources, float RADIUS, float MIN_SN);
     179bool ppSubSetSourceImageIDs (psArray *sources, int imageID);
     180
    177181///@}
    178182#endif
  • trunk/ppSub/src/ppSubBackground.c

    r26982 r29003  
    6767    for (int y = 0; y < numRows; y++) {
    6868        for (int x = 0; x < numCols; x++) {
     69            // special case 1: NAN the masked pixels
    6970            if (mask && mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskBad) {
    70                 image->data.F32[y][x] = 0.0;
    71             } else {
    72                 float value = psImageUnbinPixel(x + 0.5, y + 0.5, modelImage, binning); // Background value
    73                 if (!isfinite(value)) {
    74                     image->data.F32[y][x] = NAN;
    75                     mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= maskBad;
    76                 } else {
    77                     image->data.F32[y][x] -= value;
    78                 }
    79             }
     71                image->data.F32[y][x] = NAN;
     72                continue;
     73            }
     74            // special case 1: NAN & mask pixels without a valid background model
     75            float value = psImageUnbinPixel(x + 0.5, y + 0.5, modelImage, binning); // Background value
     76            if (!isfinite(value)) {
     77              image->data.F32[y][x] = NAN;
     78              mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= maskBad;
     79              continue;
     80            }
     81            image->data.F32[y][x] -= value;
    8082        }
    8183    }
  • trunk/ppSub/src/ppSubLoop.c

    r28121 r29003  
    1717#include <pslib.h>
    1818#include <psmodules.h>
     19#include <psphot.h>
    1920
    2021#include "ppSub.h"
     22
     23bool dumpout(pmConfig *config, char *name)
     24{
     25  pmFPAview *view = ppSubViewReadout(); // View to readout
     26  pmReadout *out = pmFPAfileThisReadout(config->files, view, "PPSUB.OUTPUT");
     27  psphotSaveImage (NULL, out->image, name);
     28  return true;
     29}
     30
    2131
    2232bool ppSubLoop(ppSubData *data)
     
    105115        return false;
    106116    }
     117    // dumpout(config, "diff.1.fits");
    107118
    108119    // Close convolved files
     
    111122        return false;
    112123    }
     124    // dumpout(config, "diff.2a.fits");
    113125
    114126    // Higher order background subtraction using psphot
     
    117129        return false;
    118130    }
     131    // dumpout(config, "diff.2b.fits");
    119132
    120133    // Perform Variance correction (rescale within a modest range)
     
    123136        return false;
    124137    }
     138    // dumpout(config, "diff.2c.fits");
    125139
    126140    if (data->quality) {
     
    138152        return false;
    139153    }
     154    // dumpout(config, "diff.3.fits");
    140155
    141156    if (!ppSubFilesIterateUp(config, PPSUB_FILES_PHOT_SUB)) {
     
    157172      }
    158173    }
     174    // dumpout(config, "diff.4.fits");
    159175   
    160176    // generate the binned image used to write the jpeg
     
    204220    } else {
    205221        // Close subtraction files
     222        // dumpout(config, "diff.5.fits");
    206223        if (!ppSubFilesIterateUp(config, PPSUB_FILES_SUB)) {
    207224            psError(PPSUB_ERR_IO, false, "Unable to close subtraction files.");
  • trunk/ppSub/src/ppSubReadoutPhotometry.c

    r26982 r29003  
    9797    psAssert (sources, "missing sources?");
    9898
     99    // a likely source of false positives is poor subtractions.  this results in
     100    // detections in the wings (or cores) of bright(er) stars found in both images.
     101    // flag detections based on their distance from the bright(er) input sources.
     102    bool matchRef = !strcasecmp(name, "PPSUB.INVERSE");
     103    ppSubFlagNeighbors (config, view, sources, matchRef);
     104
    99105    if (data->stats) {
    100106        bool mdok;
  • trunk/ppSub/src/ppSubReadoutSubtract.c

    r28006 r29003  
    5151    outRO->variance = (psImage*)psBinaryOp(outRO->variance, minuend->variance, "+", subtrahend->variance);
    5252
     53    // NAN the masked pixels in the diff image (pixels masked in A are not yet NAN'ed in B)
     54    psImageMaskType maskVal = pmConfigMaskGet("MASK.VALUE", config) | pmConfigMaskGet("BLANK", config); // Bits to mask in inputs
     55    for (int iy = 0; iy < outRO->image->numRows; iy++) {
     56        for (int ix = 0; ix < outRO->image->numCols; ix++) {
     57            if ((outRO->mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] & maskVal) == 0) continue;
     58            outRO->image->data.F32[iy][ix] = NAN;
     59        }
     60    }
     61
    5362    // Measure the variance scales
    5463    psStats *varStats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN); // Statistics for variance images
    5564    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
    5865    psImageBackground(varStats, NULL, minuend->variance, minuend->mask, maskVal, rng);
    5966    float minuendVar = varStats->robustMedian; // Mean variance for minuend
Note: See TracChangeset for help on using the changeset viewer.