Changeset 30154
- Timestamp:
- Dec 24, 2010, 3:09:13 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20101205/psModules/src/objects/pmSource.c
r30142 r30154 160 160 affecting the original. This Copy can be used to allow multiple fit attempts on the same 161 161 object. The pixels, variance, and mask arrays all point to the same original subarrays. The 162 peak and moments point at the original values. 162 peak and moments point at the original values. The models, blends, and XXX are NOT copied 163 163 *****************************************************************************/ 164 164 pmSource *pmSourceCopy(pmSource *in) … … 168 168 } 169 169 pmSource *source = pmSourceAlloc (); 170 171 // keep the original ID so we can find map back to the original172 P_PM_SOURCE_SET_ID(source, in->id);173 170 174 171 // peak has the same values as the original … … 204 201 } 205 202 206 /******************************************************************************207 pmSourceCopyData(): this creates a new, duplicate source with the same parameters as the208 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 the216 // same object. the pixels, variance, and mask arrays all point to217 // the same original subarrays. the peak and moments point at218 // 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 structure231 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 image243 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 252 203 // x,y are defined in the parent image coords of readout->image 253 204 bool pmSourceDefinePixels(pmSource *mySource, … … 287 238 psF32 x, 288 239 psF32 y, 289 psF32 Radius, 290 bool force) 240 psF32 Radius) 291 241 { 292 242 PS_ASSERT_PTR_NON_NULL(mySource, false); … … 302 252 newRegion = psRegionForImage (readout->image, newRegion); 303 253 304 // re-define if (a) required externally (force = true) or (b) required internally305 extend = f orce;254 // re-define if required by region or absence of pixels 255 extend = false; 306 256 extend |= (int)(newRegion.x0) < (int)(mySource->region.x0); 307 257 extend |= (int)(newRegion.x1) > (int)(mySource->region.x1); … … 338 288 } 339 289 return extend; 290 } 291 292 bool 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; 340 323 } 341 324 … … 678 661 if ((source->moments->SN > PSF_SN_LIM) && (radius < PSF_CLUMP_NSIGMA)) { 679 662 source->type = PM_SOURCE_TYPE_STAR; 680 source-> mode |= PM_SOURCE_MODE_PSFSTAR;663 source->tmpFlags |= PM_SOURCE_TMPF_CANDIDATE_PSFSTAR; 681 664 Npsf ++; 682 665 continue; … … 937 920 } 938 921 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 941 923 bool pmSourceCachePSF (pmSource *source, psImageMaskType maskVal) { 942 924 PS_ASSERT_PTR_NON_NULL(source, false);
Note:
See TracChangeset
for help on using the changeset viewer.
