Changeset 7717
- Timestamp:
- Jun 27, 2006, 7:12:19 PM (20 years ago)
- Location:
- trunk/psModules/src/camera
- Files:
-
- 7 edited
-
pmFPAConstruct.c (modified) (4 diffs)
-
pmFPACopy.c (modified) (2 diffs)
-
pmFPAWrite.c (modified) (10 diffs)
-
pmFPAview.c (modified) (4 diffs)
-
pmHDU.c (modified) (2 diffs)
-
pmHDU.h (modified) (1 diff)
-
pmHDUUtils.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPAConstruct.c
r7643 r7717 522 522 // Case 1: PHU=FPA and EXTENSIONS=NONE. We need to parse the single list of chip:cell:cellType entries. 523 523 if (strcasecmp(phuType, "FPA") == 0 && strcasecmp(extType, "NONE") == 0) { 524 phdu->blankPHU = false; 524 525 const char *contents = psMetadataLookupStr(&mdok, format, "CONTENTS"); // The contents of the file 525 526 if (!mdok || !contents || strlen(contents) == 0) { … … 529 530 return NULL; 530 531 } 531 532 532 if (processContents(fpa, NULL, NULL, phdu, PM_FPA_LEVEL_FPA, contents, format) < 0) { 533 533 psError(PS_ERR_IO, false, "Error setting CONTENTS"); … … 563 563 // chip/cell directly from that. 564 564 if (strcasecmp(extType, "NONE") == 0) { 565 phdu->blankPHU = false; 565 566 pmChip *chip = NULL; // The chip of interest 566 567 pmCell *cell = NULL; // The cell of interest … … 650 651 // Case 3: EXTENSIONS=CHIP or EXTENSIONS=CELL. We have extensions that we iterate through. The CONTENTS 651 652 // is a list of extensions. 653 phdu->blankPHU = true; 652 654 pmChip *chip = NULL; // The chip of interest 653 655 pmCell *cell = NULL; // The cell of interest -
trunk/psModules/src/camera/pmFPACopy.c
r7624 r7717 32 32 } 33 33 34 static pmHDU *find PHU(const pmCell *cell// The cell for which to find the PHU35 )34 static pmHDU *findBlankPHU(const pmCell *cell// The cell for which to find the PHU 35 ) 36 36 { 37 37 assert(cell); 38 38 39 if (cell->hdu && cell->hdu-> phu) {39 if (cell->hdu && cell->hdu->blankPHU) { 40 40 return cell->hdu; 41 41 } 42 42 pmChip *chip = cell->parent; // The parent chip 43 if (chip->hdu && chip->hdu-> phu) {43 if (chip->hdu && chip->hdu->blankPHU) { 44 44 return chip->hdu; 45 45 } 46 46 pmFPA *fpa = chip->parent; // The parent FPA 47 if (fpa->hdu && fpa->hdu-> phu) {47 if (fpa->hdu && fpa->hdu->blankPHU) { 48 48 return fpa->hdu; 49 49 } … … 261 261 } 262 262 // Copy the PHU over as well, if required 263 pmHDU *targetPHU = find PHU(target); // The target PHU263 pmHDU *targetPHU = findBlankPHU(target); // The target PHU 264 264 if (targetPHU && targetPHU != targetHDU && !targetPHU->header) { 265 pmHDU *sourcePHU = find PHU(source); // The source PHU265 pmHDU *sourcePHU = findBlankPHU(source); // The source PHU 266 266 targetPHU->header = psMetadataCopy(targetPHU->header, sourcePHU->header); 267 267 } -
trunk/psModules/src/camera/pmFPAWrite.c
r7618 r7717 1 1 #include <stdio.h> 2 2 #include <strings.h> 3 #include "pslib.h"3 #include <pslib.h> 4 4 5 5 #include "pmFPA.h" … … 73 73 74 74 // We can simply update an existing HDU 75 if (((hdu->phu || strcasecmp(hdu->extname, "PHU") == 0) && !psFitsMoveExtNum(fits, 0, false)) || 76 !psFitsMoveExtName(fits, hdu->extname)) { 77 psError(PS_ERR_IO, false, "Unable to move to extension %s\n", hdu->extname); 75 if (hdu->blankPHU && !psFitsMoveExtNum(fits, 0, false)) { 76 psError(PS_ERR_IO, false, "Unable to move to PHU\n"); 78 77 return false; 79 78 } … … 87 86 psFits *fits, // FITS file to which to write 88 87 psDB *db, // Database handle for "concepts" update 89 bool pixels // Write the pixels, or only the PHU header?88 bool blank // Write a blank PHU? 90 89 ) 91 90 { … … 98 97 } 99 98 100 bool success = true; // Success of writing 101 if ((!pixels && hdu->phu && !hdu->images) || // Data-less PHU 102 (pixels && (hdu->images || (!hdu->images && pmHDUGenerateForCell(cell) && hdu->images)))) { // Data 103 success &= pmConceptsWriteCell(cell, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CAMERA | 104 PM_CONCEPT_SOURCE_DEFAULTS, false, NULL); 105 success &= pmHDUWrite(hdu, fits); 106 } 107 108 if (!success) { 109 psError(PS_ERR_IO, false, "Unable to write HDU for Chip.\n"); 110 return false; 111 } 112 99 // Generate the HDU if needed --- this is required after a pmFPACopy, or similar, which does not 100 // generate the HDU, but only copies the structure. 101 if (!hdu->blankPHU && !hdu->images) { 102 if (!pmHDUGenerateForCell(cell) || !hdu->images) { 103 psAbort(__func__, "Unable to generate HDU for cell --- likely programming error.\n"); 104 } 105 } 106 107 // We only write out a blank PHU if it's specifically requested. 108 bool writeBlank = blank && hdu->blankPHU && !hdu->images; // Write a blank PHU? 109 bool writeImage = !hdu->blankPHU && hdu->images; // Write an image? 110 111 if (writeBlank || writeImage) { 112 pmConceptSource source = PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CAMERA | 113 PM_CONCEPT_SOURCE_DEFAULTS; 114 if (!pmConceptsWriteCell(cell, source, false, NULL)) { 115 psError(PS_ERR_IO, false, "Unable to write concepts for cell.\n"); 116 return false; 117 } 118 if (!pmHDUWrite(hdu, fits)) { 119 psError(PS_ERR_IO, false, "Unable to write HDU for cell.\n"); 120 return false; 121 } 122 } 113 123 // No lower levels to which to recurse 114 124 115 return success;125 return true; 116 126 } 117 127 … … 120 130 psFits *fits, // FITS file to which to write 121 131 psDB *db, // Database handle for "concepts" update 122 bool pixels, // Write the pixels, or only the PHU header?132 bool blank, // Write a blank PHU? 123 133 bool recurse // Recurse to lower levels? 124 134 ) … … 129 139 pmHDU *hdu = chip->hdu; // The HDU 130 140 131 // XXXX this makes no sense to me at all: 132 // an image made up of only cells would not have 133 // any entries at this level, and could not be written out!!! 134 135 // if we have data at this level, try to write it out 141 // If we have data at this level, try to write it out 136 142 if (hdu) { 137 // generate the HDU if needed 138 if (pixels && !hdu->images) { 139 if (!pmHDUGenerateForChip(chip)) 140 psAbort ("pmFPAWrite", "error generating HDU"); 141 if (!hdu->images) 142 psAbort ("pmChipWrite", "programming error: failure generating HDU"); 143 } 144 145 // chip->hdu represents a blank data segment 146 bool blankSegment = !pixels && hdu->phu && !hdu->images; 147 148 // chip->hdu represents an image data segment 149 bool imageSegment = pixels && hdu->images; 150 151 if (blankSegment || imageSegment) { 152 pmConceptSource source = PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CAMERA | PM_CONCEPT_SOURCE_DEFAULTS; 143 // Generate the HDU if needed --- this is required after a pmFPACopy, or similar, which does not 144 // generate the HDU, but only copies the structure. 145 if (!blank && !hdu->blankPHU && !hdu->images) { 146 if (!pmHDUGenerateForChip(chip) || !hdu->images) { 147 psAbort (__func__, "Unable to generate HDU for chip --- likely programming error.\n"); 148 } 149 } 150 151 // We only write out a blank PHU if it's specifically requested. 152 bool writeBlank = blank && hdu->blankPHU && !hdu->images; // Write a blank HDU? 153 bool writeImage = !hdu->blankPHU && hdu->images; // Write an image? 154 155 if (writeBlank || writeImage) { 156 pmConceptSource source = PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CAMERA | 157 PM_CONCEPT_SOURCE_DEFAULTS; 153 158 if (!pmConceptsWriteChip(chip, source, false, true, NULL)) { 154 psError(PS_ERR_IO, false, "Unable to write Concepts for Chip.\n");159 psError(PS_ERR_IO, false, "Unable to write concepts for chip.\n"); 155 160 return false; 156 161 } 157 162 if (!pmHDUWrite(hdu, fits)) { 158 psError(PS_ERR_IO, false, "Unable to write HDU for Chip.\n");159 return false; 160 } 161 } 162 } 163 164 // XXX are we allowed to recurse if we have already written data at this level?163 psError(PS_ERR_IO, false, "Unable to write HDU for chip.\n"); 164 return false; 165 } 166 } 167 } 168 169 // Recurse to lower level if specifically requested. 165 170 if (recurse) { 166 171 psArray *cells = chip->cells; // Array of cells 167 172 for (int i = 0; i < cells->n; i++) { 168 173 pmCell *cell = cells->data[i]; // The cell of interest 169 if (!pmCellWrite(cell, fits, db, pixels)) {174 if (!pmCellWrite(cell, fits, db, blank)) { 170 175 psError(PS_ERR_IO, false, "Unable to write Chip.\n"); 171 176 return false; … … 182 187 psFits *fits, // FITS file to which to write 183 188 psDB *db, // Database handle for "concepts" update 184 bool pixels, // Write the pixels, or only the PHU header?189 bool blank, // Write a blank PHU? 185 190 bool recurse // Recurse to lower levels? 186 191 ) … … 191 196 pmHDU *hdu = fpa->hdu; // The HDU 192 197 193 // XXXX this makes no sense to me at all: 194 // an image made up of only chips or cells would not have 195 // any entries at this level, and could not be written out!!! 196 197 // if we have data at this level, try to write it out 198 // If we have data at this level, try to write it out 198 199 if (hdu) { 199 200 // XXXXXXXXX this was extremely unclear. the conditions MUST be written more explicitly 201 // so someone else has a chance to understand it without massive reverse engineering!!!! 202 203 // generate the HDU if needed 204 if (pixels && !hdu->images) { 205 if (!pmHDUGenerateForFPA(fpa)) 206 psAbort ("pmFPAWrite", "error generating HDU"); 207 if (!hdu->images) 208 psAbort ("pmFPAWrite", "programming error: failure generating HDU"); 209 } 210 211 // fpa->hdu represents a blank data segment 212 bool blankSegment = !pixels && hdu->phu && !hdu->images; 213 214 // fpa->hdu represents an image data segment 215 bool imageSegment = pixels && hdu->images; 216 217 // if neither of these conditions is true, we probably need to recurse down to the next level and try again 218 if (blankSegment || imageSegment) { 219 pmConceptSource source = PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CAMERA | PM_CONCEPT_SOURCE_DEFAULTS; 200 // Generate the HDU if needed --- this is required after a pmFPACopy, or similar, which does not 201 // generate the HDU, but only copies the structure. 202 if (!blank && !hdu->blankPHU && !hdu->images) { 203 if (!pmHDUGenerateForFPA(fpa)) { 204 psAbort("pmFPAWrite", "error generating HDU"); 205 } 206 if (!hdu->images) { 207 psAbort("pmFPAWrite", "programming error: failure generating HDU"); 208 } 209 } 210 211 // We only write out a blank PHU if it's specifically requested. 212 bool writeBlank = blank && hdu->blankPHU && !hdu->images; // Write a blank PHU? 213 bool writeImage = !hdu->blankPHU && hdu->images; // Write an image? 214 215 if (writeBlank || writeImage) { 216 pmConceptSource source = PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CAMERA | 217 PM_CONCEPT_SOURCE_DEFAULTS; 220 218 if (!pmConceptsWriteFPA(fpa, source, true, NULL)) { 221 psError(PS_ERR_IO, false, "Unable to write Concepts for FPA.\n");219 psError(PS_ERR_IO, false, "Unable to write concepts for FPA.\n"); 222 220 return false; 223 221 } … … 229 227 } 230 228 231 // XXX what are the rules on when we allow recursion?229 // Recurse to lower levels if requested 232 230 if (recurse) { 233 231 psArray *chips = fpa->chips; // Array of chips 234 232 for (int i = 0; i < chips->n; i++) { 235 233 pmChip *chip = chips->data[i]; // The chip of interest 236 if (!pmChipWrite(chip, fits, db, pixels, true)) {234 if (!pmChipWrite(chip, fits, db, blank, true)) { 237 235 psError(PS_ERR_IO, false, "Unable to write FPA.\n"); 238 236 return false; … … 242 240 243 241 return true; 244 245 // summary: 246 // pmHDUWrite writes out the PHU header or the header + pixels 247 // we need to generate the HDU (why?) 248 // we call pmHDUWrite if: 249 // - the fpa->hdu represents a blank data segment (header w/ no pixels) 250 // - the fpa->hdu represents an image data segment (header w/ pixels) 251 } 242 } -
trunk/psModules/src/camera/pmFPAview.c
r7589 r7717 3 3 * @author EAM, IfA 4 4 * 5 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $6 * @date $Date: 2006-06- 17 01:50:43$5 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2006-06-28 05:12:19 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 253 253 if (view->chip < 0) { 254 254 hdu = pmHDUFromFPA (fpa); 255 if (hdu-> phu)255 if (hdu->blankPHU) 256 256 return hdu; 257 257 return NULL; … … 260 260 chip = pmFPAviewThisChip (view, fpa); 261 261 hdu = pmHDUFromChip (chip); 262 if (hdu-> phu)262 if (hdu->blankPHU) 263 263 return hdu; 264 264 new.chip = -1; … … 269 269 cell = pmFPAviewThisCell (view, fpa); 270 270 hdu = pmHDUFromCell (cell); 271 if (hdu-> phu)271 if (hdu->blankPHU) 272 272 return hdu; 273 273 new.cell = -1; -
trunk/psModules/src/camera/pmHDU.c
r7604 r7717 15 15 { 16 16 // Deal with the PHU case 17 if ( strcasecmp(hdu->extname, "PHU") == 0 || hdu->phu) {18 if (! psFitsMoveExtNum(fits, 0, false)) {17 if (hdu->blankPHU) { 18 if (!psFitsMoveExtNum(fits, 0, false)) { 19 19 psError(PS_ERR_IO, false, "Unable to move to primary header!\n"); 20 20 return false; 21 21 } 22 hdu->phu = true; 23 return true; 24 } 25 26 if (! psFitsMoveExtName(fits, hdu->extname)) { 22 return true; 23 } 24 25 if (!psFitsMoveExtName(fits, hdu->extname)) { 27 26 psError(PS_ERR_IO, false, "Unable to move to extension %s\n", hdu->extname); 28 27 return false; 29 }30 // Now, just in case for some reason the PHU has an extension name that we've moved to....31 if (psFitsGetExtNum(fits) == 0) {32 hdu->phu = true;33 } else {34 hdu->phu = false;35 28 } 36 29 … … 61 54 62 55 if (!extname || strlen(extname) == 0) { 63 hdu-> phu= true;64 hdu->extname = psStringCopy("PHU");56 hdu->blankPHU = true; 57 hdu->extname = NULL; 65 58 } else { 66 if (strcasecmp(extname, "PHU") == 0) { 67 hdu->phu = true; 68 } else { 69 hdu->phu = false; 70 } 59 hdu->blankPHU = false; 71 60 hdu->extname = psStringCopy(extname); 72 61 } -
trunk/psModules/src/camera/pmHDU.h
r7017 r7717 6 6 { 7 7 psString extname; // The extension name 8 bool phu; // Is this the FITS Primary Header Unit8 bool blankPHU; // Is this a blank FITS Primary Header Unit, i.e., no data? 9 9 psMetadata *format; // The camera format 10 10 psMetadata *header; // The FITS header, or NULL if primary for FITS; or section info -
trunk/psModules/src/camera/pmHDUUtils.c
r7609 r7717 94 94 PS_ASSERT_PTR_NON_NULL(hdu,); 95 95 96 if (hdu-> phu) {97 psTrace(__func__, level, "HDU: %s (PHU)\n", hdu->extname);96 if (hdu->blankPHU) { 97 psTrace(__func__, level, "HDU: (PHU)\n"); 98 98 } else { 99 99 psTrace(__func__, level, "HDU: %s\n", hdu->extname);
Note:
See TracChangeset
for help on using the changeset viewer.
