Changeset 36441 for trunk/psphot/src/psphotChooseAnalysisOptions.c
- Timestamp:
- Jan 14, 2014, 2:28:47 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
. (modified) (1 prop)
-
psphot (modified) (1 prop)
-
psphot/src (modified) (2 props)
-
psphot/src/psphotChooseAnalysisOptions.c (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/bills_branches/bills_201312 (added) merged: 36383,36386,36388-36396,36406-36407,36409-36412,36415-36420,36422-36427,36433,36436-36439
- Property svn:mergeinfo changed
-
trunk/psphot
- Property svn:mergeinfo changed
/branches/bills_branches/bills_201312/psphot (added) merged: 36406-36407,36410,36420,36437-36438
- Property svn:mergeinfo changed
-
trunk/psphot/src
- Property svn:ignore
-
old new 26 26 psphotFullForce 27 27 psmakecff 28 psphotFullForceSummary
-
- Property svn:mergeinfo changed
/branches/bills_branches/bills_201312/psphot/src (added) merged: 36406-36407,36410,36420,36437-36438
- Property svn:ignore
-
trunk/psphot/src/psphotChooseAnalysisOptions.c
r36375 r36441 60 60 } 61 61 62 bool GetGalacticCoords (psSphere *ptGal, psSphere *ptSky, psSphereRot *toGal, pmChip *chip, float xPos, float yPos);62 static bool GetGalacticCoords (psSphere *ptGal, psSphere *ptSky, psSphereRot *toGal, pmChip *chip, float xPos, float yPos); 63 63 64 64 // this function use an internal flag to mark sources which have already been measured … … 121 121 psSphereRot *toGal = NULL; 122 122 float GAL_LIMIT = 0.0; 123 float GAL_LIMIT_BULGE = 0.0; 124 float GAL_LIMIT_SIGMA2 = 0.0; 123 125 bool useGAL_LIMIT = psMetadataLookupBool(&status, recipe, "EXT.FIT.MIN.GAL.LIMIT.USE"); 124 126 assert (status); 125 127 if (useGAL_LIMIT) { 128 toGal = psSphereRotICRSToGalactic(); 126 129 GAL_LIMIT = psMetadataLookupF32(&status, recipe, "EXT.FIT.MIN.GAL.LIMIT"); 127 toGal = psSphereRotICRSToGalactic(); 130 assert (status); 131 GAL_LIMIT = DEG_TO_RAD(GAL_LIMIT); 132 GAL_LIMIT_BULGE = psMetadataLookupF32(&status, recipe, "EXT.FIT.MIN.GAL.LIMIT.BULGE"); 133 assert (status); 134 GAL_LIMIT_BULGE = DEG_TO_RAD(GAL_LIMIT_BULGE); 135 float GAL_LIMIT_SIGMA = psMetadataLookupF32(&status, recipe, "EXT.FIT.MIN.GAL.LIMIT.BULGE.SIGMA"); 136 assert (status); 137 assert(GAL_LIMIT_SIGMA > 0); 138 GAL_LIMIT_SIGMA = DEG_TO_RAD(GAL_LIMIT_SIGMA); 139 GAL_LIMIT_SIGMA2 = GAL_LIMIT_SIGMA * GAL_LIMIT_SIGMA; 128 140 } 129 141 … … 135 147 } 136 148 149 float petroFluxLim = NAN; 137 150 float extFitFluxLim = NAN; 138 151 … … 140 153 float extFitMagLimDefault = NAN; 141 154 float extFitMagLim = NAN; 155 float petroMagLimDefault = NAN; 156 float petroMagLim = NAN; 142 157 143 158 // match to the given filter … … 156 171 // find a matching filter or default to 'any' 157 172 if (!strcasecmp (thisFilter, "any")) { 158 psString extFitMagLimStr = psMetadataLookupStr (&status, item->data.md, "MAG.LIMIT"); 159 psAssert(extFitMagLimStr, "missing MAG.LIMIT"); 173 psString petroMagLimStr = psMetadataLookupStr (&status, item->data.md, "MAG.LIMIT.PETRO"); 174 psAssert(petroMagLimStr, "missing MAG.LIMIT.PETRO"); 175 petroMagLimDefault = atof (petroMagLimStr); 176 177 psString extFitMagLimStr = psMetadataLookupStr (&status, item->data.md, "MAG.LIMIT.EXTFIT"); 178 psAssert(extFitMagLimStr, "missing MAG.LIMIT.EXTFIT"); 160 179 extFitMagLimDefault = atof (extFitMagLimStr); 161 180 } 162 181 163 // find a matching filter or default to 'any'164 182 if (!strcasecmp (thisFilter, filterID)) { 165 psString extFitMagLimStr = psMetadataLookupStr (&status, item->data.md, "MAG.LIMIT"); 166 psAssert(extFitMagLimStr, "missing MAG.LIMIT"); 183 psString petroMagLimStr = psMetadataLookupStr (&status, item->data.md, "MAG.LIMIT.PETRO"); 184 psAssert(petroMagLimStr, "missing MAG.LIMIT.PETRO"); 185 petroMagLim = atof (petroMagLimStr); 186 187 psString extFitMagLimStr = psMetadataLookupStr (&status, item->data.md, "MAG.LIMIT.EXTFIT"); 188 psAssert(extFitMagLimStr, "missing MAG.LIMIT.EXTFIT"); 167 189 extFitMagLim = atof (extFitMagLimStr); 168 190 break; 169 191 } 170 192 } 193 psFree(iter); 194 if (!isfinite (petroMagLim)) petroMagLim = petroMagLimDefault; 171 195 if (!isfinite (extFitMagLim)) extFitMagLim = extFitMagLimDefault; 172 196 … … 185 209 psAssert (status, "missing FPA.ZP?"); 186 210 211 petroFluxLim = exptime * pow (10.0, 0.4*(zeropt - petroMagLim)); 187 212 extFitFluxLim = exptime * pow (10.0, 0.4*(zeropt - extFitMagLim)); 188 213 } … … 225 250 psSphere ptGal, ptSky; 226 251 GetGalacticCoords (&ptGal, &ptSky, toGal, chip, source->peak->xf, source->peak->yf); 227 if (fabs(ptGal.d) < GAL_LIMIT) continue; 252 float b = ptGal.r; 253 float limit = GAL_LIMIT + GAL_LIMIT_BULGE * exp(-0.5*(b*b/GAL_LIMIT_SIGMA2)); 254 if (fabs(ptGal.d) < limit) continue; 228 255 // include an exception for low density skycells below the limit? 229 256 } 230 257 231 258 // for petro and extFit, we will either use the mag limits or the S/N 259 if (doPetrosian) { 260 if (isfinite(petroFluxLim)) { 261 if (source->moments->KronFlux > petroFluxLim) { 262 source->tmpFlags |= PM_SOURCE_TMPF_PETRO; 263 } 264 } else if (source->moments->KronFlux > SN_LIM * source->moments->KronFluxErr) { 265 source->tmpFlags |= PM_SOURCE_TMPF_PETRO; 266 } 267 } 232 268 if (isfinite(extFitFluxLim)) { 233 269 if (source->moments->KronFlux > extFitFluxLim) { 234 270 source->tmpFlags |= PM_SOURCE_TMPF_EXT_FIT; 235 if (doPetrosian) source->tmpFlags |= PM_SOURCE_TMPF_PETRO;236 271 } 237 272 } else { 238 273 if (source->moments->KronFlux > SN_LIM * source->moments->KronFluxErr) { 239 274 source->tmpFlags |= PM_SOURCE_TMPF_EXT_FIT; 240 if (doPetrosian) source->tmpFlags |= PM_SOURCE_TMPF_PETRO;241 275 } 242 276 } … … 244 278 245 279 psLogMsg ("psphot.options", PS_LOG_WARN, "choose analysis options for %ld sources: %f sec\n", sources->n, psTimerMark ("psphot.options")); 280 281 psFree(toGal); 246 282 247 283 return true; … … 287 323 psSphereRot *toGal = NULL; 288 324 float GAL_LIMIT = 0.0; 325 float GAL_LIMIT_BULGE = 0.0; 326 float GAL_LIMIT_SIGMA2 = 0.0; 289 327 bool useGAL_LIMIT = psMetadataLookupBool(&status, recipe, "EXT.FIT.MIN.GAL.LIMIT.USE"); 290 328 assert (status); 291 329 if (useGAL_LIMIT) { 330 toGal = psSphereRotICRSToGalactic(); 292 331 GAL_LIMIT = psMetadataLookupF32(&status, recipe, "EXT.FIT.MIN.GAL.LIMIT"); 293 toGal = psSphereRotICRSToGalactic(); 332 assert (status); 333 GAL_LIMIT = DEG_TO_RAD(GAL_LIMIT); 334 GAL_LIMIT_BULGE = psMetadataLookupF32(&status, recipe, "EXT.FIT.MIN.GAL.LIMIT.BULGE"); 335 assert (status); 336 GAL_LIMIT_BULGE = DEG_TO_RAD(GAL_LIMIT_BULGE); 337 float GAL_LIMIT_SIGMA = psMetadataLookupF32(&status, recipe, "EXT.FIT.MIN.GAL.LIMIT.BULGE.SIGMA"); 338 assert (status); 339 assert(GAL_LIMIT_SIGMA > 0); 340 GAL_LIMIT_SIGMA = DEG_TO_RAD(GAL_LIMIT_SIGMA); 341 GAL_LIMIT_SIGMA2 = GAL_LIMIT_SIGMA * GAL_LIMIT_SIGMA; 294 342 } 295 343 … … 365 413 // find extFitFluxLim->data.F32[i] for i == image number 366 414 psVector *extFitFluxLim = NULL; 415 psVector *petroFluxLim = NULL; 367 416 if (magLimits) { 368 417 extFitFluxLim = psVectorAlloc (inputFilters->n, PS_TYPE_F32); 418 petroFluxLim = psVectorAlloc (inputFilters->n, PS_TYPE_F32); 369 419 psVectorInit (extFitFluxLim, NAN); 420 psVectorInit (petroFluxLim, NAN); 370 421 371 422 float extFitMagLimDefault = NAN; 423 float petroMagLimDefault = NAN; 372 424 373 425 // match mag limits (flux limits) to the filters … … 383 435 // save the default value to assign to unset filters 384 436 if (!strcasecmp (thisFilter, "any")) { 385 psString magString = psMetadataLookupStr (&status, item->data.md, "MAG.LIMIT ");386 psAssert(magString, "missing MAG.LIMIT ");437 psString magString = psMetadataLookupStr (&status, item->data.md, "MAG.LIMIT.EXTFIT"); 438 psAssert(magString, "missing MAG.LIMIT.EXTFIT"); 387 439 extFitMagLimDefault = atof (magString); 440 441 magString = psMetadataLookupStr (&status, item->data.md, "MAG.LIMIT.PETRO"); 442 psAssert(magString, "missing MAG.LIMIT.PETRO"); 443 petroMagLimDefault = atof (magString); 388 444 continue; 389 445 } … … 393 449 if (i == chisqNum) continue; 394 450 if (!strcasecmp (thisFilter, inputFilters->data[i])) { 395 psString magString = psMetadataLookupStr (&status, item->data.md, "MAG.LIMIT ");396 psAssert(magString, "missing MAG.LIMIT ");451 psString magString = psMetadataLookupStr (&status, item->data.md, "MAG.LIMIT.PETRO"); 452 psAssert(magString, "missing MAG.LIMIT.PETRO"); 397 453 float magvalue = atof (magString); 454 petroFluxLim->data.F32[i] = exptime->data.F32[i] * pow (10.0, 0.4*(zeropt->data.F32[i] - magvalue)); 455 456 magString = psMetadataLookupStr (&status, item->data.md, "MAG.LIMIT.EXTFIT"); 457 psAssert(magString, "missing MAG.LIMIT.EXTFIT"); 458 magvalue = atof (magString); 398 459 extFitFluxLim->data.F32[i] = exptime->data.F32[i] * pow (10.0, 0.4*(zeropt->data.F32[i] - magvalue)); 399 460 break; … … 401 462 } 402 463 } 464 psFree(iter); 403 465 404 466 for (int i = 0; i < num; i++) { 405 467 if (i == chisqNum) continue; 406 if (isfinite(extFitFluxLim->data.F32[i])) continue; 407 extFitFluxLim->data.F32[i] = exptime->data.F32[i] * pow (10.0, 0.4*(zeropt->data.F32[i] - extFitMagLimDefault)); 468 if (!isfinite(petroFluxLim->data.F32[i])) { 469 petroFluxLim->data.F32[i] = exptime->data.F32[i] * pow (10.0, 0.4*(zeropt->data.F32[i] - petroMagLimDefault)); 470 } 471 if (!isfinite(extFitFluxLim->data.F32[i])) { 472 extFitFluxLim->data.F32[i] = exptime->data.F32[i] * pow (10.0, 0.4*(zeropt->data.F32[i] - extFitMagLimDefault)); 473 } 408 474 } 409 475 } … … 420 486 bool doObjectRadial = false; 421 487 bool doObjectExtFit = false; 422 for (int j = 0; !doObjectExtFit && !doObjectRadial && (j < object->sources->n); j++) { 488 bool doObjectPetrosian = false; 489 for (int j = 0; !doObjectExtFit && !doObjectRadial && !doObjectPetrosian && (j < object->sources->n); j++) { 423 490 424 491 pmSource *source = object->sources->data[j]; … … 451 518 if (extFitAll) { 452 519 doObjectExtFit = true; 520 doObjectPetrosian = doPetrosian; 453 521 continue; 454 522 } … … 465 533 psSphere ptGal, ptSky; 466 534 GetGalacticCoords (&ptGal, &ptSky, toGal, chips->data[imageID], source->peak->xf, source->peak->yf); 467 if (fabs(ptGal.d) < GAL_LIMIT) continue; 468 // include an exception for low density skycells below the limit? 469 } 470 471 float fluxLim = extFitFluxLim ? extFitFluxLim->data.F32[imageID] : NAN; 535 float b = ptGal.r; 536 float limit = GAL_LIMIT + GAL_LIMIT_BULGE * exp(-0.5*(b*b/GAL_LIMIT_SIGMA2)); 537 if (fabs(ptGal.d) < limit) continue; 538 } 539 540 float fluxLim = NAN; 541 // for petro and extFit, we will either use the mag limits or the S/N 542 if (doPetrosian) { 543 fluxLim = petroFluxLim ? petroFluxLim->data.F32[imageID] : NAN; 544 if (isfinite(fluxLim)) { 545 if (source->moments->KronFlux > extFitFluxLim->data.F32[imageID]) { 546 doObjectPetrosian = true; 547 } 548 } else { 549 if (source->moments->KronFlux > SN_LIM * source->moments->KronFluxErr) { 550 doObjectPetrosian = true; 551 } 552 } 553 } 554 fluxLim = extFitFluxLim ? extFitFluxLim->data.F32[imageID] : NAN; 472 555 // for petro and extFit, we will either use the mag limits or the S/N 473 556 if (isfinite(fluxLim)) { … … 503 586 if (source->modelPSF == NULL) continue; 504 587 505 // Do the fits if the recipe requests we do extended source fits to everything506 588 if (doObjectExtFit) { 507 589 source->tmpFlags |= PM_SOURCE_TMPF_EXT_FIT; 508 if (doPetrosian) source->tmpFlags |= PM_SOURCE_TMPF_PETRO; 509 } 590 } 591 if (doObjectPetrosian) { 592 source->tmpFlags |= PM_SOURCE_TMPF_PETRO; 593 } 510 594 511 595 // Do the fits if the recipe requests we do extended source fits to everything … … 522 606 psLogMsg ("psphot.options", PS_LOG_WARN, "choose analysis options for %ld objects: %f sec\n", objects->n, psTimerMark ("psphot.options")); 523 607 608 psFree(toGal); 609 524 610 return true; 525 611 } 526 612 527 bool GetGalacticCoords (psSphere *ptGal, psSphere *ptSky, psSphereRot *toGal, pmChip *chip, float xPos, float yPos) {613 static bool GetGalacticCoords (psSphere *ptGal, psSphere *ptSky, psSphereRot *toGal, pmChip *chip, float xPos, float yPos) { 528 614 529 615 pmFPA *fpa = chip->parent; … … 543 629 psSphereRotApply (ptGal, toGal, ptSky); 544 630 631 // psSphereRotApply insures that 0 < r < 2PI. We want -PI < b <= PI 632 if (ptGal->r > M_PI) { 633 ptGal->r -= 2.0 * M_PI; 634 } 635 545 636 return true; 546 637
Note:
See TracChangeset
for help on using the changeset viewer.
