Changeset 25027 for branches/pap/psModules/src/camera/pmFPARead.c
- Timestamp:
- Aug 7, 2009, 4:08:25 PM (17 years ago)
- Location:
- branches/pap
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/pap
- Property svn:mergeinfo changed
-
branches/pap/psModules
- Property svn:mergeinfo deleted
-
branches/pap/psModules/src/camera/pmFPARead.c
r23827 r25027 64 64 65 65 // Set the "thisXXXScan" value in the readout for the appropriate image type 66 static intreadoutSetThisScan(pmReadout *readout, // Readout of interest66 static void readoutSetThisScan(pmReadout *readout, // Readout of interest 67 67 fpaReadType type, // Type of image 68 68 int thisScan // Starting scan number … … 72 72 case FPA_READ_TYPE_IMAGE: 73 73 readout->thisImageScan = thisScan; 74 return readout->lastImageScan;74 return; 75 75 case FPA_READ_TYPE_MASK: 76 76 readout->thisMaskScan = thisScan; 77 return readout->lastMaskScan;77 return; 78 78 case FPA_READ_TYPE_VARIANCE: 79 79 readout->thisVarianceScan = thisScan; 80 return readout->lastVarianceScan;80 return; 81 81 default: 82 82 psAbort("Unknown read type: %x\n", type); 83 83 } 84 return false;85 84 } 86 85 … … 103 102 104 103 // Set the "lastXXXScan" value in the readout for the appropriate image type 105 static intreadoutSetLastScan(pmReadout *readout, // Readout of interest104 static void readoutSetLastScan(pmReadout *readout, // Readout of interest 106 105 fpaReadType type, // Type of image 107 106 int lastScan // Last scan number … … 111 110 case FPA_READ_TYPE_IMAGE: 112 111 readout->lastImageScan = lastScan; 113 return readout->lastImageScan;112 return; 114 113 case FPA_READ_TYPE_MASK: 115 114 readout->lastMaskScan = lastScan; 116 return readout->lastMaskScan;115 return; 117 116 case FPA_READ_TYPE_VARIANCE: 118 117 readout->lastVarianceScan = lastScan; 119 return readout->lastVarianceScan;118 return; 120 119 default: 121 120 psAbort("Unknown read type: %x\n", type); 122 121 } 123 return false;124 122 } 125 123 … … 143 141 // Determine number of readouts in the FITS file 144 142 // In the process, reads the header and concepts 145 static boolcellNumReadouts(pmCell *cell, // Cell of interest143 static int cellNumReadouts(pmCell *cell, // Cell of interest 146 144 psFits *fits, // FITS file 147 145 pmConfig *config // Configuration … … 155 153 if (!hdu || hdu->blankPHU) { 156 154 psError(PS_ERR_IO, true, "Unable to find HDU"); 157 return false;155 return 0; 158 156 } 159 157 if (!pmCellReadHeader(cell, fits, config)) { 160 158 psError(PS_ERR_IO, false, "Unable to read header for cell!\n"); 161 return false;159 return 0; 162 160 } 163 161 if (!pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CELLS, true, NULL)) { 164 162 psError(PS_ERR_IO, false, "Failed to read concepts for cell.\n"); 165 return false;163 return 0; 166 164 } 167 165 … … 171 169 if (!mdok) { 172 170 psError(PS_ERR_IO, true, "Unable to find NAXIS in header for extension %s\n", hdu->extname); 173 return false; 174 } 171 return 0; 172 } 173 175 174 if (naxis == 0) { 176 175 // No pixels to read 177 176 psError(PS_ERR_IO, true, "No pixels in extension %s.", hdu->extname); 178 return false;177 return 0; 179 178 } 180 179 if (naxis < 2 || naxis > 3) { 181 180 psError(PS_ERR_IO, true, "NAXIS in header of extension %s (= %d) is not valid.\n", 182 181 hdu->extname, naxis); 183 return false;182 return 0; 184 183 } 185 184 int naxis3; // Number of image planes … … 188 187 if (!mdok) { 189 188 psError(PS_ERR_IO, true, "Unable to find NAXIS3 in header for extension %s\n", hdu->extname); 190 return false;189 return 0; 191 190 } 192 191 } else { … … 296 295 static bool readoutMore(pmReadout *readout, // Readout of interest 297 296 psFits *fits, // FITS file 298 int z, // Plane number 297 int z, // Plane number to read 298 int *zMax, // Max plane number in this cell 299 299 int numScans, // Number of scans to read at a time 300 300 fpaReadType type, // Type of image … … 310 310 // N readouts, but numScans set to 0. only the first should report that it requires data, 311 311 // even if all readouts lack the image pointer. 312 if (!image) { 312 if (numScans == 0) { 313 if (!image) { 313 314 return true; 314 } 315 316 // If we have already read an image, this result implies we are done (no more to read) 317 if (numScans == 0) { 318 return false; 315 } else { 316 return false; 317 } 319 318 } 320 319 … … 324 323 return false; 325 324 } 326 int naxis3= cellNumReadouts(cell, fits, config); // Number of planes327 if (z >= naxis3) {325 *zMax = cellNumReadouts(cell, fits, config); // Number of planes 326 if (z >= *zMax) { 328 327 // No more to read 329 328 return false; … … 486 485 psFits *fits, // FITS file 487 486 int z, // Desired image plane 487 int *zMax, // Max plane number in this cell 488 488 int numScans, // Number of scans (row or col depends on CELL.READDIR); 0 for all 489 489 int overlap, // Number of scans (row/col) to overlap between scans … … 511 511 512 512 int naxis3 = cellNumReadouts(cell, fits, config); // Number of image planes 513 if (zMax) *zMax = naxis3; 514 513 515 if (z >= naxis3) { 514 516 psError(PS_ERR_IO, false, "Desired image plane (%d) exceeds available number (%d).", … … 592 594 } 593 595 594 // Determine the number of scans to read 595 int lastScan = readoutSetLastScan(readout, type, thisScan + numScans); 596 int origThisScan = thisScan; // Original value of thisScan (starting point for read) 596 597 if (thisScan == 0) { 597 598 overlap = 0; … … 601 602 thisScan = 0; 602 603 } 603 readoutSetThisScan(readout, type, thisScan);604 604 605 605 // Calculate limits, adjust readout->row0,col0 … … 620 620 } 621 621 } 622 int lastScan = origThisScan + numScans; // Last scan to read 623 624 readoutSetThisScan(readout, type, thisScan); 625 readoutSetLastScan(readout, type, lastScan); 622 626 623 627 // Blow away existing data. … … 1021 1025 1022 1026 1023 bool pmReadoutMore(pmReadout *readout, psFits *fits, int z, int numScans, pmConfig *config)1027 bool pmReadoutMore(pmReadout *readout, psFits *fits, int z, int *zMax, int numScans, pmConfig *config) 1024 1028 { 1025 1029 PS_ASSERT_PTR_NON_NULL(readout, false); 1026 1030 PS_ASSERT_FITS_NON_NULL(fits, false); 1027 1031 1028 return readoutMore(readout, fits, z, numScans, FPA_READ_TYPE_IMAGE, config);1029 } 1030 1031 bool pmReadoutReadChunk(pmReadout *readout, psFits *fits, int z, int numScans, int overlap, pmConfig *config)1032 return readoutMore(readout, fits, z, zMax, numScans, FPA_READ_TYPE_IMAGE, config); 1033 } 1034 1035 bool pmReadoutReadChunk(pmReadout *readout, psFits *fits, int z, int *zMax, int numScans, int overlap, pmConfig *config) 1032 1036 { 1033 1037 PS_ASSERT_PTR_NON_NULL(readout, false); … … 1036 1040 PS_ASSERT_INT_NONNEGATIVE(numScans, false); 1037 1041 1038 return readoutReadChunk(readout, fits, z, numScans, overlap, FPA_READ_TYPE_IMAGE, config);1042 return readoutReadChunk(readout, fits, z, zMax, numScans, overlap, FPA_READ_TYPE_IMAGE, config); 1039 1043 } 1040 1044 … … 1044 1048 PS_ASSERT_FITS_NON_NULL(fits, false); 1045 1049 1046 return readoutReadChunk(readout, fits, z, 0, 0, FPA_READ_TYPE_IMAGE, config);1050 return readoutReadChunk(readout, fits, z, NULL, 0, 0, FPA_READ_TYPE_IMAGE, config); 1047 1051 } 1048 1052 … … 1084 1088 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1085 1089 1086 bool pmReadoutMoreMask(pmReadout *readout, psFits *fits, int z, int numScans, pmConfig *config)1090 bool pmReadoutMoreMask(pmReadout *readout, psFits *fits, int z, int *zMax, int numScans, pmConfig *config) 1087 1091 { 1088 1092 PS_ASSERT_PTR_NON_NULL(readout, false); 1089 1093 PS_ASSERT_FITS_NON_NULL(fits, false); 1090 1094 1091 return readoutMore(readout, fits, z, numScans, FPA_READ_TYPE_MASK, config);1092 } 1093 1094 bool pmReadoutReadChunkMask(pmReadout *readout, psFits *fits, int z, int numScans, int overlap,1095 return readoutMore(readout, fits, z, zMax, numScans, FPA_READ_TYPE_MASK, config); 1096 } 1097 1098 bool pmReadoutReadChunkMask(pmReadout *readout, psFits *fits, int z, int *zMax, int numScans, int overlap, 1095 1099 pmConfig *config) 1096 1100 { … … 1100 1104 PS_ASSERT_INT_NONNEGATIVE(numScans, false); 1101 1105 1102 return readoutReadChunk(readout, fits, z, numScans, overlap, FPA_READ_TYPE_MASK, config);1106 return readoutReadChunk(readout, fits, z, zMax, numScans, overlap, FPA_READ_TYPE_MASK, config); 1103 1107 } 1104 1108 … … 1108 1112 PS_ASSERT_FITS_NON_NULL(fits, false); 1109 1113 1110 return readoutReadChunk(readout, fits, z, 0, 0, FPA_READ_TYPE_MASK, config);1114 return readoutReadChunk(readout, fits, z, NULL, 0, 0, FPA_READ_TYPE_MASK, config); 1111 1115 } 1112 1116 … … 1139 1143 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1140 1144 1141 bool pmReadoutMoreVariance(pmReadout *readout, psFits *fits, int z, int numScans, pmConfig *config)1145 bool pmReadoutMoreVariance(pmReadout *readout, psFits *fits, int z, int *zMax, int numScans, pmConfig *config) 1142 1146 { 1143 1147 PS_ASSERT_PTR_NON_NULL(readout, false); 1144 1148 PS_ASSERT_FITS_NON_NULL(fits, false); 1145 1149 1146 return readoutMore(readout, fits, z, numScans, FPA_READ_TYPE_VARIANCE, config);1147 } 1148 1149 bool pmReadoutReadChunkVariance(pmReadout *readout, psFits *fits, int z, int numScans, int overlap,1150 return readoutMore(readout, fits, z, zMax, numScans, FPA_READ_TYPE_VARIANCE, config); 1151 } 1152 1153 bool pmReadoutReadChunkVariance(pmReadout *readout, psFits *fits, int z, int *zMax, int numScans, int overlap, 1150 1154 pmConfig *config) 1151 1155 { … … 1155 1159 PS_ASSERT_INT_NONNEGATIVE(numScans, false); 1156 1160 1157 return readoutReadChunk(readout, fits, z, numScans, overlap, FPA_READ_TYPE_VARIANCE, config);1161 return readoutReadChunk(readout, fits, z, zMax, numScans, overlap, FPA_READ_TYPE_VARIANCE, config); 1158 1162 } 1159 1163 … … 1163 1167 PS_ASSERT_FITS_NON_NULL(fits, false); 1164 1168 1165 return readoutReadChunk(readout, fits, z, 0, 0, FPA_READ_TYPE_VARIANCE, config);1169 return readoutReadChunk(readout, fits, z, NULL, 0, 0, FPA_READ_TYPE_VARIANCE, config); 1166 1170 } 1167 1171
Note:
See TracChangeset
for help on using the changeset viewer.
