IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 31384


Ignore:
Timestamp:
Apr 26, 2011, 5:54:39 PM (15 years ago)
Author:
eugene
Message:

pmSourceCopy and pmPeakCopy should copy all appropriate values; do not fit sources with moments failures

Location:
branches/eam_branches/ipp-20110404
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110404/psModules/src/objects/pmGrowthCurve.c

    r31361 r31384  
    9696    growth->refRadius = refRadius;
    9797    growth->maxRadius = maxRadius;
    98     growth->apLoss = 0.0;
    99     growth->fitMag = 0.0;
     98    growth->fitMag = NAN;
     99    growth->apRef  = NAN;
     100    growth->apLoss = NAN;
     101
    100102    return growth;
    101103}
  • branches/eam_branches/ipp-20110404/psModules/src/objects/pmPSF.c

    r31153 r31384  
    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;
  • branches/eam_branches/ipp-20110404/psModules/src/objects/pmPSF.h

    r31361 r31384  
    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
  • branches/eam_branches/ipp-20110404/psModules/src/objects/pmPeaks.c

    r31153 r31384  
    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
  • branches/eam_branches/ipp-20110404/psModules/src/objects/pmPeaks.h

    r31153 r31384  
    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()
  • branches/eam_branches/ipp-20110404/psModules/src/objects/pmSource.c

    r31360 r31384  
    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->psfMagErr        = 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->mode2 = in->mode2;
    202     source->tmpFlags = in->tmpFlags;
    203     source->imageID = in->imageID;
    204 
    205     source->psfMag             = in->psfMag;
    206     source->psfFlux            = in->psfFlux;
    207     source->psfFluxErr         = in->psfFluxErr;
    208     source->extMag             = in->extMag;
    209     source->psfMagErr          = in->psfMagErr;
    210     source->apMag              = in->apMag;
    211     source->apMagRaw           = in->apMagRaw;
    212     source->apRadius           = in->apRadius;
    213     source->apFlux             = in->apFlux;
    214     source->apFluxErr          = in->apFluxErr;
    215     source->pixWeightNotBad    = in->pixWeightNotBad;
    216     source->pixWeightNotPoor   = in->pixWeightNotPoor;
    217     source->psfChisq           = in->psfChisq;
    218     source->crNsigma           = in->crNsigma;
    219     source->extNsigma          = in->extNsigma;
    220     source->sky                = in->sky;
    221     source->skyErr             = in->skyErr;
     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;
    222221
    223222    return(source);
     
    11951194    if (!source->moments) return false;          // can't if there are no moments
    11961195    if (!source->moments->nPixels) return false; // can't if the moments were not measured
    1197     if (source->mode && PM_SOURCE_MODE_MOMENTS_FAILURE) return false; // can't if the moments failed...
     1196    if (source->mode & PM_SOURCE_MODE_MOMENTS_FAILURE) return false; // can't if the moments failed...
    11981197
    11991198    if (source->mode & PM_SOURCE_MODE_SATSTAR) return true; // moments are best for SATSTARs
  • branches/eam_branches/ipp-20110404/psModules/src/objects/pmSource.h

    r31361 r31384  
    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
    8484    float psfMagErr;                    ///< error in psfMag
     
    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
  • branches/eam_branches/ipp-20110404/psModules/src/objects/pmSourceIO_CMF_PS1_SV1.c

    r31360 r31384  
    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
  • branches/eam_branches/ipp-20110404/psphot/src/psphotBlendFit.c

    r31313 r31384  
    242242        if (source->mode &  PM_SOURCE_MODE_PAIR) continue;
    243243
     244        // do not include MOMENTS_FAILURES in the fit
     245        if (source->mode & PM_SOURCE_MODE_MOMENTS_FAILURE) continue;
     246
    244247        // limit selection to some SN limit
    245248        if (sqrt(source->peak->detValue) < FIT_SN_LIM) continue;
  • branches/eam_branches/ipp-20110404/psphot/src/psphotFitSourcesLinear.c

    r31381 r31384  
    137137        if (source->mode & PM_SOURCE_MODE_CR_LIMIT) continue;
    138138
     139        // do not include MOMENTS_FAILURES in the fit
     140        if (source->mode & PM_SOURCE_MODE_MOMENTS_FAILURE) continue;
     141
    139142        // XXX count saturated stars
    140143        if (source->mode & PM_SOURCE_MODE_SATSTAR) {
     
    166169        // apply mask?
    167170        float modelSum = 0.0;
     171        float maskedSum = 0.0;
    168172        for (int iy = 0; iy < source->modelFlux->numRows; iy++) {
    169173            for (int ix = 0; ix < source->modelFlux->numCols; ix++) {
    170174                modelSum += source->modelFlux->data.F32[iy][ix];
     175                if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] & maskVal) continue;
     176                maskedSum += source->modelFlux->data.F32[iy][ix];
    171177            }
    172178        }
    173179        if (modelSum < 0.5) continue; // skip sources with no model constraint (somewhat arbitrary limit)
    174180        if (modelSum < 0.8) {
    175             fprintf (stderr, "low-sig model @ %f, %f (%f sum, %f peak)\n",
    176                      source->peak->xf, source->peak->yf, modelSum, source->peak->rawFlux);
     181            fprintf (stderr, "low-sig model @ %f, %f (%f masked sum, %f sum, %f peak)\n",
     182                     source->peak->xf, source->peak->yf, maskedSum, modelSum, source->peak->rawFlux);
     183        }
     184        if (maskedSum < 0.5) {
     185            fprintf (stderr, "worrying model @ %f, %f (%f masked sum, %f sum, %f peak)\n",
     186                     source->peak->xf, source->peak->yf, maskedSum, modelSum, source->peak->rawFlux);
    177187        }
    178188
  • branches/eam_branches/ipp-20110404/psphot/src/psphotGuessModels.c

    r31154 r31384  
    160160        pmSource *source = sources->data[i];
    161161
    162         if (source->mode & PM_SOURCE_MODE_MOMENTS_FAILURE) {
    163             fprintf (stderr, "moment failure\n");
    164         }
    165 
    166162        // this is used to mark sources for which the model is measured. We check later that
    167163        // all are used.
     
    169165
    170166        // skip non-astronomical objects (very likely defects)
     167        if (source->mode & PM_SOURCE_MODE_MOMENTS_FAILURE) continue;
    171168        if (source->type == PM_SOURCE_TYPE_DEFECT) continue;
    172169        if (source->type == PM_SOURCE_TYPE_SATURATED) continue;
     
    196193        }
    197194
     195# if (0)
    198196        if (source->mode & PM_SOURCE_MODE_SATSTAR) {
    199197            fprintf (stderr, "satstar: %f,%f vs %f,%f : %c\n",
     
    202200                     (useMoments ? 'T' : 'F'));
    203201        }
     202# endif
    204203
    205204        // set PSF parameters for this model (apply 2D shape model to coordinates Xo, Yo)
  • branches/eam_branches/ipp-20110404/psphot/src/psphotMakeGrowthCurve.c

    r31362 r31384  
    5050# endif
    5151
     52    psLogMsg ("psphot", PS_LOG_MINUTIA, "built growth curve: %f sec\n", psTimerMark ("psphot.growth"));
     53
    5254    float offset = pmGrowthCurveCorrect (psf->growth, PSF_APERTURE);
    53     fprintf (stderr, "correction from %f to %f: %f mags\n", PSF_APERTURE, REF_RADIUS, offset);
    54 
    55     psLogMsg ("psphot", PS_LOG_MINUTIA, "built growth curve: %f sec\n", psTimerMark ("psphot.growth"));
     55    psLogMsg ("psphot", PS_LOG_DETAIL, "correction from %f to %f: %f mags\n", PSF_APERTURE, REF_RADIUS, offset);
    5656
    5757    return true;
  • branches/eam_branches/ipp-20110404/psphot/src/psphotRadialApertures.c

    r31154 r31384  
    9595        if (source->type == PM_SOURCE_TYPE_SATURATED) continue;
    9696        if (source->mode & PM_SOURCE_MODE_DEFECT) continue;
    97         if (source->mode & PM_SOURCE_MODE_SATSTAR) continue;
     97
     98        // XXX measure radial apertures even for saturated stars
     99        // if (source->mode & PM_SOURCE_MODE_SATSTAR) continue;
    98100
    99101        // limit selection to some SN limit
     
    257259        float SBstdv = sqrt((fluxStd->data.F32[i] / nPix) - PS_SQR(SBmean));
    258260
     261        // XXX report the total flux or the mask-corrected flux?
    259262        // flux->data.F32[i]    = SBmean * Area;
     263        // fluxErr->data.F32[i] = sqrt(fluxErr->data.F32[i]) * Area / nPix;
     264
     265        fluxErr->data.F32[i] = sqrt(fluxErr->data.F32[i]);
    260266        fluxStd->data.F32[i] = SBstdv * Area;
    261         fluxErr->data.F32[i] = sqrt(fluxErr->data.F32[i]) * Area / nPix;
    262 
    263         // fill->data.F32[i] /= Area;
     267        fill->data.F32[i] /= Area;
     268
    264269        psTrace ("psphot", 5, "radial bins: %3d  %5.1f : %8.1f +/- %7.2f : %8.1f +/- %8.1f : %4.2f %6.1f\n",
    265270                 i, aperRadii->data.F32[i], flux->data.F32[i], fluxErr->data.F32[i], SBmean, SBstdv, fill->data.F32[i], Area);
Note: See TracChangeset for help on using the changeset viewer.