IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 21306


Ignore:
Timestamp:
Feb 4, 2009, 5:46:21 PM (17 years ago)
Author:
Paul Price
Message:

Removing debugging fprintfs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/pap_branch_20090128/psphot/src/psphotBlendFit.c

    r21183 r21306  
    1919    int nThreads = psMetadataLookupS32(&status, config->arguments, "NTHREADS"); // Number of threads
    2020    if (!status) {
    21         nThreads = 0;
     21        nThreads = 0;
    2222    }
    2323    // nThreads = 0; // XXX until testing is complete, do not thread this function
     
    2727    psphotInitRadiusPSF (recipe, psf->type);
    2828
    29     // starts the timer, sets up the array of fitSets 
     29    // starts the timer, sets up the array of fitSets
    3030    psphotFitInit (nThreads);
    3131
     
    3939    psArray *cellGroups = psphotAssignSources (Cx, Cy, sources);
    4040
    41     fprintf (stderr, "starting with %ld sources\n", sources->n);
    42 
    4341    for (int i = 0; i < cellGroups->n; i++) {
    4442
    45         psArray *cells = cellGroups->data[i];
    46 
    47         for (int j = 0; j < cells->n; j++) {
    48 
    49             // allocate a job -- if threads are not defined, this just runs the job
    50             psThreadJob *job = psThreadJobAlloc ("PSPHOT_BLEND_FIT");
    51             psArray *newSources = psArrayAllocEmpty(16);
    52 
    53             psArrayAdd(job->args, 1, readout);
    54             psArrayAdd(job->args, 1, recipe);
    55             psArrayAdd(job->args, 1, cells->data[j]); // sources
    56             psArrayAdd(job->args, 1, psf);
    57             psArrayAdd(job->args, 1, newSources); // return for new sources
    58             psFree (newSources);
    59 
    60             PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfit
    61             PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Npsf
    62             PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Next
    63             PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfail
    64 
    65             if (!psThreadJobAddPending(job)) {
    66                 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
    67                 psFree (job);
    68                 return NULL;
    69             }
    70             psFree(job);
    71 
    72         }
    73 
    74         // wait for the threads to finish and manage results
    75         if (!psThreadPoolWait (false)) {
    76             psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
    77             return NULL;
    78         }
    79 
    80         // we have only supplied one type of job, so we can assume the types here
    81         psThreadJob *job = NULL;
    82         while ((job = psThreadJobGetDone()) != NULL) {
    83             if (job->args->n < 1) {
    84                 fprintf (stderr, "error with job\n");
    85             } else {
    86                 psScalar *scalar = NULL;
    87                 scalar = job->args->data[5];
    88                 Nfit += scalar->data.S32;
    89                 scalar = job->args->data[6];
    90                 Npsf += scalar->data.S32;
    91                 scalar = job->args->data[7];
    92                 Next += scalar->data.S32;
    93                 scalar = job->args->data[8];
    94                 Nfail += scalar->data.S32;
    95 
    96                 // add these back onto sources
    97                 psArray *newSources = job->args->data[4];
    98                 for (int j = 0; j < newSources->n; j++) {
    99                     psArrayAdd (sources, 16, newSources->data[j]);
    100                 }
    101             }
    102             psFree(job);
    103         }
     43        psArray *cells = cellGroups->data[i];
     44
     45        for (int j = 0; j < cells->n; j++) {
     46
     47            // allocate a job -- if threads are not defined, this just runs the job
     48            psThreadJob *job = psThreadJobAlloc ("PSPHOT_BLEND_FIT");
     49            psArray *newSources = psArrayAllocEmpty(16);
     50
     51            psArrayAdd(job->args, 1, readout);
     52            psArrayAdd(job->args, 1, recipe);
     53            psArrayAdd(job->args, 1, cells->data[j]); // sources
     54            psArrayAdd(job->args, 1, psf);
     55            psArrayAdd(job->args, 1, newSources); // return for new sources
     56            psFree (newSources);
     57
     58            PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfit
     59            PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Npsf
     60            PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Next
     61            PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfail
     62
     63            if (!psThreadJobAddPending(job)) {
     64                psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
     65                psFree (job);
     66                return NULL;
     67            }
     68            psFree(job);
     69
     70        }
     71
     72        // wait for the threads to finish and manage results
     73        if (!psThreadPoolWait (false)) {
     74            psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
     75            return NULL;
     76        }
     77
     78        // we have only supplied one type of job, so we can assume the types here
     79        psThreadJob *job = NULL;
     80        while ((job = psThreadJobGetDone()) != NULL) {
     81            psAssert(job->args->n > 0, "Insufficient arguments: %ld", job->args->n);
     82            psScalar *scalar = NULL;
     83            scalar = job->args->data[5];
     84            Nfit += scalar->data.S32;
     85            scalar = job->args->data[6];
     86            Npsf += scalar->data.S32;
     87            scalar = job->args->data[7];
     88            Next += scalar->data.S32;
     89            scalar = job->args->data[8];
     90            Nfail += scalar->data.S32;
     91
     92            // add these back onto sources
     93            psArray *newSources = job->args->data[4];
     94            for (int j = 0; j < newSources->n; j++) {
     95                psArrayAdd (sources, 16, newSources->data[j]);
     96            }
     97            psFree(job);
     98        }
    10499    }
    105100    psFree (cellGroups);
     
    166161        if (source->peak->SN < FIT_SN_LIM) continue;
    167162
    168         // exclude sources outside optional analysis region
     163        // exclude sources outside optional analysis region
    169164        if (source->peak->xf < AnalysisRegion.x0) continue;
    170165        if (source->peak->yf < AnalysisRegion.y0) continue;
     
    175170        if (source->modelPSF == NULL) continue;
    176171
    177         // skip sources which are insignificant flux? 
    178         // XXX this is somewhat ad-hoc
     172        // skip sources which are insignificant flux?
     173        // XXX this is somewhat ad-hoc
    179174        if (source->modelPSF->params->data.F32[1] < 0.1) {
    180175            psTrace ("psphot", 5, "skipping near-zero source: %f, %f : %f\n",
     
    193188        // try fitting PSFs or extended sources depending on source->mode
    194189        // these functions subtract the resulting fitted source
    195         if (source->mode & PM_SOURCE_MODE_EXT_LIMIT) {
    196             if (psphotFitBlob (readout, source, newSources, psf, maskVal, markVal)) {
    197                 source->type = PM_SOURCE_TYPE_EXTENDED;
    198                 psTrace ("psphot", 5, "source at %7.1f, %7.1f is ext", source->peak->xf, source->peak->yf);
    199                 Next ++;
    200                 continue;
    201             }
    202         } else {
    203             if (psphotFitBlend (readout, source, psf, maskVal, markVal)) {
    204                 source->type = PM_SOURCE_TYPE_STAR;
    205                 psTrace ("psphot", 5, "source at %7.1f, %7.1f is psf", source->peak->xf, source->peak->yf);
    206                 Npsf ++;
    207                 continue;
    208             }
    209         }
     190        if (source->mode & PM_SOURCE_MODE_EXT_LIMIT) {
     191            if (psphotFitBlob (readout, source, newSources, psf, maskVal, markVal)) {
     192                source->type = PM_SOURCE_TYPE_EXTENDED;
     193                psTrace ("psphot", 5, "source at %7.1f, %7.1f is ext", source->peak->xf, source->peak->yf);
     194                Next ++;
     195                continue;
     196            }
     197        } else {
     198            if (psphotFitBlend (readout, source, psf, maskVal, markVal)) {
     199                source->type = PM_SOURCE_TYPE_STAR;
     200                psTrace ("psphot", 5, "source at %7.1f, %7.1f is psf", source->peak->xf, source->peak->yf);
     201                Npsf ++;
     202                continue;
     203            }
     204        }
    210205
    211206        psTrace ("psphot", 5, "source at %7.1f, %7.1f failed", source->peak->xf, source->peak->yf);
Note: See TracChangeset for help on using the changeset viewer.