IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 41705 for trunk/psModules


Ignore:
Timestamp:
Jul 8, 2021, 9:47:22 AM (5 years ago)
Author:
eugene
Message:

reintegrate changes from tag ipp-ps1-20210510

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/psModules

  • trunk/psModules/src/config/pmConfigMask.c

    r28272 r41705  
    3333    { "SPIKE",     NULL,       0x08, false  }, // Pixel contains a diffraction spike
    3434    { "GHOST",     NULL,       0x08, false  }, // Pixel contains an optical ghost
    35     { "STREAK",    NULL,       0x08, false  }, // Pixel contains streak data
     35    { "CROSSTALK", NULL,       0x08, false  }, // Pixel contains crosstalk data
    3636    { "STARCORE",  NULL,       0x08, false  }, // Pixel contains a bright star core
    3737    // Effects of convolution and interpolation
  • trunk/psModules/src/objects/pmSourceIO_Glints.c

    r41391 r41705  
    175175
    176176                double glintLength = GLINT_LENGTH_MAG_SLOPE*(GLINT_LENGTH_MAG_ZERO - star->Mag);
    177                 double glintAngle = 0;
     177                double glintAngle = 0.;
    178178
    179179                //Besides brightness, the length of the glints also depends on the position of the star compared to the focal plane. But, seemingly only for stars closer than about 30k pixels
  • trunk/psModules/src/objects/pmSourceMasks.h

    r39597 r41705  
    7070    PM_SOURCE_MODE2_EXT_FITS_NONE         = 0x00400000, ///< ALL of the model fits failed
    7171   
     72    PM_SOURCE_MODE2_ON_GHOST              = 0x00800000, ///< > 25% of (PSF-weighted) pixels land on ghost
     73    PM_SOURCE_MODE2_ON_CROSSTALK          = 0x01000000, ///< peaks land on electronic crostalk
     74
    7275   
    7376} pmSourceMode2;
  • trunk/psModules/src/objects/pmSourcePhotometry.c

    r38872 r41705  
    6060static psImageMaskType maskGhost    = 0;
    6161static psImageMaskType maskGlint    = 0;
     62static psImageMaskType maskCrosstalk    = 0;
    6263
    6364bool pmSourceMagnitudesInit (pmConfig *config, psMetadata *recipe)
     
    7475        maskGhost    = pmConfigMaskGet("GHOST", config);
    7576        maskGlint    = pmConfigMaskGet("GHOST", config);
     77        maskCrosstalk    = pmConfigMaskGet("CROSSTALK", config);
    7678        maskSuspect  = maskSpike | maskStarCore | maskBurntool | maskConvPoor;
    7779    }
     
    437439    float burntoolSum = 0;
    438440    float convpoorSum = 0;
     441    float ghostSum = 0;
    439442
    440443    int Xo, Yo, dP;
     
    520523            }
    521524            // count pixels which are masked with an mask bit (bad or poor)
     525            if (mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskGhost) {
     526                ghostSum += value;
     527            }
     528            // count pixels which are masked with an mask bit (bad or poor)
    522529            if (mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskBurntool) {
    523530                burntoolSum += value;
     
    539546    if ((starcoreSum/modelSum) > 0.25) {
    540547        source->mode2 |= PM_SOURCE_MODE2_ON_STARCORE;
     548    }
     549    if ((ghostSum/modelSum) > 0.25) {
     550        source->mode2 |= PM_SOURCE_MODE2_ON_GHOST;
    541551    }
    542552    if ((burntoolSum/modelSum) > 0.25) {
     
    582592            source->mode |= PM_SOURCE_MODE_ON_SPIKE;
    583593        }
     594        if (maskValue & maskCrosstalk) {
     595            source->mode2 |= PM_SOURCE_MODE2_ON_CROSSTALK;
     596        }
     597    }
     598    return (true);
     599}
     600
     601// return source aperture magnitude
     602bool pmSourceMaskEval (pmSource *source, psImage *mask, psImageMaskType maskVal)
     603{
     604    PS_ASSERT_PTR_NON_NULL(source, false);
     605    source->pixWeightNotBad = NAN;
     606    source->pixWeightNotPoor = NAN;
     607
     608    PS_ASSERT_PTR_NON_NULL(mask, false);
     609
     610    float modelSum = 0;
     611    float spikeSum = 0;
     612    float starcoreSum = 0;
     613    float burntoolSum = 0;
     614    float convpoorSum = 0;
     615    float ghostSum = 0;
     616
     617    int Xo, Yo, dP;
     618    int dX, DX, NX;
     619    int dY, DY, NY;
     620
     621    float radius=10.;
     622    float radius2 = PS_SQR(radius);
     623
     624    // the model function returns the source flux at a position
     625    psVector *coord = psVectorAlloc(2, PS_TYPE_F32);
     626
     627    Xo = source->peak->x;
     628    Yo = source->peak->y;
     629
     630    dX = Xo - mask->col0;
     631    dP = mask->numCols - dX;
     632    DX = PS_MAX(dX, dP);
     633    NX = mask->numCols;
     634
     635    dY = Yo - mask->row0;
     636    dP = mask->numRows - dY;
     637    DY = PS_MAX(dY, dP);
     638    NY = mask->numRows;
     639
     640    psImageMaskType maskBad = maskVal;
     641    maskBad &= ~maskSuspect;
     642
     643    // were not by an edge; ie, if the source is cut in half by an image edge, we correctly
     644    // count the virtual pixels off the edge in normalizing the value of the pixWeight
     645
     646    // we skip any pixels [real or virtual] outside of the specified radius (nominally the aperture radius)
     647    for (int ix = -DX; ix < DX + 1; ix++) {
     648        if (ix > radius) continue;
     649        int mx = ix + dX;
     650        for (int iy = -DY; iy < DY + 1; iy++) {
     651            if (iy > radius) continue;
     652            if (ix*ix + iy*iy > radius2) continue;
     653            int my = iy + dY;
     654
     655            coord->data.F32[0] = (psF32) (ix + Xo);
     656            coord->data.F32[1] = (psF32) (iy + Yo);
     657
     658            modelSum += 1.;
     659            // include count only the unmasked pixels within the image area
     660            if (mx < 0) continue;
     661            if (my < 0) continue;
     662            if (mx >= NX) continue;
     663            if (my >= NY) continue;
     664
     665            // count pixels which are masked with an mask bit (bad or poor)
     666            if (mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskSpike) {
     667                spikeSum += 1.;
     668            }
     669            // count pixels which are masked with an mask bit (bad or poor)
     670            if (mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskStarCore) {
     671                starcoreSum += 1.;
     672            }
     673            // count pixels which are masked with an mask bit (bad or poor)
     674            if (mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskGhost) {
     675                ghostSum += 1.;
     676            }
     677            // count pixels which are masked with an mask bit (bad or poor)
     678            if (mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskBurntool) {
     679                burntoolSum += 1.;
     680            }
     681            // count pixels which are masked with an mask bit (bad or poor)
     682            if (mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskConvPoor) {
     683                convpoorSum += 1.;
     684            }
     685        }
     686    }
     687    psFree (coord);
     688
     689    if ((spikeSum/modelSum) > 0.25) {
     690        source->mode2 |= PM_SOURCE_MODE2_ON_SPIKE;
     691    }
     692    if ((starcoreSum/modelSum) > 0.25) {
     693        source->mode2 |= PM_SOURCE_MODE2_ON_STARCORE;
     694    }
     695    if ((ghostSum/modelSum) > 0.25) {
     696        source->mode2 |= PM_SOURCE_MODE2_ON_GHOST;
     697    }
     698    if ((burntoolSum/modelSum) > 0.25) {
     699        source->mode2 |= PM_SOURCE_MODE2_ON_BURNTOOL;
     700    }
     701    if ((convpoorSum/modelSum) > 0.25) {
     702        source->mode2 |= PM_SOURCE_MODE2_ON_CONVPOOR;
     703    }
     704
     705    // Check that if the peak is on/off a ghost, glint, or diffraction spike.  In regular IPP
     706    // processing, these values are only set in the image mask after the 'camera' stage
     707
     708    // need to access the parent if we are looking at a subimage (likely)
     709    psImage *chipImage = (source->pixels == NULL) ? source->pixels : (psImage *) source->pixels->parent;
     710
     711    bool onChip = true;
     712    onChip &= (Xo >= 0);
     713    onChip &= (Xo < chipImage->numCols);
     714    onChip &= (Yo >= 0);
     715    onChip &= (Yo < chipImage->numRows);
     716    if (!onChip) {
     717        // if the source is off the edge of the chip, raise a different bit?
     718        source->mode |= PM_SOURCE_MODE_OFF_CHIP;
     719    } else {
     720        int xMask = Xo - mask->col0;
     721        int yMask = Yo - mask->row0;
     722        psImageMaskType maskValue = mask->data.PS_TYPE_IMAGE_MASK_DATA[yMask][xMask];
     723        if (maskValue & maskGhost) {
     724            source->mode |= PM_SOURCE_MODE_ON_GHOST;
     725        }
     726        pmSourceMode PM_SOURCE_MODE_ON_GLINT = PM_SOURCE_MODE_ON_GHOST;
     727        if (maskValue & maskGlint) {
     728            source->mode |= PM_SOURCE_MODE_ON_GLINT;
     729        }
     730        if (maskValue & maskCrosstalk) {
     731            source->mode2 |= PM_SOURCE_MODE2_ON_CROSSTALK;
     732        }
     733        if (maskValue & maskSpike) {
     734            source->mode |= PM_SOURCE_MODE_ON_SPIKE;
     735        }
    584736    }
    585737    return (true);
  • trunk/psModules/src/objects/pmSourcePhotometry.h

    r34085 r41705  
    7777
    7878bool pmSourcePixelWeight (pmSource *source, pmModel *model, psImage *mask, psImageMaskType maskVal, float radius);
     79bool pmSourceMaskEval (pmSource *source, psImage *mask, psImageMaskType maskVal);
    7980
    8081bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight, psImageMaskType maskVal);
Note: See TracChangeset for help on using the changeset viewer.