Changeset 18960 for trunk/psModules/src/detrend/pmDark.c
- Timestamp:
- Aug 8, 2008, 8:09:07 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/detrend/pmDark.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/detrend/pmDark.c
r18893 r18960 102 102 bool pmDarkCombinePrepare(pmCell *output, const psArray *inputs, psArray *ordinates, const char *normConcept) 103 103 { 104 psArray *values = psArrayAlloc(inputs->n); 104 psArray *values = psArrayAlloc(inputs->n); 105 105 psVector *roMask = psVectorAlloc(inputs->n, PS_TYPE_U8); // Mask for bad readouts 106 106 psVector *norm = normConcept ? psVectorAlloc(inputs->n, PS_TYPE_F32) : NULL; // Normalizations for each … … 117 117 if (!norm) continue; 118 118 119 pmReadout *readout = inputs->data[i]; // Readout of interest120 float normValue; // Normalisation value121 if (!ordinateLookup(&normValue, &inRange, normConcept, false, NAN, NAN, readout)) {122 psWarning("Unable to find value of %s for readout %d", normConcept, i);123 roMask->data.U8[i] = 0xff;124 norm->data.F32[i] = NAN;125 numBadInputs++;126 continue;127 }128 if (normValue == 0.0) {129 psWarning("Normalisation value (%s) for readout %d is zero", normConcept, i);130 roMask->data.U8[i] = 0xff;131 norm->data.F32[i] = NAN;132 numBadInputs++;133 continue;134 }135 norm->data.F32[i] = 1.0 / normValue;119 pmReadout *readout = inputs->data[i]; // Readout of interest 120 float normValue; // Normalisation value 121 if (!ordinateLookup(&normValue, &inRange, normConcept, false, NAN, NAN, readout)) { 122 psWarning("Unable to find value of %s for readout %d", normConcept, i); 123 roMask->data.U8[i] = 0xff; 124 norm->data.F32[i] = NAN; 125 numBadInputs++; 126 continue; 127 } 128 if (normValue == 0.0) { 129 psWarning("Normalisation value (%s) for readout %d is zero", normConcept, i); 130 roMask->data.U8[i] = 0xff; 131 norm->data.F32[i] = NAN; 132 numBadInputs++; 133 continue; 134 } 135 norm->data.F32[i] = 1.0 / normValue; 136 136 } 137 137 … … 144 144 psFree(roMask); 145 145 psFree(orders); 146 psFree(norm);146 psFree(norm); 147 147 return false; 148 148 } … … 215 215 } 216 216 217 pmReadoutStackDefineOutput(readout, col0, row0, numCols, numRows, false, false, 0);218 psTrace("psModules.imcombine", 7, "Output minimum: %d,%d\n", col0, row0);217 pmReadoutStackDefineOutput(readout, col0, row0, numCols, numRows, false, false, 0); 218 psTrace("psModules.imcombine", 7, "Output minimum: %d,%d\n", col0, row0); 219 219 } 220 220 … … 269 269 bool mdok = false; 270 270 271 // retrieve the required parameter vectors 272 psArray *values = psMetadataLookupPtr(&mdok, output->analysis, "DARK.VALUES"); psAssert (values, "values not supplied");273 psVector *roMask = psMetadataLookupPtr(&mdok, output->analysis, "DARK.RO.MASK"); psAssert (roMask, "roMask not supplied");271 // retrieve the required parameter vectors 272 psArray *values = psMetadataLookupPtr(&mdok, output->analysis, "DARK.VALUES"); psAssert (values, "values not supplied"); 273 psVector *roMask = psMetadataLookupPtr(&mdok, output->analysis, "DARK.RO.MASK"); psAssert (roMask, "roMask not supplied"); 274 274 psPolynomialMD *poly = psMetadataLookupPtr(&mdok, output->analysis, "DARK.POLY"); psAssert (poly, "orders not supplied"); 275 275 276 276 // retrieve the norm vector, if supplied 277 psVector *norm = psMetadataLookupPtr(&mdok, output->analysis, "DARK.NORM");277 psVector *norm = psMetadataLookupPtr(&mdok, output->analysis, "DARK.NORM"); 278 278 279 279 // retrieve the 'counts' and 'sigma' images … … 367 367 } 368 368 369 bool pmDarkApplyScan_Threaded (psThreadJob *job) { 369 bool pmDarkApplyScan_Threaded(const psThreadJob *job) 370 { 371 PS_ASSERT_THREAD_JOB_NON_NULL(job, false); 372 370 373 pmReadout *readout = job->args->data[0]; 371 374 pmCell *dark = job->args->data[1]; … … 478 481 bool threaded = true; 479 482 int scanRows = pmDetrendGetScanRows(); 480 if (scanRows == 0) { 481 threaded = false;482 scanRows = readout->image->numRows;483 if (scanRows == 0) { 484 threaded = false; 485 scanRows = readout->image->numRows; 483 486 } 484 487 … … 486 489 int rowStop = PS_MIN (rowStart + scanRows, readout->image->numRows); 487 490 488 # define PS_ARRAY_ADD_SCALAR(ARRAY, VALUE, TYPE) { \489 psScalar *scalar = psScalarAlloc(VALUE, TYPE); \490 psArrayAdd(ARRAY, 1, scalar); \491 psFree (scalar); }492 493 491 if (threaded) { 494 // allocate a job, construct the arguments for this job 495 psThreadJob *job = psThreadJobAlloc ("PSMODULES_DETREND_DARK"); 496 psArrayAdd (job->args, 1, readout); 497 psArrayAdd (job->args, 1, dark); 498 psArrayAdd (job->args, 1, poly); 499 psArrayAdd (job->args, 1, values); 500 PS_ARRAY_ADD_SCALAR (job->args, bad, PS_TYPE_MASK); 501 PS_ARRAY_ADD_SCALAR (job->args, doNorm, PS_TYPE_U8); 502 PS_ARRAY_ADD_SCALAR (job->args, norm, PS_TYPE_F32); 503 PS_ARRAY_ADD_SCALAR (job->args, rowStart, PS_TYPE_S32); 504 PS_ARRAY_ADD_SCALAR (job->args, rowStop, PS_TYPE_S32); 505 506 // ppImageDetrendReadout(config, options, view) 507 if (!psThreadJobAddPending (job)) { 508 return false; 509 } 492 // allocate a job, construct the arguments for this job 493 psThreadJob *job = psThreadJobAlloc ("PSMODULES_DETREND_DARK"); 494 psArrayAdd (job->args, 1, readout); 495 psArrayAdd (job->args, 1, dark); 496 psArrayAdd (job->args, 1, poly); 497 psArrayAdd (job->args, 1, values); 498 PS_ARRAY_ADD_SCALAR (job->args, bad, PS_TYPE_MASK); 499 PS_ARRAY_ADD_SCALAR (job->args, doNorm, PS_TYPE_U8); 500 PS_ARRAY_ADD_SCALAR (job->args, norm, PS_TYPE_F32); 501 PS_ARRAY_ADD_SCALAR (job->args, rowStart, PS_TYPE_S32); 502 PS_ARRAY_ADD_SCALAR (job->args, rowStop, PS_TYPE_S32); 503 504 // ppImageDetrendReadout(config, options, view) 505 if (!psThreadJobAddPending (job)) { 506 psFree(job); 507 return false; 508 } 509 psFree(job); 510 510 } else { 511 pmDarkApplyScan (readout, dark, poly, values, bad, doNorm, norm, rowStart, rowStop);511 pmDarkApplyScan (readout, dark, poly, values, bad, doNorm, norm, rowStart, rowStop); 512 512 } 513 513 } 514 514 515 515 if (threaded) { 516 // wait here for the threaded jobs to finish517 if (!psThreadPoolWait ()) {518 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image.");519 return false;520 }521 fprintf (stderr, "success for threaded jobs\n");522 523 // free the done jobs524 psThreadJob *job = NULL;525 while ((job = psThreadJobGetDone()) != NULL) {526 psFree (job);527 }516 // wait here for the threaded jobs to finish 517 if (!psThreadPoolWait(false)) { 518 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image."); 519 return false; 520 } 521 fprintf (stderr, "success for threaded jobs\n"); 522 523 // free the done jobs 524 psThreadJob *job = NULL; 525 while ((job = psThreadJobGetDone()) != NULL) { 526 psFree (job); 527 } 528 528 } 529 529
Note:
See TracChangeset
for help on using the changeset viewer.
