Changeset 27838 for branches/tap_branches/psModules/src/objects/pmSource.c
- Timestamp:
- May 3, 2010, 8:41:49 AM (16 years ago)
- Location:
- branches/tap_branches
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/tap_branches
- Property svn:mergeinfo changed
-
branches/tap_branches/psModules
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk/psModules merged eligible /branches/eam_branches/stackphot.20100406/psModules 27623-27653 /branches/pap_delete/psModules 27530-27595
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/tap_branches/psModules/src/objects/pmSource.c
r25754 r27838 3 3 * Functions to define and manipulate sources on images 4 4 * 5 * @author GLG, MHPCC6 * @author EAM, IfA: significant modifications.5 * @author EAM, IfA 6 * @author GLG, MHPCC (initial code base) 7 7 * 8 8 * @version $Revision: 1.70 $ $Name: not supported by cvs2svn $ 9 9 * @date $Date: 2009-02-16 22:29:59 $ 10 * 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 12 * 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 13 11 */ 14 12 … … 48 46 psFree(tmp->maskView); 49 47 psFree(tmp->modelFlux); 50 psFree(tmp->psf Flux);48 psFree(tmp->psfImage); 51 49 psFree(tmp->moments); 52 50 psFree(tmp->modelPSF); … … 54 52 psFree(tmp->modelFits); 55 53 psFree(tmp->extpars); 54 psFree(tmp->moments); 55 psFree(tmp->diffStats); 56 56 psFree(tmp->blends); 57 57 psTrace("psModules.objects", 10, "---- end ----\n"); … … 70 70 psFree (source->maskView); 71 71 psFree (source->modelFlux); 72 psFree (source->psf Flux);72 psFree (source->psfImage); 73 73 74 74 source->pixels = NULL; … … 77 77 source->maskView = NULL; 78 78 source->modelFlux = NULL; 79 source->psf Flux= NULL;79 source->psfImage = NULL; 80 80 return; 81 81 } … … 105 105 source->maskView = NULL; 106 106 source->modelFlux = NULL; 107 source->psf Flux= NULL;107 source->psfImage = NULL; 108 108 source->moments = NULL; 109 109 source->blends = NULL; … … 115 115 source->tmpFlags = 0; 116 116 source->extpars = NULL; 117 source->diffStats = NULL; 118 117 119 source->region = psRegionSet(NAN, NAN, NAN, NAN); 118 120 psMemSetDeallocator(source, (psFreeFunc) sourceFree); 119 121 120 122 // default values are NAN 121 source->psfMag = NAN; 123 source->psfMag = NAN; 124 source->psfFlux = NAN; 125 source->psfFluxErr = NAN; 122 126 source->extMag = NAN; 123 127 source->errMag = NAN; … … 176 180 source->type = in->type; 177 181 source->mode = in->mode; 182 source->imageID = in->imageID; 178 183 179 184 return(source); … … 261 266 mySource->modelFlux = NULL; 262 267 263 // drop the old psf Fluxpixels and force the user to re-create264 psFree (mySource->psf Flux);265 mySource->psf Flux= NULL;268 // drop the old psfImage pixels and force the user to re-create 269 psFree (mySource->psfImage); 270 mySource->psfImage = NULL; 266 271 } 267 272 return extend; … … 277 282 // psphot-specific function which applies the recipe values 278 283 // only apply selection to sources within specified region 279 pmPSFClump pmSourcePSFClump(ps Region *region, psArray *sources, psMetadata *recipe)284 pmPSFClump pmSourcePSFClump(psImage **savedImage, psRegion *region, psArray *sources, float PSF_SN_LIM, float PSF_CLUMP_GRID_SCALE, psF32 SX_MAX, psF32 SY_MAX, psF32 AR_MAX) 280 285 { 281 286 psTrace("psModules.objects", 10, "---- begin ----\n"); … … 287 292 288 293 PS_ASSERT_PTR_NON_NULL(sources, errorClump); 289 PS_ASSERT_PTR_NON_NULL(recipe, errorClump);290 291 bool status = true; // Status of MD lookup292 float PSF_SN_LIM = psMetadataLookupF32(&status, recipe, "PSF_SN_LIM");293 if (!status) {294 PSF_SN_LIM = 0;295 }296 float PSF_CLUMP_GRID_SCALE = psMetadataLookupF32(&status, recipe, "PSF_CLUMP_GRID_SCALE");297 if (!status) {298 PSF_CLUMP_GRID_SCALE = 0.1;299 }300 294 301 295 // find the sigmaX, sigmaY clump 302 296 { 303 psF32 SX_MAX = psMetadataLookupF32(&status, recipe, "MOMENTS_SX_MAX");304 if (!status) {305 psWarning("MOMENTS_SX_MAX not set in recipe");306 SX_MAX = 10.0;307 }308 psF32 SY_MAX = psMetadataLookupF32(&status, recipe, "MOMENTS_SY_MAX");309 if (!status) {310 psWarning("MOMENTS_SY_MAX not set in recipe");311 SY_MAX = 10.0;312 }313 psF32 AR_MAX = psMetadataLookupF32(&status, recipe, "MOMENTS_AR_MAX");314 if (!status) {315 psWarning("MOMENTS_AR_MAX not set in recipe");316 AR_MAX = 3.0;317 }318 297 psF32 AR_MIN = 1.0 / AR_MAX; 319 298 … … 401 380 psfClump.nSigma = stats->sampleStdev; 402 381 403 const bool keep_psf_clump = psMetadataLookupBool(NULL, recipe, "KEEP_PSF_CLUMP"); 404 if (keep_psf_clump) 405 { 406 psMetadataAdd(recipe, PS_LIST_TAIL, 407 "PSF_CLUMP", PS_DATA_IMAGE, "Image of PSF coefficients", splane); 382 if (savedImage) { 383 *savedImage = psMemIncrRefCounter(splane); 408 384 } 409 385 psFree (splane); … … 411 387 412 388 // if we failed to find a valid peak, return the empty clump (failure signal) 413 if (peaks == NULL) 389 if (peaks == NULL) { 390 psError(PS_ERR_UNKNOWN, false, "failure in peak analysis for PSF clump.\n"); 391 psFree (peaks); 392 return emptyClump; 393 } 394 395 if (peaks->n == 0) 414 396 { 415 397 psLogMsg ("psphot", 3, "failed to find a peak in the PSF clump image\n"); … … 419 401 psLogMsg ("psphot", 3, "no significant peak\n"); 420 402 } 403 psFree (peaks); 421 404 return (emptyClump); 422 405 } … … 525 508 *****************************************************************************/ 526 509 527 bool pmSourceRoughClass(psRegion *region, psArray *sources, psMetadata *recipe, pmPSFClump clump, psImageMaskType maskSat)510 bool pmSourceRoughClass(psRegion *region, psArray *sources, float PSF_SN_LIM, float PSF_CLUMP_NSIGMA, pmPSFClump clump, psImageMaskType maskSat) 528 511 { 529 512 psTrace("psModules.objects", 10, "---- begin ----"); 530 513 531 514 PS_ASSERT_PTR_NON_NULL(sources, false); 532 PS_ASSERT_PTR_NON_NULL(recipe, false);533 515 534 516 int Nsat = 0; … … 543 525 psVector *starsn_peaks = psVectorAllocEmpty (sources->n, PS_TYPE_F32); 544 526 psVector *starsn_moments = psVectorAllocEmpty (sources->n, PS_TYPE_F32); 545 546 // get basic parameters, or set defaults547 bool status;548 float PSF_SN_LIM = psMetadataLookupF32 (&status, recipe, "PSF_SN_LIM");549 if (!status) PSF_SN_LIM = 20.0;550 float PSF_CLUMP_NSIGMA = psMetadataLookupF32 (&status, recipe, "PSF_CLUMP_NSIGMA");551 if (!status) PSF_CLUMP_NSIGMA = 1.5;552 553 // float INNER_RADIUS = psMetadataLookupF32 (&status, recipe, "SKY_INNER_RADIUS");554 527 555 528 pmSourceMode noMoments = PM_SOURCE_MODE_MOMENTS_FAILURE | PM_SOURCE_MODE_SKYVAR_FAILURE | PM_SOURCE_MODE_SKY_FAILURE | PM_SOURCE_MODE_BELOW_MOMENTS_SN; … … 907 880 908 881 // if we already have a cached image, re-use that memory 909 source->psf Flux = psImageCopy (source->psfFlux, source->pixels, PS_TYPE_F32);910 psImageInit (source->psf Flux, 0.0);882 source->psfImage = psImageCopy (source->psfImage, source->pixels, PS_TYPE_F32); 883 psImageInit (source->psfImage, 0.0); 911 884 912 885 // in some places (psphotEnsemble), we need a normalized version 913 886 // in others, we just want the model. which is more commonly used? 914 // psf Fluxalways has unity normalization (I0 = 1.0)915 pmModelAdd (source->psf Flux, source->maskObj, source->modelPSF, PM_MODEL_OP_FULL | PM_MODEL_OP_NORM, maskVal);887 // psfImage always has unity normalization (I0 = 1.0) 888 pmModelAdd (source->psfImage, source->maskObj, source->modelPSF, PM_MODEL_OP_FULL | PM_MODEL_OP_NORM, maskVal); 916 889 return true; 917 890 } … … 1086 1059 psF32 fA = (A->peak == NULL) ? 0 : A->peak->y; 1087 1060 psF32 fB = (B->peak == NULL) ? 0 : B->peak->y; 1061 1062 psF32 diff = fA - fB; 1063 if (diff > FLT_EPSILON) return (+1); 1064 if (diff < FLT_EPSILON) return (-1); 1065 return (0); 1066 } 1067 1068 // sort by X (ascending) 1069 int pmSourceSortByX (const void **a, const void **b) 1070 { 1071 pmSource *A = *(pmSource **)a; 1072 pmSource *B = *(pmSource **)b; 1073 1074 psF32 fA = (A->peak == NULL) ? 0 : A->peak->x; 1075 psF32 fB = (B->peak == NULL) ? 0 : B->peak->x; 1088 1076 1089 1077 psF32 diff = fA - fB;
Note:
See TracChangeset
for help on using the changeset viewer.
