IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 5, 2012, 4:04:34 PM (14 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20120805/psphot
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20120805/psphot

  • branches/eam_branches/ipp-20120805/psphot/src

  • branches/eam_branches/ipp-20120805/psphot/src/psphotStackReadout.c

    r34266 r34399  
    22
    33static bool psphotStackLoadWCS(pmConfig *config, const pmFPAview *view, const char *filerule);
     4static void logMemStats(const char *heading);
    45
    56// we have 3 possible real filesets:
     
    5152    // by the multiple threads, not the total time used by all threads.
    5253    psTimerStart ("psphotReadout");
     54
     55    logMemStats("Start");
    5356
    5457    pmModelClassSetLimits(PM_MODEL_LIMITS_LAX); // allow models to have ugly fits (eg, central cusp)
     
    8285    }
    8386
    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)
    8589    if (!psphotSetMaskAndVariance (config, view, STACK_DET)) {
     90        return psphotReadoutCleanup (config, view, STACK_SRC);
     91    }
     92    if (!psphotSetMaskAndVariance (config, view, STACK_OUT)) {
    8693        return psphotReadoutCleanup (config, view, STACK_SRC);
    8794    }
     
    114121    }
    115122
     123#ifdef MAKE_CHISQ_IMAGE
    116124    // also make the chisq detection image
    117125    if (!psphotStackChisqImage(config, view, STACK_DET, STACK_SRC)) {
     
    119127        return psphotReadoutCleanup (config, view, STACK_SRC);
    120128    }
     129#endif
    121130    if (!strcasecmp (breakPt, "CHISQ")) {
    122131        return psphotReadoutCleanup (config, view, STACK_SRC);
     
    151160    // psphotDumpTest (config, view, STACK_SRC);
    152161    psMemDump("sourcestats");
     162    logMemStats("sourcestats");
    153163
    154164    // classify sources based on moments, brightness
     
    196206    // window of size PSF_MOMENTS_RADIUS (same window used to measure the psf-scale moments)
    197207    // 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");
    199211
    200212    // identify CRs and extended sources
     
    208220    psphotReplaceAllSources (config, view, STACK_SRC, false); // pass 1 (detections->allSources)
    209221
     222    logMemStats("pass1");
    210223
    211224    // if we only do one pass, skip to extended source analysis
     
    299312    }
    300313
     314    logMemStats("prematch");
     315
    301316    // generate the objects (objects unify the sources from the different images) NOTE: could
    302317    // this just match the detections for the chisq image, and not bother measuring the source
     
    331346    // re-measure the kron mags with models subtracted
    332347    // 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");
    334351
    335352    // measure source size for the remaining sources
     
    338355
    339356    psMemDump("psfstats");
     357
     358    // drop matched sources without any useful measurements
     359    psphotDropBadMatchedSources (config, view, STACK_SRC, objects);
    340360
    341361    // measure elliptical apertures, petrosians (objects sorted by S/N)
     
    354374    }
    355375
    356 
    357376    bool radial_apertures = psMetadataLookupBool(NULL, recipe, "RADIAL_APERTURES");
    358377    if (radial_apertures) {
     
    361380
    362381        // 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 pixels
     382        // those are the ones that are psf matched and are the source of STACK_OUT's pixels
    364383        // XXX: Actually if PSPHOT.STACK.MATCH.PSF.SOURCE were set to RAW this wouldn't be true.
    365384        // but in that case we don't get past the psf matching step because there is no
     
    419438        // psphotEfficiency wants to have the PSF of the image, but since we are measuring on
    420439        // the convolved images we need to generate PSFs for the DET images
    421         if (!psphotChoosePSF (config, view, STACK_DET, false)) { // pass 1
     440        if (!psphotChoosePSF (config, view, STACK_DET, false)) {
    422441            psLogMsg ("psphot", 3, "failure to construct a psf model for raw input");
    423442            return psphotReadoutCleanup (config, view, STACK_DET);
     
    430449    psphotCopyEfficiency (config, view, STACK_OUT, STACK_DET);
    431450
     451    logMemStats("final");
     452#if (1)
     453    psphotSourceMemory(config, view, STACK_SRC);
     454    psphotSourceMemory(config, view, STACK_OUT);
     455#endif
     456
    432457    // replace failed sources?
    433458    // psphotReplaceUnfitSources (sources);
     
    440465    psphotSourceFreePixels (config, view, STACK_SRC);
    441466
     467#ifdef MAKE_CHISQ_IMAGE
    442468    // remove chisq image from config->file:PSPHOT.INPUT
    443469    psphotStackRemoveChisqFromInputs(config, STACK_DET);
     
    445471        psphotStackRemoveChisqFromInputs(config, STACK_SRC);
    446472    }
     473#endif
    447474
    448475    psFree (objects);
     
    474501    return true;
    475502}
     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
     508static 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
    476536
    477537/* here is the process:
Note: See TracChangeset for help on using the changeset viewer.