IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32822


Ignore:
Timestamp:
Nov 25, 2011, 2:30:40 PM (14 years ago)
Author:
eugene
Message:

add a test for matching psfMags to see if the positive detection is a self-detection or not

Location:
trunk/ppSub/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppSub/src/ppSubFlagNeighbors.c

    r32807 r32822  
    1818#include "ppSub.h"
    1919
     20# define MIN_ERROR 0.02 /* padding for self-match flux test */
     21# define MAX_OFFSET 5.0 /* delta mag greater than this is not a self match */
     22
    2023// match the diff sources to the detections from the positive or negative input images
    2124// matchRef : false if this is the standard diff image, true if this is the inverse (in-ref vs ref-in)
    2225// this is needed to choose which value is positive and which is negative relative to the difference
    23 bool ppSubFlagNeighbors(pmConfig *config, pmFPAview *view, psArray *sources, bool matchRef) {
     26bool ppSubFlagNeighbors(pmConfig *config, pmFPAview *view, psArray *sources, bool subInverse) {
    2427
    2528    bool status;
     
    106109              psAssert ((sourceM1->imageID == 1) || (sourceM1->imageID == 2), "error in pmPhotObj construction (second entry is not from 1 or 2");
    107110
     111              // which image gives the match, the positive or negative one?
     112              bool positive = false;
     113              if (subInverse) {
     114                  positive = (sourceM1->imageID == 2);
     115              } else {
     116                  positive = (sourceM1->imageID == 1);
     117              }
     118
     119              // check if source and sourceM1 are likely to be the same flux (ie, isolated detection in one image)
     120              if (positive && isfinite(sourceM1->psfMag) && isfinite(source->psfMag)) {
     121                  float dMag = sourceM1->psfMag - source->psfMag;
     122                  float nSig = fabs(dMag) / hypot(MIN_ERROR, source->psfMagErr);
     123                  if (nSig < MAX_OFFSET) {
     124                      source->mode2 |= PM_SOURCE_MODE2_DIFF_SELF_MATCH;
     125                  }
     126              }
     127
    108128              // only one match.  set a flag?
    109129              source->mode2 |= PM_SOURCE_MODE2_DIFF_WITH_SINGLE;
    110130              if (source->diffStats) {
    111                   // which is match need an xor here...
    112                   bool positive = !matchRef && (sourceM1->imageID == 1);
    113                   positive |= matchRef && (sourceM1->imageID == 2);
    114131                  float SN1 = isfinite(sourceM1->psfMagErr) ? 1.0 / sourceM1->psfMagErr : NAN;
    115132                  if (positive) {
     
    133150              psAssert (sourceM1->imageID != sourceM2->imageID, "error in pmPhotObj construction (case 3.3)");
    134151
     152              // we don't know which matched source (sourceM1 or sourceM2) is the positive detection,
     153              // and the answer depends on both the ID and the subtraction order (in-ref vs ref-in)
     154              // positive is true if sourceM1 is the positive detection
     155              bool positive = false;
     156              if (subInverse) {
     157                  positive = (sourceM1->imageID == 2);
     158              } else {
     159                  positive = (sourceM1->imageID == 1);
     160              }
     161
     162              // check for self-detection
     163              float magPSF1 = positive ? sourceM1->psfMag : sourceM2->psfMag;
     164              if (isfinite(magPSF1) && isfinite(source->psfMag)) {
     165                  float dMag = magPSF1 - source->psfMag;
     166                  float nSig = fabs(dMag) / hypot(MIN_ERROR, source->psfMagErr);
     167                  if (nSig < MAX_OFFSET) {
     168                      source->mode2 |= PM_SOURCE_MODE2_DIFF_SELF_MATCH;
     169                  }
     170              }
     171
    135172              source->mode2 |= PM_SOURCE_MODE2_DIFF_WITH_DOUBLE;
    136173              if (source->diffStats) {
    137                   // which is match need an xor here...
    138                   bool positive = !matchRef && (sourceM1->imageID == 1);
    139                   positive |= matchRef && (sourceM1->imageID == 2);
    140174                  float SN1 = isfinite(sourceM1->psfMagErr) ? 1.0 / sourceM1->psfMagErr : NAN;
    141175                  float SN2 = isfinite(sourceM2->psfMagErr) ? 1.0 / sourceM2->psfMagErr : NAN;
  • trunk/ppSub/src/ppSubReadoutPhotometry.c

    r31449 r32822  
    9292    // detections in the wings (or cores) of bright(er) stars found in both images.
    9393    // flag detections based on their distance from the bright(er) input sources.
    94     bool matchRef = !strcasecmp(name, "PPSUB.INVERSE");
    95     ppSubFlagNeighbors (config, view, sources, matchRef);
     94    bool subInverse = !strcasecmp(name, "PPSUB.INVERSE");
     95    ppSubFlagNeighbors (config, view, sources, subInverse);
    9696
    9797    if (data->stats) {
Note: See TracChangeset for help on using the changeset viewer.