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