Changeset 34415
- Timestamp:
- Sep 7, 2012, 10:06:48 AM (14 years ago)
- Location:
- branches/eam_branches/ipp-20120905/psphot/src
- Files:
-
- 9 edited
-
psphotAddNoise.c (modified) (6 diffs)
-
psphotBlendFit.c (modified) (5 diffs)
-
psphotDeblendSatstars.c (modified) (2 diffs)
-
psphotFindDetections.c (modified) (1 diff)
-
psphotFitSourcesLinear.c (modified) (1 diff)
-
psphotKronIterate.c (modified) (2 diffs)
-
psphotReadout.c (modified) (4 diffs)
-
psphotSourceSize.c (modified) (1 diff)
-
psphotStackReadout.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20120905/psphot/src/psphotAddNoise.c
r34404 r34415 1 1 # include "psphotInternal.h" 2 3 bool psphotMaskSource(pmSource *source, bool add, psImageMaskType maskVal); 2 4 3 5 bool psphotAddNoise (pmConfig *config, const pmFPAview *view, const char *filerule) { … … 30 32 } 31 33 34 static int Nmasked = 0; 35 32 36 bool psphotAddOrSubNoiseReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index, psMetadata *recipe, bool add) { 33 37 … … 56 60 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 57 61 psAssert (maskVal, "missing mask value?"); 62 63 psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT"); // Mask value for bad pixels 64 psAssert (markVal, "missing mask value?"); 58 65 59 66 // increase variance by factor*(object noise): … … 94 101 95 102 pmSourceNoiseOp (source, PM_MODEL_OP_FULL | PM_MODEL_OP_NOISE, FACTOR, SIZE, add, maskVal, 0, 0); 103 104 psphotMaskSource (source, add, markVal); 96 105 } 97 106 if (add) { … … 100 109 psLogMsg ("psphot.noise", PS_LOG_WARN, "sub noise for %ld objects: %f sec\n", sources->n, psTimerMark ("psphot.noise")); 101 110 } 111 fprintf (stderr, "masked %d objects\n", Nmasked); 102 112 103 113 psphotVisualShowImage (readout); … … 105 115 return true; 106 116 } 117 118 bool psphotMaskSource(pmSource *source, bool add, psImageMaskType maskVal) { 119 120 if (!source) return false; 121 if (!source->peak) return false; // XXX how can we have a peak-less source? 122 if (source->type == PM_SOURCE_TYPE_DEFECT) return false; 123 if (source->type == PM_SOURCE_TYPE_SATURATED) return false; 124 125 float Xc = source->peak->xf - source->pixels->col0 - 0.5; 126 float Yc = source->peak->yf - source->pixels->row0 - 0.5; 127 128 psImageMaskType notMaskVal = ~maskVal; 129 130 for (int iy = 0; iy < source->pixels->numRows; iy++) { 131 for (int ix = 0; ix < source->pixels->numCols; ix++) { 132 133 float radius = hypot (ix - Xc, iy - Yc) ; 134 135 if (radius > 4) continue; 136 137 if (add) { 138 source->maskView->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] |= maskVal; 139 } else { 140 source->maskView->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] &= notMaskVal; 141 } 142 } 143 } 144 Nmasked ++; 145 146 return true; 147 } 148 -
branches/eam_branches/ipp-20120905/psphot/src/psphotBlendFit.c
r34409 r34415 96 96 assert (status && isfinite(skySig) && skySig > 0); 97 97 98 # if ( 1)98 # if (0) 99 99 // **** test block : generate an ID image where pixels are set based the source models (flux > 0.1 peak && flux > 2.0 skySig) 100 100 psImage *IDimage = psImageAlloc (readout->image->numCols, readout->image->numRows, PS_TYPE_S32); … … 258 258 259 259 int TEST_ON = false; 260 # if ( 1)260 # if (0) 261 261 # define TEST_X 653 262 262 # define TEST_Y 466 263 263 if ((fabs(source->peak->xf - TEST_X) < 5) && (fabs(source->peak->yf - TEST_Y) < 5)) { 264 264 fprintf (stderr, "test object\n"); 265 //psTraceSetLevel("psLib.math.psMinimizeLMChi2", 5);265 psTraceSetLevel("psLib.math.psMinimizeLMChi2", 5); 266 266 TEST_ON = true; 267 267 } … … 379 379 if (!source) return false; 380 380 if (!source->peak) return false; // XXX how can we have a peak-less source? 381 382 # if (0) 383 # define TEST_X 653 384 # define TEST_Y 466 385 if ((fabs(source->peak->xf - TEST_X) < 5) && (fabs(source->peak->yf - TEST_Y) < 5)) { 386 fprintf (stderr, "test object\n"); 387 } 388 # undef TEST_X 389 # undef TEST_Y 390 # endif 391 381 392 if (!source->moments) return false; 382 393 if (source->type == PM_SOURCE_TYPE_DEFECT) return false; … … 473 484 474 485 // what is the radius for a specific peak fraction? 475 for (int i = 0; i < logFmodel->n; i++) {486 for (int i = 1; i < logFmodel->n; i++) { 476 487 float logF = logFmodel->data.F32[i]; 488 if (!isfinite(logF)) continue; 489 477 490 float flux = pow(10.0, logF); 478 491 if (flux > threshold) continue; 479 if (i == 0) continue;480 492 481 493 float logF0 = logFmodel->data.F32[i - 1]; … … 512 524 int ID = source->id; 513 525 526 fprintf (stderr, "Xo,Yo: %f,%f; radius: %f\n", Xo, Yo, radius); 527 514 528 for (int iy = minY; iy < maxY; iy++) { 515 529 for (int ix = minX; ix < maxX; ix++) { -
branches/eam_branches/ipp-20120905/psphot/src/psphotDeblendSatstars.c
r34408 r34415 121 121 int BIG_SIGMA = BIG_RADIUS / 4.0; 122 122 123 int display = psphotKapaChannel (1);124 psphotVisualScaleImage (display, (psImage *) source->pixels->parent, NULL, "image", 1.0, 0);123 // int display = psphotKapaChannel (1); 124 // psphotVisualScaleImage (display, (psImage *) source->pixels->parent, NULL, "image", 1.0, 0); 125 125 126 126 // examine sources in decreasing SN order … … 182 182 } 183 183 // show the image after object have been subtracted 184 psphotVisualScaleImage (display, (psImage *) source->pixels->parent, NULL, "image", 1.0, 1);184 // psphotVisualScaleImage (display, (psImage *) source->pixels->parent, NULL, "image", 1.0, 1); 185 185 186 186 psFree (SN); -
branches/eam_branches/ipp-20120905/psphot/src/psphotFindDetections.c
r34404 r34415 45 45 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 46 46 psAssert (maskVal, "missing mask value?"); 47 48 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 49 psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT"); // Mask value for bad pixels 50 psAssert (markVal, "missing mark value?"); 51 52 maskVal |= markVal; 47 53 48 54 // Use the new pmFootprints approach? -
branches/eam_branches/ipp-20120905/psphot/src/psphotFitSourcesLinear.c
r34404 r34415 439 439 model->params->data.F32[PM_PAR_I0] = norm->data.F32[i]; 440 440 model->dparams->data.F32[PM_PAR_I0] = errors->data.F32[i]; 441 442 if (norm->data.F32[i] < MIN_VALID_FLUX) { 443 fprintf (stderr, "fit out of bounds for %f,%f : %f\n", source->peak->xf, source->peak->yf, norm->data.F32[i]); 444 model->params->data.F32[PM_PAR_I0] = MIN_VALID_FLUX; 445 } 441 446 442 447 // clear the 'mark' pixels so the subtraction covers the full window -
branches/eam_branches/ipp-20120905/psphot/src/psphotKronIterate.c
r34404 r34415 321 321 if (!source->peak) continue; // XXX how can we have a peak-less source? 322 322 323 # if (0) 324 # define TEST_X 653 325 # define TEST_Y 466 326 if ((fabs(source->peak->xf - TEST_X) < 5) && (fabs(source->peak->yf - TEST_Y) < 5)) { 327 fprintf (stderr, "test object\n"); 328 } 329 # undef TEST_X 330 # undef TEST_Y 331 # endif 332 323 333 // check status of this source's moments 324 334 if (!source->moments) continue; … … 541 551 if (RF <= 0. || RS <= 0 || !isfinite(MrfTry)) { 542 552 // We did not get a good measurement 543 source->moments->Mrf = NAN;553 source->moments->Mrf = NAN; 544 554 source->moments->KronFlux = NAN; 545 555 source->moments->KronFluxErr = NAN; -
branches/eam_branches/ipp-20120905/psphot/src/psphotReadout.c
r34404 r34415 185 185 186 186 // linear PSF fit to source peaks, subtract the models from the image (in PSF mask) 187 psphotFitSourcesLinear (config, view, filerule, false, false); // pass 1 (detections->allSources)187 psphotFitSourcesLinear (config, view, filerule, false, true); // pass 1 (detections->allSources) 188 188 189 189 // measure the radial profiles to the sky … … 212 212 // linear fit to include all sources (subtract again) 213 213 // NOTE : apply to ALL sources (extended + psf) 214 psphotFitSourcesLinear (config, view, filerule, true, false); // pass 2 (detections->allSources)214 psphotFitSourcesLinear (config, view, filerule, true, true); // pass 2 (detections->allSources) 215 215 216 216 // if we only do one pass, skip to extended source analysis … … 260 260 261 261 // NOTE: apply to ALL sources 262 psphotFitSourcesLinear (config, view, filerule, true, false); // pass 3 (detections->allSources)262 psphotFitSourcesLinear (config, view, filerule, true, true); // pass 3 (detections->allSources) 263 263 } 264 264 … … 300 300 301 301 // NOTE: apply to ALL sources 302 psphotFitSourcesLinear (config, view, filerule, true, false); // pass 3 (detections->allSources)302 psphotFitSourcesLinear (config, view, filerule, true, true); // pass 3 (detections->allSources) 303 303 } 304 304 -
branches/eam_branches/ipp-20120905/psphot/src/psphotSourceSize.c
r34404 r34415 675 675 return false; 676 676 } 677 psFree(readout->mask); 678 readout->mask = newMask; 677 // Copy the new mask pixel values to the old mask array. NOTE: we cannot replace 678 // the mask pointer because the source->maskView objects point to the old data 679 // area 680 psImage *oldMask = readout->mask; 681 readout->mask = psImageCopy (readout->mask, newMask, PS_TYPE_IMAGE_MASK); 682 psAssert (oldMask == readout->mask, "should have copied the values in-situ"); 683 psFree(newMask); 679 684 } 680 685 -
branches/eam_branches/ipp-20120905/psphot/src/psphotStackReadout.c
r34354 r34415 332 332 psphotStackObjectsSelectForAnalysis (config, view, STACK_SRC, objects); 333 333 334 if (splitLinearFit) { 335 // NOTE: apply to Matched sources. Since the sources that we fit above are subtracted, they will 336 // not be included in this fit. 337 psphotFitSourcesLinear (config, view, STACK_SRC, true, false); // pass 4 (detections->allSources) 338 } else { 339 // Fit all sources together 340 psphotFitSourcesLinear (config, view, STACK_SRC, true, false); // pass 3 (detections->allSources) 341 } 334 // final linear fit. NOTE: if splitLinearFit is true above, this pass will only fit 335 // the unsubtracted (matched) sources (the sources that we fit above are subtracted) 336 psphotFitSourcesLinear (config, view, STACK_SRC, true, false); // pass 4 (detections->allSources) 342 337 343 338 // measure the radial profiles to the sky (only measures new objects)
Note:
See TracChangeset
for help on using the changeset viewer.
