Changeset 23218
- Timestamp:
- Mar 6, 2009, 3:11:24 PM (17 years ago)
- Location:
- trunk/psphot/src
- Files:
-
- 2 edited
-
psphotSetThreads.c (modified) (1 diff)
-
psphotSourceStats.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotSetThreads.c
r21392 r23218 25 25 psFree(task); 26 26 27 task = psThreadTaskAlloc("PSPHOT_SOURCE_STATS", 4);27 task = psThreadTaskAlloc("PSPHOT_SOURCE_STATS", 5); 28 28 task->function = &psphotSourceStats_Threaded; 29 29 psThreadTaskAdd(task); -
trunk/psphot/src/psphotSourceStats.c
r21519 r23218 15 15 int nThreads = psMetadataLookupS32(&status, config->arguments, "NTHREADS"); // Number of threads 16 16 if (!status) { 17 nThreads = 0;17 nThreads = 0; 18 18 } 19 19 … … 41 41 pmSource *source = pmSourceAlloc(); 42 42 43 // add the peak43 // add the peak 44 44 source->peak = psMemIncrRefCounter(peak); 45 45 46 // allocate space for moments46 // allocate space for moments 47 47 source->moments = pmMomentsAlloc(); 48 48 … … 50 50 pmSourceDefinePixels (source, readout, source->peak->x, source->peak->y, OUTER); 51 51 52 peak->assigned = true;53 psArrayAdd (sources, 100, source);54 psFree (source);52 peak->assigned = true; 53 psArrayAdd (sources, 100, source); 54 psFree (source); 55 55 } 56 56 57 57 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; 62 62 } 63 63 … … 65 65 int Nfail = 0; 66 66 int Nmoments = 0; 67 int Nfaint = 0; 67 68 68 69 // choose Cx, Cy (see psphotThreadTools.c for overview of the concepts) … … 74 75 for (int i = 0; i < cellGroups->n; i++) { 75 76 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 job81 psThreadJob *job = psThreadJobAlloc ("PSPHOT_SOURCE_STATS");82 83 psArrayAdd(job->args, 1, cells->data[j]); // sources84 psArrayAdd(job->args, 1, recipe);85 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nmoments86 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfail87 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); 94 95 95 96 # 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; 104 105 # 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 } 127 130 } 128 131 129 132 psFree (cellGroups); 130 133 131 psLogMsg ("psphot", PS_LOG_INFO, "%ld sources, %d moments, %d fai led: %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")); 132 135 133 136 psphotVisualShowMoments (sources); … … 166 169 int Nfail = 0; 167 170 int Nmoments = 0; 171 int Nfaint = 0; 168 172 for (int i = 0; i < sources->n; i++) { 169 173 pmSource *source = sources->data[i]; … … 171 175 // skip faint sources for moments measurement 172 176 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++; 174 179 continue; 175 180 } … … 179 184 status = pmSourceLocalSky (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal); 180 185 if (!status) { 181 source->mode |= PM_SOURCE_MODE_SKY_FAILURE;182 psErrorClear(); // XXX re-consider the errors raised here183 Nfail ++;184 continue;186 source->mode |= PM_SOURCE_MODE_SKY_FAILURE; 187 psErrorClear(); // XXX re-consider the errors raised here 188 Nfail ++; 189 continue; 185 190 } 186 191 … … 189 194 status = pmSourceLocalSkyVariance (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal); 190 195 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; 195 200 } 196 201 … … 208 213 status = pmSourceMoments (source, BIG_RADIUS); 209 214 if (status) { 210 source->mode |= PM_SOURCE_MODE_BIG_RADIUS;215 source->mode |= PM_SOURCE_MODE_BIG_RADIUS; 211 216 Nmoments ++; 212 217 continue; 213 218 } 214 219 215 source->mode |= PM_SOURCE_MODE_MOMENTS_FAILURE;220 source->mode |= PM_SOURCE_MODE_MOMENTS_FAILURE; 216 221 Nfail ++; 217 222 psErrorClear(); … … 225 230 scalar = job->args->data[3]; 226 231 scalar->data.S32 = Nfail; 227 232 233 scalar = job->args->data[4]; 234 scalar->data.S32 = Nfaint; 235 228 236 return true; 229 237 } … … 268 276 status = pmSourceLocalSky (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal); 269 277 if (!status) { 270 psErrorClear(); // XXX re-consider the errors raised here271 Nfail ++;272 continue;278 psErrorClear(); // XXX re-consider the errors raised here 279 Nfail ++; 280 continue; 273 281 } 274 282 … … 277 285 status = pmSourceLocalSkyVariance (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal); 278 286 if (!status) { 279 Nfail ++;280 psErrorClear();281 continue;287 Nfail ++; 288 psErrorClear(); 289 continue; 282 290 } 283 291 … … 307 315 *nmoments = Nmoments; 308 316 *nfail = Nfail; 309 317 310 318 return true; 311 319 } 312 # endif 320 # endif
Note:
See TracChangeset
for help on using the changeset viewer.
