Changeset 34317 for trunk/psphot/src/psphotStackReadout.c
- Timestamp:
- Aug 16, 2012, 2:38:37 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotStackReadout.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotStackReadout.c
r34266 r34317 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 } … … 151 158 // psphotDumpTest (config, view, STACK_SRC); 152 159 psMemDump("sourcestats"); 160 logMemStats("sourcestats"); 153 161 154 162 // classify sources based on moments, brightness … … 196 204 // window of size PSF_MOMENTS_RADIUS (same window used to measure the psf-scale moments) 197 205 // but iterates to an appropriately larger size 198 psphotKronIterate(config, view, STACK_SRC); 206 logMemStats("before.kron.1"); 207 psphotKronIterate(config, view, STACK_SRC, 1); 208 logMemStats("after.kron.1"); 199 209 200 210 // identify CRs and extended sources … … 208 218 psphotReplaceAllSources (config, view, STACK_SRC, false); // pass 1 (detections->allSources) 209 219 220 logMemStats("pass1"); 210 221 211 222 // if we only do one pass, skip to extended source analysis … … 299 310 } 300 311 312 logMemStats("prematch"); 313 301 314 // generate the objects (objects unify the sources from the different images) NOTE: could 302 315 // this just match the detections for the chisq image, and not bother measuring the source … … 331 344 // re-measure the kron mags with models subtracted 332 345 // psphotKronMasked(config, view, STACK_SRC); 333 psphotKronIterate(config, view, STACK_SRC); 346 logMemStats("before.kron.2"); 347 psphotKronIterate(config, view, STACK_SRC, 2); 348 logMemStats("after.kron.2"); 334 349 335 350 // measure source size for the remaining sources … … 353 368 return psphotReadoutCleanup (config, view, STACK_SRC); 354 369 } 355 356 370 357 371 bool radial_apertures = psMetadataLookupBool(NULL, recipe, "RADIAL_APERTURES"); … … 419 433 // psphotEfficiency wants to have the PSF of the image, but since we are measuring on 420 434 // the convolved images we need to generate PSFs for the DET images 421 if (!psphotChoosePSF (config, view, STACK_DET, false)) { // pass 1435 if (!psphotChoosePSF (config, view, STACK_DET, false)) { 422 436 psLogMsg ("psphot", 3, "failure to construct a psf model for raw input"); 423 437 return psphotReadoutCleanup (config, view, STACK_DET); … … 429 443 } 430 444 psphotCopyEfficiency (config, view, STACK_OUT, STACK_DET); 445 446 logMemStats("final"); 447 #if (1) 448 psphotSourceMemory(config, view, STACK_SRC); 449 psphotSourceMemory(config, view, STACK_OUT); 450 #endif 431 451 432 452 // replace failed sources? … … 474 494 return true; 475 495 } 496 497 // read the memory usage data from /proc and log them out 498 // This will only work on a system that has /proc (not MacOS for instance) but since this function just 499 // tries to open and read from a file it is safe 500 static void logMemStats(const char *heading) { 501 502 // file containing memory statistics for this process proc. See proc(5) 503 const char* statm_path = "/proc/self/statm"; 504 505 FILE *f = fopen(statm_path,"r"); 506 if (!f) { 507 psLogMsg ("psphot", PS_LOG_WARN, "failed to open %s", statm_path); 508 return; 509 } 510 511 unsigned long vmSize, resident, share, text, lib, data; 512 513 int nread; 514 nread = fscanf(f,"%ld %ld %ld %ld %ld %ld", &vmSize, &resident, &share, &text, &lib, &data); 515 fclose(f); 516 if (nread != 6) { 517 psLogMsg ("psphot", PS_LOG_WARN, "failed to read 6 items from %s", statm_path); 518 return; 519 } 520 521 // assuming 4 KB page size here 522 # define PAGES_TO_MB(_v) (_v * 4.096 / 1024.) 523 psLogMsg ("psphot", PS_LOG_INFO, "Memory usage at %20s: Total VmSize: %8.2f MB Resident %8.2f MB Data: %8.2f MB\n", 524 heading, PAGES_TO_MB(vmSize), PAGES_TO_MB(resident), PAGES_TO_MB(data)); 525 } 526 527 476 528 477 529 /* here is the process:
Note:
See TracChangeset
for help on using the changeset viewer.
