IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 24, 2010, 3:09:13 PM (15 years ago)
Author:
eugene
Message:

deprecate pmSourceCopyData; add pmSourceRedefinePixelsByRegion; candidate PSFSTARS from pmSourceRoughClass now noted in tmpFlags (not mode)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20101205/psModules/src/objects/pmSource.c

    r30142 r30154  
    160160affecting the original.  This Copy can be used to allow multiple fit attempts on the same
    161161object.  The pixels, variance, and mask arrays all point to the same original subarrays.  The
    162 peak and moments point at the original values.
     162peak and moments point at the original values.  The models, blends, and XXX are NOT copied
    163163*****************************************************************************/
    164164pmSource *pmSourceCopy(pmSource *in)
     
    168168    }
    169169    pmSource *source = pmSourceAlloc ();
    170 
    171     // keep the original ID so we can find map back to the original
    172     P_PM_SOURCE_SET_ID(source, in->id);
    173170
    174171    // peak has the same values as the original
     
    204201}
    205202
    206 /******************************************************************************
    207 pmSourceCopyData(): this creates a new, duplicate source with the same parameters as the
    208 original (but is actually a new source at the same location)
    209 *****************************************************************************/
    210 pmSource *pmSourceCopyData(pmSource *in)
    211 {
    212     if (in == NULL) {
    213         return(NULL);
    214     }
    215     // this copy is used to allow multiple fit attempts on the
    216     // same object.  the pixels, variance, and mask arrays all point to
    217     // the same original subarrays.  the peak and moments point at
    218     // the original values.
    219     pmSource *source = pmSourceAlloc ();
    220 
    221     // this is actually the same peak as the original, is this the correct way to handle this?
    222     if (in->peak != NULL) {
    223         source->peak = pmPeakAlloc (in->peak->x, in->peak->y, in->peak->value, in->peak->type);
    224         source->peak->xf = in->peak->xf;
    225         source->peak->yf = in->peak->yf;
    226         source->peak->flux = in->peak->flux;
    227         source->peak->SN = in->peak->SN;
    228     }
    229 
    230     // copy the values in the moments structure
    231     if (in->moments != NULL) {
    232         source->moments  =  pmMomentsAlloc();
    233         *source->moments = *in->moments;
    234     }
    235 
    236     // These images are all views to the parent.
    237     // We want a new view, but pointing at the same pixels.
    238     source->pixels   = psImageCopyView(NULL, in->pixels);
    239     source->variance   = psImageCopyView(NULL, in->variance);
    240     source->maskView = in->maskView ? psImageCopyView(NULL, in->maskView) : NULL;
    241 
    242     // the maskObj is a unique mask array; create a new mask image
    243     source->maskObj = in->maskObj ? psImageCopy (NULL, in->maskObj, PS_TYPE_IMAGE_MASK) : NULL;
    244 
    245     source->type = in->type;
    246     source->mode = in->mode;
    247     source->imageID = in->imageID;
    248 
    249     return(source);
    250 }
    251 
    252203// x,y are defined in the parent image coords of readout->image
    253204bool pmSourceDefinePixels(pmSource *mySource,
     
    287238                            psF32 x,
    288239                            psF32 y,
    289                             psF32 Radius,
    290                             bool force)
     240                            psF32 Radius)
    291241{
    292242    PS_ASSERT_PTR_NON_NULL(mySource, false);
     
    302252    newRegion = psRegionForImage (readout->image, newRegion);
    303253
    304     // re-define if (a) required externally (force = true) or (b) required internally
    305     extend = force;
     254    // re-define if required by region or absence of pixels
     255    extend = false;
    306256    extend |= (int)(newRegion.x0) < (int)(mySource->region.x0);
    307257    extend |= (int)(newRegion.x1) > (int)(mySource->region.x1);
     
    338288    }
    339289    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;
    340323}
    341324
     
    678661            if ((source->moments->SN > PSF_SN_LIM) && (radius < PSF_CLUMP_NSIGMA)) {
    679662                source->type = PM_SOURCE_TYPE_STAR;
    680                 source->mode |= PM_SOURCE_MODE_PSFSTAR;
     663                source->tmpFlags |= PM_SOURCE_TMPF_CANDIDATE_PSFSTAR;
    681664                Npsf ++;
    682665                continue;
     
    937920}
    938921
    939 // construct a realization of the source model
    940 // 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
    941923bool pmSourceCachePSF (pmSource *source, psImageMaskType maskVal) {
    942924    PS_ASSERT_PTR_NON_NULL(source, false);
Note: See TracChangeset for help on using the changeset viewer.