IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28676


Ignore:
Timestamp:
Jul 15, 2010, 6:30:19 AM (16 years ago)
Author:
eugene
Message:

add pmSourceCopyData vs pmSourceCopy

Location:
branches/eam_branches/ipp-20100621/psModules/src/objects
Files:
3 edited

Legend:

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

    r28643 r28676  
    105105    static int id = 1;
    106106    pmSource *source = (pmSource *) psAlloc(sizeof(pmSource));
    107     *(int *)&source->id = id++;
     107    P_PM_SOURCE_SET_ID(source, id++);
     108
    108109    source->seq = -1;
    109110    source->peak = NULL;
     
    149150
    150151/******************************************************************************
    151 pmSourceCopy(): copy the pmSource structure and contents
    152 XXX : are we OK with incrementing the ID?
     152pmSourceCopy(): copy the pmSource, yielding a copy of the source that can be used without
     153affecting the original.  This Copy can be used to allow multiple fit attempts on the same
     154object.  The pixels, variance, and mask arrays all point to the same original subarrays.  The
     155peak and moments point at the original values.
    153156*****************************************************************************/
    154157pmSource *pmSourceCopy(pmSource *in)
     158{
     159    if (in == NULL) {
     160        return(NULL);
     161    }
     162    pmSource *source = pmSourceAlloc ();
     163
     164    // keep the original ID so we can find map back to the original
     165    P_PM_SOURCE_SET_ID(source, in->id);
     166
     167    // peak has the same values as the original
     168    if (in->peak != NULL) {
     169        source->peak = pmPeakAlloc (in->peak->x, in->peak->y, in->peak->value, in->peak->type);
     170        source->peak->xf = in->peak->xf;
     171        source->peak->yf = in->peak->yf;
     172        source->peak->flux = in->peak->flux;
     173        source->peak->SN = in->peak->SN;
     174    }
     175
     176    // copy the values in the moments structure
     177    if (in->moments != NULL) {
     178        source->moments  =  pmMomentsAlloc();
     179        *source->moments = *in->moments;
     180    }
     181
     182    // These images are all views to the parent.  We want a new view, but pointing at the same
     183    // pixels.  Modifying these pixels (ie, subtracting the model) will affect the pixels seen
     184    // by all copies.
     185    source->pixels   = psImageCopyView(NULL, in->pixels);
     186    source->variance   = psImageCopyView(NULL, in->variance);
     187    source->maskView = in->maskView ? psImageCopyView(NULL, in->maskView) : NULL;
     188
     189    // the maskObj is a unique mask array; create a new mask image
     190    source->maskObj = in->maskObj ? psImageCopy (NULL, in->maskObj, PS_TYPE_IMAGE_MASK) : NULL;
     191
     192    source->type = in->type;
     193    source->mode = in->mode;
     194    source->imageID = in->imageID;
     195
     196    return(source);
     197}
     198
     199/******************************************************************************
     200pmSourceCopyData(): this creates a new, duplicate source with the same parameters as the
     201original (but is actually a new source at the same location)
     202*****************************************************************************/
     203pmSource *pmSourceCopyData(pmSource *in)
    155204{
    156205    if (in == NULL) {
  • branches/eam_branches/ipp-20100621/psModules/src/objects/pmSource.h

    r28643 r28676  
    104104pmPSFClump;
    105105
     106// private macro to set the source ID (a const)
     107#define P_PM_SOURCE_SET_ID(S,V) { *(int *)&(S)->id = (V); }
    106108
    107109/** pmSourceAlloc()
     
    117119
    118120pmSource  *pmSourceCopy(pmSource *source);
     121pmSource *pmSourceCopyData(pmSource *in);
    119122
    120123// free just the pixels for a source, keeping derived data
  • branches/eam_branches/ipp-20100621/psModules/src/objects/pmSourceFitModel.c

    r28656 r28676  
    8686    psVector *yErr = psVectorAllocEmpty(nPix, PS_TYPE_F32);
    8787
     88    // XXX for a test, skip the central pixel in the sersic fit
     89    bool skipCenter = false && (model->type == pmModelClassGetType("PS_MODEL_SERSIC"));
     90    float Xo = model->params->data.F32[PM_PAR_XPOS];
     91    float Yo = model->params->data.F32[PM_PAR_YPOS];
     92
    8893    // fill in the coordinate and value entries
    8994    nPix = 0;
     
    109114            }
    110115
    111             psVector *coord = psVectorAlloc(2, PS_TYPE_F32);
    112 
    113116            // Convert i/j to image space:
    114117            // 0.5 PIX: the coordinate values must be in pixel coords, not index           
    115             coord->data.F32[0] = (psF32) (j + 0.5 + source->pixels->col0);
    116             coord->data.F32[1] = (psF32) (i + 0.5 + source->pixels->row0);
     118            float Xv = (psF32) (j + 0.5 + source->pixels->col0);
     119            float Yv = (psF32) (i + 0.5 + source->pixels->row0);
     120
     121            // XXX possible skip of center pixel:
     122            if (skipCenter) {
     123                float r = hypot(Xv - Xo, Yv - Yo);
     124                if (r < 0.75) {
     125                    continue;
     126                }
     127            }
     128
     129            psVector *coord = psVectorAlloc(2, PS_TYPE_F32);
     130            coord->data.F32[0] = Xv;
     131            coord->data.F32[1] = Yv;
    117132            x->data[nPix] = (psPtr *) coord;
    118133            y->data.F32[nPix] = source->pixels->data.F32[i][j];
Note: See TracChangeset for help on using the changeset viewer.