Changeset 23287 for trunk/psphot/src/psphotMagnitudes.c
- Timestamp:
- Mar 11, 2009, 5:22:15 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotMagnitudes.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotMagnitudes.c
r21519 r23287 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 … … 36 36 37 37 // the binning details are saved on the analysis metadata 38 psImageBinning *binning = psMetadataLookupPtr(&status, recipe, "PSPHOT.BACKGROUND.BINNING");38 psImageBinning *binning = psMetadataLookupPtr(&status, backModel->analysis, "PSPHOT.BACKGROUND.BINNING"); 39 39 40 40 bool IGNORE_GROWTH = psMetadataLookupBool (&status, recipe, "IGNORE_GROWTH"); … … 53 53 for (int i = 0; i < cellGroups->n; i++) { 54 54 55 psArray *cells = cellGroups->data[i];56 57 for (int j = 0; j < cells->n; j++) {58 59 // allocate a job -- if threads are not defined, this just runs the job60 psThreadJob *job = psThreadJobAlloc ("PSPHOT_MAGNITUDES");61 62 psArrayAdd(job->args, 1, cells->data[j]); // sources63 psArrayAdd(job->args, 1, psf);64 psArrayAdd(job->args, 1, binning);65 psArrayAdd(job->args, 1, backModel);66 psArrayAdd(job->args, 1, backStdev);67 68 PS_ARRAY_ADD_SCALAR(job->args, photMode, PS_TYPE_S32);69 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK);70 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for nAp71 72 if (!psThreadJobAddPending(job)) {73 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");74 psFree (job);75 return false;76 }77 psFree(job);55 psArray *cells = cellGroups->data[i]; 56 57 for (int j = 0; j < cells->n; j++) { 58 59 // allocate a job -- if threads are not defined, this just runs the job 60 psThreadJob *job = psThreadJobAlloc ("PSPHOT_MAGNITUDES"); 61 62 psArrayAdd(job->args, 1, cells->data[j]); // sources 63 psArrayAdd(job->args, 1, psf); 64 psArrayAdd(job->args, 1, binning); 65 psArrayAdd(job->args, 1, backModel); 66 psArrayAdd(job->args, 1, backStdev); 67 68 PS_ARRAY_ADD_SCALAR(job->args, photMode, PS_TYPE_S32); 69 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK); 70 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for nAp 71 72 if (!psThreadJobAddPending(job)) { 73 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 74 psFree (job); 75 return false; 76 } 77 psFree(job); 78 78 79 79 # if (0) 80 int nap = 0;81 if (!psphotMagnitudes_Unthreaded (&nap, cells->data[j], psf, binning, backModel, backStdev, photMode, maskVal)) {82 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");83 return false;84 }85 Nap += nap;80 int nap = 0; 81 if (!psphotMagnitudes_Unthreaded (&nap, cells->data[j], psf, binning, backModel, backStdev, photMode, maskVal)) { 82 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 83 return false; 84 } 85 Nap += nap; 86 86 # endif 87 }88 89 // wait for the threads to finish and manage results90 if (!psThreadPoolWait (false)) {91 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");92 return false;93 }94 95 // we have only supplied one type of job, so we can assume the types here96 psThreadJob *job = NULL;97 while ((job = psThreadJobGetDone()) != NULL) {98 if (job->args->n < 1) {99 fprintf (stderr, "error with job\n");100 } else {101 psScalar *scalar = job->args->data[7];102 Nap += scalar->data.S32;103 }104 psFree(job);105 }87 } 88 89 // wait for the threads to finish and manage results 90 if (!psThreadPoolWait (false)) { 91 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 92 return false; 93 } 94 95 // we have only supplied one type of job, so we can assume the types here 96 psThreadJob *job = NULL; 97 while ((job = psThreadJobGetDone()) != NULL) { 98 if (job->args->n < 1) { 99 fprintf (stderr, "error with job\n"); 100 } else { 101 psScalar *scalar = job->args->data[7]; 102 Nap += scalar->data.S32; 103 } 104 psFree(job); 105 } 106 106 } 107 107 … … 130 130 if (status && isfinite(source->apMag)) Nap ++; 131 131 132 if (backModel) {133 psAssert (binning, "if backModel is defined, so should binning be");134 source->sky = psImageUnbinPixel(source->peak->x, source->peak->y, backModel->image, binning);135 if (isnan(source->sky) && false) {136 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.sky");137 }138 } else {139 source->sky = NAN;140 }141 142 if (backStdev) {143 psAssert (binning, "if backStdev is defined, so should binning be");144 source->skyErr = psImageUnbinPixel(source->peak->x, source->peak->y, backStdev->image, binning);145 if (isnan(source->skyErr) && false) {146 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.skyErr");147 }148 } else {149 source->skyErr = NAN;150 }132 if (backModel) { 133 psAssert (binning, "if backModel is defined, so should binning be"); 134 source->sky = psImageUnbinPixel(source->peak->x, source->peak->y, backModel->image, binning); 135 if (isnan(source->sky) && false) { 136 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.sky"); 137 } 138 } else { 139 source->sky = NAN; 140 } 141 142 if (backStdev) { 143 psAssert (binning, "if backStdev is defined, so should binning be"); 144 source->skyErr = psImageUnbinPixel(source->peak->x, source->peak->y, backStdev->image, binning); 145 if (isnan(source->skyErr) && false) { 146 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.skyErr"); 147 } 148 } else { 149 source->skyErr = NAN; 150 } 151 151 } 152 152 … … 169 169 if (status && isfinite(source->apMag)) Nap ++; 170 170 171 if (backModel) {172 psAssert (binning, "if backModel is defined, so should binning be");173 source->sky = psImageUnbinPixel(source->peak->x, source->peak->y, backModel->image, binning);174 if (isnan(source->sky) && false) {175 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.sky");176 }177 } else {178 source->sky = NAN;179 }180 181 if (backStdev) {182 psAssert (binning, "if backStdev is defined, so should binning be");183 source->skyErr = psImageUnbinPixel(source->peak->x, source->peak->y, backStdev->image, binning);184 if (isnan(source->skyErr) && false) {185 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.skyErr");186 }187 } else {188 source->skyErr = NAN;189 }171 if (backModel) { 172 psAssert (binning, "if backModel is defined, so should binning be"); 173 source->sky = psImageUnbinPixel(source->peak->x, source->peak->y, backModel->image, binning); 174 if (isnan(source->sky) && false) { 175 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.sky"); 176 } 177 } else { 178 source->sky = NAN; 179 } 180 181 if (backStdev) { 182 psAssert (binning, "if backStdev is defined, so should binning be"); 183 source->skyErr = psImageUnbinPixel(source->peak->x, source->peak->y, backStdev->image, binning); 184 if (isnan(source->skyErr) && false) { 185 psLogMsg ("psphot.magnitudes", PS_LOG_DETAIL, "error setting pmSource.skyErr"); 186 } 187 } else { 188 source->skyErr = NAN; 189 } 190 190 } 191 191 … … 210 210 int nThreads = psMetadataLookupS32(&status, config->arguments, "NTHREADS"); // Number of threads 211 211 if (!status) { 212 nThreads = 0;212 nThreads = 0; 213 213 } 214 214 nThreads = 0; // XXX until testing is complete, do not thread this function … … 233 233 for (int i = 0; i < cellGroups->n; i++) { 234 234 235 psArray *cells = cellGroups->data[i];236 237 for (int j = 0; j < cells->n; j++) {238 239 // allocate a job -- if threads are not defined, this just runs the job240 psThreadJob *job = psThreadJobAlloc ("PSPHOT_PSF_WEIGHTS");241 242 psArrayAdd(job->args, 1, cells->data[j]); // sources243 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK);244 245 if (!psThreadJobAddPending(job)) {246 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");247 psFree (job);248 return false;249 }250 psFree(job);251 252 }253 254 // wait for the threads to finish and manage results255 if (!psThreadPoolWait (false)) {256 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");257 return false;258 }259 260 // we have only supplied one type of job, so we can assume the types here261 psThreadJob *job = NULL;262 while ((job = psThreadJobGetDone()) != NULL) {263 if (job->args->n < 1) {264 fprintf (stderr, "error with job\n");265 } 266 psFree(job);267 }235 psArray *cells = cellGroups->data[i]; 236 237 for (int j = 0; j < cells->n; j++) { 238 239 // allocate a job -- if threads are not defined, this just runs the job 240 psThreadJob *job = psThreadJobAlloc ("PSPHOT_PSF_WEIGHTS"); 241 242 psArrayAdd(job->args, 1, cells->data[j]); // sources 243 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK); 244 245 if (!psThreadJobAddPending(job)) { 246 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 247 psFree (job); 248 return false; 249 } 250 psFree(job); 251 252 } 253 254 // wait for the threads to finish and manage results 255 if (!psThreadPoolWait (false)) { 256 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 257 return false; 258 } 259 260 // we have only supplied one type of job, so we can assume the types here 261 psThreadJob *job = NULL; 262 while ((job = psThreadJobGetDone()) != NULL) { 263 if (job->args->n < 1) { 264 fprintf (stderr, "error with job\n"); 265 } 266 psFree(job); 267 } 268 268 } 269 269 … … 285 285 pmSource *source = (pmSource *) sources->data[i]; 286 286 287 // we must have a valid model288 pmModel *model = pmSourceGetModel (&isPSF, source);289 if (model == NULL) {290 psTrace ("psphot", 3, "fail mag : no valid model");291 source->pixWeight = NAN;292 continue;293 }287 // we must have a valid model 288 pmModel *model = pmSourceGetModel (&isPSF, source); 289 if (model == NULL) { 290 psTrace ("psphot", 3, "fail mag : no valid model"); 291 source->pixWeight = NAN; 292 continue; 293 } 294 294 295 295 status = pmSourcePixelWeight (&source->pixWeight, model, source->maskObj, maskVal); 296 if (!status) {297 psTrace ("psphot", 3, "fail to measure pixel weight");298 source->pixWeight = NAN;299 continue;300 }301 302 } 303 304 return true; 305 } 296 if (!status) { 297 psTrace ("psphot", 3, "fail to measure pixel weight"); 298 source->pixWeight = NAN; 299 continue; 300 } 301 302 } 303 304 return true; 305 }
Note:
See TracChangeset
for help on using the changeset viewer.
