IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 16, 2009, 12:34:24 PM (17 years ago)
Author:
eugene
Message:

added additional flag values, threaded functions always use the threaded version

File:
1 edited

Legend:

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

    r21359 r21519  
    11# include "psphotInternal.h"
    2 
    3 bool psphotApResidMags_Unthreaded (int *nskip, int *nfail, psArray *sources, pmPSF *psf, pmSourcePhotometryMode photMode, psImageMaskType maskVal);
    42
    53# define SKIPSTAR(MSG) { psTrace ("psphot", 3, "invalid : %s", MSG); continue; }
     
    9593        for (int j = 0; j < cells->n; j++) {
    9694
    97             if (nThreads) {
    98                 // allocate a job -- if threads are not defined, this just runs the job
    99                 psThreadJob *job = psThreadJobAlloc ("PSPHOT_APRESID_MAGS");
    100 
    101                 psArrayAdd(job->args, 1, cells->data[j]); // sources
    102                 psArrayAdd(job->args, 1, psf);
    103                 PS_ARRAY_ADD_SCALAR(job->args, photMode, PS_TYPE_S32);
    104                 PS_ARRAY_ADD_SCALAR(job->args, maskVal,  PS_TYPE_IMAGE_MASK);
    105 
    106                 PS_ARRAY_ADD_SCALAR(job->args, 0,        PS_TYPE_S32); // this is used as a return value for Nskip
    107                 PS_ARRAY_ADD_SCALAR(job->args, 0,        PS_TYPE_S32); // this is used as a return value for Nfail
    108 
    109                 if (!psThreadJobAddPending(job)) {
    110                     psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
    111                     psFree (job);
    112                     return false;
    113                 }
    114                 psFree(job);
    115             } else {
     95            // allocate a job -- if threads are not defined, this just runs the job
     96            psThreadJob *job = psThreadJobAlloc ("PSPHOT_APRESID_MAGS");
     97
     98            psArrayAdd(job->args, 1, cells->data[j]); // sources
     99            psArrayAdd(job->args, 1, psf);
     100            PS_ARRAY_ADD_SCALAR(job->args, photMode, PS_TYPE_S32);
     101            PS_ARRAY_ADD_SCALAR(job->args, maskVal,  PS_TYPE_IMAGE_MASK);
     102
     103            PS_ARRAY_ADD_SCALAR(job->args, 0,        PS_TYPE_S32); // this is used as a return value for Nskip
     104            PS_ARRAY_ADD_SCALAR(job->args, 0,        PS_TYPE_S32); // this is used as a return value for Nfail
     105
     106            if (!psThreadJobAddPending(job)) {
     107                psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
     108                psFree (job);
     109                return false;
     110            }
     111            psFree(job);
     112
     113# if (0)
    116114                int nskip = 0;
    117115                int nfail = 0;
     
    123121                Nskip += nskip;
    124122                Nfail += nfail;
    125             }           
     123# endif
    126124
    127125        }
    128126
    129         if (nThreads) {
    130             // wait for the threads to finish and manage results
    131             if (!psThreadPoolWait (false)) {
    132                 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
    133                 return false;
     127        // wait for the threads to finish and manage results
     128        if (!psThreadPoolWait (false)) {
     129            psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");
     130            return false;
     131        }
     132
     133        // we have only supplied one type of job, so we can assume the types here
     134        psThreadJob *job = NULL;
     135        while ((job = psThreadJobGetDone()) != NULL) {
     136            if (job->args->n < 1) {
     137                fprintf (stderr, "error with job\n");
     138            } else {
     139                psScalar *scalar = NULL;
     140                scalar = job->args->data[4];
     141                Nskip += scalar->data.S32;
     142                scalar = job->args->data[5];
     143                Nfail += scalar->data.S32;
    134144            }
    135 
    136             // we have only supplied one type of job, so we can assume the types here
    137             psThreadJob *job = NULL;
    138             while ((job = psThreadJobGetDone()) != NULL) {
    139                 if (job->args->n < 1) {
    140                     fprintf (stderr, "error with job\n");
    141                 } else {
    142                     psScalar *scalar = NULL;
    143                     scalar = job->args->data[4];
    144                     Nskip += scalar->data.S32;
    145                     scalar = job->args->data[5];
    146                     Nfail += scalar->data.S32;
    147                 }
    148                 psFree(job);
    149             }
     145            psFree(job);
    150146        }
    151147    }
     
    497493            continue;
    498494        }
     495        source->mode |= PM_SOURCE_MODE_AP_MAGS;
    499496    }
    500497
     
    509506}
    510507
     508# if (0)
    511509bool psphotApResidMags_Unthreaded (int *nskip, int *nfail, psArray *sources, pmPSF *psf, pmSourcePhotometryMode photMode, psImageMaskType maskVal) {
    512510
     
    542540    return true;
    543541}
     542# endif
Note: See TracChangeset for help on using the changeset viewer.