IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32839


Ignore:
Timestamp:
Nov 30, 2011, 11:41:21 AM (15 years ago)
Author:
eugene
Message:

merged from trunk: fixes to the neighbor flagging

Location:
tags/ipp-20111110/ppSub
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • tags/ipp-20111110/ppSub

  • tags/ipp-20111110/ppSub/src

  • tags/ipp-20111110/ppSub/src/ppSubFlagNeighbors.c

    r31449 r32839  
    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;
     
    187221        pmPhotObj *obj = objects->data[j];
    188222 
     223        // fprintf (stderr, "%f, %f vs %f, %f\n", src->peak->xf, src->peak->yf, obj->x, obj->y);
     224
    189225        if (!src) NEXT1;
    190226        if (!src->peak) NEXT1;
     
    209245            src = sources->data[I];
    210246           
    211             if (!src) NEXT1;
    212             if (!src->peak) NEXT1;
    213             if (!isfinite(src->peak->xf)) NEXT1;
    214             if (!isfinite(src->peak->yf)) NEXT1;
    215             if (!isfinite(src->peak->detValue)) NEXT1;
    216             if (sqrt(src->peak->detValue) < MIN_SN) NEXT1;
     247            if (!src) continue;
     248            if (!src->peak) continue;
     249            if (!isfinite(src->peak->xf)) continue;
     250            if (!isfinite(src->peak->yf)) continue;
     251            if (!isfinite(src->peak->detValue)) continue;
     252            if (sqrt(src->peak->detValue) < MIN_SN) continue;
    217253
    218254            dx = src->peak->xf - obj->x;
  • tags/ipp-20111110/ppSub/src/ppSubLoop.c

    • Property svn:mergeinfo deleted
  • tags/ipp-20111110/ppSub/src/ppSubMakePSF.c

    • Property svn:mergeinfo deleted
  • tags/ipp-20111110/ppSub/src/ppSubMatchPSFs.c

    • Property svn:mergeinfo deleted
  • tags/ipp-20111110/ppSub/src/ppSubReadoutPhotometry.c

    r31449 r32839  
    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.