- Timestamp:
- Sep 5, 2012, 4:04:34 PM (14 years ago)
- Location:
- branches/eam_branches/ipp-20120805/psphot
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20120805/psphot
- Property svn:mergeinfo changed
/trunk/psphot (added) merged: 34293,34307,34311,34317,34319,34321,34336,34338,34352-34354,34363
- Property svn:mergeinfo changed
-
branches/eam_branches/ipp-20120805/psphot/src
- Property svn:mergeinfo changed
/trunk/psphot/src (added) merged: 34293,34307,34311,34317,34319,34321,34336,34338,34352-34354,34363
- Property svn:mergeinfo changed
-
branches/eam_branches/ipp-20120805/psphot/src/psphotStackReadout.c
r34266 r34399 2 2 3 3 static bool psphotStackLoadWCS(pmConfig *config, const pmFPAview *view, const char *filerule); 4 static void logMemStats(const char *heading); 4 5 5 6 // we have 3 possible real filesets: … … 51 52 // by the multiple threads, not the total time used by all threads. 52 53 psTimerStart ("psphotReadout"); 54 55 logMemStats("Start"); 53 56 54 57 pmModelClassSetLimits(PM_MODEL_LIMITS_LAX); // allow models to have ugly fits (eg, central cusp) … … 82 85 } 83 86 84 // Generate the mask and weight images (if not supplied) and set mask bits 87 // Generate the mask and weight images (if not supplied) and set mask bits. 88 // This also insures that all invalid pixels are masked (this is done for STACK_CNV in psphotStackMatchPSFs) 85 89 if (!psphotSetMaskAndVariance (config, view, STACK_DET)) { 90 return psphotReadoutCleanup (config, view, STACK_SRC); 91 } 92 if (!psphotSetMaskAndVariance (config, view, STACK_OUT)) { 86 93 return psphotReadoutCleanup (config, view, STACK_SRC); 87 94 } … … 114 121 } 115 122 123 #ifdef MAKE_CHISQ_IMAGE 116 124 // also make the chisq detection image 117 125 if (!psphotStackChisqImage(config, view, STACK_DET, STACK_SRC)) { … … 119 127 return psphotReadoutCleanup (config, view, STACK_SRC); 120 128 } 129 #endif 121 130 if (!strcasecmp (breakPt, "CHISQ")) { 122 131 return psphotReadoutCleanup (config, view, STACK_SRC); … … 151 160 // psphotDumpTest (config, view, STACK_SRC); 152 161 psMemDump("sourcestats"); 162 logMemStats("sourcestats"); 153 163 154 164 // classify sources based on moments, brightness … … 196 206 // window of size PSF_MOMENTS_RADIUS (same window used to measure the psf-scale moments) 197 207 // but iterates to an appropriately larger size 198 psphotKronIterate(config, view, STACK_SRC); 208 logMemStats("before.kron.1"); 209 psphotKronIterate(config, view, STACK_SRC, 1); 210 logMemStats("after.kron.1"); 199 211 200 212 // identify CRs and extended sources … … 208 220 psphotReplaceAllSources (config, view, STACK_SRC, false); // pass 1 (detections->allSources) 209 221 222 logMemStats("pass1"); 210 223 211 224 // if we only do one pass, skip to extended source analysis … … 299 312 } 300 313 314 logMemStats("prematch"); 315 301 316 // generate the objects (objects unify the sources from the different images) NOTE: could 302 317 // this just match the detections for the chisq image, and not bother measuring the source … … 331 346 // re-measure the kron mags with models subtracted 332 347 // psphotKronMasked(config, view, STACK_SRC); 333 psphotKronIterate(config, view, STACK_SRC); 348 logMemStats("before.kron.2"); 349 psphotKronIterate(config, view, STACK_SRC, 2); 350 logMemStats("after.kron.2"); 334 351 335 352 // measure source size for the remaining sources … … 338 355 339 356 psMemDump("psfstats"); 357 358 // drop matched sources without any useful measurements 359 psphotDropBadMatchedSources (config, view, STACK_SRC, objects); 340 360 341 361 // measure elliptical apertures, petrosians (objects sorted by S/N) … … 354 374 } 355 375 356 357 376 bool radial_apertures = psMetadataLookupBool(NULL, recipe, "RADIAL_APERTURES"); 358 377 if (radial_apertures) { … … 361 380 362 381 // NOTE: we always do the radial apertures analysis on the convolved image since 363 // those are the ones that are psf matched and the source of STACK_OUT's pixels382 // those are the ones that are psf matched and are the source of STACK_OUT's pixels 364 383 // XXX: Actually if PSPHOT.STACK.MATCH.PSF.SOURCE were set to RAW this wouldn't be true. 365 384 // but in that case we don't get past the psf matching step because there is no … … 419 438 // psphotEfficiency wants to have the PSF of the image, but since we are measuring on 420 439 // the convolved images we need to generate PSFs for the DET images 421 if (!psphotChoosePSF (config, view, STACK_DET, false)) { // pass 1440 if (!psphotChoosePSF (config, view, STACK_DET, false)) { 422 441 psLogMsg ("psphot", 3, "failure to construct a psf model for raw input"); 423 442 return psphotReadoutCleanup (config, view, STACK_DET); … … 430 449 psphotCopyEfficiency (config, view, STACK_OUT, STACK_DET); 431 450 451 logMemStats("final"); 452 #if (1) 453 psphotSourceMemory(config, view, STACK_SRC); 454 psphotSourceMemory(config, view, STACK_OUT); 455 #endif 456 432 457 // replace failed sources? 433 458 // psphotReplaceUnfitSources (sources); … … 440 465 psphotSourceFreePixels (config, view, STACK_SRC); 441 466 467 #ifdef MAKE_CHISQ_IMAGE 442 468 // remove chisq image from config->file:PSPHOT.INPUT 443 469 psphotStackRemoveChisqFromInputs(config, STACK_DET); … … 445 471 psphotStackRemoveChisqFromInputs(config, STACK_SRC); 446 472 } 473 #endif 447 474 448 475 psFree (objects); … … 474 501 return true; 475 502 } 503 504 // read the memory usage data from /proc and log them out 505 // This will only work on a system that has /proc (not MacOS for instance) but since this function just 506 // tries to open and read from a file it is safe 507 // XXX: refine this and move it to psLib 508 static void logMemStats(const char *heading) { 509 510 // file containing memory statistics for this process proc. See proc(5) 511 const char* statm_path = "/proc/self/statm"; 512 513 FILE *f = fopen(statm_path,"r"); 514 if (!f) { 515 psLogMsg ("psphot", PS_LOG_WARN, "failed to open %s", statm_path); 516 return; 517 } 518 519 unsigned long vmSize, resident, share, text, lib, data; 520 521 int nread; 522 nread = fscanf(f,"%ld %ld %ld %ld %ld %ld", &vmSize, &resident, &share, &text, &lib, &data); 523 fclose(f); 524 if (nread != 6) { 525 psLogMsg ("psphot", PS_LOG_WARN, "failed to read 6 items from %s", statm_path); 526 return; 527 } 528 529 // XXX: assuming 4 KB page size here 530 # define PAGES_TO_MB(_v) (_v * 4.096 / 1024.) 531 psLogMsg ("psphot", PS_LOG_INFO, "Memory usage at %20s: Total VmSize: %8.2f MB Resident %8.2f MB Data: %8.2f MB\n", 532 heading, PAGES_TO_MB(vmSize), PAGES_TO_MB(resident), PAGES_TO_MB(data)); 533 } 534 535 476 536 477 537 /* here is the process:
Note:
See TracChangeset
for help on using the changeset viewer.
