Changeset 26893 for trunk/psModules/src/camera
- Timestamp:
- Feb 10, 2010, 7:34:39 PM (16 years ago)
- Location:
- trunk/psModules/src/camera
- Files:
-
- 6 edited
-
pmFPA.c (modified) (1 diff)
-
pmFPAMaskWeight.c (modified) (4 diffs)
-
pmFPAMosaic.c (modified) (6 diffs)
-
pmFPAfile.c (modified) (2 diffs)
-
pmFPAfile.h (modified) (1 diff)
-
pmFPAfileIO.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPA.c
r26466 r26893 105 105 psFree(fpa->concepts); 106 106 psFree(fpa->analysis); 107 psFree( (void *)fpa->camera);107 psFree(fpa->camera); 108 108 psFree(fpa->hdu); 109 109 -
trunk/psModules/src/camera/pmFPAMaskWeight.c
r26076 r26893 370 370 371 371 psImage *image = readout->image, *mask = readout->mask, *variance = readout->variance; // Readout parts 372 373 372 int numCols = image->numCols, numRows = image->numRows; // Size of image 374 int numPix = numCols * numRows; // Number of pixels 375 int num = PS_MAX(sample, numPix); // Number we care about 373 374 int xMin, xMax, yMin, yMax; // Bounds of image 375 if (mask) { 376 xMin = numCols; 377 xMax = 0; 378 yMin = numRows; 379 yMax = 0; 380 for (int y = 0; y < numRows; y++) { 381 for (int x = 0; x < numCols; x++) { 382 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) { 383 continue; 384 } 385 xMin = PS_MIN(xMin, x); 386 xMax = PS_MAX(xMax, x); 387 yMin = PS_MIN(yMin, y); 388 yMax = PS_MAX(yMax, y); 389 } 390 } 391 } else { 392 xMin = 0; 393 xMax = numCols; 394 yMin = 0; 395 yMax = numRows; 396 } 397 398 int xNum = xMax - xMin, yNum = yMax - yMin; // Number of pixels 399 400 int numPix = xNum * yNum; // Number of pixels 401 int num = PS_MIN(sample, numPix); // Number we care about 376 402 psVector *signoise = psVectorAllocEmpty(num, PS_TYPE_F32); // Signal-to-noise values 377 403 … … 379 405 // We have an image smaller than Nsubset, so just loop over the image pixels 380 406 int index = 0; // Index for vector 381 for (int y = 0; y < numRows; y++) {382 for (int x = 0; x < numCols; x++) {407 for (int y = yMin; y < yMax; y++) { 408 for (int x = xMin; x < xMax; x++) { 383 409 if ((mask && mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) || 384 410 !isfinite(image->data.F32[y][x]) || !isfinite(variance->data.F32[y][x])) { … … 397 423 // Pixel coordinates 398 424 int pixel = numPix * psRandomUniform(rng); 399 int x = pixel % numCols;400 int y = pixel / numCols;425 int x = xMin + pixel % xNum; 426 int y = yMin + pixel / xNum; 401 427 402 428 if ((mask && mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) || … … 428 454 // Check valid range of correction factor 429 455 if ((isfinite(minValid) && correction < minValid) || (isfinite(maxValid) && correction > maxValid)) { 430 psWarning("Variance renormalisation is outside valid range: %f vs %f:%f --- no correction made", 431 correction, minValid, maxValid); 432 return true; 433 } 434 435 psBinaryOp(variance, variance, "*", psScalarAlloc(PS_SQR(correction), PS_TYPE_F32)); 456 psError(PS_ERR_UNKNOWN, true, "Variance renormalisation is outside valid range: %f vs %f:%f --- no correction made", correction, minValid, maxValid); 457 psMetadataAddF32(readout->analysis, PS_LIST_TAIL, PM_READOUT_ANALYSIS_RENORM, 0, "Renormalisation of variance", PS_SQR(correction)); 458 return false; 459 } 460 461 psImage *subImage = psImageSubset(variance, psRegionSet(xMin, xMax, yMin, yMax)); // Smaller image 462 psBinaryOp(subImage, subImage, "*", psScalarAlloc(PS_SQR(correction), PS_TYPE_F32)); 463 psFree(subImage); 436 464 437 465 pmHDU *hdu = pmHDUFromReadout(readout); // HDU for readout -
trunk/psModules/src/camera/pmFPAMosaic.c
r25383 r26893 626 626 bool good = true; // Is everything good? 627 627 628 const char *cellName = psMetadataLookupStr(NULL, cell->concepts, "CELL.NAME"); // Name of cell 629 const char *chipName = psMetadataLookupStr(NULL, cell->parent->concepts, "CHIP.NAME"); // Name of chip 630 628 631 // Offset of the cell on the chip 629 632 int x0Cell = psMetadataLookupS32(&mdok, cell->concepts, "CELL.X0"); 630 633 if (!mdok) { 631 psError(PS_ERR_UNKNOWN, true, "CELL.X0 for cell is not set.\n");634 psError(PS_ERR_UNKNOWN, true, "CELL.X0 for cell %s,%s is not set.\n", chipName, cellName); 632 635 good = false; 633 636 } 634 637 int y0Cell = psMetadataLookupS32(&mdok, cell->concepts, "CELL.Y0"); 635 638 if (!mdok) { 636 psError(PS_ERR_UNKNOWN, true, "CELL.Y0 for cell is not set.\n");639 psError(PS_ERR_UNKNOWN, true, "CELL.Y0 for cell %s,%s is not set.\n", chipName, cellName); 637 640 good = false; 638 641 } 639 psTrace("psModules.camera", 5, "Cell %ld: x0=%d y0=%d\n", index, x0Cell, y0Cell); 642 psTrace("psModules.camera", 5, "Cell %s,%s (%ld): x0=%d y0=%d\n", 643 chipName, cellName, index, x0Cell, y0Cell); 640 644 641 645 // Offset of the chip on the FPA … … 649 653 x0Chip = psMetadataLookupS32(&mdok, chip->concepts, "CHIP.X0"); 650 654 if (!mdok) { 651 psError(PS_ERR_UNKNOWN, true, "CHIP.X0 for chip is not set.\n");655 psError(PS_ERR_UNKNOWN, true, "CHIP.X0 for chip %s is not set.\n", chipName); 652 656 good = false; 653 657 } 654 658 y0Chip = psMetadataLookupS32(&mdok, chip->concepts, "CHIP.Y0"); 655 659 if (!mdok) { 656 psError(PS_ERR_UNKNOWN, true, "CHIP.Y0 for chip is not set.\n");660 psError(PS_ERR_UNKNOWN, true, "CHIP.Y0 for chip %s is not set.\n", chipName); 657 661 good = false; 658 662 } … … 662 666 xBin->data.S32[index] = psMetadataLookupS32(&mdok, cell->concepts, "CELL.XBIN"); 663 667 if (!mdok || xBin->data.S32[index] == 0) { 664 psError(PS_ERR_UNKNOWN, true, "CELL.XBIN for cell is not set.\n");668 psError(PS_ERR_UNKNOWN, true, "CELL.XBIN for cell %s,%s is not set.\n", chipName, cellName); 665 669 return false; 666 670 } else if (xBin->data.S32[index] < *xBinMin) { … … 669 673 yBin->data.S32[index] = psMetadataLookupS32(&mdok, cell->concepts, "CELL.YBIN"); 670 674 if (!mdok || yBin->data.S32[index] == 0) { 671 psError(PS_ERR_UNKNOWN, true, "CELL.YBIN for cell is not set.\n");675 psError(PS_ERR_UNKNOWN, true, "CELL.YBIN for cell %s,%s is not set.\n", chipName, cellName); 672 676 return false; 673 677 } else if (yBin->data.S32[index] < *yBinMin) { … … 678 682 int xParityCell = psMetadataLookupS32(&mdok, cell->concepts, "CELL.XPARITY"); 679 683 if (!mdok || (xParityCell != 1 && xParityCell != -1)) { 680 psError(PS_ERR_UNKNOWN, true, "CELL.XPARITY for cell is not set.\n");684 psError(PS_ERR_UNKNOWN, true, "CELL.XPARITY for cell %s,%s is not set.\n", chipName, cellName); 681 685 return false; 682 686 } 683 687 int yParityCell = psMetadataLookupS32(&mdok, cell->concepts, "CELL.YPARITY"); 684 688 if (!mdok || (yParityCell != 1 && yParityCell != -1)) { 685 psError(PS_ERR_UNKNOWN, true, "CELL.YPARITY for cell is not set.\n");689 psError(PS_ERR_UNKNOWN, true, "CELL.YPARITY for cell %s,%s is not set.\n", chipName, cellName); 686 690 return false; 687 691 } … … 693 697 xParityChip = psMetadataLookupS32(&mdok, chip->concepts, "CHIP.XPARITY"); 694 698 if (!mdok || (xParityChip != 1 && xParityChip != -1)) { 695 psError(PS_ERR_UNKNOWN, true, "CHIP.XPARITY for chip is not set.\n");699 psError(PS_ERR_UNKNOWN, true, "CHIP.XPARITY for chip %s is not set.\n", chipName); 696 700 return false; 697 701 } 698 702 yParityChip = psMetadataLookupS32(&mdok, chip->concepts, "CHIP.YPARITY"); 699 703 if (!mdok || (yParityChip != 1 && yParityChip != -1)) { 700 psError(PS_ERR_UNKNOWN, true, "CHIP.YPARITY for chip is not set.\n");704 psError(PS_ERR_UNKNOWN, true, "CHIP.YPARITY for chip %s is not set.\n", chipName); 701 705 return false; 702 706 } -
trunk/psModules/src/camera/pmFPAfile.c
r23746 r26893 519 519 if (!strcasecmp(type, "SUBKERNEL")) { 520 520 return PM_FPA_FILE_SUBKERNEL; 521 } 522 if (!strcasecmp(type, "PATTERN")) { 523 return PM_FPA_FILE_PATTERN; 521 524 } 522 525 … … 563 566 case PM_FPA_FILE_SUBKERNEL: 564 567 return ("SUBKERNEL"); 568 case PM_FPA_FILE_PATTERN: 569 return "PATTERN"; 565 570 default: 566 571 return ("NONE"); -
trunk/psModules/src/camera/pmFPAfile.h
r25979 r26893 49 49 PM_FPA_FILE_SUBKERNEL, 50 50 PM_FPA_FILE_SRCTEXT, 51 PM_FPA_FILE_PATTERN, 51 52 } pmFPAfileType; 52 53 -
trunk/psModules/src/camera/pmFPAfileIO.c
r25979 r26893 43 43 #include "pmFPAConstruct.h" 44 44 #include "pmSubtractionIO.h" 45 #include "pmPatternIO.h" 45 46 #include "pmConcepts.h" 46 47 #include "pmConfigRun.h" … … 66 67 67 68 switch (place) { 68 case PM_FPA_BEFORE:69 case PM_FPA_BEFORE: 69 70 if (!pmFPAfileRead (file, view, config)) { 70 71 psError(PS_ERR_IO, false, "failed READ in FPA_BEFORE block for %s", file->name); … … 76 77 } 77 78 break; 78 case PM_FPA_AFTER:79 if (!pmFPAfileWrite (file, view, config)) {79 case PM_FPA_AFTER: 80 if (!pmFPAfileWrite (file, view, config)) { 80 81 psError(PS_ERR_IO, false, "failed WRITE in FPA_AFTER block for %s", file->name); 81 82 goto failure; … … 86 87 } 87 88 break; 88 default:89 default: 89 90 psAbort("You can't get here"); 90 91 } … … 202 203 status = pmSubtractionReadKernels(view, file, config); 203 204 break; 205 case PM_FPA_FILE_PATTERN: 206 status = pmPatternRead(view, file, config); 207 break; 204 208 case PM_FPA_FILE_SX: 205 209 case PM_FPA_FILE_RAW: … … 273 277 case PM_FPA_FILE_VARIANCE: 274 278 case PM_FPA_FILE_FRINGE: 275 case PM_FPA_FILE_DARK: { 276 // create FPA structure component based on view 277 psMetadata *format = file->format; // Camera format configuration 278 if (!format) { 279 format = config->format; 280 } 281 282 pmFPA *nameSource = file->src; // Source of FPA.OBS 283 if (!nameSource) { 284 nameSource = file->fpa; 285 } 286 bool mdok; // Status of MD lookup 287 const char *fpaObs = psMetadataLookupStr(&mdok, nameSource->concepts, "FPA.OBS"); // Obs. id 288 289 pmFPAAddSourceFromView(file->fpa, fpaObs, view, format); 290 psTrace ("psModules.camera", 5, "created fpa data elements for %s (%s) (%d:%d:%d)\n", 291 file->name, file->name, view->chip, view->cell, view->readout); 292 break; 293 } 279 case PM_FPA_FILE_DARK: 280 case PM_FPA_FILE_PATTERN: 281 { 282 // create FPA structure component based on view 283 psMetadata *format = file->format; // Camera format configuration 284 if (!format) { 285 format = config->format; 286 } 287 288 pmFPA *nameSource = file->src; // Source of FPA.OBS 289 if (!nameSource) { 290 nameSource = file->fpa; 291 } 292 bool mdok; // Status of MD lookup 293 const char *fpaObs = psMetadataLookupStr(&mdok, nameSource->concepts, "FPA.OBS"); // Obs. id 294 295 pmFPAAddSourceFromView(file->fpa, fpaObs, view, format); 296 psTrace ("psModules.camera", 5, "created fpa data elements for %s (%s) (%d:%d:%d)\n", 297 file->name, file->name, view->chip, view->cell, view->readout); 298 break; 299 } 294 300 case PM_FPA_FILE_HEADER: 295 301 psAbort ("Create not defined for HEADER"); … … 462 468 status = pmSubtractionWriteKernels(view, file, config); 463 469 break; 470 case PM_FPA_FILE_PATTERN: 471 status = pmPatternWrite(view, file, config); 472 break; 464 473 case PM_FPA_FILE_SX: 465 474 case PM_FPA_FILE_RAW: … … 543 552 case PM_FPA_FILE_DARK: 544 553 case PM_FPA_FILE_SUBKERNEL: 554 case PM_FPA_FILE_PATTERN: 545 555 case PM_FPA_FILE_CMF: 546 556 case PM_FPA_FILE_WCS: … … 610 620 break; 611 621 case PM_FPA_FILE_SUBKERNEL: 622 case PM_FPA_FILE_PATTERN: 612 623 case PM_FPA_FILE_SX: 613 624 case PM_FPA_FILE_RAW: … … 771 782 case PM_FPA_FILE_DARK: 772 783 case PM_FPA_FILE_SUBKERNEL: 784 case PM_FPA_FILE_PATTERN: 773 785 case PM_FPA_FILE_CMF: 774 786 case PM_FPA_FILE_WCS: … … 962 974 case PM_FPA_FILE_SUBKERNEL: 963 975 status = pmSubtractionWritePHU(view, file, config); 976 break; 977 case PM_FPA_FILE_PATTERN: 978 status = pmPatternWritePHU(view, file, config); 979 break; 964 980 case PM_FPA_FILE_CMF: 965 981 status = pmSource_CMF_WritePHU (view, file, config);
Note:
See TracChangeset
for help on using the changeset viewer.
