- Timestamp:
- Feb 2, 2009, 2:37:06 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/pap_branch_20090128/psModules/src/camera/pmHDUGenerate.c
r21264 r21269 356 356 psElemType maskType = 0; // Type of readout masks 357 357 psElemType varianceType = 0; // Type of readout variances 358 psElemType covarianceType = 0; // Type of readout covariances359 358 { 360 359 psListIterator *iter = psListIteratorAlloc(cells, PS_LIST_HEAD, false); // Iterator for cells … … 385 384 varianceType = checkTypes(varianceType, readout->variance->type.type); 386 385 } 387 if (!hdu->covariances && readout->covariance) {388 covarianceType = checkTypes(covarianceType, PS_TYPE_F32);389 }390 386 } 391 387 } 392 388 psFree(iter); 393 389 } 394 if (numReadouts == 0 || (imageType == 0 && maskType == 0 && varianceType == 0 && covarianceType == 0)) {390 if (numReadouts == 0 || (imageType == 0 && maskType == 0 && varianceType == 0)) { 395 391 // Nothing from which to create an HDU 396 392 psFree(cells); … … 432 428 hdu->variances->data[i] = variance; 433 429 } 434 }435 if (covarianceType) {436 hdu->covariances = psHashAlloc(psListLength(cells));437 430 } 438 431 … … 456 449 psArray *readouts = cell->readouts; // Array of readouts 457 450 458 // Check size of covariances459 int xMinCovar = INT_MAX, xMaxCovar = INT_MIN, yMinCovar = INT_MAX, yMaxCovar = INT_MIN; // Size460 if (covarianceType) {461 for (int i = 0; i < readouts->n; i++) {462 pmReadout *readout = readouts->data[i]; // The readout of interest463 if (!readout) {464 continue;465 }466 psKernel *covar = readout->covariance; // Covariance matrix467 xMinCovar = PS_MIN(xMinCovar, covar->xMin);468 xMaxCovar = PS_MAX(xMaxCovar, covar->xMax);469 yMinCovar = PS_MIN(yMinCovar, covar->yMin);470 yMaxCovar = PS_MAX(yMaxCovar, covar->yMax);471 }472 }473 474 451 psArray *hduImages = hdu->images; // Array of images in the HDU 475 452 psArray *hduMasks = hdu->masks; // Array of masks in the HDU 476 453 psArray *hduVariances = hdu->variances; // Array of variances in the HDU 477 psArray *covariances = (covarianceType ? psArrayAlloc(readouts->n) : NULL; // Covariance images478 454 for (int i = 0; i < readouts->n; i++) { 479 455 pmReadout *readout = readouts->data[i]; // The readout of interest … … 496 472 psFree(readout->variance); 497 473 readout->variance = new; 498 }499 if (readout->covariance) {500 psKernel *covar = readout->covariance; // Covariance matrix501 int xMin = covar->xMin, xMax = covar->xMax, yMin = covar->yMin, yMax = covar->yMax;// Size502 if (xMin == xMinCovar && xMax == xMaxCovar && yMin == yMinCovar && yMax == yMaxCovar) {503 variances->data[i] = psMemIncrRefCounter(readout->covariance);504 } else {505 psKernel *new = psKernelAlloc(xMinCovar, xMaxCovar, yMinCovar, yMaxCovar);// New covar506 psImageInit(covar->image, 0);507 psImageOverlaySection(new->image, covar->image,508 xMinCovar - xMin, yMinCovar - yMin, "=");509 variances->data[i] = new;510 }511 474 } 512 475 … … 533 496 } 534 497 psFree(biassecsIter); 535 536 if (covariances) {537 const char *cellName = psMetadataLookupStr(NULL, cell->concepts, "CELL.NAME"); // Name of cell538 pmChip *chip = cell->parent; // Parent chip539 const char *chipName = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME"); // Name of chip540 if (!cellName || !chipName) {541 psError(PS_ERR_UNKNOWN, false, "Unable to find cell or chip name.");542 return false;543 }544 psString name = NULL; // Name for covariance extension545 psStringAppend(&name, "COVAR_%s_%s", chipName, cellName);546 if (psHashLookup(hdu->covariances, name)) {547 psHashRemove(hash, name);548 }549 psHashAdd(hdu->covariances, name, covariance);550 psFree(name);551 }552 498 } // Iterating over cells within the HDU 553 499 psFree(iter); … … 636 582 return false; 637 583 } 638 if (hdu->images && hdu->masks && hdu->variances && hdu->covariances) {584 if (hdu->images && hdu->masks && hdu->variances) { 639 585 // It's already here! 640 586 return true; … … 686 632 return generateForCells(chip); 687 633 } 688 if (hdu->images && hdu->masks && hdu->variances && hdu->covariances) {634 if (hdu->images && hdu->masks && hdu->variances) { 689 635 // It's already here! 690 636 return true; … … 735 681 return generateForChips(fpa); 736 682 } 737 if (hdu->images && hdu->masks && hdu->variances && hdu->covariances) {683 if (hdu->images && hdu->masks && hdu->variances) { 738 684 // It's already here! 739 685 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
