Changeset 21519 for trunk/psphot/src/psphotGuessModels.c
- Timestamp:
- Feb 16, 2009, 12:34:24 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotGuessModels.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotGuessModels.c
r21381 r21519 22 22 } 23 23 24 bool psphotGuessModel_Unthreaded (pmReadout *readout, psArray *sources, pmPSF *psf, psImageMaskType maskVal, psImageMaskType markVal);25 26 24 // construct an initial PSF model for each object 27 25 bool psphotGuessModels (pmConfig *config, pmReadout *readout, psArray *sources, pmPSF *psf) { … … 67 65 for (int j = 0; j < cells->n; j++) { 68 66 69 if (nThreads) {70 // allocate a job -- if threads are not defined, this just runs the job71 psThreadJob *job = psThreadJobAlloc ("PSPHOT_GUESS_MODEL");72 psArrayAdd(job->args, 1, readout);73 psArrayAdd(job->args, 1, cells->data[j]); // sources74 psArrayAdd(job->args, 1, psf); 75 76 // XXX change these to use abstract mask type info77 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK);78 PS_ARRAY_ADD_SCALAR(job->args, markVal, PS_TYPE_IMAGE_MASK); 79 80 if (!psThreadJobAddPending(job)) {81 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");82 psFree (job);83 return false;84 }85 psFree(job); 86 } else { 67 // allocate a job -- if threads are not defined, this just runs the job 68 psThreadJob *job = psThreadJobAlloc ("PSPHOT_GUESS_MODEL"); 69 psArrayAdd(job->args, 1, readout); 70 psArrayAdd(job->args, 1, cells->data[j]); // sources 71 psArrayAdd(job->args, 1, psf); 72 73 // XXX change these to use abstract mask type info 74 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK); 75 PS_ARRAY_ADD_SCALAR(job->args, markVal, PS_TYPE_IMAGE_MASK); 76 77 if (!psThreadJobAddPending(job)) { 78 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 79 psFree (job); 80 return false; 81 } 82 psFree(job); 83 84 # if (0) 87 85 if (!psphotGuessModel_Unthreaded (readout, cells->data[j], psf, maskVal, markVal)) { 88 86 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 89 87 return false; 90 88 } 91 } 92 } 93 94 if (nThreads) { 95 // wait for the threads to finish and manage results 96 // wait here for the threaded jobs to finish 97 // fprintf (stderr, "wait for threads (%d, %d)\n", jx, jy); 98 if (!psThreadPoolWait (false)) { 99 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 100 return false; 101 } 102 103 // we have only supplied one type of job, so we can assume the types here 104 psThreadJob *job = NULL; 105 while ((job = psThreadJobGetDone()) != NULL) { 106 // we have no returned data from this operation 107 if (job->args->n < 1) { 108 fprintf (stderr, "error with job\n"); 109 } 110 psFree(job); 111 } 89 # endif 90 } 91 92 // wait for the threads to finish and manage results 93 // wait here for the threaded jobs to finish 94 // fprintf (stderr, "wait for threads (%d, %d)\n", jx, jy); 95 if (!psThreadPoolWait (false)) { 96 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 97 return false; 98 } 99 100 // we have only supplied one type of job, so we can assume the types here 101 psThreadJob *job = NULL; 102 while ((job = psThreadJobGetDone()) != NULL) { 103 // we have no returned data from this operation 104 if (job->args->n < 1) { 105 fprintf (stderr, "error with job\n"); 106 } 107 psFree(job); 112 108 } 113 109 } … … 116 112 int nMiss = 0; 117 113 for (int i = 0; i < sources->n; i++) { 118 119 114 pmSource *source = sources->data[i]; 120 if (source->mode & PM_SOURCE_MODE_EXT_LIMIT) { 121 source->mode &= ~PM_SOURCE_MODE_EXT_LIMIT; 115 if (source->tmpFlags & PM_SOURCE_TMPF_MODEL_GUESS) { 122 116 continue; 123 117 } 124 125 118 nMiss ++; 126 119 } 127 ps LogMsg ("psphot.models", 4, "failedto build models for %d objects\n", nMiss);120 psAssert (nMiss == 0, "failed to attempt to build models for %d objects\n", nMiss); 128 121 129 122 psFree (cellGroups); … … 148 141 pmSource *source = sources->data[i]; 149 142 150 // XXXX this is just for a test: use this to mark sources for which the model is measured151 // check later thatall are used.152 source-> mode |= PM_SOURCE_MODE_EXT_LIMIT;143 // this is used to mark sources for which the model is measured. We check later that 144 // all are used. 145 source->tmpFlags |= PM_SOURCE_TMPF_MODEL_GUESS; 153 146 154 147 // skip non-astronomical objects (very likely defects) … … 185 178 pmModel *modelPSF = pmModelFromPSF (modelEXT, psf); // ALLOC X5 186 179 if (modelPSF == NULL) { 187 psError(PSPHOT_ERR_PSF, false, 188 "Failed to determine PSF model at r,c = (%d,%d); trying centre of image", 180 psWarning ("Failed to determine PSF model at r,c = (%d,%d); trying centre of image", 189 181 source->peak->y, source->peak->x); 190 // 191 // Try the centre of the image 192 // 182 183 // Try the center of the image 193 184 modelEXT->params->data.F32[PM_PAR_XPOS] = 0.5*readout->image->numCols; 194 185 modelEXT->params->data.F32[PM_PAR_YPOS] = 0.5*readout->image->numRows; 195 186 modelPSF = pmModelFromPSF (modelEXT, psf); 196 187 if (modelPSF == NULL) { 197 psError(PSPHOT_ERR_PSF, false, 198 "Failed to determine PSF model at centre of image"); 188 psError(PSPHOT_ERR_PSF, false, "Failed to determine PSF model at center of image"); 199 189 psFree(modelEXT); 200 190 return false; 201 191 } 202 203 192 source->mode |= PM_SOURCE_MODE_BADPSF; 204 193 } … … 221 210 } 222 211 212 # if (0) 223 213 // construct models only for sources in the specified region 224 214 bool psphotGuessModel_Unthreaded (pmReadout *readout, psArray *sources, pmPSF *psf, psImageMaskType maskVal, psImageMaskType markVal) { … … 301 291 return true; 302 292 } 293 # endif
Note:
See TracChangeset
for help on using the changeset viewer.
