Changeset 28676
- Timestamp:
- Jul 15, 2010, 6:30:19 AM (16 years ago)
- Location:
- branches/eam_branches/ipp-20100621/psModules/src/objects
- Files:
-
- 3 edited
-
pmSource.c (modified) (2 diffs)
-
pmSource.h (modified) (2 diffs)
-
pmSourceFitModel.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20100621/psModules/src/objects/pmSource.c
r28643 r28676 105 105 static int id = 1; 106 106 pmSource *source = (pmSource *) psAlloc(sizeof(pmSource)); 107 *(int *)&source->id = id++; 107 P_PM_SOURCE_SET_ID(source, id++); 108 108 109 source->seq = -1; 109 110 source->peak = NULL; … … 149 150 150 151 /****************************************************************************** 151 pmSourceCopy(): copy the pmSource structure and contents 152 XXX : are we OK with incrementing the ID? 152 pmSourceCopy(): copy the pmSource, yielding a copy of the source that can be used without 153 affecting the original. This Copy can be used to allow multiple fit attempts on the same 154 object. The pixels, variance, and mask arrays all point to the same original subarrays. The 155 peak and moments point at the original values. 153 156 *****************************************************************************/ 154 157 pmSource *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 /****************************************************************************** 200 pmSourceCopyData(): this creates a new, duplicate source with the same parameters as the 201 original (but is actually a new source at the same location) 202 *****************************************************************************/ 203 pmSource *pmSourceCopyData(pmSource *in) 155 204 { 156 205 if (in == NULL) { -
branches/eam_branches/ipp-20100621/psModules/src/objects/pmSource.h
r28643 r28676 104 104 pmPSFClump; 105 105 106 // private macro to set the source ID (a const) 107 #define P_PM_SOURCE_SET_ID(S,V) { *(int *)&(S)->id = (V); } 106 108 107 109 /** pmSourceAlloc() … … 117 119 118 120 pmSource *pmSourceCopy(pmSource *source); 121 pmSource *pmSourceCopyData(pmSource *in); 119 122 120 123 // free just the pixels for a source, keeping derived data -
branches/eam_branches/ipp-20100621/psModules/src/objects/pmSourceFitModel.c
r28656 r28676 86 86 psVector *yErr = psVectorAllocEmpty(nPix, PS_TYPE_F32); 87 87 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 88 93 // fill in the coordinate and value entries 89 94 nPix = 0; … … 109 114 } 110 115 111 psVector *coord = psVectorAlloc(2, PS_TYPE_F32);112 113 116 // Convert i/j to image space: 114 117 // 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; 117 132 x->data[nPix] = (psPtr *) coord; 118 133 y->data.F32[nPix] = source->pixels->data.F32[i][j];
Note:
See TracChangeset
for help on using the changeset viewer.
