IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23218


Ignore:
Timestamp:
Mar 6, 2009, 3:11:24 PM (17 years ago)
Author:
Paul Price
Message:

Add additional diagnostic: number of sources rejected as too faint.

Location:
trunk/psphot/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotSetThreads.c

    r21392 r23218  
    2525    psFree(task);
    2626
    27     task = psThreadTaskAlloc("PSPHOT_SOURCE_STATS", 4);
     27    task = psThreadTaskAlloc("PSPHOT_SOURCE_STATS", 5);
    2828    task->function = &psphotSourceStats_Threaded;
    2929    psThreadTaskAdd(task);
  • trunk/psphot/src/psphotSourceStats.c

    r21519 r23218  
    1515    int nThreads = psMetadataLookupS32(&status, config->arguments, "NTHREADS"); // Number of threads
    1616    if (!status) {
    17         nThreads = 0;
     17        nThreads = 0;
    1818    }
    1919
     
    4141        pmSource *source = pmSourceAlloc();
    4242
    43         // add the peak
     43        // add the peak
    4444        source->peak = psMemIncrRefCounter(peak);
    4545
    46         // allocate space for moments
     46        // allocate space for moments
    4747        source->moments = pmMomentsAlloc();
    4848
     
    5050        pmSourceDefinePixels (source, readout, source->peak->x, source->peak->y, OUTER);
    5151
    52         peak->assigned = true;
    53         psArrayAdd (sources, 100, source);
    54         psFree (source);
     52        peak->assigned = true;
     53        psArrayAdd (sources, 100, source);
     54        psFree (source);
    5555    }
    5656
    5757    if (!strcasecmp (breakPt, "PEAKS")) {
    58         psLogMsg ("psphot", PS_LOG_INFO, "%ld sources : %f sec\n", sources->n, psTimerMark ("psphot.stats"));
    59         psLogMsg ("psphot", PS_LOG_INFO, "break point PEAKS, skipping MOMENTS\n");
    60         psphotVisualShowMoments (sources);
    61         return sources;
     58        psLogMsg ("psphot", PS_LOG_INFO, "%ld sources : %f sec\n", sources->n, psTimerMark ("psphot.stats"));
     59        psLogMsg ("psphot", PS_LOG_INFO, "break point PEAKS, skipping MOMENTS\n");
     60        psphotVisualShowMoments (sources);
     61        return sources;
    6262    }
    6363
     
    6565    int Nfail = 0;
    6666    int Nmoments = 0;
     67    int Nfaint = 0;
    6768
    6869    // choose Cx, Cy (see psphotThreadTools.c for overview of the concepts)
     
    7475    for (int i = 0; i < cellGroups->n; i++) {
    7576
    76         psArray *cells = cellGroups->data[i];
    77 
    78         for (int j = 0; j < cells->n; j++) {
    79 
    80             // allocate a job -- if threads are not defined, this just runs the job
    81             psThreadJob *job = psThreadJobAlloc ("PSPHOT_SOURCE_STATS");
    82 
    83             psArrayAdd(job->args, 1, cells->data[j]); // sources
    84             psArrayAdd(job->args, 1, recipe);
    85             PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nmoments
    86             PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfail
    87 
    88             if (!psThreadJobAddPending(job)) {
    89                 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
    90                 psFree (job);
    91                 return NULL;
    92             }
    93             psFree(job);
     77        psArray *cells = cellGroups->data[i];
     78
     79        for (int j = 0; j < cells->n; j++) {
     80
     81            // allocate a job -- if threads are not defined, this just runs the job
     82            psThreadJob *job = psThreadJobAlloc ("PSPHOT_SOURCE_STATS");
     83
     84            psArrayAdd(job->args, 1, cells->data[j]); // sources
     85            psArrayAdd(job->args, 1, recipe);
     86            PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nmoments
     87            PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfail
     88
     89            if (!psThreadJobAddPending(job)) {
     90                psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
     91                psFree (job);
     92                return NULL;
     93            }
     94            psFree(job);
    9495
    9596# if (0)
    96                 int nfail = 0;
    97                 int nmoments = 0;
    98                 if (!psphotSourceStats_Unthreaded (&nfail, &nmoments, cells->data[j], recipe)) {
    99                     psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
    100                     return NULL;
    101                 }
    102                 Nfail += nfail;
    103                 Nmoments += nmoments;
     97                int nfail = 0;
     98                int nmoments = 0;
     99                if (!psphotSourceStats_Unthreaded (&nfail, &nmoments, cells->data[j], recipe)) {
     100                    psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
     101                    return NULL;
     102                }
     103                Nfail += nfail;
     104                Nmoments += nmoments;
    104105# endif
    105         }
    106 
    107         // wait for the threads to finish and manage results
    108         if (!psThreadPoolWait (false)) {
    109             psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
    110             return NULL;
    111         }
    112 
    113         // we have only supplied one type of job, so we can assume the types here
    114         psThreadJob *job = NULL;
    115         while ((job = psThreadJobGetDone()) != NULL) {
    116             if (job->args->n < 1) {
    117                 fprintf (stderr, "error with job\n");
    118             } else {
    119                 psScalar *scalar = NULL;
    120                 scalar = job->args->data[2];
    121                 Nmoments += scalar->data.S32;
    122                 scalar = job->args->data[3];
    123                 Nfail += scalar->data.S32;
    124             }
    125             psFree(job);
    126         }
     106        }
     107
     108        // wait for the threads to finish and manage results
     109        if (!psThreadPoolWait (false)) {
     110            psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
     111            return NULL;
     112        }
     113
     114        // we have only supplied one type of job, so we can assume the types here
     115        psThreadJob *job = NULL;
     116        while ((job = psThreadJobGetDone()) != NULL) {
     117            if (job->args->n < 1) {
     118                fprintf (stderr, "error with job\n");
     119            } else {
     120                psScalar *scalar = NULL;
     121                scalar = job->args->data[2];
     122                Nmoments += scalar->data.S32;
     123                scalar = job->args->data[3];
     124                Nfail += scalar->data.S32;
     125                scalar = job->args->data[4];
     126                Nfaint += scalar->data.S32;
     127            }
     128            psFree(job);
     129        }
    127130    }
    128131
    129132    psFree (cellGroups);
    130133
    131     psLogMsg ("psphot", PS_LOG_INFO, "%ld sources, %d moments, %d failed: %f sec\n", sources->n, Nmoments, Nfail, psTimerMark ("psphot.stats"));
     134    psLogMsg ("psphot", PS_LOG_INFO, "%ld sources, %d moments, %d faint, %d failed: %f sec\n", sources->n, Nmoments, Nfaint, Nfail, psTimerMark ("psphot.stats"));
    132135
    133136    psphotVisualShowMoments (sources);
     
    166169    int Nfail = 0;
    167170    int Nmoments = 0;
     171    int Nfaint = 0;
    168172    for (int i = 0; i < sources->n; i++) {
    169173        pmSource *source = sources->data[i];
     
    171175        // skip faint sources for moments measurement
    172176        if (source->peak->SN < MIN_SN) {
    173             source->mode |= PM_SOURCE_MODE_BELOW_MOMENTS_SN;
     177            source->mode |= PM_SOURCE_MODE_BELOW_MOMENTS_SN;
     178            Nfaint++;
    174179            continue;
    175180        }
     
    179184        status = pmSourceLocalSky (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal);
    180185        if (!status) {
    181             source->mode |= PM_SOURCE_MODE_SKY_FAILURE;
    182             psErrorClear(); // XXX re-consider the errors raised here
    183             Nfail ++;
    184             continue;
     186            source->mode |= PM_SOURCE_MODE_SKY_FAILURE;
     187            psErrorClear(); // XXX re-consider the errors raised here
     188            Nfail ++;
     189            continue;
    185190        }
    186191
     
    189194        status = pmSourceLocalSkyVariance (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal);
    190195        if (!status) {
    191             source->mode |= PM_SOURCE_MODE_SKYVAR_FAILURE;
    192             Nfail ++;
    193             psErrorClear();
    194             continue;
     196            source->mode |= PM_SOURCE_MODE_SKYVAR_FAILURE;
     197            Nfail ++;
     198            psErrorClear();
     199            continue;
    195200        }
    196201
     
    208213        status = pmSourceMoments (source, BIG_RADIUS);
    209214        if (status) {
    210             source->mode |= PM_SOURCE_MODE_BIG_RADIUS;
     215            source->mode |= PM_SOURCE_MODE_BIG_RADIUS;
    211216            Nmoments ++;
    212217            continue;
    213218        }
    214219
    215         source->mode |= PM_SOURCE_MODE_MOMENTS_FAILURE;
     220        source->mode |= PM_SOURCE_MODE_MOMENTS_FAILURE;
    216221        Nfail ++;
    217222        psErrorClear();
     
    225230    scalar = job->args->data[3];
    226231    scalar->data.S32 = Nfail;
    227    
     232
     233    scalar = job->args->data[4];
     234    scalar->data.S32 = Nfaint;
     235
    228236    return true;
    229237}
     
    268276        status = pmSourceLocalSky (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal);
    269277        if (!status) {
    270             psErrorClear(); // XXX re-consider the errors raised here
    271             Nfail ++;
    272             continue;
     278            psErrorClear(); // XXX re-consider the errors raised here
     279            Nfail ++;
     280            continue;
    273281        }
    274282
     
    277285        status = pmSourceLocalSkyVariance (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal);
    278286        if (!status) {
    279             Nfail ++;
    280             psErrorClear();
    281             continue;
     287            Nfail ++;
     288            psErrorClear();
     289            continue;
    282290        }
    283291
     
    307315    *nmoments = Nmoments;
    308316    *nfail = Nfail;
    309    
     317
    310318    return true;
    311319}
    312 # endif 
     320# endif
Note: See TracChangeset for help on using the changeset viewer.