IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 14, 2011, 1:05:28 PM (15 years ago)
Author:
watersc1
Message:

Merge of trunk back into branch.

Location:
branches/czw_branch/20101203
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20101203

  • branches/czw_branch/20101203/psModules/src/objects

    • Property svn:mergeinfo deleted
  • branches/czw_branch/20101203/psModules/src/objects/pmSource.c

    r30118 r30631  
    6161    psFree(tmp->moments);
    6262    psFree(tmp->diffStats);
    63     psFree(tmp->radial);
     63    psFree(tmp->radialAper);
    6464    psFree(tmp->blends);
    6565    psTrace("psModules.objects", 10, "---- end ----\n");
     
    126126    source->extpars = NULL;
    127127    source->diffStats = NULL;
    128     source->radial = NULL;
     128    source->radialAper = NULL;
     129    source->parent = NULL;
    129130
    130131    source->region = psRegionSet(NAN, NAN, NAN, NAN);
     
    159160affecting the original.  This Copy can be used to allow multiple fit attempts on the same
    160161object.  The pixels, variance, and mask arrays all point to the same original subarrays.  The
    161 peak and moments point at the original values.
     162peak and moments point at the original values.  The models, blends, and XXX are NOT copied
    162163*****************************************************************************/
    163164pmSource *pmSourceCopy(pmSource *in)
     
    167168    }
    168169    pmSource *source = pmSourceAlloc ();
    169 
    170     // keep the original ID so we can find map back to the original
    171     P_PM_SOURCE_SET_ID(source, in->id);
    172170
    173171    // peak has the same values as the original
     
    203201}
    204202
    205 /******************************************************************************
    206 pmSourceCopyData(): this creates a new, duplicate source with the same parameters as the
    207 original (but is actually a new source at the same location)
    208 *****************************************************************************/
    209 pmSource *pmSourceCopyData(pmSource *in)
    210 {
    211     if (in == NULL) {
    212         return(NULL);
    213     }
    214     // this copy is used to allow multiple fit attempts on the
    215     // same object.  the pixels, variance, and mask arrays all point to
    216     // the same original subarrays.  the peak and moments point at
    217     // the original values.
    218     pmSource *source = pmSourceAlloc ();
    219 
    220     // this is actually the same peak as the original, is this the correct way to handle this?
    221     if (in->peak != NULL) {
    222         source->peak = pmPeakAlloc (in->peak->x, in->peak->y, in->peak->value, in->peak->type);
    223         source->peak->xf = in->peak->xf;
    224         source->peak->yf = in->peak->yf;
    225         source->peak->flux = in->peak->flux;
    226         source->peak->SN = in->peak->SN;
    227     }
    228 
    229     // copy the values in the moments structure
    230     if (in->moments != NULL) {
    231         source->moments  =  pmMomentsAlloc();
    232         *source->moments = *in->moments;
    233     }
    234 
    235     // These images are all views to the parent.
    236     // We want a new view, but pointing at the same pixels.
    237     source->pixels   = psImageCopyView(NULL, in->pixels);
    238     source->variance   = psImageCopyView(NULL, in->variance);
    239     source->maskView = in->maskView ? psImageCopyView(NULL, in->maskView) : NULL;
    240 
    241     // the maskObj is a unique mask array; create a new mask image
    242     source->maskObj = in->maskObj ? psImageCopy (NULL, in->maskObj, PS_TYPE_IMAGE_MASK) : NULL;
    243 
    244     source->type = in->type;
    245     source->mode = in->mode;
    246     source->imageID = in->imageID;
    247 
    248     return(source);
    249 }
    250 
    251203// x,y are defined in the parent image coords of readout->image
    252204bool pmSourceDefinePixels(pmSource *mySource,
     
    300252    newRegion = psRegionForImage (readout->image, newRegion);
    301253
     254    // re-define if required by region or absence of pixels
    302255    extend = false;
    303256    extend |= (int)(newRegion.x0) < (int)(mySource->region.x0);
     
    335288    }
    336289    return extend;
     290}
     291
     292bool pmSourceRedefinePixelsByRegion(pmSource *mySource,
     293                                    const pmReadout *readout,
     294                                    psRegion newRegion)
     295{
     296    PS_ASSERT_PTR_NON_NULL(mySource, false);
     297    PS_ASSERT_PTR_NON_NULL(readout, false);
     298    PS_ASSERT_PTR_NON_NULL(readout->image, false);
     299
     300    // re-create the subimage
     301    psFree (mySource->pixels);
     302    psFree (mySource->variance);
     303    psFree (mySource->maskView);
     304       
     305    mySource->pixels   = psImageSubset(readout->image,    newRegion);
     306    mySource->variance = psImageSubset(readout->variance, newRegion);
     307    mySource->maskView = psImageSubset(readout->mask,     newRegion);
     308    mySource->region   = newRegion;
     309
     310    // re-copy the main mask pixels.  NOTE: the user will need to reset the object mask
     311    // pixels (eg, with psImageKeepCircle)
     312    mySource->maskObj = psImageCopy (mySource->maskObj, mySource->maskView, PS_TYPE_IMAGE_MASK);
     313
     314    // drop the old modelFlux pixels and force the user to re-create
     315    psFree (mySource->modelFlux);
     316    mySource->modelFlux = NULL;
     317
     318    // drop the old psfImage pixels and force the user to re-create
     319    psFree (mySource->psfImage);
     320    mySource->psfImage = NULL;
     321
     322    return true;
    337323}
    338324
     
    675661            if ((source->moments->SN > PSF_SN_LIM) && (radius < PSF_CLUMP_NSIGMA)) {
    676662                source->type = PM_SOURCE_TYPE_STAR;
    677                 source->mode |= PM_SOURCE_MODE_PSFSTAR;
     663                source->tmpFlags |= PM_SOURCE_TMPF_CANDIDATE_PSFSTAR;
    678664                Npsf ++;
    679665                continue;
     
    934920}
    935921
    936 // construct a realization of the source model
    937 // XXX this function should optionally save an existing psf image from modelFlux
     922// construct a realization of the PSF model at the location of this source
    938923bool pmSourceCachePSF (pmSource *source, psImageMaskType maskVal) {
    939924    PS_ASSERT_PTR_NON_NULL(source, false);
     
    10201005    }
    10211006
    1022     if (!addNoise) {
    1023         if (add) {
    1024             status = pmModelAddWithOffset (target, source->maskObj, model, PM_MODEL_OP_FULL, maskVal, dx, dy);
    1025             source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED;
    1026         } else {
    1027             status = pmModelSubWithOffset (target, source->maskObj, model, PM_MODEL_OP_FULL, maskVal, dx, dy);
    1028             source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED;
    1029         }
     1007    if (add) {
     1008        status = pmModelAddWithOffset (target, source->maskObj, model, PM_MODEL_OP_FULL, maskVal, dx, dy);
     1009        source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED;
     1010    } else {
     1011        status = pmModelSubWithOffset (target, source->maskObj, model, PM_MODEL_OP_FULL, maskVal, dx, dy);
     1012        source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED;
    10301013    }
    10311014
Note: See TracChangeset for help on using the changeset viewer.