- Timestamp:
- Mar 8, 2009, 4:29:34 PM (17 years ago)
- Location:
- branches/eam_branches/eam_branch_20090303
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
psphot/src/psphotSourceStats.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/eam_branch_20090303
-
branches/eam_branches/eam_branch_20090303/psphot/src/psphotSourceStats.c
r21519 r23225 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 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 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfaint 89 90 if (!psThreadJobAddPending(job)) { 91 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 92 psFree (job); 93 return NULL; 94 } 95 psFree(job); 94 96 95 97 # 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;98 int nfail = 0; 99 int nmoments = 0; 100 if (!psphotSourceStats_Unthreaded (&nfail, &nmoments, cells->data[j], recipe)) { 101 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 102 return NULL; 103 } 104 Nfail += nfail; 105 Nmoments += nmoments; 104 106 # 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 } 107 } 108 109 // wait for the threads to finish and manage results 110 if (!psThreadPoolWait (false)) { 111 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 112 return NULL; 113 } 114 115 // we have only supplied one type of job, so we can assume the types here 116 psThreadJob *job = NULL; 117 while ((job = psThreadJobGetDone()) != NULL) { 118 if (job->args->n < 1) { 119 fprintf (stderr, "error with job\n"); 120 } else { 121 psScalar *scalar = NULL; 122 scalar = job->args->data[2]; 123 Nmoments += scalar->data.S32; 124 scalar = job->args->data[3]; 125 Nfail += scalar->data.S32; 126 scalar = job->args->data[4]; 127 Nfaint += scalar->data.S32; 128 } 129 psFree(job); 130 } 127 131 } 128 132 129 133 psFree (cellGroups); 130 134 131 psLogMsg ("psphot", PS_LOG_INFO, "%ld sources, %d moments, %d fai led: %f sec\n", sources->n, Nmoments, Nfail, psTimerMark ("psphot.stats"));135 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 136 133 137 psphotVisualShowMoments (sources); … … 166 170 int Nfail = 0; 167 171 int Nmoments = 0; 172 int Nfaint = 0; 168 173 for (int i = 0; i < sources->n; i++) { 169 174 pmSource *source = sources->data[i]; … … 171 176 // skip faint sources for moments measurement 172 177 if (source->peak->SN < MIN_SN) { 173 source->mode |= PM_SOURCE_MODE_BELOW_MOMENTS_SN; 178 source->mode |= PM_SOURCE_MODE_BELOW_MOMENTS_SN; 179 Nfaint++; 174 180 continue; 175 181 } … … 179 185 status = pmSourceLocalSky (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal); 180 186 if (!status) { 181 source->mode |= PM_SOURCE_MODE_SKY_FAILURE;182 psErrorClear(); // XXX re-consider the errors raised here183 Nfail ++;184 continue;187 source->mode |= PM_SOURCE_MODE_SKY_FAILURE; 188 psErrorClear(); // XXX re-consider the errors raised here 189 Nfail ++; 190 continue; 185 191 } 186 192 … … 189 195 status = pmSourceLocalSkyVariance (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal); 190 196 if (!status) { 191 source->mode |= PM_SOURCE_MODE_SKYVAR_FAILURE;192 Nfail ++;193 psErrorClear();194 continue;197 source->mode |= PM_SOURCE_MODE_SKYVAR_FAILURE; 198 Nfail ++; 199 psErrorClear(); 200 continue; 195 201 } 196 202 … … 208 214 status = pmSourceMoments (source, BIG_RADIUS); 209 215 if (status) { 210 source->mode |= PM_SOURCE_MODE_BIG_RADIUS;216 source->mode |= PM_SOURCE_MODE_BIG_RADIUS; 211 217 Nmoments ++; 212 218 continue; 213 219 } 214 220 215 source->mode |= PM_SOURCE_MODE_MOMENTS_FAILURE;221 source->mode |= PM_SOURCE_MODE_MOMENTS_FAILURE; 216 222 Nfail ++; 217 223 psErrorClear(); … … 225 231 scalar = job->args->data[3]; 226 232 scalar->data.S32 = Nfail; 227 233 234 scalar = job->args->data[4]; 235 scalar->data.S32 = Nfaint; 236 228 237 return true; 229 238 } … … 268 277 status = pmSourceLocalSky (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal); 269 278 if (!status) { 270 psErrorClear(); // XXX re-consider the errors raised here271 Nfail ++;272 continue;279 psErrorClear(); // XXX re-consider the errors raised here 280 Nfail ++; 281 continue; 273 282 } 274 283 … … 277 286 status = pmSourceLocalSkyVariance (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal); 278 287 if (!status) { 279 Nfail ++;280 psErrorClear();281 continue;288 Nfail ++; 289 psErrorClear(); 290 continue; 282 291 } 283 292 … … 307 316 *nmoments = Nmoments; 308 317 *nfail = Nfail; 309 318 310 319 return true; 311 320 } 312 # endif 321 # endif
Note:
See TracChangeset
for help on using the changeset viewer.
