IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 31451


Ignore:
Timestamp:
May 5, 2011, 11:02:53 AM (15 years ago)
Author:
eugene
Message:

merge updates from eam branch 20110404

Location:
trunk/psModules
Files:
49 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmFPAMaskWeight.c

    r29544 r31451  
    587587                double imageValue, varianceValue; // Image and variance value from interpolation
    588588                psImageMaskType maskValue = 0; // Mask value from interpolation
    589                 psImageInterpolateStatus status = psImageInterpolate(&imageValue, &varianceValue, &maskValue, x, y, interp);
     589
     590                // interpolate to pixel center (index + 0.5)
     591                psImageInterpolateStatus status = psImageInterpolate(&imageValue, &varianceValue, &maskValue, x + 0.5, y + 0.5, interp);
    590592                if (status == PS_INTERPOLATE_STATUS_ERROR || status == PS_INTERPOLATE_STATUS_OFF) {
    591593                    psError(PS_ERR_UNKNOWN, false, "Unable to interpolate readout at %d,%d", x, y);
  • trunk/psModules/src/imcombine/pmPSFEnvelope.c

    r29543 r31451  
    380380
    381381        // measure the source moments: tophat windowing, no pixel S/N cutoff
    382         if (!pmSourceMoments(source, maxRadius, 0.0, 0.0, maskVal)) {
     382        if (!pmSourceMoments(source, maxRadius, 0.0, 0.0, 0.0, maskVal)) {
    383383            // Can't do anything about it; limp along as best we can
    384384            psErrorClear();
  • trunk/psModules/src/imcombine/pmSubtractionStamps.c

    r31153 r31451  
    11971197       
    11981198        // fprintf (stderr, "%f,%f : %f %f : %f %f\n", source->peak->xf, source->peak->yf,
    1199         // source->psfMag, source->apMag, source->psfMag - source->apMag, source->errMag);
     1199        // source->psfMag, source->apMag, source->psfMag - source->apMag, source->psfMagErr);
    12001200
    12011201        // XXX this is somewhat arbitrary...
    1202         if (source->errMag > 0.05) continue;
     1202        if (source->psfMagErr > 0.05) continue;
    12031203        if (fabs(source->psfMag - source->apMag) > 0.5) continue;
    12041204
  • trunk/psModules/src/objects/Makefile.am

    r31153 r31451  
    114114        pmTrend2D.h \
    115115        pmGrowthCurve.h \
     116        pmGrowthCurveGenerate.h \
    116117        pmSourceMatch.h \
    117118        pmDetEff.h \
  • trunk/psModules/src/objects/models/pmModel_DEV.c

    r31153 r31451  
    268268    float f0 = 1.0;
    269269    float f1, f2;
    270     for (z = DZ; z < 50; z += DZ) {
     270    for (z = DZ; z < 150; z += DZ) {
    271271        f1 = exp(-pow(z,ALPHA));
    272272        z += DZ;
  • trunk/psModules/src/objects/models/pmModel_EXP.c

    r31153 r31451  
    255255    float f0 = 1.0;
    256256    float f1, f2;
    257     for (z = DZ; z < 50; z += DZ) {
     257    for (z = DZ; z < 150; z += DZ) {
    258258        f1 = exp(-sqrt(z));
    259259        z += DZ;
  • trunk/psModules/src/objects/models/pmModel_PGAUSS.c

    r31153 r31451  
    239239    float f0 = 1.0;
    240240    float f1, f2;
    241     for (z = DZ; z < 50; z += DZ) {
     241    for (z = DZ; z < 150; z += DZ) {
    242242        f1 = 1.0 / (1 + z + z*z/2.0 + z*z*z/6.0);
    243243        z += DZ;
  • trunk/psModules/src/objects/models/pmModel_PS1_V1.c

    r31153 r31451  
    261261    float f0 = 1.0;
    262262    float f1, f2;
    263     for (z = DZ; z < 50; z += DZ) {
     263    for (z = DZ; z < 150; z += DZ) {
    264264        f1 = 1.0 / (1 + PAR[PM_PAR_7]*z + pow(z, ALPHA));
    265265        z += DZ;
  • trunk/psModules/src/objects/models/pmModel_QGAUSS.c

    r31153 r31451  
    262262    float f0 = 1.0;
    263263    float f1, f2;
    264     for (z = DZ; z < 50; z += DZ) {
     264    for (z = DZ; z < 150; z += DZ) {
    265265        f1 = 1.0 / (1 + PAR[PM_PAR_7]*z + pow(z, ALPHA));
    266266        z += DZ;
  • trunk/psModules/src/objects/models/pmModel_RGAUSS.c

    r31153 r31451  
    251251    float f0 = 1.0;
    252252    float f1, f2;
    253     for (z = DZ; z < 50; z += DZ) {
     253    for (z = DZ; z < 150; z += DZ) {
    254254        f1 = 1.0 / (1 + z + pow(z, PAR[PM_PAR_7]));
    255255        z += DZ;
  • trunk/psModules/src/objects/models/pmModel_SERSIC.c

    r31153 r31451  
    316316    float f0 = 1.0;
    317317    float f1, f2;
    318     for (z = DZ; z < 50; z += DZ) {
     318    for (z = DZ; z < 150; z += DZ) {
    319319        // f1 = 1.0 / (1 + PAR[PM_PAR_7]*z + pow(z, 2.25));
    320320        f1 = exp(-pow(z,PAR[PM_PAR_7]));
  • trunk/psModules/src/objects/pmGrowthCurve.c

    r29004 r31451  
    7373    // Fractional pixel radii are not well defined; use integer pixel radii.  Use 1 pixel steps
    7474    // until the scaling factor steps in intervals larger than 1 pixel
    75     float Rlin = 1.0 / (fR - 1.0);
     75    // float Rlin = 1.0 / (fR - 1.0);
    7676
    7777    growth->radius = psVectorAllocEmpty (NPTS, PS_DATA_F32);
     
    7979    // there will be NPTS radii + a few extras
    8080    float radius = minRadius;
    81     while (radius < Rlin) {
     81    while (radius < refRadius) {
    8282        // fprintf (stderr, "r: %f\n", radius);
    83         psVectorAppend (growth->radius, radius);
     83        psVectorAppend (growth->radius, radius - 0.001);
    8484        radius += 1.0;
    8585    }   
     86    growth->refBin = growth->radius->n - 1;
    8687    while (radius < maxRadius) {
    8788        // fprintf (stderr, "r: %f\n", radius);
    88         psVectorAppend (growth->radius, radius);
     89        psVectorAppend (growth->radius, radius - 0.001);
    8990        radius *= fR;
    9091        radius = (int) (radius + 0.5);
     
    9697    growth->refRadius = refRadius;
    9798    growth->maxRadius = maxRadius;
    98     growth->apLoss = 0.0;
    99     growth->fitMag = 0.0;
     99    growth->fitMag = NAN;
     100    growth->refMag = NAN;
     101    growth->apRef  = NAN;
     102    growth->apLoss = NAN;
     103
    100104    return growth;
    101105}
  • trunk/psModules/src/objects/pmGrowthCurve.h

    r15562 r31451  
    2222    psF32 maxRadius;
    2323    psF32 fitMag;
     24    psF32 refMag;
    2425    psF32 apRef;   // apMag[refRadius]
    2526    psF32 apLoss;  // fitMag - apRef
     27    int refBin;
    2628}
    2729pmGrowthCurve;
  • trunk/psModules/src/objects/pmGrowthCurveGenerate.c

    r29546 r31451  
    5050
    5151#include "pmSourcePhotometry.h"
    52 
    53 pmGrowthCurve *pmGrowthCurveForPosition (psImage *image, pmPSF *psf, bool ignore, psImageMaskType maskVal, psImageMaskType markVal, float xc, float yc);
     52#include "pmGrowthCurveGenerate.h"
    5453
    5554/*****************************************************************************/
     
    197196        // mask the given aperture and measure the apMag
    198197        psImageKeepCircle (mask, xc, yc, radius, "OR", markVal);
    199         if (!pmSourcePhotometryAper (&apMag, NULL, NULL, model, pixels, NULL, mask, maskVal)) {
     198        if (!pmSourcePhotometryAper (NULL, &apMag, NULL, NULL, model, pixels, NULL, mask, maskVal)) {
    200199            psFree (growth);
    201200            psFree (view);
     
    226225    return growth;
    227226}
     227
     228# define DEBUG 0
     229# if (DEBUG)
     230static FILE *fgr = NULL;
     231# endif
     232
     233// we generate the growth curve for the center of the image with the specified psf model
     234bool pmGrowthCurveGenerateFromSources (pmReadout *readout, pmPSF *psf, psArray *sources, bool INTERPOLATE_AP, psImageMaskType maskVal, psImageMaskType markVal)
     235{
     236    PS_ASSERT_PTR_NON_NULL(readout, false);
     237    PS_ASSERT_PTR_NON_NULL(readout->image, false);
     238
     239    // maskVal is used to test for rejected pixels, and must include markVal
     240    maskVal |= markVal;
     241
     242    pmSourcePhotometryMode photMode = INTERPOLATE_AP ? PM_SOURCE_PHOT_INTERP : 0;
     243   
     244    // measure the growth curve for each PSF source and average them together
     245    psArray *growths = psArrayAllocEmpty (100);
     246
     247# if (DEBUG)
     248    fgr = fopen ("growth.mags.dat", "w");
     249# endif
     250
     251    for (int i = 0; i < sources->n; i++) {
     252
     253        pmSource *source = sources->data[i];
     254
     255        if (!(source->mode & PM_SOURCE_MODE_PSFSTAR)) continue;
     256
     257        pmGrowthCurve *growth = pmGrowthCurveForSource (source, psf, photMode, maskVal, markVal);
     258        if (!growth) continue;
     259       
     260        psArrayAdd (growths, 100, growth);
     261        psFree (growth);
     262    }
     263    psAssert (growths->n, "cannot build growth curve (no valid PSF stars?)");
     264
     265# if (DEBUG)
     266    fclose (fgr);
     267# endif
     268
     269    // just use a simple sample median to get the 'best' value from each growth curve...
     270    psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN);
     271
     272    psVector *values = psVectorAlloc (growths->n, PS_DATA_F32);
     273
     274    // loop over a range of source fluxes
     275    // no need to interpolate since we have forced the object center
     276    // to 0.5, 0.5 above
     277    for (int i = 0; i < psf->growth->radius->n; i++) {
     278
     279        // median the values for each radial bin
     280        values->n = 0;
     281        for (int j = 0; j < growths->n; j++) {
     282            pmGrowthCurve *growth = growths->data[j];
     283            if (!isfinite(growth->apMag->data.F32[i])) continue;
     284            psVectorAppend (values, growth->apMag->data.F32[i] - growth->refMag);
     285        }
     286        if (values->n == 0) {
     287            psf->growth->apMag->data.F32[i] = NAN;
     288        } else {
     289            if (!psVectorStats (stats, values, NULL, NULL, 0)) {
     290                psError(PS_ERR_UNKNOWN, false, "failure to measure stats");
     291                return false;
     292            }
     293            psf->growth->apMag->data.F32[i] = stats->sampleMedian;
     294        }
     295    }
     296
     297    psf->growth->fitMag = psf->growth->apMag->data.F32[psf->growth->radius->n-1];
     298    psf->growth->apRef = psVectorInterpolate (psf->growth->radius, psf->growth->apMag, psf->growth->refRadius);
     299    psf->growth->apLoss = psf->growth->fitMag - psf->growth->apRef;
     300
     301    psLogMsg ("psphot.growth", 4, "GrowthCurve : apLoss : %f (fitMag - apMag @ ref : %f - %f)\n", psf->growth->apLoss, psf->growth->fitMag, psf->growth->apRef);
     302
     303    psFree (growths);
     304    psFree (stats);
     305    psFree (values);
     306
     307    return true;
     308}
     309
     310pmGrowthCurve *pmGrowthCurveForSource (pmSource *source, pmPSF *psf, pmSourcePhotometryMode photMode, psImageMaskType maskVal, psImageMaskType markVal) {
     311
     312    float radius;
     313
     314    assert (psf->growth);
     315
     316    float minRadius = psf->growth->radius->data.F32[0];
     317    pmGrowthCurve *growth = pmGrowthCurveAlloc (minRadius, psf->growth->maxRadius, psf->growth->refRadius);
     318
     319    // measure the fitMag for this source (for normalization)
     320    // pmSourcePhotometryModel (&fitMag, NULL, source->psfModel);
     321    growth->fitMag = source->psfMag;
     322
     323    float xc = source->peak->xf;
     324    float yc = source->peak->yf;
     325
     326    // Loop over the range of radii
     327    for (int i = 0; i < growth->radius->n; i++) {
     328
     329        radius = growth->radius->data.F32[i];
     330
     331        // mask the given aperture and measure the apMag
     332        psImageKeepCircle (source->maskObj, xc, yc, radius, "OR", markVal);
     333
     334        if (!pmSourceMagnitudes (source, psf, photMode, maskVal, markVal, radius)) {
     335            psFree (growth);
     336            return NULL;
     337        }
     338
     339        // if (!pmSourcePhotometryAper (NULL, &apMag, NULL, NULL, NULL, source->pixels, NULL, source->maskObj, maskVal)) {
     340        //     psFree (growth);
     341        //     return NULL;
     342        // }
     343
     344        psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); // clear the circular mask
     345
     346        growth->apMag->data.F32[i] = source->apMag;
     347    }
     348    psAssert(growth->refBin >= 0, "invalid growth reference bin");
     349    psAssert(growth->refBin < growth->apMag->n, "invalid growth reference bin");
     350    growth->refMag = growth->apMag->data.F32[growth->refBin];
     351
     352    // Loop over the range of radii
     353# if (DEBUG)
     354    for (int i = 0; i < growth->radius->n; i++) {
     355        fprintf (fgr, "%f %f  %f %f %f %f\n", xc, yc, growth->radius->data.F32[i], growth->apMag->data.F32[i], growth->fitMag, growth->refMag);
     356    }
     357# endif
     358
     359    return growth;
     360}
  • trunk/psModules/src/objects/pmPCMdata.c

    r31153 r31451  
    263263bool pmPCMupdate(pmPCMdata *pcm, pmSource *source, pmSourceFitOptions *fitOptions, pmModel *model) {
    264264
    265     bool newWindow = (source->pixels->numRows != pcm->modelFlux->numRows) || (source->pixels->numCols != pcm->modelFlux->numCols);
     265    bool sameWindow = (source->pixels->numRows == pcm->modelFlux->numRows);
     266    sameWindow     &= (source->pixels->numCols == pcm->modelFlux->numCols);
     267    sameWindow     &= (source->pixels->col0    == pcm->modelFlux->col0);
     268    sameWindow     &= (source->pixels->row0    == pcm->modelFlux->row0);
    266269
    267270    // re-count the number of unmasked pixels:
    268     if (newWindow) {
     271    if (!sameWindow) {
    269272        for (psS32 i = 0; i < source->pixels->numRows; i++) {
    270273            for (psS32 j = 0; j < source->pixels->numCols; j++) {
     
    346349
    347350    // has the source pixel window changed?
    348     if (newWindow) {
     351    if (!sameWindow) {
    349352
    350353        // adjust all supporting images:
  • trunk/psModules/src/objects/pmPSF.c

    r31153 r31451  
    7373
    7474    options->type          = 0;
    75 
    7675    options->stats         = NULL;
    77     options->fitOptions    = NULL; // XXX this has to be set before calling pmPSF fit functions
    7876
    7977    options->psfTrendMode  = PM_TREND_NONE;
     
    9088
    9189    options->chiFluxTrend = true;
    92 
     90    options->fitOptions    = NULL; // XXX this has to be set before calling pmPSF fit functions
     91
     92    options->fitRadius = NAN;
     93    options->apRadius = NAN;
    9394    return options;
    9495}
     
    141142
    142143    psf->type     = options->type;
     144
    143145    psf->chisq    = 0.0;
    144146    psf->ApResid  = 0.0;
  • trunk/psModules/src/objects/pmPSF.h

    r29004 r31451  
    3131struct pmPSF {
    3232    pmModelType type;                   ///< PSF Model in use
    33     psArray *params;                    ///< Model parameters (psPolynomial2D)
    34     psStats *psfTrendStats;             ///< psf parameter trend clipping stats
    35     pmTrend2DMode psfTrendMode;
    36     psPolynomial1D *ChiTrend;           ///< Chisq vs flux fit (correction for systematic errors)
    37     pmTrend2D *ApTrend;                 ///< ApResid vs (x,y)
    38     pmTrend2D *FluxScale;               ///< Flux for PSF at (x,y) for normalization = 1.0
     33
     34    float chisq;                        ///< PSF goodness statistic (unused??)
    3935    float ApResid;                      ///< apMag - psfMag (for PSF stars)
    4036    float dApResid;                     ///< scatter of ApResid
    4137    float skyBias;                      ///< implied residual sky offset from ApResid fit
    4238    float skySat;                       ///< roll-over of ApResid fit
    43     float chisq;                        ///< PSF goodness statistic (unused??)
    4439    int nPSFstars;                      ///< number of stars used to measure PSF
    4540    int nApResid;                       ///< number of stars used to measure ApResid
     41
     42    bool poissonErrorsPhotLMM;          ///< use poission errors for non-linear model fitting
     43    bool poissonErrorsPhotLin;          ///< use poission errors for linear model fitting
     44    bool poissonErrorsParams;           ///< use poission errors for model parameter fitting
     45
     46    pmTrend2D *ApTrend;                 ///< ApResid vs (x,y)
     47    pmTrend2D *FluxScale;               ///< Flux for PSF at (x,y) for normalization = 1.0
     48    psPolynomial1D *ChiTrend;           ///< Chisq vs flux fit (correction for systematic errors)
     49
     50    pmGrowthCurve *growth;              ///< apMag vs Radius
     51    pmResiduals *residuals;             ///< normalized residual image (no spatial variation)
     52
     53    psArray *params;                    ///< Model parameters (psPolynomial2D)
     54    psStats *psfTrendStats;             ///< psf parameter trend clipping stats
     55
     56    pmTrend2DMode psfTrendMode;
    4657    int trendNx;
    4758    int trendNy;
     
    5061    int fieldXo;
    5162    int fieldYo;
    52     bool poissonErrorsPhotLMM;          ///< use poission errors for non-linear model fitting
    53     bool poissonErrorsPhotLin;          ///< use poission errors for linear model fitting
    54     bool poissonErrorsParams;           ///< use poission errors for model parameter fitting
    55     pmGrowthCurve *growth;              ///< apMag vs Radius
    56     pmResiduals *residuals;             ///< normalized residual image (no spatial variation)
    5763};
    5864
     
    6066    pmModelType   type;
    6167    psStats      *stats;                // psfTrend clipping stats
     68
    6269    pmTrend2DMode psfTrendMode;
    6370    int           psfTrendNx;
     
    6774    int           psfFieldXo;
    6875    int           psfFieldYo;
     76
    6977    bool          poissonErrorsPhotLMM; ///< use poission errors for non-linear model fitting
    7078    bool          poissonErrorsPhotLin; ///< use poission errors for linear model fitting
    7179    bool          poissonErrorsParams; ///< use poission errors for model parameter fitting
     80
     81    bool          chiFluxTrend;         // Fit a trend in Chi2 as a function of flux?
     82    pmSourceFitOptions *fitOptions;
     83
    7284    float         fitRadius;
    7385    float         apRadius;
    74     bool          chiFluxTrend;         // Fit a trend in Chi2 as a function of flux?
    75     pmSourceFitOptions *fitOptions;
    7686} pmPSFOptions;
    7787
     
    94104double pmPSF_SXYtoModel (psF32 *fittedPar);
    95105
    96 bool pmGrowthCurveGenerate (pmReadout *readout, pmPSF *psf, bool ignore, psImageMaskType maskVal, psImageMaskType mark);
    97106pmPSF *pmPSFBuildSimple (char *typeName, float sxx, float syy, float sxy, ...);
    98107
  • trunk/psModules/src/objects/pmPSF_IO.c

    r30031 r31451  
    6363
    6464bool pmPSFmodelReadPSFClump (psMetadata *analysis, psMetadata *header);
     65bool pmPSFmodelRead_ApTrend (pmPSF *psf, pmFPAfile *file);
     66bool pmPSFmodelWrite_ApTrend (pmFPAfile *file, pmPSF *psf);
     67
     68bool pmPSFmodelRead_GrowthCurve (pmPSF *psf, pmFPAfile *file);
     69bool pmPSFmodelWrite_GrowthCurve (pmFPAfile *file, pmPSF *psf);
    6570
    6671bool pmPSFmodelCheckDataStatusForView (const pmFPAview *view, const pmFPAfile *file)
     
    197202        psError(psErrorCodeLast(), false, "Failed to write PSF for chip");
    198203        return false;
     204    }
     205    return true;
     206}
     207
     208// XXX we save the model term identifiers (item) as S32, but they probably should be more flexible
     209bool pmTrend2DtoTable (psArray *table, pmTrend2D *trend, char *label, int item) {
     210
     211    if (trend == NULL) return true;
     212
     213    if (trend->mode == PM_TREND_MAP) {
     214        // write the image components into a table: this is needed because they may each be a different size
     215        psImageMap *map = trend->map;
     216        for (int ix = 0; ix < map->map->numCols; ix++) {
     217            for (int iy = 0; iy < map->map->numRows; iy++) {
     218                psMetadata *row = psMetadataAlloc ();
     219                psMetadataAddS32 (row, PS_LIST_TAIL, label,        0, "", item);
     220                psMetadataAddS32 (row, PS_LIST_TAIL, "X_POWER",    0, "", ix);
     221                psMetadataAddS32 (row, PS_LIST_TAIL, "Y_POWER",    0, "", iy);
     222                psMetadataAddF32 (row, PS_LIST_TAIL, "VALUE",      0, "", map->map->data.F32[iy][ix]);
     223                psMetadataAddF32 (row, PS_LIST_TAIL, "ERROR",      0, "", map->error->data.F32[iy][ix]);
     224                psMetadataAddU8  (row, PS_LIST_TAIL, "MASK",       0, "", 0); // no cells are masked
     225
     226                psArrayAdd (table, 100, row);
     227                psFree (row);
     228            }
     229        }
     230    } else {
     231        // write the polynomial components into a table
     232        psPolynomial2D *poly = trend->poly;
     233        for (int ix = 0; ix <= poly->nX; ix++) {
     234            for (int iy = 0; iy <= poly->nY; iy++) {
     235                psMetadata *row = psMetadataAlloc ();
     236                psMetadataAddS32 (row, PS_LIST_TAIL, label,        0, "", item);
     237                psMetadataAddS32 (row, PS_LIST_TAIL, "X_POWER",    0, "", ix);
     238                psMetadataAddS32 (row, PS_LIST_TAIL, "Y_POWER",    0, "", iy);
     239                psMetadataAddF32 (row, PS_LIST_TAIL, "VALUE",      0, "", poly->coeff[ix][iy]);
     240                psMetadataAddF32 (row, PS_LIST_TAIL, "ERROR",      0, "", poly->coeffErr[ix][iy]);
     241                psMetadataAddU8  (row, PS_LIST_TAIL, "MASK",       0, "", poly->coeffMask[ix][iy]);
     242
     243                psArrayAdd (table, 100, row);
     244                psFree (row);
     245            }
     246        }
     247    }
     248    return true;
     249}
     250
     251// extra trend2D elements from a row
     252bool pmTrend2DfromTableRow (pmTrend2D *trend, psMetadata *row) {
     253
     254    bool status = false;
     255
     256    int xPow = psMetadataLookupS32 (&status, row, "X_POWER");
     257    int yPow = psMetadataLookupS32 (&status, row, "Y_POWER");
     258
     259    if (trend->mode == PM_TREND_MAP) {
     260        psImageMap *map = trend->map;
     261        assert (map);
     262        assert (map->map);
     263        assert (map->error);
     264        assert (xPow >= 0);
     265        assert (yPow >= 0);
     266        assert (xPow < map->map->numCols);
     267        assert (yPow < map->map->numRows);
     268        map->map->data.F32[yPow][xPow]    = psMetadataLookupF32 (&status, row, "VALUE");
     269        map->error->data.F32[yPow][xPow]  = psMetadataLookupF32 (&status, row, "ERROR");
     270    } else {
     271        psPolynomial2D *poly = trend->poly;
     272        assert (poly);
     273        assert (xPow >= 0);
     274        assert (yPow >= 0);
     275        assert (xPow <= poly->nX);
     276        assert (yPow <= poly->nY);
     277        poly->coeff[xPow][yPow]     = psMetadataLookupF32 (&status, row, "VALUE");
     278        poly->coeffErr[xPow][yPow]  = psMetadataLookupF32 (&status, row, "ERROR");
     279        poly->coeffMask[xPow][yPow] = psMetadataLookupU8  (&status, row, "MASK");
    199280    }
    200281    return true;
     
    403484
    404485            if (trend->mode == PM_TREND_MAP) {
    405               nX = trend->map->map->numCols;
    406               nY = trend->map->map->numRows;
     486                nX = trend->map->map->numCols;
     487                nY = trend->map->map->numRows;
    407488            } else {
    408               nX = trend->poly->nX;
    409               nY = trend->poly->nY;
     489                nX = trend->poly->nX;
     490                nY = trend->poly->nY;
    410491            }
    411492            snprintf (name, 9, "PAR%02d_NX", i);
     
    428509        psMetadataAddF32 (header, PS_LIST_TAIL, "SKY_BIAS", PS_DATA_F32, "sky bias level", psf->skyBias);
    429510
     511        float PSF_APERTURE =  psMetadataLookupF32(&status, roAnalysis, "PSF_APERTURE");
     512        if (status) {
     513            psMetadataAddF32 (header, PS_LIST_TAIL, "PSF_APERTURE", PS_DATA_F32, "aperture for psf objects", PSF_APERTURE);
     514        }
     515        float PSF_FIT_RADIUS =  psMetadataLookupF32(&status, roAnalysis, "PSF_FIT_RADIUS");
     516        if (status) {
     517            psMetadataAddF32 (header, PS_LIST_TAIL, "PSF_FIT_RADIUS", PS_DATA_F32, "aperture for psf objects", PSF_FIT_RADIUS);
     518        }
     519
    430520        // build a FITS table of the PSF parameters
    431521        psArray *psfTable = psArrayAllocEmpty (100);
    432522        for (int i = 0; i < nPar; i++) {
    433523            pmTrend2D *trend = psf->params->data[i];
    434             if (trend == NULL) continue; // skip unset parameters (eg, XPOS)
    435 
    436             if (trend->mode == PM_TREND_MAP) {
    437                 // write the image components into a table: this is needed because they may each be a different size
    438                 psImageMap *map = trend->map;
    439                 for (int ix = 0; ix < map->map->numCols; ix++) {
    440                     for (int iy = 0; iy < map->map->numRows; iy++) {
    441                         psMetadata *row = psMetadataAlloc ();
    442                         psMetadataAddS32 (row, PS_LIST_TAIL, "MODEL_TERM", 0, "", i);
    443                         psMetadataAddS32 (row, PS_LIST_TAIL, "X_POWER",    0, "", ix);
    444                         psMetadataAddS32 (row, PS_LIST_TAIL, "Y_POWER",    0, "", iy);
    445                         psMetadataAddF32 (row, PS_LIST_TAIL, "VALUE",      0, "", map->map->data.F32[iy][ix]);
    446                         psMetadataAddF32 (row, PS_LIST_TAIL, "ERROR",      0, "", map->error->data.F32[iy][ix]);
    447                         psMetadataAddU8  (row, PS_LIST_TAIL, "MASK",       0, "", 0); // no cells are masked
    448 
    449                         psArrayAdd (psfTable, 100, row);
    450                         psFree (row);
    451                     }
    452                 }
    453             } else {
    454                 // write the polynomial components into a table
    455                 psPolynomial2D *poly = trend->poly;
    456                 for (int ix = 0; ix <= poly->nX; ix++) {
    457                     for (int iy = 0; iy <= poly->nY; iy++) {
    458                         psMetadata *row = psMetadataAlloc ();
    459                         psMetadataAddS32 (row, PS_LIST_TAIL, "MODEL_TERM", 0, "", i);
    460                         psMetadataAddS32 (row, PS_LIST_TAIL, "X_POWER",    0, "", ix);
    461                         psMetadataAddS32 (row, PS_LIST_TAIL, "Y_POWER",    0, "", iy);
    462                         psMetadataAddF32 (row, PS_LIST_TAIL, "VALUE",      0, "", poly->coeff[ix][iy]);
    463                         psMetadataAddF32 (row, PS_LIST_TAIL, "ERROR",      0, "", poly->coeffErr[ix][iy]);
    464                         psMetadataAddU8  (row, PS_LIST_TAIL, "MASK",       0, "", poly->coeffMask[ix][iy]);
    465 
    466                         psArrayAdd (psfTable, 100, row);
    467                         psFree (row);
    468                     }
    469                 }
    470             }
     524            pmTrend2DtoTable (psfTable, trend, "MODEL_TERM", i);
    471525        }
    472526
     
    547601    }
    548602
     603    if (!pmPSFmodelWrite_ApTrend(file, psf)) {
     604        psError(psErrorCodeLast(), false, "Unable to write PSF ApTrend");
     605        return false;
     606    }
     607
     608    if (!pmPSFmodelWrite_GrowthCurve(file, psf)) {
     609        psError(psErrorCodeLast(), false, "Unable to write PSF Growth Curve");
     610        return false;
     611    }
     612
    549613    // write a representation of the psf model
    550614    {
    551615        psMetadata *header = psMetadataAlloc ();
    552 
    553         if (0) {
    554             // set some header keywords to make it clear there are no residuals?
    555             if (!psFitsWriteBlank (file->fits, header, residName)) {
    556                 psError(psErrorCodeLast(), false, "Unable to write blank PSF residuals.");
    557                 psFree(residName);
    558                 psFree(header);
    559                 return false;
    560             }
    561             psFree (residName);
    562             psFree (header);
    563             return true;
    564         }
    565616
    566617        int DX = 65;
     
    651702}
    652703
     704
     705
    653706// if this file needs to have a PHU written out, write one
    654707bool pmPSFmodelWritePHU (const pmFPAview *view, pmFPAfile *file, pmConfig *config)
     
    934987    psf->skyBias   = psMetadataLookupF32 (&status, header, "SKY_BIAS");
    935988
     989    if (roAnalysis) {
     990        float PSF_APERTURE =  psMetadataLookupF32(&status, header, "PSF_APERTURE");
     991        if (status) {
     992            psMetadataAddF32 (roAnalysis, PS_LIST_TAIL, "PSF_APERTURE", PS_DATA_F32, "aperture for psf objects", PSF_APERTURE);
     993        }
     994        float PSF_FIT_RADIUS =  psMetadataLookupF32(&status, header, "PSF_FIT_RADIUS");
     995        if (status) {
     996            psMetadataAddF32 (roAnalysis, PS_LIST_TAIL, "PSF_FIT_RADIUS", PS_DATA_F32, "aperture for psf objects", PSF_FIT_RADIUS);
     997        }
     998    } else {
     999        psWarning ("unable to read PSF_APERTURE or PSF_FIT_RADIUS");
     1000    }
     1001
    9361002    // read the raw table data
    9371003    psArray *table = psFitsReadTable (file->fits);
     
    9451011    for (int i = 0; i < table->n; i++) {
    9461012        psMetadata *row = table->data[i];
     1013
    9471014        int iPar = psMetadataLookupS32 (&status, row, "MODEL_TERM");
    948         int xPow = psMetadataLookupS32 (&status, row, "X_POWER");
    949         int yPow = psMetadataLookupS32 (&status, row, "Y_POWER");
    9501015
    9511016        pmTrend2D *trend = psf->params->data[iPar];
     
    9551020        }
    9561021
    957         if (trend->mode == PM_TREND_MAP) {
    958             psImageMap *map = trend->map;
    959             assert (map);
    960             assert (map->map);
    961             assert (map->error);
    962             assert (xPow >= 0);
    963             assert (yPow >= 0);
    964             assert (xPow < map->map->numCols);
    965             assert (yPow < map->map->numRows);
    966             map->map->data.F32[yPow][xPow]    = psMetadataLookupF32 (&status, row, "VALUE");
    967             map->error->data.F32[yPow][xPow]  = psMetadataLookupF32 (&status, row, "ERROR");
    968         } else {
    969             psPolynomial2D *poly = trend->poly;
    970             assert (poly);
    971             assert (xPow >= 0);
    972             assert (yPow >= 0);
    973             assert (xPow <= poly->nX);
    974             assert (yPow <= poly->nY);
    975             poly->coeff[xPow][yPow]     = psMetadataLookupF32 (&status, row, "VALUE");
    976             poly->coeffErr[xPow][yPow]  = psMetadataLookupF32 (&status, row, "ERROR");
    977             poly->coeffMask[xPow][yPow] = psMetadataLookupU8  (&status, row, "MASK");
    978         }
     1022        pmTrend2DfromTableRow(trend, row);
    9791023    }
    9801024    psFree (header);
     
    10631107    }
    10641108
     1109    if (!pmPSFmodelRead_ApTrend (psf, file)) {
     1110        psError(psErrorCodeLast(), false, "Unable to read PSF ApTrend data.");
     1111        return false;
     1112    }
     1113
     1114    if (!pmPSFmodelRead_GrowthCurve(psf, file)) {
     1115        psError(psErrorCodeLast(), false, "Unable to read PSF Growth Curve");
     1116        return false;
     1117    }
     1118
    10651119    psMetadataAdd (chipAnalysis, PS_LIST_TAIL, "PSPHOT.PSF",     PS_DATA_UNKNOWN,  "psphot psf", psf);
    10661120    psFree (psf);
     
    10701124    psFree (header);
    10711125
     1126    return true;
     1127}
     1128
     1129// write aperture trend to a FITS table
     1130bool pmPSFmodelWrite_ApTrend (pmFPAfile *file, pmPSF *psf) {
     1131
     1132    pmTrend2D *trend = psf->ApTrend;
     1133    if (trend == NULL) {
     1134        psWarning ("no PSF ApTrend to write out, skipping");
     1135        return true;
     1136    }
     1137
     1138    // we need to write a header for the table,
     1139    psMetadata *header = psMetadataAlloc();
     1140
     1141    int nX = 0, nY = 0;
     1142    if (trend->mode == PM_TREND_MAP) {
     1143        nX = trend->map->map->numCols;
     1144        nY = trend->map->map->numRows;
     1145    } else {
     1146        nX = trend->poly->nX;
     1147        nY = trend->poly->nY;
     1148    }
     1149    psMetadataAddS32 (header, PS_LIST_TAIL, "TREND_NX", 0, "", nX);
     1150    psMetadataAddS32 (header, PS_LIST_TAIL, "TREND_NY", 0, "", nY);
     1151    char *modeName = pmTrend2DModeToString (trend->mode);
     1152    psMetadataAddStr (header, PS_LIST_TAIL, "TREND_MD", 0, "", modeName);
     1153    psFree (modeName);
     1154
     1155    // build a FITS table of the ApTrend (only 1)
     1156    psArray *table = psArrayAllocEmpty (100);
     1157    pmTrend2DtoTable (table, trend, "APTREND", 0);
     1158
     1159    // write an empty FITS segment if we have no PSF information
     1160    if (table->n == 0) {
     1161        psError(PM_ERR_PROG, true, "No PSF data to write.");
     1162        psFree(table);
     1163        psFree(header);
     1164        return false;
     1165    }
     1166
     1167    psTrace ("pmFPAfile", 5, "writing psf ApTrend data %s\n", "AP_TREND");
     1168    if (!psFitsWriteTable(file->fits, header, table, "AP_TREND")) {
     1169        psError(psErrorCodeLast(), false, "Error writing psf table data %s\n", "AP_TREND");
     1170        psFree(table);
     1171        psFree(header);
     1172        return false;
     1173    }
     1174
     1175    psFree (table);
     1176    psFree (header);
     1177    return true;
     1178}
     1179
     1180// read aperture trend to a FITS table
     1181bool pmPSFmodelRead_ApTrend (pmPSF *psf, pmFPAfile *file) {
     1182
     1183    bool status;
     1184
     1185    // move fits pointer to AP_TREND section
     1186    // advance to the table data extension
     1187    if (!psFitsMoveExtNameClean (file->fits, "AP_TREND")) {
     1188        psWarning ("no Aperture Trend data in PSF file, skipping");
     1189        return true;
     1190    }
     1191
     1192    psMetadata *header = psFitsReadHeader (NULL, file->fits);
     1193    if (!header) {
     1194        psError(psErrorCodeLast(), false, "Unable to read AP_TREND header.");
     1195        return false;
     1196    }
     1197       
     1198    // read the raw table data
     1199    psArray *table = psFitsReadTable (file->fits);
     1200    if (!table) {
     1201        psError(psErrorCodeLast(), false, "Unable to read AP_TREND table.");
     1202        psFree(header);
     1203        return false;
     1204    }
     1205
     1206    // XXX allow user to set this optionally?
     1207    psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV);
     1208
     1209    psImageBinning *binning = psImageBinningAlloc();
     1210    binning->nXfine = psf->fieldNx;
     1211    binning->nYfine = psf->fieldNy;
     1212    binning->nXruff = psMetadataLookupS32 (&status, header, "TREND_NX");
     1213    binning->nYruff = psMetadataLookupS32 (&status, header, "TREND_NY");
     1214    psImageBinningSetScale (binning, PS_IMAGE_BINNING_CENTER);
     1215    char *modeName  = psMetadataLookupStr (&status, header, "TREND_MD");
     1216    if (!status) {
     1217        psError(PM_ERR_PROG, true, "inconsistent PSF header: NX & NY defined for AP TREND, but not MD");
     1218        psFree (header);
     1219        psFree (stats);
     1220        psFree (table);
     1221        return false;
     1222    }
     1223    pmTrend2DMode psfTrendMode = pmTrend2DModeFromString (modeName);
     1224    if (psfTrendMode == PM_TREND_NONE) {
     1225        psfTrendMode = PM_TREND_POLY_ORD;
     1226    }
     1227
     1228    // measure Trend2D for the current spatial scale
     1229    pmTrend2D *apTrend = pmTrend2DNoImageAlloc (PM_TREND_MAP, binning, stats);
     1230
     1231    // fill in the matching psf->params entries
     1232    for (int i = 0; i < table->n; i++) {
     1233        psMetadata *row = table->data[i];
     1234        pmTrend2DfromTableRow(apTrend, row);
     1235    }
     1236    psf->ApTrend = apTrend;
     1237
     1238    psFree (binning);
     1239    psFree (header);
     1240    psFree (stats);
     1241    psFree (table);
     1242    return true;
     1243}
     1244
     1245// write aperture trend to a FITS table
     1246bool pmPSFmodelWrite_GrowthCurve (pmFPAfile *file, pmPSF *psf) {
     1247
     1248    pmGrowthCurve *growth = psf->growth;
     1249    if (growth == NULL) {
     1250        psWarning ("no PSF Growth Curve to write out, skipping");
     1251        return true;
     1252    }
     1253
     1254    // we need to write a header for the table,
     1255    psMetadata *header = psMetadataAlloc();
     1256
     1257    psMetadataAddF32 (header, PS_LIST_TAIL, "GROWTH_MIN_RAD", 0, "", growth->radius->data.F32[0]);
     1258    psMetadataAddF32 (header, PS_LIST_TAIL, "GROWTH_MAX_RAD", 0, "", growth->maxRadius);
     1259    psMetadataAddF32 (header, PS_LIST_TAIL, "GROWTH_REF_RAD", 0, "", growth->refRadius);
     1260    psMetadataAddF32 (header, PS_LIST_TAIL, "GROWTH_AP_LOSS", 0, "", growth->apLoss);
     1261    psMetadataAddF32 (header, PS_LIST_TAIL, "GROWTH_AP_REF",  0, "", growth->apRef);
     1262    psMetadataAddF32 (header, PS_LIST_TAIL, "GROWTH_FIT_MAG", 0, "", growth->fitMag);
     1263
     1264    // build a FITS table of the ApTrend (only 1)
     1265    psArray *table = psArrayAllocEmpty (100);
     1266    for (int i = 0; i < growth->apMag->n; i++) {
     1267        psMetadata *row = psMetadataAlloc ();
     1268        psMetadataAddF32 (row, PS_LIST_TAIL, "RADIUS", 0, "", growth->radius->data.F32[i]);
     1269        psMetadataAddF32 (row, PS_LIST_TAIL, "AP_MAG", 0, "", growth->apMag->data.F32[i]);
     1270        psArrayAdd (table, 100, row);
     1271        psFree (row);
     1272    }
     1273
     1274    // write an empty FITS segment if we have no PSF information
     1275    if (table->n == 0) {
     1276        psError(PM_ERR_PROG, true, "No PSF data to write.");
     1277        psFree(table);
     1278        psFree(header);
     1279        return false;
     1280    }
     1281
     1282    psTrace ("pmFPAfile", 5, "writing psf Growth Curve data %s\n", "GROWTH_CURVE");
     1283    if (!psFitsWriteTable(file->fits, header, table, "GROWTH_CURVE")) {
     1284        psError(psErrorCodeLast(), false, "Error writing psf table data %s\n", "GROWTH_CURVE");
     1285        psFree(table);
     1286        psFree(header);
     1287        return false;
     1288    }
     1289
     1290    psFree (table);
     1291    psFree (header);
     1292    return true;
     1293}
     1294
     1295// read aperture trend to a FITS table
     1296bool pmPSFmodelRead_GrowthCurve (pmPSF *psf, pmFPAfile *file) {
     1297
     1298    bool status;
     1299
     1300    // move fits pointer to AP_TREND section
     1301    // advance to the table data extension
     1302    if (!psFitsMoveExtNameClean (file->fits, "GROWTH_CURVE")) {
     1303        psWarning ("no Growth Curve data in PSF file, skipping");
     1304        return true;
     1305    }
     1306
     1307    psMetadata *header = psFitsReadHeader (NULL, file->fits);
     1308    if (!header) {
     1309        psError(psErrorCodeLast(), false, "Unable to read GROWTH_CURVE header.");
     1310        return false;
     1311    }
     1312       
     1313    // read the raw table data
     1314    psArray *table = psFitsReadTable (file->fits);
     1315    if (!table) {
     1316        psError(psErrorCodeLast(), false, "Unable to read GROWTH_CURVE table.");
     1317        psFree(header);
     1318        return false;
     1319    }
     1320
     1321    float minRadius = psMetadataLookupF32 (&status, header, "GROWTH_MIN_RAD"); if (!status) return false;
     1322    float maxRadius = psMetadataLookupF32 (&status, header, "GROWTH_MAX_RAD"); if (!status) return false;
     1323    float refRadius = psMetadataLookupF32 (&status, header, "GROWTH_REF_RAD"); if (!status) return false;
     1324
     1325    psf->growth = pmGrowthCurveAlloc(minRadius, maxRadius, refRadius);
     1326
     1327    psf->growth->apLoss = psMetadataLookupF32 (&status, header, "GROWTH_AP_LOSS"); if (!status) return false;
     1328    psf->growth->apRef  = psMetadataLookupF32 (&status, header, "GROWTH_AP_REF"); if (!status) return false;
     1329    psf->growth->fitMag = psMetadataLookupF32 (&status, header, "GROWTH_FIT_MAG"); if (!status) return false;
     1330
     1331    // fill in the matching psf->params entries
     1332    for (int i = 0; i < table->n; i++) {
     1333        psMetadata *row = table->data[i];
     1334        psf->growth->apMag->data.F32[i] = psMetadataLookupF32 (&status, row, "AP_MAG"); if (!status) return false;
     1335    }
     1336
     1337    psFree (header);
     1338    psFree (table);
    10721339    return true;
    10731340}
  • trunk/psModules/src/objects/pmPSFtryFitPSF.c

    r31153 r31451  
    122122        psfTry->fitMag->data.F32[i] = source->psfMag;
    123123        psfTry->metric->data.F32[i] = source->apMag - source->psfMag;
    124         psfTry->metricErr->data.F32[i] = source->errMag;
     124        psfTry->metricErr->data.F32[i] = source->psfMagErr;
    125125
    126126        // XXX this did not work: modifies shape of psf too much
     
    131131                 source->peak->xf, source->peak->yf,
    132132                 source->modelPSF->params->data.F32[PM_PAR_XPOS], source->modelPSF->params->data.F32[PM_PAR_YPOS],
    133                  source->psfMag, source->apMag, source->errMag,
     133                 source->psfMag, source->apMag, source->psfMagErr,
    134134                 source->modelPSF->params->data.F32[PM_PAR_I0],
    135135                 source->modelPSF->params->data.F32[PM_PAR_SXX], source->modelPSF->params->data.F32[PM_PAR_SXY],
  • trunk/psModules/src/objects/pmPeaks.c

    r31153 r31451  
    150150    tmp->x = x;
    151151    tmp->y = y;
     152    tmp->xf = x;
     153    tmp->yf = y;
     154    tmp->dx = NAN;
     155    tmp->dy = NAN;
    152156    tmp->detValue        = value;
    153157    tmp->rawFlux         = value; // set this by default: it is up to the user to supply a better value
     
    155159    tmp->smoothFlux      = value; // set this by default: it is up to the user to supply a better value
    156160    tmp->smoothFluxStdev = NAN;
    157     // tmp->SN = 0;
    158     tmp->xf = x;
    159     tmp->yf = y;
    160161    tmp->assigned = false;
    161162    tmp->type = type;
     
    166167    psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__);
    167168    return(tmp);
     169}
     170
     171// copy to an already allocated peak
     172bool pmPeakCopy(pmPeak *out, pmPeak *in)
     173{
     174    out->x               = in->x;
     175    out->y               = in->y;
     176    out->xf              = in->xf;
     177    out->yf              = in->yf;
     178    out->dx              = in->dx;
     179    out->dy              = in->dy;
     180    out->detValue        = in->detValue;
     181    out->rawFlux         = in->rawFlux;
     182    out->rawFluxStdev    = in->rawFluxStdev;
     183    out->smoothFlux      = in->smoothFlux;
     184    out->smoothFluxStdev = in->smoothFluxStdev;
     185    out->assigned        = in->assigned;
     186    out->type            = in->type;
     187
     188    return true;
    168189}
    169190
  • trunk/psModules/src/objects/pmPeaks.h

    r31153 r31451  
    6969    float smoothFlux;                   ///< peak flux in smoothed signal image
    7070    float smoothFluxStdev;              ///< peak stdev in smoothed signal image
    71     // float SNestimated;                  ///< S/N estimated from the detection image
    7271    bool assigned;                      ///< is peak assigned to a source?
    7372    pmPeakType type;                    ///< Description of peak.
     
    8988
    9089bool psMemCheckPeak(psPtr ptr);
     90
     91bool pmPeakCopy(pmPeak *out, pmPeak *in);
    9192
    9293/** pmPeaksInVector()
  • trunk/psModules/src/objects/pmSource.c

    r31153 r31451  
    116116    source->psfImage = NULL;
    117117    source->moments = NULL;
    118     source->blends = NULL;
    119118    source->modelPSF = NULL;
    120119    source->modelEXT = NULL;
     
    124123    source->mode2 = PM_SOURCE_MODE_DEFAULT;
    125124    source->tmpFlags = 0;
    126     source->extpars = NULL;
    127     source->diffStats = NULL;
    128     source->radialAper = NULL;
    129     source->parent = NULL;
    130 
    131     source->region = psRegionSet(NAN, NAN, NAN, NAN);
    132     psMemSetDeallocator(source, (psFreeFunc) sourceFree);
    133125
    134126    // default values are NAN
    135127    source->psfMag           = NAN;
     128    source->psfMagErr        = NAN;
    136129    source->psfFlux          = NAN;
    137130    source->psfFluxErr       = NAN;
    138131    source->extMag           = NAN;   
    139     source->errMag           = NAN;
    140132    source->apMag            = NAN;
    141133    source->apMagRaw         = NAN;
     
    143135    source->apFlux           = NAN;
    144136    source->apFluxErr        = NAN;
    145     source->sky              = NAN;
    146     source->skyErr           = NAN;   
     137
    147138    source->pixWeightNotBad  = NAN;
    148139    source->pixWeightNotPoor = NAN;
     
    151142    source->crNsigma         = NAN;
    152143    source->extNsigma        = NAN;
     144    source->sky              = NAN;
     145    source->skyErr           = NAN;   
     146
     147    source->region = psRegionSet(NAN, NAN, NAN, NAN);
     148    source->blends = NULL;
     149    source->extpars = NULL;
     150    source->diffStats = NULL;
     151    source->radialAper = NULL;
     152    source->parent = NULL;
     153    source->imageID = -1;
     154
     155    psMemSetDeallocator(source, (psFreeFunc) sourceFree);
    153156
    154157    psTrace("psModules.objects", 10, "---- end ----\n");
     
    172175    if (in->peak != NULL) {
    173176        source->peak = pmPeakAlloc (in->peak->x, in->peak->y, in->peak->detValue, in->peak->type);
    174         source->peak->xf = in->peak->xf;
    175         source->peak->yf = in->peak->yf;
    176         source->peak->rawFlux         = in->peak->rawFlux;
    177         source->peak->rawFluxStdev    = in->peak->rawFluxStdev;
    178         source->peak->smoothFlux      = in->peak->smoothFlux;
    179         source->peak->smoothFluxStdev = in->peak->smoothFluxStdev;
    180         // source->peak->SN = in->peak->SN;
     177        pmPeakCopy(source->peak, in->peak);
    181178    }
    182179
     
    195192
    196193    // the maskObj is a unique mask array; create a new mask image
    197     source->maskObj = in->maskObj ? psImageCopy (NULL, in->maskObj, PS_TYPE_IMAGE_MASK) : NULL;
    198 
    199     source->type = in->type;
    200     source->mode = in->mode;
    201     source->imageID = in->imageID;
     194    source->maskObj = in->maskObj   ? psImageCopy (NULL, in->maskObj, PS_TYPE_IMAGE_MASK) : NULL;
     195
     196    // NOTE : because of the const id element, we cannot just assign *source = *in
     197
     198    source->type             = in->type;
     199    source->mode             = in->mode;
     200    source->mode2            = in->mode2;
     201    source->tmpFlags         = in->tmpFlags;
     202    source->psfMag           = in->psfMag;
     203    source->psfMagErr        = in->psfMagErr;
     204    source->psfFlux          = in->psfFlux;
     205    source->psfFluxErr       = in->psfFluxErr;
     206    source->extMag           = in->extMag;
     207    source->apMag            = in->apMag;
     208    source->apMagRaw         = in->apMagRaw;
     209    source->apRadius         = in->apRadius;
     210    source->apFlux           = in->apFlux;
     211    source->apFluxErr        = in->apFluxErr;
     212    source->pixWeightNotBad  = in->pixWeightNotBad;
     213    source->pixWeightNotPoor = in->pixWeightNotPoor;
     214    source->psfChisq         = in->psfChisq;
     215    source->crNsigma         = in->crNsigma;
     216    source->extNsigma        = in->extNsigma;
     217    source->sky              = in->sky;
     218    source->skyErr           = in->skyErr;
     219
     220    source->region           = in->region;
    202221
    203222    return(source);
     
    266285    extend |= (mySource->maskObj == NULL);
    267286    extend |= (mySource->maskView == NULL);
     287
     288    // if ((fabs(x - 2020) < 5) && (fabs(y - 366) < 5)) {
     289    //  if (extend) {
     290    //      fprintf (stderr, "extend T, %f, %f : %f, %f vs %f, %f : %f, %f\n",
     291    //               newRegion.x0, newRegion.y0, newRegion.x1, newRegion.y1,
     292    //               mySource->region.x0, mySource->region.y0, mySource->region.x1, mySource->region.y1);
     293    //  } else {
     294    //      fprintf (stderr, "extend F, %f, %f : %f, %f vs %f, %f : %f, %f\n",
     295    //               newRegion.x0, newRegion.y0, newRegion.x1, newRegion.y1,
     296    //               mySource->region.x0, mySource->region.y0, mySource->region.x1, mySource->region.y1);
     297    //  }
     298    // }
    268299
    269300    if (extend) {
     
    486517        // create vectors with Sx, Sy values in window
    487518        // clip sources based on S/N
    488         for (psS32 i = 0 ; i < sources->n ; i++)
     519        for (psS32 i = 0; i < sources->n; i++)
    489520        {
    490521            pmSource *tmpSrc = (pmSource *) sources->data[i];
     
    11751206    if (!source->moments) return false;          // can't if there are no moments
    11761207    if (!source->moments->nPixels) return false; // can't if the moments were not measured
    1177     if (source->mode && PM_SOURCE_MODE_MOMENTS_FAILURE) return false; // can't if the moments failed...
     1208    if (source->mode & PM_SOURCE_MODE_MOMENTS_FAILURE) return false; // can't if the moments failed...
    11781209
    11791210    if (source->mode & PM_SOURCE_MODE_SATSTAR) return true; // moments are best for SATSTARs
  • trunk/psModules/src/objects/pmSource.h

    r31153 r31451  
    8080    pmSourceMode2 mode2;                ///< analysis flags set for object.
    8181    pmSourceTmpF tmpFlags;              ///< internal-only flags
    82     psArray *blends;                    ///< collection of sources thought to be confused with object
     82
    8383    float psfMag;                       ///< calculated from flux in modelPSF
     84    float psfMagErr;                    ///< error in psfMag
    8485    float psfFlux;                      ///< calculated from flux in modelPSF
    85     float psfFluxErr;                   ///< calculated from flux in modelPSF
    86     float extMag;                       ///< calculated from flux in modelEXT
    87     float errMag;                       ///< error in psfMag OR extMag (depending on type)
     86    float psfFluxErr;                   ///< error in psfFlux
     87    float extMag;                       ///< calculated from flux in modelEXT -- NOTE this is not actually used
    8888    float apMag;                        ///< apMag corresponding to psfMag or extMag (depending on type)
    8989    float apMagRaw;                     ///< raw mag in given aperture
     
    9898    float crNsigma;                     ///< Nsigma deviation from PSF to CR
    9999    float extNsigma;                    ///< Nsigma deviation from PSF to EXT
    100     float sky, skyErr;                  ///< The sky and its error at the center of the object
     100    float sky;                          ///< The sky at the center of the object
     101    float skyErr;                       ///< The sky error at the center of the object
     102
    101103    psRegion region;                    ///< area on image covered by selected pixels
     104    psArray *blends;                    ///< collection of sources thought to be confused with object
    102105    pmSourceExtendedPars *extpars;      ///< extended source parameters
    103106    pmSourceDiffStats *diffStats;       ///< extra parameters for difference detections
     
    254257    float sigma,      ///< size of Gaussian window function (<= 0.0 -> skip window)
    255258    float minSN,              ///< minimum pixel significance
     259    float minKronRadius,      ///< minimum pixel significance
    256260    psImageMaskType maskVal
    257261);
     
    273277  float xGuess, float yGuess);
    274278
     279float pmSourceMinKronRadius(psArray *sources, float PSF_SN_LIM);
     280
    275281pmModel *pmSourceGetModel (bool *isPSF, const pmSource *source);
    276282
  • trunk/psModules/src/objects/pmSourceIO_CMF_PS1_DV1.c

    r31153 r31451  
    125125        psMetadataAdd (row, PS_LIST_TAIL, "PLTSCALE",         PS_DATA_F32, "plate scale at source (arcsec/pixel)",       outputs.pltScale);
    126126        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG",     PS_DATA_F32, "PSF fit instrumental magnitude",             source->psfMag);
    127         psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude",        source->errMag);
     127        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude",        source->psfMagErr);
    128128        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX",    PS_DATA_F32, "PSF fit instrumental magnitude",             source->psfFlux);
    129129        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX_SIG",PS_DATA_F32, "Sigma of PSF instrumental magnitude",        source->psfFluxErr);
     
    256256
    257257        source->psfMag    = psMetadataLookupF32 (&status, row, "PSF_INST_MAG");
    258         source->errMag    = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG");
     258        source->psfMagErr    = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG");
    259259        source->apMag     = psMetadataLookupF32 (&status, row, "AP_MAG");
    260260
    261261        // XXX this scaling is incorrect: does not include the 2 \pi AREA factor
    262262        PAR[PM_PAR_I0]    = (isfinite(source->psfMag)) ? pow(10.0, -0.4*source->psfMag) : NAN;
    263         dPAR[PM_PAR_I0]   = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->errMag : NAN;
     263        dPAR[PM_PAR_I0]   = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->psfMagErr : NAN;
    264264
    265265        pmPSF_AxesToModel (PAR, axes);
  • trunk/psModules/src/objects/pmSourceIO_CMF_PS1_DV2.c

    r31153 r31451  
    124124        psMetadataAdd (row, PS_LIST_TAIL, "PLTSCALE",         PS_DATA_F32, "plate scale at source (arcsec/pixel)",       outputs.pltScale);
    125125        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG",     PS_DATA_F32, "PSF fit instrumental magnitude",             source->psfMag);
    126         psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude",        source->errMag);
     126        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude",        source->psfMagErr);
    127127        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX",    PS_DATA_F32, "PSF fit instrumental magnitude",             source->psfFlux);
    128128        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX_SIG",PS_DATA_F32, "Sigma of PSF instrumental magnitude",        source->psfFluxErr);
     
    274274
    275275        source->psfMag    = psMetadataLookupF32 (&status, row, "PSF_INST_MAG");
    276         source->errMag    = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG");
     276        source->psfMagErr    = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG");
    277277        source->apMag     = psMetadataLookupF32 (&status, row, "AP_MAG");
    278278
    279279        // XXX this scaling is incorrect: does not include the 2 \pi AREA factor
    280280        PAR[PM_PAR_I0]    = (isfinite(source->psfMag)) ? pow(10.0, -0.4*source->psfMag) : NAN;
    281         dPAR[PM_PAR_I0]   = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->errMag : NAN;
     281        dPAR[PM_PAR_I0]   = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->psfMagErr : NAN;
    282282
    283283        pmPSF_AxesToModel (PAR, axes);
  • trunk/psModules/src/objects/pmSourceIO_CMF_PS1_SV1.c

    r31153 r31451  
    125125        psMetadataAdd (row, PS_LIST_TAIL, "PLTSCALE",         PS_DATA_F32, "plate scale at source (arcsec/pixel)",       outputs.pltScale);
    126126        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG",     PS_DATA_F32, "PSF fit instrumental magnitude",             source->psfMag);
    127         psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude",        source->errMag);
     127        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude",        source->psfMagErr);
    128128        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX",    PS_DATA_F32, "PSF fit instrumental flux (counts)",         source->psfFlux);
    129129        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX_SIG",PS_DATA_F32, "Sigma of PSF instrumental flux",             source->psfFluxErr);
     
    273273        // XXX use these to determine PAR[PM_PAR_I0]?
    274274        source->psfMag    = psMetadataLookupF32 (&status, row, "PSF_INST_MAG");
    275         source->errMag    = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG");
     275        source->psfMagErr    = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG");
    276276        source->apMag     = psMetadataLookupF32 (&status, row, "AP_MAG");
    277277
    278278        // XXX this scaling is incorrect: does not include the 2 \pi AREA factor
    279279        PAR[PM_PAR_I0]    = (isfinite(source->psfMag)) ? pow(10.0, -0.4*source->psfMag) : NAN;
    280         dPAR[PM_PAR_I0]   = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->errMag : NAN;
     280        dPAR[PM_PAR_I0]   = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->psfMagErr : NAN;
    281281
    282282        pmPSF_AxesToModel (PAR, axes);
     
    720720      sprintf (keyword1, "RMIN_%02d", i);
    721721      sprintf (keyword2, "RMAX_%02d", i);
    722       psMetadataAddF32 (imageHeader, PS_LIST_TAIL, keyword1, PS_META_REPLACE, "min radius for SB profile", radMin->data.F32[i]);
    723       psMetadataAddF32 (imageHeader, PS_LIST_TAIL, keyword2, PS_META_REPLACE, "min radius for SB profile", radMax->data.F32[i]);
     722      psMetadataAddF32 (outhead, PS_LIST_TAIL, keyword1, PS_META_REPLACE, "min radius for SB profile", radMin->data.F32[i]);
     723      psMetadataAddF32 (outhead, PS_LIST_TAIL, keyword2, PS_META_REPLACE, "min radius for SB profile", radMax->data.F32[i]);
    724724    }
    725725
  • trunk/psModules/src/objects/pmSourceIO_CMF_PS1_V1.c

    r31153 r31451  
    118118        psMetadataAdd (row, PS_LIST_TAIL, "PLTSCALE",         PS_DATA_F32, "plate scale at source (arcsec/pixel)",       outputs.pltScale);
    119119        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG",     PS_DATA_F32, "PSF fit instrumental magnitude",             source->psfMag);
    120         psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude",        source->errMag);
     120        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude",        source->psfMagErr);
    121121        psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG",           PS_DATA_F32, "magnitude in standard aperture",             source->apMag);
    122122        psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG_RADIUS",    PS_DATA_F32, "radius used for aperture mags",              outputs.apRadius);
     
    241241        // XXX use these to determine PAR[PM_PAR_I0]?
    242242        source->psfMag    = psMetadataLookupF32 (&status, row, "PSF_INST_MAG");
    243         source->errMag    = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG");
     243        source->psfMagErr    = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG");
    244244        source->apMag     = psMetadataLookupF32 (&status, row, "AP_MAG");
    245245
    246246        // XXX this scaling is incorrect: does not include the 2 \pi AREA factor
    247247        PAR[PM_PAR_I0]    = (isfinite(source->psfMag)) ? pow(10.0, -0.4*source->psfMag) : NAN;
    248         dPAR[PM_PAR_I0]   = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->errMag : NAN;
     248        dPAR[PM_PAR_I0]   = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->psfMagErr : NAN;
    249249
    250250        pmPSF_AxesToModel (PAR, axes);
  • trunk/psModules/src/objects/pmSourceIO_CMF_PS1_V2.c

    r31153 r31451  
    116116        psMetadataAdd (row, PS_LIST_TAIL, "PLTSCALE",         PS_DATA_F32, "plate scale at source (arcsec/pixel)",       outputs.pltScale);
    117117        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG",     PS_DATA_F32, "PSF fit instrumental magnitude",             source->psfMag);
    118         psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude",        source->errMag);
     118        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude",        source->psfMagErr);
    119119        psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG",           PS_DATA_F32, "magnitude in standard aperture",             source->apMag);
    120120        psMetadataAdd (row, PS_LIST_TAIL, "AP_MAG_RADIUS",    PS_DATA_F32, "radius used for aperture mags",              outputs.apRadius);
     
    247247        // XXX use these to determine PAR[PM_PAR_I0]?
    248248        source->psfMag    = psMetadataLookupF32 (&status, row, "PSF_INST_MAG");
    249         source->errMag    = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG");
     249        source->psfMagErr    = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG");
    250250        source->apMag     = psMetadataLookupF32 (&status, row, "AP_MAG");
    251251
    252252        // XXX this scaling is incorrect: does not include the 2 \pi AREA factor
    253253        PAR[PM_PAR_I0]    = (isfinite(source->psfMag)) ? pow(10.0, -0.4*source->psfMag) : NAN;
    254         dPAR[PM_PAR_I0]   = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->errMag : NAN;
     254        dPAR[PM_PAR_I0]   = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->psfMagErr : NAN;
    255255
    256256        pmPSF_AxesToModel (PAR, axes);
  • trunk/psModules/src/objects/pmSourceIO_CMF_PS1_V3.c

    r31153 r31451  
    116116        psMetadataAdd (row, PS_LIST_TAIL, "PLTSCALE",         PS_DATA_F32, "plate scale at source (arcsec/pixel)",       outputs.pltScale);
    117117        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG",     PS_DATA_F32, "PSF fit instrumental magnitude",             source->psfMag);
    118         psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude",        source->errMag);
     118        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude",        source->psfMagErr);
    119119        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX",    PS_DATA_F32, "PSF fit instrumental flux (counts)",         source->psfFlux);
    120120        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_FLUX_SIG",PS_DATA_F32, "Sigma of PSF instrumental flux",             source->psfFluxErr);
     
    161161        psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX_INNER",  PS_DATA_F32, "Kron Flux (in 2.5 R1)",                      moments.Kinner);
    162162        psMetadataAdd (row, PS_LIST_TAIL, "KRON_FLUX_OUTER",  PS_DATA_F32, "Kron Flux (in 2.5 R1)",                      moments.Kouter);
     163
     164        // Do NOT write these : not consistent with the definition of PS1_V3 in Ohana/src/libautocode/dev/cmf-ps1-v3.d
    163165        // psMetadataAdd (row, PS_LIST_TAIL, "KRON_CORE_FLUX",   PS_DATA_F32, "Kron Flux (in 1.0 R1)",                      moments.KronCore);
    164         // psMetadataAdd (row, PS_LIST_TAIL, "KRON_CORE_ERROR",  PS_DATA_F32, "Kron Error (in 1.0 R1)",                     moments.KronCoreErr);
     166        // psMetadataAdd (row, PS_LIST_TAIL, "KRON_CORE_ERROR",  PS_DATA_F32, "Kron Error (in 1.0 R1)",                     moments.KronCoreErr);
    165167        psMetadataAdd (row, PS_LIST_TAIL, "FLAGS",            PS_DATA_U32, "psphot analysis flags",                      source->mode);
    166168        psMetadataAdd (row, PS_LIST_TAIL, "FLAGS2",           PS_DATA_U32, "psphot analysis flags",                      source->mode2);
     
    270272        // XXX use these to determine PAR[PM_PAR_I0]?
    271273        source->psfMag    = psMetadataLookupF32 (&status, row, "PSF_INST_MAG");
    272         source->errMag    = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG");
     274        source->psfMagErr    = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG");
    273275        source->apMag     = psMetadataLookupF32 (&status, row, "AP_MAG");
    274276
    275277        // XXX this scaling is incorrect: does not include the 2 \pi AREA factor
    276278        PAR[PM_PAR_I0]    = (isfinite(source->psfMag)) ? pow(10.0, -0.4*source->psfMag) : NAN;
    277         dPAR[PM_PAR_I0]   = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->errMag : NAN;
     279        dPAR[PM_PAR_I0]   = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->psfMagErr : NAN;
    278280
    279281        pmPSF_AxesToModel (PAR, axes);
     
    292294
    293295        // we no longer sort by S/N, only flux
    294         // if (isfinite (source->errMag) && (source->errMag > 0.0)) {
    295         //   source->peak->SN = 1.0 / source->errMag;
     296        // if (isfinite (source->psfMagErr) && (source->psfMagErr > 0.0)) {
     297        //   source->peak->SN = 1.0 / source->psfMagErr;
    296298        // } else {
    297299        //   source->peak->SN = sqrt(source->peak->flux); // an alternate proxy: various functions sort by peak S/N
  • trunk/psModules/src/objects/pmSourceIO_CMP.c

    r29004 r31451  
    137137        axes = pmPSF_ModelToAxes (PAR, 20.0);
    138138
    139         float errMag = isfinite(source->errMag) ? source->errMag : 999;
     139        float psfMagErr = isfinite(source->psfMagErr) ? source->psfMagErr : 999;
    140140
    141141        psLineInit (line);
     
    143143        psLineAdd (line, "%6.1f ",  PAR[PM_PAR_YPOS]);
    144144        psLineAdd (line, "%6.3f ",  PS_MIN (99.0, source->psfMag + ZERO_POINT));
    145         psLineAdd (line, "%03d ",   PS_MIN (999, (int)errMag));
     145        psLineAdd (line, "%03d ",   PS_MIN (999, (int)psfMagErr));
    146146        psLineAdd (line, "%2d ",    type);
    147147        psLineAdd (line, "%3.1f ",  lsky);
     
    280280            source->psfMag = atof (array->data[2]);
    281281            source->extMag = atof (array->data[6]);
    282             source->errMag = atof (array->data[3]) / 1000.0;
     282            source->psfMagErr = atof (array->data[3]) / 1000.0;
    283283            source->apMag  = atof (array->data[7]);
    284284            axes.major     = atof (array->data[8]);
  • trunk/psModules/src/objects/pmSourceIO_PS1_CAL_0.c

    r31153 r31451  
    7171    psF32 xPos, yPos;
    7272    psF32 xErr, yErr;
    73     psF32 errMag, chisq;
     73    psF32 psfMagErr, chisq;
    7474
    7575    pmChip *chip = readout->parent->parent;
     
    121121            chisq = model->chisq;
    122122
    123             // need to determine the PSF photometry error: source->errMag is the error on the 'best' model mag.
    124             errMag = model->dparams->data.F32[PM_PAR_I0] / model->params->data.F32[PM_PAR_I0];
     123            // need to determine the PSF photometry error: source->psfMagErr is the error on the 'best' model mag.
     124            psfMagErr = model->dparams->data.F32[PM_PAR_I0] / model->params->data.F32[PM_PAR_I0];
    125125        } else {
    126126            xPos = source->peak->xf;
     
    132132            axes.theta = NAN;
    133133            chisq = NAN;
    134             errMag = NAN;
     134            psfMagErr = NAN;
    135135        }
    136136
     
    167167        psMetadataAdd (row, PS_LIST_TAIL, "Y_PSF_SIG",        PS_DATA_F32, "Sigma in PSF y coordinate",                  yErr);
    168168        psMetadataAdd (row, PS_LIST_TAIL, "CAL_PSF_MAG",      PS_DATA_F32, "Calibrated Magnitude from PSF Fit",          calMag);
    169         psMetadataAdd (row, PS_LIST_TAIL, "CAL_PSF_MAG_SIG",  PS_DATA_F32, "Calibrated Magnitude Error",                 errMag);
     169        psMetadataAdd (row, PS_LIST_TAIL, "CAL_PSF_MAG_SIG",  PS_DATA_F32, "Calibrated Magnitude Error",                 psfMagErr);
    170170        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG",     PS_DATA_F32, "PSF fit instrumental magnitude",             source->psfMag);
    171         psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude",        errMag);
     171        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude",        psfMagErr);
    172172        psMetadataAdd (row, PS_LIST_TAIL, "PEAK_FLUX_AS_MAG", PS_DATA_F32, "Peak flux expressed as magnitude",           peakMag);
    173173        psMetadataAdd (row, PS_LIST_TAIL, "SKY",              PS_DATA_F32, "Sky level",                                  source->sky);
     
    284284        // XXX use these to determine PAR[PM_PAR_I0]?
    285285        source->psfMag    = psMetadataLookupF32 (&status, row, "PSF_INST_MAG");
    286         source->errMag    = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG");
     286        source->psfMagErr    = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG");
    287287        PAR[PM_PAR_I0]    = (isfinite(source->psfMag)) ? pow(10.0, -0.4*source->psfMag) : NAN;
    288         dPAR[PM_PAR_I0]   = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->errMag : NAN;
     288        dPAR[PM_PAR_I0]   = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->psfMagErr : NAN;
    289289
    290290        pmPSF_AxesToModel (PAR, axes);
  • trunk/psModules/src/objects/pmSourceIO_PS1_DEV_0.c

    r31153 r31451  
    113113        psMetadataAdd (row, PS_LIST_TAIL, "Y_PSF_SIG",        PS_DATA_F32, "Sigma in PSF y coordinate",                  yErr);
    114114        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG",     PS_DATA_F32, "PSF fit instrumental magnitude",             PS_MIN (99.0, source->psfMag));
    115         psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude",        PS_MIN (99.0, source->errMag));
     115        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude",        PS_MIN (99.0, source->psfMagErr));
    116116        psMetadataAdd (row, PS_LIST_TAIL, "PEAK_FLUX_AS_MAG", PS_DATA_F32, "Peak flux expressed as magnitude",           PS_MIN (99.0, peakMag));
    117117        psMetadataAdd (row, PS_LIST_TAIL, "SKY",              PS_DATA_F32, "Sky level",                                  source->sky);
     
    212212        // XXX use these to determine PAR[PM_PAR_I0]?
    213213        source->psfMag    = psMetadataLookupF32 (&status, row, "PSF_INST_MAG");
    214         source->errMag    = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG");
     214        source->psfMagErr    = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG");
    215215
    216216        pmPSF_AxesToModel (PAR, axes);
  • trunk/psModules/src/objects/pmSourceIO_PS1_DEV_1.c

    r31153 r31451  
    7070    psF32 xPos, yPos;
    7171    psF32 xErr, yErr;
    72     psF32 errMag, chisq;
     72    psF32 psfMagErr, chisq;
    7373
    7474    // let's write these out in S/N order
     
    103103            chisq = model->chisq;
    104104
    105             // need to determine the PSF photometry error: source->errMag is the error on the 'best' model mag.
    106             errMag = model->dparams->data.F32[PM_PAR_I0] / model->params->data.F32[PM_PAR_I0];
     105            // need to determine the PSF photometry error: source->psfMagErr is the error on the 'best' model mag.
     106            psfMagErr = model->dparams->data.F32[PM_PAR_I0] / model->params->data.F32[PM_PAR_I0];
    107107        } else {
    108108            xPos = source->peak->xf;
     
    114114            axes.theta = NAN;
    115115            chisq = NAN;
    116             errMag = NAN;
     116            psfMagErr = NAN;
    117117        }
    118118
     
    128128        psMetadataAdd (row, PS_LIST_TAIL, "Y_PSF_SIG",        PS_DATA_F32, "Sigma in PSF y coordinate",                  yErr);
    129129        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG",     PS_DATA_F32, "PSF fit instrumental magnitude",             source->psfMag);
    130         psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude",        errMag);
     130        psMetadataAdd (row, PS_LIST_TAIL, "PSF_INST_MAG_SIG", PS_DATA_F32, "Sigma of PSF instrumental magnitude",        psfMagErr);
    131131        psMetadataAdd (row, PS_LIST_TAIL, "PEAK_FLUX_AS_MAG", PS_DATA_F32, "Peak flux expressed as magnitude",           peakMag);
    132132        psMetadataAdd (row, PS_LIST_TAIL, "SKY",              PS_DATA_F32, "Sky level",                                  source->sky);
     
    253253        // XXX use these to determine PAR[PM_PAR_I0]?
    254254        source->psfMag    = psMetadataLookupF32 (&status, row, "PSF_INST_MAG");
    255         source->errMag    = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG");
     255        source->psfMagErr    = psMetadataLookupF32 (&status, row, "PSF_INST_MAG_SIG");
    256256        PAR[PM_PAR_I0]    = (isfinite(source->psfMag)) ? pow(10.0, -0.4*source->psfMag) : NAN;
    257         dPAR[PM_PAR_I0]   = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->errMag : NAN;
     257        dPAR[PM_PAR_I0]   = (isfinite(source->psfMag)) ? PAR[PM_PAR_I0] * source->psfMagErr : NAN;
    258258
    259259        pmPSF_AxesToModel (PAR, axes);
  • trunk/psModules/src/objects/pmSourceIO_RAW.c

    r31153 r31451  
    110110        fprintf (f, "%7.1f %7.1f  %7.1f %8.4f  %7.4f %7.4f  ",
    111111                 PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], source->sky,
    112                  source->psfMag, source->errMag, dPos);
     112                 source->psfMag, source->psfMagErr, dPos);
    113113
    114114        for (j = 4; j < model->params->n; j++) {
     
    174174        fprintf (f, "%7.1f %7.1f  %7.1f %8.4f  %7.4f %7.4f  ",
    175175                 PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], source->sky,
    176                  source->extMag, source->errMag, dPos);
     176                 source->extMag, source->psfMagErr, dPos);
    177177
    178178        for (j = 4; j < model->params->n; j++) {
  • trunk/psModules/src/objects/pmSourceIO_SMPDATA.c

    r31153 r31451  
    106106        psMetadataAdd (row, PS_LIST_TAIL, "Y_PIX",   PS_DATA_F32, "", yPos);
    107107        psMetadataAdd (row, PS_LIST_TAIL, "MAG_RAW", PS_DATA_F32, "", PS_MIN (99.0, source->psfMag + ZERO_POINT));
    108         psMetadataAdd (row, PS_LIST_TAIL, "MAG_ERR", PS_DATA_F32, "", PS_MIN (999, 1000*source->errMag));
     108        psMetadataAdd (row, PS_LIST_TAIL, "MAG_ERR", PS_DATA_F32, "", PS_MIN (999, 1000*source->psfMagErr));
    109109        psMetadataAdd (row, PS_LIST_TAIL, "MAG_GAL", PS_DATA_F32, "", PS_MIN (99.0, source->extMag + ZERO_POINT));
    110110        psMetadataAdd (row, PS_LIST_TAIL, "MAG_AP",  PS_DATA_F32, "", PS_MIN (99.0, source->apMag + ZERO_POINT));
     
    194194        source->psfMag = psMetadataLookupF32 (&status, row, "MAG_RAW") - ZERO_POINT;
    195195        source->extMag = psMetadataLookupF32 (&status, row, "MAG_GAL") - ZERO_POINT;
    196         source->errMag = psMetadataLookupF32 (&status, row, "MAG_ERR") * 0.001;
     196        source->psfMagErr = psMetadataLookupF32 (&status, row, "MAG_ERR") * 0.001;
    197197        source->apMag  = psMetadataLookupF32 (&status, row, "MAG_AP")  - ZERO_POINT;
    198198
  • trunk/psModules/src/objects/pmSourceIO_SX.c

    r29004 r31451  
    8888        psLineAdd (line, "%11.3f", PAR[PM_PAR_YPOS]);
    8989        psLineAdd (line, "%9.4f",  source->psfMag);
    90         psLineAdd (line, "%9.4f",  source->errMag);
     90        psLineAdd (line, "%9.4f",  source->psfMagErr);
    9191        psLineAdd (line, "%13.4f", source->sky);
    9292        psLineAdd (line, "%9.2f",  axes.major);
  • trunk/psModules/src/objects/pmSourceMasks.h

    r31153 r31451  
    1414    PM_SOURCE_MODE_PSFSTAR          = 0x00000040, ///< Source used to define PSF model
    1515    PM_SOURCE_MODE_SATSTAR          = 0x00000080, ///< Source model peak is above saturation
    16     PM_SOURCE_MODE_BLEND            = 0x00000100, ///< Source is a blend with other sourcers
     16    PM_SOURCE_MODE_BLEND            = 0x00000100, ///< Source is a blend with other sources
    1717    PM_SOURCE_MODE_EXTERNAL         = 0x00000200, ///< Source based on supplied input position
    1818    PM_SOURCE_MODE_BADPSF           = 0x00000400, ///< Failed to get good estimate of object's PSF
     
    5151    PM_SOURCE_MODE2_ON_BURNTOOL      = 0x00000020, ///< > 25% of (PSF-weighted) pixels land on burntool
    5252    PM_SOURCE_MODE2_ON_CONVPOOR      = 0x00000040, ///< > 25% of (PSF-weighted) pixels land on convpoor
     53
     54    PM_SOURCE_MODE2_PASS1_SRC        = 0x00000080, ///< source detected in first pass analysis
    5355} pmSourceMode2;
    5456
  • trunk/psModules/src/objects/pmSourceMatch.c

    r29004 r31451  
    8888        pmSource *source = sources->data[i]; // Source of interest
    8989        if (!source || (source->mode & SOURCE_MASK) || !isfinite(source->psfMag) ||
    90             !isfinite(source->errMag) || source->psfMag > SOURCE_FAINTEST) {
     90            !isfinite(source->psfMagErr) || source->psfMag > SOURCE_FAINTEST) {
    9191            continue;
    9292        }
     
    102102        (*y)->data.F32[num] = ySrc;
    103103        (*mag)->data.F32[num] = source->psfMag;
    104         (*magErr)->data.F32[num] = source->errMag;
     104        (*magErr)->data.F32[num] = source->psfMagErr;
    105105        (*indices)->data.S32[num] = i;
    106106        num++;
  • trunk/psModules/src/objects/pmSourceMoments.c

    r31153 r31451  
    6666// if mode & EXTERNAL or mode2 & MATCHED, do not re-calculate the centroid (use peak as centroid)
    6767
    68 bool pmSourceMoments(pmSource *source, psF32 radius, psF32 sigma, psF32 minSN, psImageMaskType maskVal)
     68bool pmSourceMoments(pmSource *source, float radius, float sigma, float minSN, float minKronRadius, psImageMaskType maskVal)
    6969{
    7070    PS_ASSERT_PTR_NON_NULL(source, false);
     
    7474
    7575    // this function assumes the sky has been well-subtracted for the image
    76     psF32 sky = 0.0;
     76    float sky = 0.0;
    7777
    7878    if (source->moments == NULL) {
     
    8080    }
    8181
    82     psF32 Sum = 0.0;
    83     psF32 Var = 0.0;
    84     psF32 SumCore = 0.0;
    85     psF32 VarCore = 0.0;
    86     psF32 R2 = PS_SQR(radius);
    87     psF32 minSN2 = PS_SQR(minSN);
    88     psF32 rsigma2 = 0.5 / PS_SQR(sigma);
     82    float Sum = 0.0;
     83    float Var = 0.0;
     84    float SumCore = 0.0;
     85    float VarCore = 0.0;
     86    float R2 = PS_SQR(radius);
     87    float minSN2 = PS_SQR(minSN);
     88    float rsigma2 = 0.5 / PS_SQR(sigma);
    8989
    9090    // a note about coordinates: coordinates of objects throughout psphot refer to the primary
     
    109109    // Xn  = SUM (x - xc)^n * (z - sky)
    110110
    111     psF32 RF = 0.0;
    112     psF32 RH = 0.0;
    113     psF32 RS = 0.0;
    114     psF32 XX = 0.0;
    115     psF32 XY = 0.0;
    116     psF32 YY = 0.0;
    117     psF32 XXX = 0.0;
    118     psF32 XXY = 0.0;
    119     psF32 XYY = 0.0;
    120     psF32 YYY = 0.0;
    121     psF32 XXXX = 0.0;
    122     psF32 XXXY = 0.0;
    123     psF32 XXYY = 0.0;
    124     psF32 XYYY = 0.0;
    125     psF32 YYYY = 0.0;
     111    float RFW = 0.0;
     112    float RHW = 0.0;
     113
     114    float RF = 0.0;
     115    float RH = 0.0;
     116    float RS = 0.0;
     117    float XX = 0.0;
     118    float XY = 0.0;
     119    float YY = 0.0;
     120    float XXX = 0.0;
     121    float XXY = 0.0;
     122    float XYY = 0.0;
     123    float YYY = 0.0;
     124    float XXXX = 0.0;
     125    float XXXY = 0.0;
     126    float XXYY = 0.0;
     127    float XYYY = 0.0;
     128    float YYYY = 0.0;
    126129
    127130    Sum = 0.0;  // the second pass may include slightly different pixels, re-determine Sum
     131
     132    // float dX = source->moments->Mx - source->peak->xf;
     133    // float dY = source->moments->My - source->peak->yf;
     134    // float dR = hypot(dX, dY);
     135    // float Xo = (dR < 2.0) ? source->moments->Mx : source->peak->xf;
     136    // float Yo = (dR < 2.0) ? source->moments->My : source->peak->yf;
     137    float Xo = source->moments->Mx;
     138    float Yo = source->moments->My;
    128139
    129140    // center of mass in subimage.  Note: the calculation below uses pixel index, so we correct
    130141    // xCM, yCM from pixel coords to pixel index here.
    131     psF32 xCM = source->moments->Mx - 0.5 - source->pixels->col0; // coord of peak in subimage
    132     psF32 yCM = source->moments->My - 0.5 - source->pixels->row0; // coord of peak in subimage
     142    float xCM = Xo - 0.5 - source->pixels->col0; // coord of peak in subimage
     143    float yCM = Yo - 0.5 - source->pixels->row0; // coord of peak in subimage
    133144
    134145    for (psS32 row = 0; row < source->pixels->numRows ; row++) {
    135146
    136         psF32 yDiff = row - yCM;
     147        float yDiff = row - yCM;
    137148        if (fabs(yDiff) > radius) continue;
    138149
    139         psF32 *vPix = source->pixels->data.F32[row];
    140         psF32 *vWgt = source->variance->data.F32[row];
     150        float *vPix = source->pixels->data.F32[row];
     151        float *vWgt = source->variance->data.F32[row];
     152
    141153        psImageMaskType  *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[row];
     154        // psImageMaskType  *vMsk = (source->maskView == NULL) ? NULL : source->maskView->data.PS_TYPE_IMAGE_MASK_DATA[row];
    142155
    143156        for (psS32 col = 0; col < source->pixels->numCols ; col++, vPix++, vWgt++) {
     
    151164            if (isnan(*vPix)) continue;
    152165
    153             psF32 xDiff = col - xCM;
     166            float xDiff = col - xCM;
    154167            if (fabs(xDiff) > radius) continue;
    155168
    156169            // radius is just a function of (xDiff, yDiff)
    157             psF32 r2  = PS_SQR(xDiff) + PS_SQR(yDiff);
     170            float r2  = PS_SQR(xDiff) + PS_SQR(yDiff);
    158171            if (r2 > R2) continue;
    159172
    160             psF32 fDiff = *vPix - sky;
    161             psF32 pDiff = fDiff;
    162             psF32 wDiff = *vWgt;
     173            float fDiff = *vPix - sky;
     174            float pDiff = fDiff;
     175            float wDiff = *vWgt;
    163176
    164177            // skip pixels below specified significance level.  this is allowed, but should be
     
    171184            // weighting over weights the sky for faint sources
    172185            if (sigma > 0.0) {
    173                 psF32 z = r2 * rsigma2;
     186                float z = r2 * rsigma2;
    174187                assert (z >= 0.0);
    175                 psF32 weight  = exp(-z);
     188                float weight  = exp(-z);
    176189
    177190                wDiff *= weight;
     
    182195
    183196            // Kron Flux uses the 1st radial moment (NOT Gaussian windowed?)
    184             psF32 r = sqrt(r2);
    185             psF32 rf = r * fDiff;
    186             psF32 rh = sqrt(r) * fDiff;
    187             psF32 rs = fDiff;
    188 
    189             psF32 x = xDiff * pDiff;
    190             psF32 y = yDiff * pDiff;
    191 
    192             psF32 xx = xDiff * x;
    193             psF32 xy = xDiff * y;
    194             psF32 yy = yDiff * y;
    195 
    196             psF32 xxx = xDiff * xx / r;
    197             psF32 xxy = xDiff * xy / r;
    198             psF32 xyy = xDiff * yy / r;
    199             psF32 yyy = yDiff * yy / r;
    200 
    201             psF32 xxxx = xDiff * xxx / r2;
    202             psF32 xxxy = xDiff * xxy / r2;
    203             psF32 xxyy = xDiff * xyy / r2;
    204             psF32 xyyy = xDiff * yyy / r2;
    205             psF32 yyyy = yDiff * yyy / r2;
     197            float r = sqrt(r2);
     198            float rf = r * fDiff;
     199            float rh = sqrt(r) * fDiff;
     200            float rs = fDiff;
     201
     202            float rfw = r * pDiff;
     203            float rhw = sqrt(r) * pDiff;
     204
     205            float x = xDiff * pDiff;
     206            float y = yDiff * pDiff;
     207
     208            float xx = xDiff * x;
     209            float xy = xDiff * y;
     210            float yy = yDiff * y;
     211
     212            float xxx = xDiff * xx / r;
     213            float xxy = xDiff * xy / r;
     214            float xyy = xDiff * yy / r;
     215            float yyy = yDiff * yy / r;
     216
     217            float xxxx = xDiff * xxx / r2;
     218            float xxxy = xDiff * xxy / r2;
     219            float xxyy = xDiff * xyy / r2;
     220            float xyyy = xDiff * yyy / r2;
     221            float yyyy = yDiff * yyy / r2;
    206222
    207223            RF  += rf;
    208224            RH  += rh;
    209225            RS  += rs;
     226
     227            RFW  += rfw;
     228            RHW  += rhw;
    210229
    211230            XX  += xx;
     
    244263    source->moments->Myyyy = YYYY/Sum;
    245264
    246     // Calculate the Kron magnitude (make this block optional?)
    247     float radKinner = 1.0*source->moments->Mrf;
    248     float radKron   = 2.5*source->moments->Mrf;
    249     float radKouter = 4.0*source->moments->Mrf;
     265    // if Mrf (first radial moment) is very small, we are getting into low-significance
     266    // territory.  saturate at minKronRadius.  conversely, if Mrf is > radius, we are clearly
     267    // making an error.  saturate at radius.
     268    float kronRefRadius = MIN(radius, MAX(minKronRadius, source->moments->Mrf));
     269
     270    float radKinner = 1.0*kronRefRadius;
     271    float radKron   = 2.5*kronRefRadius;
     272    float radKouter = 4.0*kronRefRadius;
    250273
    251274    int nKronPix = 0;
     
    259282    for (psS32 row = 0; row < source->pixels->numRows ; row++) {
    260283
    261         psF32 yDiff = row - yCM;
     284        float yDiff = row - yCM;
    262285        if (fabs(yDiff) > radKouter) continue;
    263286
    264         psF32 *vPix = source->pixels->data.F32[row];
    265         psF32 *vWgt = source->variance->data.F32[row];
     287        float *vPix = source->pixels->data.F32[row];
     288        float *vWgt = source->variance->data.F32[row];
     289
    266290        psImageMaskType  *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[row];
     291        // psImageMaskType  *vMsk = (source->maskView == NULL) ? NULL : source->maskView->data.PS_TYPE_IMAGE_MASK_DATA[row];
    267292
    268293        for (psS32 col = 0; col < source->pixels->numCols ; col++, vPix++, vWgt++) {
     
    276301            if (isnan(*vPix)) continue;
    277302
    278             psF32 xDiff = col - xCM;
     303            float xDiff = col - xCM;
    279304            if (fabs(xDiff) > radKouter) continue;
    280305
    281306            // radKron is just a function of (xDiff, yDiff)
    282             psF32 r2  = PS_SQR(xDiff) + PS_SQR(yDiff);
    283 
    284             psF32 pDiff = *vPix - sky;
    285             psF32 wDiff = *vWgt;
     307            float r2  = PS_SQR(xDiff) + PS_SQR(yDiff);
     308
     309            float pDiff = *vPix - sky;
     310            float wDiff = *vWgt;
    286311
    287312            // skip pixels below specified significance level.  this is allowed, but should be
     
    290315            if (PS_SQR(pDiff) < minSN2*wDiff) continue;
    291316
    292             psF32 r  = sqrt(r2);
     317            float r  = sqrt(r2);
    293318            if (r < radKron) {
    294319                Sum += pDiff;
     
    335360}
    336361
    337 bool pmSourceMomentsGetCentroid(pmSource *source, psF32 radius, psF32 sigma, psF32 minSN, psImageMaskType maskVal, float xGuess, float yGuess) {
     362bool pmSourceMomentsGetCentroid(pmSource *source, float radius, float sigma, float minSN, psImageMaskType maskVal, float xGuess, float yGuess) {
    338363
    339364    // First Pass: calculate the first moments (these are subtracted from the coordinates below)
     
    342367    // .. etc
    343368
    344     psF32 sky = 0.0;
    345 
    346     psF32 peakPixel = -PS_MAX_F32;
     369    float sky = 0.0;
     370
     371    float peakPixel = -PS_MAX_F32;
    347372    psS32 numPixels = 0;
    348     psF32 Sum = 0.0;
    349     psF32 Var = 0.0;
    350     psF32 X1 = 0.0;
    351     psF32 Y1 = 0.0;
    352     psF32 R2 = PS_SQR(radius);
    353     psF32 minSN2 = PS_SQR(minSN);
    354     psF32 rsigma2 = 0.5 / PS_SQR(sigma);
     373    float Sum = 0.0;
     374    float Var = 0.0;
     375    float X1 = 0.0;
     376    float Y1 = 0.0;
     377    float R2 = PS_SQR(radius);
     378    float minSN2 = PS_SQR(minSN);
     379    float rsigma2 = 0.5 / PS_SQR(sigma);
    355380
    356381    float xPeak = xGuess - source->pixels->col0; // coord of peak in subimage
     
    358383
    359384    // we are guaranteed to have a valid pixel and variance at this location (right? right?)
    360     // psF32 weightNorm = source->pixels->data.F32[yPeak][xPeak] / sqrt (source->variance->data.F32[yPeak][xPeak]);
     385    // float weightNorm = source->pixels->data.F32[yPeak][xPeak] / sqrt (source->variance->data.F32[yPeak][xPeak]);
    361386    // psAssert (isfinite(source->pixels->data.F32[yPeak][xPeak]), "peak must be on valid pixel");
    362387    // psAssert (isfinite(source->variance->data.F32[yPeak][xPeak]), "peak must be on valid pixel");
     
    370395    for (psS32 row = 0; row < source->pixels->numRows ; row++) {
    371396
    372         psF32 yDiff = row + 0.5 - yPeak;
     397        float yDiff = row + 0.5 - yPeak;
    373398        if (fabs(yDiff) > radius) continue;
    374399
    375         psF32 *vPix = source->pixels->data.F32[row];
    376         psF32 *vWgt = source->variance->data.F32[row];
     400        float *vPix = source->pixels->data.F32[row];
     401        float *vWgt = source->variance->data.F32[row];
     402
    377403        psImageMaskType *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[row];
     404        // psImageMaskType *vMsk = (source->maskView == NULL) ? NULL : source->maskView->data.PS_TYPE_IMAGE_MASK_DATA[row];
    378405
    379406        for (psS32 col = 0; col < source->pixels->numCols ; col++, vPix++, vWgt++) {
     
    387414            if (isnan(*vPix)) continue;
    388415
    389             psF32 xDiff = col + 0.5 - xPeak;
     416            float xDiff = col + 0.5 - xPeak;
    390417            if (fabs(xDiff) > radius) continue;
    391418
    392419            // radius is just a function of (xDiff, yDiff)
    393             psF32 r2  = PS_SQR(xDiff) + PS_SQR(yDiff);
     420            float r2  = PS_SQR(xDiff) + PS_SQR(yDiff);
    394421            if (r2 > R2) continue;
    395422
    396             psF32 pDiff = *vPix - sky;
    397             psF32 wDiff = *vWgt;
     423            float pDiff = *vPix - sky;
     424            float wDiff = *vWgt;
    398425
    399426            // skip pixels below specified significance level.  for a PSFs, this
     
    408435            // weighting over weights the sky for faint sources
    409436            if (sigma > 0.0) {
    410                 psF32 z  = r2*rsigma2;
     437                float z  = r2*rsigma2;
    411438                assert (z >= 0.0);
    412                 psF32 weight  = exp(-z);
     439                float weight  = exp(-z);
    413440
    414441                wDiff *= weight;
     
    419446            Sum += pDiff;
    420447
    421             psF32 xWght = xDiff * pDiff;
    422             psF32 yWght = yDiff * pDiff;
     448            float xWght = xDiff * pDiff;
     449            float yWght = yDiff * pDiff;
    423450
    424451            X1  += xWght;
     
    477504    return true;
    478505}
     506
     507float pmSourceMinKronRadius(psArray *sources, float PSF_SN_LIM) {
     508
     509    psVector *radii = psVectorAllocEmpty(100, PS_TYPE_F32);
     510
     511    for (int i = 0; i < sources->n; i++) {
     512        pmSource *src = sources->data[i]; // Source of interest
     513        if (!src || !src->moments) {
     514            continue;
     515        }
     516
     517        if (src->mode & PM_SOURCE_MODE_BLEND) {
     518            continue;
     519        }
     520
     521        if (!src->moments->nPixels) continue;
     522
     523        if (src->moments->SN < PSF_SN_LIM) continue;
     524
     525        // XXX put in Mxx,Myy cut based on clump location
     526
     527        psVectorAppend(radii, src->moments->Mrf);
     528    }
     529
     530    // find the peak in this image
     531    psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN);
     532
     533    if (!psVectorStats (stats, radii, NULL, NULL, 0)) {
     534        psError(PS_ERR_UNKNOWN, false, "Unable to get image statistics.\n");
     535        psFree(stats);
     536        return NAN;
     537    }
     538
     539    float minRadius = stats->sampleMedian;
     540
     541    psFree(radii);
     542    psFree(stats);
     543    return minRadius;
     544}
     545
  • trunk/psModules/src/objects/pmSourceOutputs.c

    r31153 r31451  
    9898        outputs->xPos = PAR[PM_PAR_XPOS];
    9999        outputs->yPos = PAR[PM_PAR_YPOS];
    100         if (source->mode & PM_SOURCE_MODE_NONLINEAR_FIT) {
     100        if ((source->mode & PM_SOURCE_MODE_NONLINEAR_FIT) && !(source->mode & PM_SOURCE_MODE_EXTMODEL)) {
     101            // we only do non-linear PSF fits for non-extended objects
    101102            outputs->xErr = dPAR[PM_PAR_XPOS];
    102103            outputs->yErr = dPAR[PM_PAR_YPOS];
    103104        } else {
    104             outputs->xErr = fwhmMajor * source->errMag / 2.35;
    105             outputs->yErr = fwhmMinor * source->errMag / 2.35;
     105            outputs->xErr = fwhmMajor * source->psfMagErr / 2.35;
     106            outputs->yErr = fwhmMinor * source->psfMagErr / 2.35;
    106107        }
    107         if (isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXX])) {
     108        if (isfinite(PAR[PM_PAR_SXX]) && isfinite(PAR[PM_PAR_SXY]) && isfinite(PAR[PM_PAR_SYY])) {
    108109            axes = pmPSF_ModelToAxes (PAR, 20.0);
    109110            outputs->psfMajor = axes.major;
     
    125126            outputs->xPos = source->moments->Mx;
    126127            outputs->yPos = source->moments->My;
    127             outputs->xErr = fwhmMajor * source->errMag / 2.35;
    128             outputs->yErr = fwhmMinor * source->errMag / 2.35;
     128            outputs->xErr = fwhmMajor * source->psfMagErr / 2.35;
     129            outputs->yErr = fwhmMinor * source->psfMagErr / 2.35;
    129130        } else {
    130131            outputs->xPos = source->peak->xf;
  • trunk/psModules/src/objects/pmSourcePhotometry.c

    r31153 r31451  
    8282   - apMag  : only if S/N > AP_MIN_SN
    8383   : is optionally corrected for curve-of-growth if:
    84    - the source is a STAR (PSF)
    8584   - the option is selected (mode & PM_SOURCE_PHOT_GROWTH)
    8685   - psfMag : all sources with non-NULL modelPSF
    8786   : is optionally corrected for aperture residual if:
    88    - the source is a STAR (PSF)
    8987   - the option is selected (mode & PM_SOURCE_PHOT_APCORR)
    90 
    9188   - extMag : all sources with non-NULL modelEXT
    9289**/
     
    10097
    10198    int status = false;
    102     bool isPSF;
    10399    float x, y;
    104     float rflux;
    105100    float SN;
    106     pmModel *model;
    107101
    108102    source->psfMag    = NAN;
    109103    source->extMag    = NAN;
    110     source->errMag    = NAN;
     104    source->psfMagErr = NAN;
    111105    source->apMag     = NAN;
    112106    source->apMagRaw  = NAN;
     
    114108    source->apFluxErr = NAN;
    115109
    116     // we must have a valid model
    117     // XXX allow aperture magnitudes for sources without a model
    118     model = pmSourceGetModel (&isPSF, source);
    119     if (model == NULL) {
    120         psTrace ("psModules.objects", 3, "fail mag : no valid model");
     110    // XXXXXX review:
     111    // Select the 'best' model -- this is used for PSF_QF,_PERFECT & ???. isPSF is true if this
     112    // object is a PSF (not extended).  We must have a valid model.  XXX NOTE: allow aperture
     113    // magnitudes for sources without a model
     114
     115    // select the psf model
     116    pmModel *modelPSF = source->modelPSF;
     117    if (modelPSF == NULL) {
     118        psTrace ("psModules.objects", 3, "fail mag : no valid PSF model");
    121119        return false;
    122120    }
    123121
    124     // XXX handle negative flux, low-significance
    125     if (model->dparams->data.F32[PM_PAR_I0] > 0) {
    126         SN = fabs(model->params->data.F32[PM_PAR_I0] / model->dparams->data.F32[PM_PAR_I0]);
    127         source->errMag = 1.0 / SN;
     122    // get the error on the PSF model magnitude
     123    if (modelPSF->dparams->data.F32[PM_PAR_I0] > 0) {
     124        SN = fabs(modelPSF->params->data.F32[PM_PAR_I0] / modelPSF->dparams->data.F32[PM_PAR_I0]);
     125        source->psfMagErr = 1.0 / SN;
    128126    } else {
    129127        SN = NAN;
    130         source->errMag = NAN;
    131     }
    132     x = model->params->data.F32[PM_PAR_XPOS];
    133     y = model->params->data.F32[PM_PAR_YPOS];
     128        source->psfMagErr = NAN;
     129    }
     130    // the source position is used to recenter the aperture for ap photometry
     131    x = modelPSF->params->data.F32[PM_PAR_XPOS];
     132    y = modelPSF->params->data.F32[PM_PAR_YPOS];
    134133
    135134    // measure PSF model photometry
    136     // XXX TEST: do not use flux scale
    137     // XXX NOTE: turn this back on?
    138     if (0 && psf->FluxScale) {
    139         // the source peak pixel is guaranteed to be on the image, and only minimally different from the source center
    140         double fluxScale = pmTrend2DEval (psf->FluxScale, (float)source->peak->x, (float)source->peak->y);
    141         psAssert (isfinite(fluxScale), "how can the flux scale be invalid? source at %d, %d\n", source->peak->x, source->peak->y);
    142         psAssert (fluxScale > 0.0, "how can the flux scale be negative? source at %d, %d\n", source->peak->x, source->peak->y);
    143         source->psfFlux = fluxScale * source->modelPSF->params->data.F32[PM_PAR_I0];
    144         source->psfFluxErr = fluxScale * source->modelPSF->dparams->data.F32[PM_PAR_I0];
    145         source->psfMag = -2.5*log10(source->psfFlux);
    146     } else {
    147         status = pmSourcePhotometryModel (&source->psfMag, &source->psfFlux, source->modelPSF);
    148         source->psfFluxErr = source->psfFlux * (source->modelPSF->dparams->data.F32[PM_PAR_I0] / source->modelPSF->params->data.F32[PM_PAR_I0]);
    149     }
     135    status = pmSourcePhotometryModel (&source->psfMag, &source->psfFlux, modelPSF);
     136    source->psfFluxErr = source->psfFlux * source->psfMagErr;
     137
     138# if (0)
     139    // XXX NOTE: old code to use the flux scale.  test & turn this back on?  if so, need to save with psf model
     140    // the source peak pixel is guaranteed to be on the image, and only minimally different from the source center
     141    double fluxScale = pmTrend2DEval (psf->FluxScale, (float)source->peak->x, (float)source->peak->y);
     142    psAssert (isfinite(fluxScale), "how can the flux scale be invalid? source at %d, %d\n", source->peak->x, source->peak->y);
     143    psAssert (fluxScale > 0.0, "how can the flux scale be negative? source at %d, %d\n", source->peak->x, source->peak->y);
     144    source->psfFlux = fluxScale * modelPSF->params->data.F32[PM_PAR_I0];
     145    source->psfFluxErr = fluxScale * modelPSF->dparams->data.F32[PM_PAR_I0];
     146    source->psfMag = -2.5*log10(source->psfFlux);
     147# endif
    150148
    151149    if (mode == PM_SOURCE_PHOT_PSFONLY) {
     
    153151    }
    154152
     153    // get the EXT model photometry (all EXT models)
    155154    // if we have a collection of model fits, check if one of them is a pointer to modelEXT
    156155    if (source->modelFits) {
     
    173172    }
    174173
    175     // for PSFs, correct both apMag and psfMag to same system, consistent with infinite flux star in aperture RADIUS
    176     // XXX add a flag for "ap_mag is corrected?"
    177     if ((mode & PM_SOURCE_PHOT_APCORR) && isPSF && psf && psf->ApTrend) {
     174    // Correct psfMag to match aperture magnitude system (NOTE : Growth curve is already applied to ApTrend)
     175    if ((mode & PM_SOURCE_PHOT_APCORR) && psf && psf->ApTrend) {
    178176        // the source peak pixel is guaranteed to be on the image, and only minimally different from the source center
    179177        double apTrend = pmTrend2DEval (psf->ApTrend, (float)source->peak->x, (float)source->peak->y);
    180178        source->psfMag += apTrend;
    181     }
    182 
    183     // measure the contribution of included pixels
     179        source->psfFlux *= pow(10.0, -0.4*apTrend);
     180        source->psfFluxErr *= pow(10.0, -0.4*apTrend);
     181    }
     182
     183    // measure the contribution of included pixels to the PSF model fit
    184184    if (mode & PM_SOURCE_PHOT_WEIGHT) {
    185         pmSourcePixelWeight (source, model, source->maskObj, maskVal, radius);
     185        pmSourcePixelWeight (source, modelPSF, source->maskObj, maskVal, radius);
    186186    }
    187187
     
    217217        y += dy;
    218218
    219         if (!psImageShiftMask(&flux, &mask, source->pixels, source->maskObj, maskVal, dx, dy,
    220                               NAN, 0xff, PS_INTERPOLATE_BIQUADRATIC)) {
     219        // if (!psImageShiftMask(&flux, &mask, source->pixels, source->maskObj, maskVal, dx, dy, NAN, 0xff, PS_INTERPOLATE_LANCZOS2)) {
     220        // if (!psImageShiftMask(&flux, &mask, source->pixels, source->maskObj, maskVal, dx, dy, NAN, 0xff, PS_INTERPOLATE_BIQUADRATIC)) {
     221        if (!psImageShiftMask(&flux, &mask, source->pixels, source->maskObj, maskVal, dx, dy, NAN, 0xff, PS_INTERPOLATE_BILINEAR)) {
    221222            // Not much we can do about it
    222223            psErrorClear();
     
    232233
    233234    // measure object aperture photometry
    234     status = pmSourcePhotometryAperSource (source, model, flux, variance, mask, maskVal);
     235    status = pmSourcePhotometryAperSource (source, modelPSF, flux, variance, mask, maskVal);
    235236    if (!status) {
    236237        psTrace ("psModules.objects", 3, "fail mag : bad Ap Mag");
     
    241242    // detection limits (esp near bright neighbors)
    242243    source->apMag = source->apMagRaw;
    243     if (isfinite (source->apMag) && isPSF && psf) {
     244    if (isfinite (source->apMag) && psf) {
    244245        if (psf->growth && (mode & PM_SOURCE_PHOT_GROWTH)) {
    245             source->apMag = source->apMagRaw + pmGrowthCurveCorrect (psf->growth, source->apRadius);
    246             // XXX correct the apFlux?
    247         }
    248         if (mode & PM_SOURCE_PHOT_APCORR) {
    249             // XXX this should be removed -- we no longer fit for the 'sky bias'
    250             // XXX is this happening???
    251             rflux   = pow (10.0, 0.4*source->psfMag);
    252             psAssert (psf->skyBias == 0.0, "sky bias not 0");
    253             psAssert (psf->skySat == 0.0, "sky sat not 0");
    254             source->apMag -= PS_SQR(source->apRadius)*rflux * psf->skyBias + psf->skySat / rflux;
     246            float apOffset = pmGrowthCurveCorrect (psf->growth, source->apRadius);
     247            source->apMag = source->apMagRaw + apOffset;
     248            source->apFlux *= pow(10.0, -0.4*apOffset);
     249            source->apFluxErr *= pow(10.0, -0.4*apOffset);
    255250        }
    256251    }
     
    309304
    310305    bool status;
    311     status = pmSourcePhotometryAper(&source->apMagRaw, &source->apFlux, &source->apFluxErr, model, image, variance, mask, maskVal);
    312 
     306    int nPix = 0;
     307    status = pmSourcePhotometryAper(&nPix, &source->apMagRaw, &source->apFlux, &source->apFluxErr, model, image, variance, mask, maskVal);
     308    if (status) {
     309        source->mode |= PM_SOURCE_MODE_AP_MAGS;
     310    }
    313311    return status;
    314312}
    315313
    316314// return source aperture magnitude
    317 bool pmSourcePhotometryAper (float *apMag, float *apFluxOut, float *apFluxErr, pmModel *model, psImage *image, psImage *variance, psImage *mask, psImageMaskType maskVal)
     315bool pmSourcePhotometryAper (int *nPixOut, float *apMag, float *apFluxOut, float *apFluxErr, pmModel *model, psImage *image, psImage *variance, psImage *mask, psImageMaskType maskVal)
    318316{
    319317    PS_ASSERT_PTR_NON_NULL(apMag, false);
     
    328326    float apFlux = 0;
    329327    float apFluxVar = 0;
     328    int nPix = 0;
    330329
    331330    if (DO_SKY) {
     
    345344            apFlux += imData[iy][ix] - sky;
    346345            apFluxVar += varData[iy][ix];
    347         }
    348     }
     346            nPix ++;
     347        }
     348    }
     349   
    349350    if (apFluxOut) *apFluxOut = apFlux;
    350351    if (apFluxErr) *apFluxErr = sqrt(fabs(apFluxVar));
     352    if (nPixOut) *nPixOut = nPix;
    351353
    352354    if (apFlux <= 0) {
     
    412414    psImageMaskType maskBad = maskVal;
    413415    maskBad &= ~maskSuspect;
     416
     417    psImageMaskType maskPoor = maskVal | maskSuspect;
    414418
    415419    // measure modelSum and validSum.  this function is applied to a sources' subimage.  the
     
    446450
    447451            // count pixels which are masked with an mask bit (bad or poor)
    448             if (!(mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskVal)) {
     452            if (!(mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskPoor)) {
    449453                notPoorSum += value;
    450454            }
     
    487491
    488492    if (isfinite(source->pixWeightNotBad) && isfinite(source->pixWeightNotPoor)) {
    489         psAssert (source->pixWeightNotBad <= source->pixWeightNotPoor, "error: all bad pixels should also be poor");
     493        psAssert (source->pixWeightNotPoor <= source->pixWeightNotBad, "error: all bad pixels should also be poor");
    490494    }
    491495
  • trunk/psModules/src/objects/pmSourcePhotometry.h

    r31153 r31451  
    4545
    4646bool pmSourcePhotometryAper(
     47    int *nPixOut,
    4748    float *apMag,
    4849    float *apFluxOut,
  • trunk/psModules/src/objects/pmSourceUtils.h

    r14652 r31451  
    3838
    3939/// @}
    40 # endif /* PM_MODEL_CLASS_H */
     40# endif /* PM_SOURCE_UTILS_H */
  • trunk/psModules/src/psmodules.h

    r30623 r31451  
    148148#include <pmModelUtils.h>
    149149#include <pmSourcePhotometry.h>
     150#include <pmGrowthCurveGenerate.h>
    150151#include <pmSourceVisual.h>
    151152#include <pmSourceMatch.h>
  • trunk/psModules/test/objects/tap_pmSource.c

    r31153 r31451  
    9191        ok(isnan(src->psfMag), "pmSourceAlloc() pmSource->psfMag correctly");
    9292        ok(isnan(src->extMag), "pmSourceAlloc() pmSource->extMag correctly");
    93         ok(isnan(src->errMag), "pmSourceAlloc() pmSource->errMag correctly");
     93        ok(isnan(src->psfMagErr), "pmSourceAlloc() pmSource->psfMagErr correctly");
    9494        ok(isnan(src->apMag), "pmSourceAlloc() pmSource->apMag correctly");
    9595        ok(isnan(src->sky), "pmSourceAlloc() pmSource->sky correctly");
  • trunk/psModules/test/objects/tap_pmSourceIO_PS1_DEV_0.c

    r21223 r31451  
    167167            model->dparams->data.F32[PM_PAR_YPOS] = TEST_BASE_Y_ERR + (float) i;
    168168            src->psfMag = TEST_BASE_PSF_MAG + (float) i;
    169             src->errMag = TEST_BASE_ERR_MAG + (float) i;
     169            src->psfMagErr = TEST_BASE_ERR_MAG + (float) i;
    170170            src->peak->flux = TEST_BASE_PEAK_FLUX + (float) i;
    171171            src->sky = TEST_BASE_SKY + (float) i;
     
    215215             ok(src->psfMag == (TEST_BASE_PSF_MAG + (float) i), "pmSourcesRead_PS1_DEV_0() set src->psfMag correctly (is %.2f, should be %.2f)",
    216216                src->psfMag, (TEST_BASE_PSF_MAG + (float) i));
    217              ok(src->errMag == (TEST_BASE_ERR_MAG + (float) i), "pmSourcesRead_PS1_DEV_0() set src->errMag correctly (is %.2f, should be %.2f)",
    218                 src->errMag, (TEST_BASE_ERR_MAG + (float) i));
     217             ok(src->psfMagErr == (TEST_BASE_ERR_MAG + (float) i), "pmSourcesRead_PS1_DEV_0() set src->psfMagErr correctly (is %.2f, should be %.2f)",
     218                src->psfMagErr, (TEST_BASE_ERR_MAG + (float) i));
    219219
    220220             // XXX: Source code always sets src->modelPSF.  Is that right?
  • trunk/psModules/test/objects/tap_pmSourceIO_PS1_DEV_1.c

    r24852 r31451  
    196196            model->dparams->data.F32[PM_PAR_YPOS] = TEST_BASE_Y_ERR + (float) i;
    197197            src->psfMag = TEST_BASE_PSF_MAG + (float) i;
    198             src->errMag = TEST_BASE_ERR_MAG + (float) i;
     198            src->psfMagErr = TEST_BASE_ERR_MAG + (float) i;
    199199            src->peak->flux = TEST_BASE_PEAK_FLUX + (float) i;
    200200            src->sky = TEST_BASE_SKY + (float) i;
     
    203203            sources->data[i] = (psPtr *) src;
    204204            src->psfMag = TEST_BASE_PSF_MAG + (float) i;
    205             src->errMag = TEST_BASE_ERR_MAG + (float) i;
     205            src->psfMagErr = TEST_BASE_ERR_MAG + (float) i;
    206206            src->sky = TEST_BASE_SKY + (float) i;
    207207            src->skyErr = TEST_BASE_SKY_ERR + (float) i;
     
    280280             ok(src->psfMag == (TEST_BASE_PSF_MAG + (float) i), "pmSourcesRead_PS1_DEV_1() set src->psfMag correctly (is %.2f, should be %.2f)",
    281281                src->psfMag, (TEST_BASE_PSF_MAG + (float) i));
    282              ok(src->errMag == (TEST_BASE_ERR_MAG + (float) i), "pmSourcesRead_PS1_DEV_1() set src->errMag correctly (is %.2f, should be %.2f)",
    283                 src->errMag, (TEST_BASE_ERR_MAG + (float) i));
     282             ok(src->psfMagErr == (TEST_BASE_ERR_MAG + (float) i), "pmSourcesRead_PS1_DEV_1() set src->psfMagErr correctly (is %.2f, should be %.2f)",
     283                src->psfMagErr, (TEST_BASE_ERR_MAG + (float) i));
    284284
    285285             // XXX: Source code always sets src->modelPSF.  Is that right?
  • trunk/psModules/test/objects/tap_pmSourceIO_SMPDATA.c

    r21223 r31451  
    167167            model->dparams->data.F32[PM_PAR_YPOS] = TEST_BASE_Y_ERR + (float) i;
    168168            src->psfMag = TEST_BASE_PSF_MAG + (float) i;
    169             src->errMag = TEST_BASE_ERR_MAG + (float) i;
     169            src->psfMagErr = TEST_BASE_ERR_MAG + (float) i;
    170170            src->peak->flux = TEST_BASE_PEAK_FLUX + (float) i;
    171171            src->sky = TEST_BASE_SKY + (float) i;
     
    226226                src->psfMag, (TEST_BASE_PSF_MAG + (float) i));
    227227             float tmpF =  0.001 * PS_MIN(999, (1000 * (TEST_BASE_ERR_MAG + (float) i)));
    228              ok(src->errMag == tmpF, "pmSourcesRead_SMPDATA() set src->errMag correctly (is %.2f, should be %.2f)",
    229                 src->errMag, tmpF);
     228             ok(src->psfMagErr == tmpF, "pmSourcesRead_SMPDATA() set src->psfMagErr correctly (is %.2f, should be %.2f)",
     229                src->psfMagErr, tmpF);
    230230             tmpF = PS_MIN(99.0, (TEST_BASE_EXT_MAG + ZERO_POINT)) - ZERO_POINT;
    231231             ok(src->extMag == tmpF, "pmSourcesRead_SMPDATA() set src->extMag correctly (is %.2f, should be %.2f)",
  • trunk/psModules/test/objects/tap_pmSourcePhotometry.c

    r25754 r31451  
    103103    ok_float_tol(source->psfMag, fitMag, 0.0002, "source fitMag is %f", source->psfMag);
    104104    ok_float_tol(source->apMag,  apMag, 0.0002, "source apMag is %f", source->apMag);
    105     ok_float(source->errMag,   0.001, "source errMag is %f", source->errMag);
     105    ok_float(source->psfMagErr,   0.001, "source psfMagErr is %f", source->psfMagErr);
    106106    float refMag = source->apMag;
    107107
Note: See TracChangeset for help on using the changeset viewer.