IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 24, 2007, 12:28:44 PM (19 years ago)
Author:
magnier
Message:

more rational implementation for pmSourceCopy

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_02_branch/psModules/src/objects/pmSource.c

    r12986 r13001  
    66 *  @author EAM, IfA: significant modifications.
    77 *
    8  *  @version $Revision: 1.25.4.7 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-04-24 18:15:33 $
     8 *  @version $Revision: 1.25.4.8 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-04-24 22:28:44 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    123123    // the original values.
    124124    pmSource *source = pmSourceAlloc ();
    125     source->peak = psMemIncrRefCounter (in->peak);
    126     source->pixels = psMemIncrRefCounter (in->pixels);
    127     source->weight = psMemIncrRefCounter (in->weight);
    128     source->maskObj = psMemIncrRefCounter (in->maskObj);
    129     source->maskView = psMemIncrRefCounter (in->maskView);
    130     source->moments = psMemIncrRefCounter (in->moments);
    131     source->blends = NULL;
    132     source->modelPSF = NULL;
    133     source->modelEXT = NULL;
    134     source->modelFlux = NULL;
     125
     126    // this is actually the same peak as the original, is this the correct way to handle this?
     127    source->peak = pmPeakAlloc (in->peak->x, in->peak->y, in->peak->value, in->peak->type);
     128    source->peak->xf = in->peak->xf;
     129    source->peak->yf = in->peak->yf;
     130    source->peak->flux = in->peak->flux;
     131    source->peak->SN = in->peak->SN;
     132
     133    // copy the values in the moments structure
     134    source->moments  =  pmMomentsAlloc();
     135    *source->moments = *in->moments;
     136
     137    // These images are all views to the parent. 
     138    // We want a new view, but pointing at the same pixels.
     139    source->pixels   = psImageCopyView (NULL, in->pixels);
     140    source->weight   = psImageCopyView (NULL, in->weight);
     141    source->maskView = psImageCopyView (NULL, in->maskView);
     142
     143    // the maskObj is a unique mask array; create a new mask image
     144    if (in->maskObj) {
     145        source->maskObj = psImageCopy (NULL, in->maskObj, PS_TYPE_MASK);
     146    }
     147
    135148    source->type = in->type;
    136149    source->mode = in->mode;
    137     psMemSetDeallocator(source, (psFreeFunc) sourceFree);
    138 
    139     // default values are NAN
    140     source->psfMag = NAN;
    141     source->extMag = NAN;
    142     source->errMag = NAN;
    143     source->apMag  = NAN;
    144     source->sky    = NAN;
    145     source->skyErr = NAN;
    146     source->pixWeight = NAN;
    147150
    148151    return(source);
     
    213216        mySource->region   = newRegion;
    214217
    215         // XXX how do we extend the mask?  do we need to keep the old masked pixels?
    216         // the object mask is a copy, and used to define the source pixels
     218        // re-copy the main mask pixels.  NOTE: the user will need to reset the object mask
     219        // pixels (eg, with psImageKeepCircle)
    217220        mySource->maskObj = psImageCopy (mySource->maskObj, mySource->maskView, PS_TYPE_MASK);
    218221       
    219         // XXX what about the modelFlux image?
     222        // drop the old modelFlux pixels and force the user to re-create
     223        psFree (mySource->modelFlux);
     224        mySource->modelFlux = NULL;
    220225    }
    221226    return extend;
Note: See TracChangeset for help on using the changeset viewer.