Changeset 11864
- Timestamp:
- Feb 16, 2007, 4:34:39 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/camera/pmFPAfileFitsIO.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPAfileFitsIO.c
r11801 r11864 28 28 } 29 29 30 // Need to change format 31 pmFPA *fpa = pmFPAConstruct(file->camera); 30 // May need to change format 31 pmFPALevel level = pmFPAviewLevel(view); // Level for the view 32 if (level == PM_FPA_LEVEL_NONE || level == PM_FPA_LEVEL_READOUT) { 33 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 34 "This function shouldn't be called at the readout (or unknown) level."); 35 return NULL; 36 } 37 38 // Does the HDU of interest conform to the desired format? 39 pmHDU *hdu = pmFPAviewThisHDU(view, file->fpa); // The HDU of interest 40 if (hdu && hdu->format == file->format) { 41 // No work required 42 return psMemIncrRefCounter(file->fpa); 43 } 44 45 // Otherwise, we have to generate a copy with the correct format 32 46 33 47 pmFPAview *phuView = pmFPAviewAlloc(0); // View corresponding to the PHU … … 35 49 pmFPALevel phuLevel = pmFPAPHULevel(file->format); // Level for the PHU 36 50 switch (phuLevel) { 37 case PM_FPA_LEVEL_FPA:51 case PM_FPA_LEVEL_FPA: 38 52 phuView->chip = -1; 39 53 // Flow through 40 case PM_FPA_LEVEL_CHIP:54 case PM_FPA_LEVEL_CHIP: 41 55 phuView->cell = -1; 42 56 // Flow through 43 case PM_FPA_LEVEL_CELL:57 case PM_FPA_LEVEL_CELL: 44 58 phuView->readout = -1; 45 59 break; 46 case PM_FPA_LEVEL_READOUT:47 case PM_FPA_LEVEL_NONE:48 default:60 case PM_FPA_LEVEL_READOUT: 61 case PM_FPA_LEVEL_NONE: 62 default: 49 63 psAbort("Should never get here: bad phu level.\n"); 50 64 } … … 57 71 const char *fpaname = psMetadataLookupStr(&mdok, nameSource->concepts, "FPA.NAME"); // Name of FPA 58 72 59 if (!pmFPAAddSourceFromView(fpa, fpaname, phuView, file->format)) { 73 pmFPA *copy = pmFPAConstruct(file->camera); // FPA to return 74 if (!pmFPAAddSourceFromView(copy, fpaname, phuView, file->format)) { 60 75 psError(PS_ERR_UNKNOWN, false, "Unable to insert HDU into FPA for writing.\n"); 61 psFree( fpa);76 psFree(copy); 62 77 psFree(phuView); 63 78 return false; … … 65 80 psFree(phuView); 66 81 67 68 switch (phuLevel) { 69 case PM_FPA_LEVEL_FPA: 70 if (!pmFPACopy(fpa, file->fpa)) { 82 switch (level) { 83 case PM_FPA_LEVEL_FPA: 84 if (!pmFPACopy(copy, file->fpa)) { 71 85 psError(PS_ERR_UNKNOWN, false, "Unable to copy FPA for format conversion.\n"); 72 86 return NULL; 73 87 } 74 return fpa;75 case PM_FPA_LEVEL_CHIP: {76 pmChip *chip = pmFPAviewThisChip(view, fpa); // Chip of interest77 pmChip *srcChip = pmFPAviewThisChip(view, file->fpa); // Source chip78 if (!pmChipCopy(chip, srcChip)) {79 psError(PS_ERR_UNKNOWN, false, "Unable to copy chip for format conversion.\n");80 return false;81 }82 return fpa;83 }84 case PM_FPA_LEVEL_CELL: {85 pmCell *cell = pmFPAviewThisCell(view, fpa); // Cell of interest86 pmCell *srcCell = pmFPAviewThisCell(view, file->fpa); // Source cell87 if (!pmCellCopy(cell, srcCell)) {88 psError(PS_ERR_UNKNOWN, false, "Unable to copy cell for format conversion.\n");89 return false;90 }91 return fpa;92 }93 case PM_FPA_LEVEL_READOUT:94 case PM_FPA_LEVEL_NONE:95 default:88 return copy; 89 case PM_FPA_LEVEL_CHIP: { 90 pmChip *chip = pmFPAviewThisChip(view, copy); // Chip of interest 91 pmChip *srcChip = pmFPAviewThisChip(view, file->fpa); // Source chip 92 if (!pmChipCopy(chip, srcChip)) { 93 psError(PS_ERR_UNKNOWN, false, "Unable to copy chip for format conversion.\n"); 94 return false; 95 } 96 return copy; 97 } 98 case PM_FPA_LEVEL_CELL: { 99 pmCell *cell = pmFPAviewThisCell(view, copy); // Cell of interest 100 pmCell *srcCell = pmFPAviewThisCell(view, file->fpa); // Source cell 101 if (!pmCellCopy(cell, srcCell)) { 102 psError(PS_ERR_UNKNOWN, false, "Unable to copy cell for format conversion.\n"); 103 return false; 104 } 105 return copy; 106 } 107 case PM_FPA_LEVEL_READOUT: 108 case PM_FPA_LEVEL_NONE: 109 default: 96 110 psAbort("Should never get here: bad phu level.\n"); 97 111 } 112 98 113 return NULL; 114 99 115 } 100 116
Note:
See TracChangeset
for help on using the changeset viewer.
