IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 12978


Ignore:
Timestamp:
Apr 23, 2007, 4:54:30 PM (19 years ago)
Author:
eugene
Message:

moving to maskObj and maskView, re-wrote psphotEnsemblePSF using modelFlux, renamed to psphotFitSourcesLinear

Location:
branches/eam_02_branch/psphot/src
Files:
1 added
12 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_02_branch/psphot/src/Makefile.am

    r12945 r12978  
    3030        psphotChoosePSF.c       \
    3131        psphotGuessModels.c     \
    32         psphotEnsemblePSF.c     \
     32        psphotFitSourcesLinear.c \
    3333        psphotBlendFit.c        \
    3434        psphotReplaceUnfit.c    \
     
    4646        psphotModelTest.c       \
    4747        psphotFitSet.c          \
    48         psphotWeightBias.c      \
    4948        psphotSourceFreePixels.c \
    5049        psphotSummaryPlots.c     \
    51         psphotTestPSF.c          \
    5250        psphotMergeSources.c     \
    5351        psphotReadoutCleanup.c   \
     
    5755        psphotMosaicSubimage.c   \
    5856        psphotMakeResiduals.c    \
    59         psphotTestSourceOutput.c \
    6057        psphotAddNoise.c
    6158
  • branches/eam_02_branch/psphot/src/psphot.h

    r12945 r12978  
    3636bool            psphotMomentsStats (pmReadout *readout, psMetadata *recipe, psArray *sources);
    3737bool            psphotEnsemblePSF (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, bool final);
     38bool            psphotFitSourcesLinear (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, bool final);
    3839bool            psphotGuessModels (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf);
    3940bool            psphotBlendFit (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf);
  • branches/eam_02_branch/psphot/src/psphotChoosePSF.c

    r12959 r12978  
    239239
    240240            // set the mask and subtract the PSF model
     241            // XXX should we be using maskObj? should we be unsetting the mask?
     242            assert (source->maskObj);
    241243            psImageKeepCircle (source->maskObj, x, y, RADIUS, "OR", PM_MASK_MARK);
    242244            pmModelSub (source->pixels, source->maskObj, source->modelPSF, PM_MODEL_OP_FULL);
  • branches/eam_02_branch/psphot/src/psphotFitSet.c

    r12957 r12978  
    11# include "psphotInternal.h"
    22
    3 // XXX this is not used in main psphot code
     3// This is not used in main psphot code (only in psphotModelTest.c)
    44bool psphotFitSet (pmSource *source, pmModel *oneModel, char *fitset, pmSourceFitMode mode) {
    55
     
    3333    for (int i = 0; i < modelSet->n; i++) {
    3434        pmModel *model = modelSet->data[i];
    35         pmModelSub (source->pixels, source->mask, model, PM_MODEL_OP_FULL);
     35        pmModelSub (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL);
    3636
    3737        fprintf (stderr, "output parameters (obj %d):\n", i);
     
    4343    // write out
    4444    psphotSaveImage (NULL, source->pixels, "resid.fits");
    45     psphotSaveImage (NULL, source->mask, "mask.fits");
     45    psphotSaveImage (NULL, source->maskObj, "mask.fits");
    4646    return true;
    4747}
  • branches/eam_02_branch/psphot/src/psphotGuessModels.c

    r12947 r12978  
    5656    source->modelPSF = modelPSF;
    5757    source->modelPSF->residuals = psf->residuals;
     58
     59    pmSourceCacheModel (source);
    5860  }
    5961  psLogMsg ("psphot.models", 4, "built models for %ld objects: %f sec\n", sources->n, psTimerMark ("psphot"));
  • branches/eam_02_branch/psphot/src/psphotMakeResiduals.c

    r12957 r12978  
    7676        if (model == NULL) continue;  // model must be defined
    7777
    78         psImage *image  = psImageCopy (NULL, source->pixels, PS_TYPE_F32);
    79         psImage *weight = psImageCopy (NULL, source->weight, PS_TYPE_F32);
    80         psImage *mask   = psImageCopy (NULL, source->mask,   PS_TYPE_U8);
     78        // why is the mask copied? 
     79        psImage *image  = psImageCopy (NULL, source->pixels,  PS_TYPE_F32);
     80        psImage *weight = psImageCopy (NULL, source->weight,  PS_TYPE_F32);
     81        // NOTE: this function is expected to be called BEFORE the object pixels
     82        // are masked.  Thus, we use the maskView, NOT the maskObj image.
     83        psImage *mask   = psImageCopy (NULL, source->maskView, PS_TYPE_U8);
    8184        pmModelSub (image, mask, model, PM_MODEL_OP_FULL);
    8285       
  • branches/eam_02_branch/psphot/src/psphotModelTest.c

    r12957 r12978  
    22static char DEFAULT_MODE[] = "EXT";
    33
     4// XXX consider this function : add more test information?
    45bool psphotModelTest (pmReadout *readout, psMetadata *recipe) {
    56
     
    158159
    159160    // define the pixels used for the fit
    160     psImageKeepCircle (source->mask, xObj, yObj, RADIUS, "OR", PM_MASK_MARK);
     161    psImageKeepCircle (source->maskObj, xObj, yObj, RADIUS, "OR", PM_MASK_MARK);
    161162
    162163    char *fitset = psMetadataLookupStr (&status, recipe, "TEST_FIT_SET");
     
    170171    // measure the source mags
    171172    pmSourcePhotometryModel (&fitMag, model);
    172     pmSourcePhotometryAper  (&obsMag, model, source->pixels, source->mask);
     173    pmSourcePhotometryAper  (&obsMag, model, source->pixels, source->maskObj);
    173174    fprintf (stderr, "ap: %f, fit: %f, apmifit: %f\n", obsMag, fitMag, obsMag - fitMag);
    174175
     
    177178
    178179    // subtract object, leave local sky
    179     pmModelSub (source->pixels, source->mask, model, PM_MODEL_OP_FULL);
     180    pmModelSub (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL);
    180181
    181182    fprintf (stderr, "output parameters: \n");
     
    186187    // write out
    187188    psphotSaveImage (NULL, source->pixels, "resid.fits");
    188     psphotSaveImage (NULL, source->mask, "mask.fits");
     189    psphotSaveImage (NULL, source->maskObj, "mask.fits");
    189190
    190191    exit (0);
  • branches/eam_02_branch/psphot/src/psphotOutput.c

    r12957 r12978  
    5656        for (int j = 0; j < source->pixels->numCols; j++) {
    5757            // skip masked points
    58             if (source->mask->data.U8[i][j]) {
     58            if (source->maskObj->data.U8[i][j]) {
    5959                continue;
    6060            }
     
    6969                     source->pixels->data.F32[i][j],
    7070                     1.0 / source->weight->data.F32[i][j],
    71                      source->mask->data.U8[i][j]);
     71                     source->maskObj->data.U8[i][j]);
    7272        }
    7373    }
     
    101101    for (int i = 0; (sources != NULL) && (i < sources->n); i++) {
    102102        pmSource *source = (pmSource *) sources->data[i];
    103         pmModel *model = pmSourceSelectModel (source);
     103        pmModel *model = pmSourceGetModel (NULL, source);
    104104        if (model == NULL)
    105105            continue;
  • branches/eam_02_branch/psphot/src/psphotRadialPlot.c

    r12933 r12978  
    6060    for (int iy = 0; iy < source->pixels->numRows; iy++) {
    6161        for (int ix = 0; ix < source->pixels->numCols; ix++) {
    62             if (source->mask->data.U8[iy][ix]) {
     62            if (source->maskObj->data.U8[iy][ix]) {
    6363                rb->data.F32[nb] = hypot (ix - Xo, iy - Yo) ;
    6464                fb->data.F32[nb] = log10(source->pixels->data.F32[iy][ix]);
  • branches/eam_02_branch/psphot/src/psphotRadiusChecks.c

    r12792 r12978  
    2525bool psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model)
    2626{
     27    psF32 *PAR = model->params->data.F32;
     28
     29    // XXX do we have a better value for the sky noise level?  not really...
    2730    pmMoments *moments = source->moments;
    28     // do we have a better value for the sky noise level?
    29     // not really...
    3031
    3132    // set the fit radius based on the object flux limit and the model
     
    4647    }
    4748
    48     bool status = pmSourceRedefinePixels (source, readout, model->params->data.F32[2], model->params->data.F32[3], model->radiusFit);
     49    bool status = pmSourceRedefinePixels (source, readout, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->radiusFit);
     50
     51    // set the mask to flag the excluded pixels
     52    psImageKeepCircle (source->maskObj, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->radiusFit, "OR", PM_MASK_MARK);
    4953    return status;
    5054}
    5155
    5256bool psphotCheckRadiusPSFBlend (pmReadout *readout, pmSource *source, pmModel *model, float dR) {
     57
     58    psF32 *PAR = model->params->data.F32;
    5359
    5460    pmMoments *moments = source->moments;
     
    6369    }
    6470
    65     bool status = pmSourceRedefinePixels (source, readout, model->params->data.F32[2], model->params->data.F32[3], model->radiusFit);
     71    bool status = pmSourceRedefinePixels (source, readout, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->radiusFit);
     72
     73    // set the mask to flag the excluded pixels
     74    psImageKeepCircle (source->maskObj, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->radiusFit, "OR", PM_MASK_MARK);
    6675    return status;
    6776}
     
    8695bool psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model) {
    8796
     97    psF32 *PAR = model->params->data.F32;
     98
    8899    pmMoments *moments = source->moments;
    89100    if (moments == NULL) return false;
     
    94105
    95106    // redefine the pixels if needed
    96     bool status = pmSourceRedefinePixels (source, readout, model->params->data.F32[2], model->params->data.F32[3], model->radiusFit);
     107    bool status = pmSourceRedefinePixels (source, readout, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->radiusFit);
     108
     109    // set the mask to flag the excluded pixels
     110    psImageKeepCircle (source->maskObj, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->radiusFit, "OR", PM_MASK_MARK);
    97111    return status;
    98112}
  • branches/eam_02_branch/psphot/src/psphotReadout.c

    r12945 r12978  
    115115
    116116    // linear PSF fit to peaks
    117     psphotEnsemblePSF (readout, sources, recipe, psf, FALSE);
     117    psphotFitSourcesLinear (readout, sources, recipe, psf, FALSE);
    118118    if (dump) psphotSaveImage (NULL, readout->image,  "image.v1.fits");
    119119    if (!strcasecmp (breakPt, "ENSEMBLE")) {
     
    130130
    131131    // linear PSF fit to remaining peaks
    132     psphotEnsemblePSF (readout, sources, recipe, psf, TRUE);
     132    psphotFitSourcesLinear (readout, sources, recipe, psf, TRUE);
    133133    if (dump) psphotSaveImage (NULL, readout->image,  "image.v4.fits");
    134134    if (!strcasecmp (breakPt, "PASS1")) {
     
    170170
    171171    // linear PSF fit to remaining peaks
    172     psphotEnsemblePSF (readout, sources, recipe, psf, TRUE);
     172    psphotFitSourcesLinear (readout, sources, recipe, psf, TRUE);
    173173    if (dump) psphotSaveImage (NULL, readout->image,  "image.v6.fits");
    174174
  • branches/eam_02_branch/psphot/src/psphotSourceFits.c

    r12957 r12978  
    6767        // these should never be invalid values
    6868        // XXX drop these tests eventually
    69         if (isnan(model->params->data.F32[PM_PAR_I0])) psAbort("nan in blend fit");
     69        if (isnan(model->params->data.F32[PM_PAR_I0]))   psAbort("nan in blend fit");
    7070        if (isnan(model->params->data.F32[PM_PAR_XPOS])) psAbort("nan in blend fit");
    7171        if (isnan(model->params->data.F32[PM_PAR_YPOS])) psAbort("nan in blend fit");
     
    8383
    8484    // fit PSF model (set/unset the pixel mask)
    85     psImageKeepCircle (source->mask, x, y, PSF->radiusFit, "OR", PM_MASK_MARK);
    8685    pmSourceFitSet (source, modelSet, PM_SOURCE_FIT_PSF);
    87     psImageKeepCircle (source->mask, x, y, PSF->radiusFit, "AND", PS_NOT_U8(PM_MASK_MARK));
    8886
    8987    // correct model chisq for flux trend
     
    110108        blend->modelPSF = psMemIncrRefCounter (model);
    111109        psTrace ("psphot", 5, "fitted blend as PSF\n");
    112         pmModelSub (source->pixels, source->mask, model, PM_MODEL_OP_FULL);
     110        pmModelSub (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL);
    113111        blend->mode |=  PM_SOURCE_MODE_SUBTRACTED;
    114112        blend->mode &= ~PM_SOURCE_MODE_TEMPSUB;
     
    128126
    129127    psTrace ("psphot", 5, "fitted primary as PSF\n");
    130     pmModelSub (source->pixels, source->mask, PSF, PM_MODEL_OP_FULL);
     128    pmModelSub (source->pixels, source->maskObj, PSF, PM_MODEL_OP_FULL);
    131129    psFree (source->modelPSF);
    132130    source->modelPSF = PSF;
     
    138136bool psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf) {
    139137
    140     float x, y;
    141138    double chiTrend;
    142139
     
    150147    psphotCheckRadiusPSF (readout, source, PSF);
    151148
    152     x = PSF->params->data.F32[PM_PAR_XPOS];
    153     y = PSF->params->data.F32[PM_PAR_YPOS];
    154 
    155149    // fit PSF model (set/unset the pixel mask)
    156     psImageKeepCircle (source->mask, x, y, PSF->radiusFit, "OR", PM_MASK_MARK);
    157150    pmSourceFitModel (source, PSF, PM_SOURCE_FIT_PSF);
    158     psImageKeepCircle (source->mask, x, y, PSF->radiusFit, "AND", PS_NOT_U8(PM_MASK_MARK));
    159151
    160152    // correct model chisq for flux trend
     
    169161
    170162    psTrace ("psphot", 5, "fitted as PSF\n");
    171     pmModelSub (source->pixels, source->mask, PSF, PM_MODEL_OP_FULL);
     163    // should this be pmSourceSub?
     164    pmModelSub (source->pixels, source->maskObj, PSF, PM_MODEL_OP_FULL);
    172165
    173166    // free old model, save new model
     
    264257    // sub EXT
    265258    psFree (DBL);
    266     pmModelSub (source->pixels, source->mask, EXT, PM_MODEL_OP_FULL);
     259    pmModelSub (source->pixels, source->maskObj, EXT, PM_MODEL_OP_FULL);
    267260    psTrace ("psphot", 5, "blob as EXT: %f %f\n", EXT->params->data.F32[PM_PAR_XPOS], EXT->params->data.F32[PM_PAR_YPOS]);
    268261
     
    276269    // sub DLB
    277270    psFree (EXT);
    278     pmModelSub (source->pixels, source->mask, (pmModel *) DBL->data[0], PM_MODEL_OP_FULL);
    279     pmModelSub (source->pixels, source->mask, (pmModel *) DBL->data[1], PM_MODEL_OP_FULL);
     271    pmModelSub (source->pixels, source->maskObj, (pmModel *) DBL->data[0], PM_MODEL_OP_FULL);
     272    pmModelSub (source->pixels, source->maskObj, (pmModel *) DBL->data[1], PM_MODEL_OP_FULL);
    280273    psTrace ("psphot", 5, "blob as DBL: %f %f\n", ONE->params->data.F32[PM_PAR_XPOS], ONE->params->data.F32[PM_PAR_YPOS]);
    281274
     
    292285    newSrc->pixels   = psMemIncrRefCounter (source->pixels);
    293286    newSrc->weight   = psMemIncrRefCounter (source->weight);
    294     newSrc->mask     = psMemIncrRefCounter (source->mask);
     287    newSrc->maskObj  = psMemIncrRefCounter (source->maskObj);
    295288    newSrc->moments  = psMemIncrRefCounter (source->moments);
    296289    newSrc->modelPSF = psMemIncrRefCounter (DBL->data[1]);
     
    306299psArray *psphotFitDBL (pmReadout *readout, pmSource *source) {
    307300
    308     float x, y, dx, dy;
     301    float dx, dy;
    309302    pmModel *DBL;
    310303    pmModel *PSF;
     
    344337    modelSet->data[1] = DBL;
    345338
    346     x = source->moments->x;
    347     y = source->moments->y;
    348 
    349339    // fit PSF model (set/unset the pixel mask)
    350     psImageKeepCircle (source->mask, x, y, PSF->radiusFit, "OR", PM_MASK_MARK);
    351340    pmSourceFitSet (source, modelSet, PM_SOURCE_FIT_PSF);
    352     psImageKeepCircle (source->mask, x, y, PSF->radiusFit, "AND", PS_NOT_U8(PM_MASK_MARK));
    353 
    354341    return (modelSet);
    355342}
    356343
    357344pmModel *psphotFitEXT (pmReadout *readout, pmSource *source) {
    358 
    359     float x, y;
    360345
    361346    NfitEXT ++;
     
    369354    psphotCheckRadiusEXT (readout, source, EXT);
    370355
    371     x = EXT->params->data.F32[PM_PAR_XPOS];
    372     y = EXT->params->data.F32[PM_PAR_YPOS];
    373 
    374356    if ((source->moments->Sx < 1e-3) || (source->moments->Sx < 1e-3)) {
    375357        psTrace ("psphot", 5, "problem source: moments: %f %f\n", source->moments->Sx, source->moments->Sy);
     
    377359
    378360    // fit EXT (not PSF) model (set/unset the pixel mask)
    379     psImageKeepCircle (source->mask, x, y, EXT->radiusFit, "OR", PM_MASK_MARK);
    380361    pmSourceFitModel (source, EXT, PM_SOURCE_FIT_EXT);
    381     psImageKeepCircle (source->mask, x, y, EXT->radiusFit, "AND", PS_NOT_U8(PM_MASK_MARK));
    382 
    383362    return (EXT);
    384363}
Note: See TracChangeset for help on using the changeset viewer.