Changeset 28484 for branches/pap/psphot/src/psphotBlendFit.c
- Timestamp:
- Jun 24, 2010, 2:59:09 PM (16 years ago)
- Location:
- branches/pap
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/pap
- Property svn:mergeinfo changed
-
branches/pap/psphot
- Property svn:mergeinfo changed
/branches/czw_branch/20100519/psphot (added) merged: 28164,28304
- Property svn:mergeinfo changed
-
branches/pap/psphot/src/psphotBlendFit.c
r28013 r28484 15 15 // loop over the available readouts 16 16 for (int i = 0; i < num; i++) { 17 if (!psphotBlendFitReadout (config, view, filerule, i, recipe)) {17 if (!psphotBlendFitReadout (config, view, filerule, i, recipe)) { 18 18 psError (PSPHOT_ERR_CONFIG, false, "failed to fit sources (non-linear) for %s entry %d", filerule, i); 19 return false;20 }19 return false; 20 } 21 21 } 22 22 return true; … … 48 48 49 49 if (!sources->n) { 50 psLogMsg ("psphot", PS_LOG_INFO, "no sources, skipping blend fit");51 return true;50 psLogMsg ("psphot", PS_LOG_INFO, "no sources, skipping blend fit"); 51 return true; 52 52 } 53 53 … … 87 87 sources = psArraySort (sources, pmSourceSortBySN); 88 88 if (!sources->n) { 89 psLogMsg ("psphot", PS_LOG_INFO, "no sources, skipping blend");90 return true;89 psLogMsg ("psphot", PS_LOG_INFO, "no sources, skipping blend"); 90 return true; 91 91 } 92 92 … … 103 103 for (int j = 0; j < cells->n; j++) { 104 104 105 // allocate a job -- if threads are not defined, this just runs the job 106 psThreadJob *job = psThreadJobAlloc ("PSPHOT_BLEND_FIT"); 107 psArray *newSources = psArrayAllocEmpty(16); 108 109 psArrayAdd(job->args, 1, readout); 110 psArrayAdd(job->args, 1, recipe); 111 psArrayAdd(job->args, 1, cells->data[j]); // sources 112 psArrayAdd(job->args, 1, psf); 113 psArrayAdd(job->args, 1, newSources); // return for new sources 114 psFree (newSources); 115 116 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfit 117 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Npsf 118 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Next 119 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfail 120 121 if (!psThreadJobAddPending(job)) { 122 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 123 psFree (job); 124 return NULL; 125 } 126 psFree(job); 105 // allocate a job -- if threads are not defined, this just runs the job 106 psThreadJob *job = psThreadJobAlloc ("PSPHOT_BLEND_FIT"); 107 psArray *newSources = psArrayAllocEmpty(16); 108 109 psArrayAdd(job->args, 1, readout); 110 psArrayAdd(job->args, 1, recipe); 111 psArrayAdd(job->args, 1, cells->data[j]); // sources 112 psArrayAdd(job->args, 1, psf); 113 psArrayAdd(job->args, 1, newSources); // return for new sources 114 psFree (newSources); 115 116 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfit 117 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Npsf 118 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Next 119 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfail 120 121 if (!psThreadJobAddPending(job)) { 122 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 123 return NULL; 124 } 127 125 128 126 # if (0) … … 152 150 } 153 151 154 // wait for the threads to finish and manage results155 if (!psThreadPoolWait (false)) {156 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");157 return NULL;158 }159 160 // we have only supplied one type of job, so we can assume the types here161 psThreadJob *job = NULL;162 while ((job = psThreadJobGetDone()) != NULL) {163 if (job->args->n < 1) {164 fprintf (stderr, "error with job\n");165 } else {166 psScalar *scalar = NULL;167 scalar = job->args->data[5];168 Nfit += scalar->data.S32;169 scalar = job->args->data[6];170 Npsf += scalar->data.S32;171 scalar = job->args->data[7];172 Next += scalar->data.S32;173 scalar = job->args->data[8];174 Nfail += scalar->data.S32;175 176 // add these back onto sources177 psArray *newSources = job->args->data[4];178 for (int j = 0; j < newSources->n; j++) {179 psArrayAdd (sources, 16, newSources->data[j]);180 }181 }182 psFree(job);152 // wait for the threads to finish and manage results 153 if (!psThreadPoolWait (false)) { 154 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 155 return NULL; 156 } 157 158 // we have only supplied one type of job, so we can assume the types here 159 psThreadJob *job = NULL; 160 while ((job = psThreadJobGetDone()) != NULL) { 161 if (job->args->n < 1) { 162 fprintf (stderr, "error with job\n"); 163 } else { 164 psScalar *scalar = NULL; 165 scalar = job->args->data[5]; 166 Nfit += scalar->data.S32; 167 scalar = job->args->data[6]; 168 Npsf += scalar->data.S32; 169 scalar = job->args->data[7]; 170 Next += scalar->data.S32; 171 scalar = job->args->data[8]; 172 Nfail += scalar->data.S32; 173 174 // add these back onto sources 175 psArray *newSources = job->args->data[4]; 176 for (int j = 0; j < newSources->n; j++) { 177 psArrayAdd (sources, 16, newSources->data[j]); 178 } 179 } 180 psFree(job); 183 181 } 184 182 } … … 278 276 psTrace ("psphot", 5, "source at %7.1f, %7.1f is ext", source->peak->xf, source->peak->yf); 279 277 Next ++; 280 source->mode |= PM_SOURCE_MODE_NONLINEAR_FIT;278 source->mode |= PM_SOURCE_MODE_NONLINEAR_FIT; 281 279 continue; 282 280 } … … 286 284 psTrace ("psphot", 5, "source at %7.1f, %7.1f is psf", source->peak->xf, source->peak->yf); 287 285 Npsf ++; 288 source->mode |= PM_SOURCE_MODE_NONLINEAR_FIT;286 source->mode |= PM_SOURCE_MODE_NONLINEAR_FIT; 289 287 continue; 290 288 }
Note:
See TracChangeset
for help on using the changeset viewer.
