- Timestamp:
- Feb 14, 2011, 1:05:28 PM (15 years ago)
- Location:
- branches/czw_branch/20101203
- Files:
-
- 3 edited
-
. (modified) (1 prop)
-
psModules/src/objects (modified) (1 prop)
-
psModules/src/objects/pmSource.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20101203
- Property svn:mergeinfo changed
-
branches/czw_branch/20101203/psModules/src/objects
- Property svn:mergeinfo deleted
-
branches/czw_branch/20101203/psModules/src/objects/pmSource.c
r30118 r30631 61 61 psFree(tmp->moments); 62 62 psFree(tmp->diffStats); 63 psFree(tmp->radial );63 psFree(tmp->radialAper); 64 64 psFree(tmp->blends); 65 65 psTrace("psModules.objects", 10, "---- end ----\n"); … … 126 126 source->extpars = NULL; 127 127 source->diffStats = NULL; 128 source->radial = NULL; 128 source->radialAper = NULL; 129 source->parent = NULL; 129 130 130 131 source->region = psRegionSet(NAN, NAN, NAN, NAN); … … 159 160 affecting the original. This Copy can be used to allow multiple fit attempts on the same 160 161 object. The pixels, variance, and mask arrays all point to the same original subarrays. The 161 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 162 163 *****************************************************************************/ 163 164 pmSource *pmSourceCopy(pmSource *in) … … 167 168 } 168 169 pmSource *source = pmSourceAlloc (); 169 170 // keep the original ID so we can find map back to the original171 P_PM_SOURCE_SET_ID(source, in->id);172 170 173 171 // peak has the same values as the original … … 203 201 } 204 202 205 /******************************************************************************206 pmSourceCopyData(): this creates a new, duplicate source with the same parameters as the207 original (but is actually a new source at the same location)208 *****************************************************************************/209 pmSource *pmSourceCopyData(pmSource *in)210 {211 if (in == NULL) {212 return(NULL);213 }214 // this copy is used to allow multiple fit attempts on the215 // same object. the pixels, variance, and mask arrays all point to216 // the same original subarrays. the peak and moments point at217 // the original values.218 pmSource *source = pmSourceAlloc ();219 220 // this is actually the same peak as the original, is this the correct way to handle this?221 if (in->peak != NULL) {222 source->peak = pmPeakAlloc (in->peak->x, in->peak->y, in->peak->value, in->peak->type);223 source->peak->xf = in->peak->xf;224 source->peak->yf = in->peak->yf;225 source->peak->flux = in->peak->flux;226 source->peak->SN = in->peak->SN;227 }228 229 // copy the values in the moments structure230 if (in->moments != NULL) {231 source->moments = pmMomentsAlloc();232 *source->moments = *in->moments;233 }234 235 // These images are all views to the parent.236 // We want a new view, but pointing at the same pixels.237 source->pixels = psImageCopyView(NULL, in->pixels);238 source->variance = psImageCopyView(NULL, in->variance);239 source->maskView = in->maskView ? psImageCopyView(NULL, in->maskView) : NULL;240 241 // the maskObj is a unique mask array; create a new mask image242 source->maskObj = in->maskObj ? psImageCopy (NULL, in->maskObj, PS_TYPE_IMAGE_MASK) : NULL;243 244 source->type = in->type;245 source->mode = in->mode;246 source->imageID = in->imageID;247 248 return(source);249 }250 251 203 // x,y are defined in the parent image coords of readout->image 252 204 bool pmSourceDefinePixels(pmSource *mySource, … … 300 252 newRegion = psRegionForImage (readout->image, newRegion); 301 253 254 // re-define if required by region or absence of pixels 302 255 extend = false; 303 256 extend |= (int)(newRegion.x0) < (int)(mySource->region.x0); … … 335 288 } 336 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; 337 323 } 338 324 … … 675 661 if ((source->moments->SN > PSF_SN_LIM) && (radius < PSF_CLUMP_NSIGMA)) { 676 662 source->type = PM_SOURCE_TYPE_STAR; 677 source-> mode |= PM_SOURCE_MODE_PSFSTAR;663 source->tmpFlags |= PM_SOURCE_TMPF_CANDIDATE_PSFSTAR; 678 664 Npsf ++; 679 665 continue; … … 934 920 } 935 921 936 // construct a realization of the source model 937 // 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 938 923 bool pmSourceCachePSF (pmSource *source, psImageMaskType maskVal) { 939 924 PS_ASSERT_PTR_NON_NULL(source, false); … … 1020 1005 } 1021 1006 1022 if (!addNoise) { 1023 if (add) { 1024 status = pmModelAddWithOffset (target, source->maskObj, model, PM_MODEL_OP_FULL, maskVal, dx, dy); 1025 source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED; 1026 } else { 1027 status = pmModelSubWithOffset (target, source->maskObj, model, PM_MODEL_OP_FULL, maskVal, dx, dy); 1028 source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED; 1029 } 1007 if (add) { 1008 status = pmModelAddWithOffset (target, source->maskObj, model, PM_MODEL_OP_FULL, maskVal, dx, dy); 1009 source->tmpFlags &= ~PM_SOURCE_TMPF_SUBTRACTED; 1010 } else { 1011 status = pmModelSubWithOffset (target, source->maskObj, model, PM_MODEL_OP_FULL, maskVal, dx, dy); 1012 source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED; 1030 1013 } 1031 1014
Note:
See TracChangeset
for help on using the changeset viewer.
