Changeset 19758
- Timestamp:
- Sep 25, 2008, 12:29:12 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/imcombine/pmSubtractionIO.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmSubtractionIO.c
r19535 r19758 36 36 #define NAME_NUMSTAMPS "NUMSTAMPS" // Number of good stamps 37 37 38 #define FALLBACK_EXTNAME "SUBTRACTION_KERNEL" // Fallback extension name 39 40 // Generate an extension name for the subtraction kernel 41 // In the case that there is no chip/cell (the readout is orphaned), the fallback extension name is used 42 static psString subtractionKernelExtname(const pmReadout *ro // Readout containing kernel 43 ) 44 { 45 psAssert(ro, "Required parameter"); 46 47 psString extname = NULL; // Name of FITS extension 48 pmCell *cell = ro->parent; // Parent cell 49 if (cell && cell->parent) { 50 pmChip *chip = cell->parent; // Parent chip 51 const char *chipName = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME"); // Name of chip 52 const char *cellName = psMetadataLookupStr(NULL, cell->concepts, "CELL.NAME"); // Name of cell 53 psAssert(chipName && cellName, "Chip and cell names should be defined in concepts."); 54 int roNum = -1; // Index of readout 55 for (int i = 0; i < cell->readouts->n && roNum == -1; i++) { 56 if (cell->readouts->data[i] == ro) { 57 roNum = i; 58 } 59 } 60 if (roNum != -1) { 61 psStringAppend(&extname, "%s_%s_%d", chipName, cellName, roNum); 62 } else { 63 psWarning("Unable to find readout number"); 64 } 65 } 66 67 if (!extname) { 68 extname = psStringCopy(FALLBACK_EXTNAME); 69 } 70 71 return extname; 72 } 38 #define EXTNAME "SUBTRACTION_KERNEL" // Extension name 73 39 74 40 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// … … 173 139 // CVS tags, used to identify the version of this file (in case incompatibilities are introduced) 174 140 psString cvsFile = psStringCopy("$RCSfile: pmSubtractionIO.c,v $"); 175 psString cvsRev = psStringCopy("$Revision: 1. 5$");176 psString cvsDate = psStringCopy("$Date: 2008-09- 12 19:01:46$");141 psString cvsRev = psStringCopy("$Revision: 1.6 $"); 142 psString cvsDate = psStringCopy("$Date: 2008-09-25 22:29:12 $"); 177 143 psStringSubstitute(&cvsFile, NULL, "RCSfile: "); 178 144 psStringSubstitute(&cvsRev, NULL, "Revision: "); … … 188 154 psFree(version); 189 155 190 psString extname = subtractionKernelExtname(ro); // Extension name 191 192 if (!psFitsWriteTable(fits, header, rows, extname)) { 156 if (!psFitsWriteTable(fits, header, rows, EXTNAME)) { 193 157 psError(PS_ERR_IO, false, "Unable to write subtraction kernel to FITS table."); 194 158 psFree(header); 195 159 psFree(rows); 196 psFree(extname);197 160 return false; 198 161 } … … 200 163 psFree(header); 201 164 psFree(rows); 202 psFree(extname);203 165 204 166 return true; … … 282 244 PS_ASSERT_FITS_NON_NULL(fits, false); 283 245 284 psString extname = subtractionKernelExtname(ro); // Extension name 285 if (!psFitsMoveExtName(fits, extname)) { 286 if (strcmp(extname, FALLBACK_EXTNAME) != 0) { 287 psErrorClear(); 288 if (!psFitsMoveExtName(fits, FALLBACK_EXTNAME)) { 289 psError(PS_ERR_IO, false, "Unable to move to subtraction kernel table."); 290 psFree(extname); 291 return false; 292 } 293 } else { 294 psError(PS_ERR_IO, false, "Unable to move to subtraction kernel table."); 295 psFree(extname); 296 return false; 297 } 298 } 299 psFree(extname); 246 if (!psFitsMoveExtName(fits, EXTNAME)) { 247 psError(PS_ERR_IO, false, "Unable to move to subtraction kernel table."); 248 return false; 249 } 300 250 301 251 psArray *table = psFitsReadTable(fits); // Table of interest
Note:
See TracChangeset
for help on using the changeset viewer.
