Changeset 24951 for branches/czw_branch/cleanup/psModules/src/camera
- Timestamp:
- Jul 30, 2009, 5:20:29 PM (17 years ago)
- Location:
- branches/czw_branch/cleanup
- Files:
-
- 10 edited
- 2 copied
-
. (modified) (1 prop)
-
psModules/src/camera/Makefile.am (modified) (2 diffs)
-
psModules/src/camera/pmFPABin.c (modified) (1 diff)
-
psModules/src/camera/pmFPAMaskWeight.c (modified) (3 diffs)
-
psModules/src/camera/pmFPARead.c (modified) (18 diffs)
-
psModules/src/camera/pmFPARead.h (modified) (6 diffs)
-
psModules/src/camera/pmFPAWrite.c (modified) (2 diffs)
-
psModules/src/camera/pmFPAfileFringeIO.c (copied) (copied from trunk/psModules/src/camera/pmFPAfileFringeIO.c )
-
psModules/src/camera/pmFPAfileFringeIO.h (copied) (copied from trunk/psModules/src/camera/pmFPAfileFringeIO.h )
-
psModules/src/camera/pmFPAfileIO.c (modified) (3 diffs)
-
psModules/src/camera/pmHDUGenerate.c (modified) (4 diffs)
-
psModules/src/camera/pmReadoutStack.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/cleanup
- Property svn:mergeinfo changed
/trunk (added) merged: 24714-24742,24744-24784,24786-24798,24801-24824,24827-24834,24836-24859,24861-24901,24903-24912,24914-24939
- Property svn:mergeinfo changed
-
branches/czw_branch/cleanup/psModules/src/camera/Makefile.am
r19695 r24951 23 23 pmFPAfileIO.c \ 24 24 pmFPAfileFitsIO.c \ 25 pmFPAfileFringeIO.c \ 25 26 pmFPAFlags.c \ 26 27 pmFPALevel.c \ … … 51 52 pmFPAfileIO.h \ 52 53 pmFPAfileFitsIO.h \ 54 pmFPAfileFringeIO.h \ 53 55 pmFPAFlags.h \ 54 56 pmFPALevel.h \ -
branches/czw_branch/cleanup/psModules/src/camera/pmFPABin.c
r24479 r24951 60 60 continue; 61 61 } 62 if (!isfinite(inImage->data.F32[y][x])) { 63 continue; 64 } 62 65 sum += inImage->data.F32[y][x]; 63 66 numPix++; -
branches/czw_branch/cleanup/psModules/src/camera/pmFPAMaskWeight.c
r24483 r24951 109 109 float saturation = psMetadataLookupF32(&mdok, cell->concepts, "CELL.SATURATION"); // Saturation level 110 110 if (!mdok || isnan(saturation)) { 111 psError(PS_ERR_IO, true, "CELL.SATURATION is not set --- unable to set mask.\n"); 112 return false; 111 // psError(PS_ERR_IO, true, "CELL.SATURATION is not set --- unable to set mask.\n"); 112 // return false; 113 psWarning("CELL.SATURATION is not set --- completely masking cell.\n"); 114 saturation = NAN; 113 115 } 114 116 float bad = psMetadataLookupF32(&mdok, cell->concepts, "CELL.BAD"); // Bad level 115 117 if (!mdok || isnan(bad)) { 116 psError(PS_ERR_IO, true, "CELL.BAD is not set --- unable to set mask.\n"); 117 return false; 118 // psError(PS_ERR_IO, true, "CELL.BAD is not set --- unable to set mask.\n"); 119 // return false; 120 psWarning("CELL.BAD is not set --- completely masking cell.\n"); 121 bad = NAN; 118 122 } 119 123 psTrace("psModules.camera", 5, "Saturation: %f, bad: %f\n", saturation, bad); 120 124 125 // if CELL.GAIN or CELL.READNOISE are not set, then the variance will be set to NAN; 126 // in this case, we have to set the mask as well 127 float gain = psMetadataLookupF32(&mdok, cell->concepts, "CELL.GAIN"); // Cell gain 128 if (!mdok) { gain = NAN; } 129 float readnoise = psMetadataLookupF32(&mdok, cell->concepts, "CELL.READNOISE"); // Cell read noise 130 if (!mdok) { readnoise = NAN; } 121 131 122 132 // Set up the mask … … 127 137 } 128 138 psImage *mask = readout->mask; // The mask pixels 139 140 // completely mask if SATURATION or BAD are invalid 141 if (isnan(saturation) || isnan(bad) || isnan(gain) || isnan(readnoise)) { 142 psImageInit(mask, badMask); 143 return true; 144 } 145 129 146 psImageInit(mask, 0); 130 147 … … 210 227 float gain = psMetadataLookupF32(&mdok, cell->concepts, "CELL.GAIN"); // Cell gain 211 228 if (!mdok || isnan(gain)) { 212 psError(PS_ERR_IO, true, "CELL.GAIN is not set --- unable to set variance.\n"); 213 return false; 229 // psError(PS_ERR_IO, true, "CELL.GAIN is not set --- unable to set variance.\n"); 230 // return false; 231 psWarning("CELL.GAIN is not set --- setting variance to NAN\n"); 232 gain = NAN; 214 233 } 215 234 float readnoise = psMetadataLookupF32(&mdok, cell->concepts, "CELL.READNOISE"); // Cell read noise 216 235 if (!mdok || isnan(readnoise)) { 217 psError(PS_ERR_IO, true, "CELL.READNOISE is not set --- unable to set variance.\n"); 218 return false; 219 } 220 if (psMetadataLookup(cell->concepts, "CELL.READNOISE.UPDATE")) { 236 // psError(PS_ERR_IO, true, "CELL.READNOISE is not set --- unable to set variance.\n"); 237 // return false; 238 psWarning("CELL.READNOISE is not set --- setting variance to NAN\n"); 239 readnoise = NAN; 240 } 241 // if we have a non-NAN readnoise, then we need to ensure it has been updated (not necessary if NAN) 242 if (!isnan(gain) && psMetadataLookup(cell->concepts, "CELL.READNOISE.UPDATE")) { 221 243 psError(PS_ERR_IO, true, "CELL.READNOISE has not yet been updated for the gain"); 222 244 return false; 245 } 246 247 // for invalid input data, set the readout variance to NAN 248 if (isnan(gain) || isnan(readnoise)) { 249 if (!readout->variance) { 250 // generate the image if needed 251 readout->variance = psImageAlloc(readout->image->numCols, readout->image->numRows, PS_TYPE_F32); 252 } 253 // XXX need to set the mask, if defined 254 psImageInit(readout->variance, NAN); 255 return true; 223 256 } 224 257 -
branches/czw_branch/cleanup/psModules/src/camera/pmFPARead.c
r24058 r24951 141 141 // Determine number of readouts in the FITS file 142 142 // In the process, reads the header and concepts 143 static boolcellNumReadouts(pmCell *cell, // Cell of interest143 static int cellNumReadouts(pmCell *cell, // Cell of interest 144 144 psFits *fits, // FITS file 145 145 pmConfig *config // Configuration … … 153 153 if (!hdu || hdu->blankPHU) { 154 154 psError(PS_ERR_IO, true, "Unable to find HDU"); 155 return false;155 return 0; 156 156 } 157 157 if (!pmCellReadHeader(cell, fits, config)) { 158 158 psError(PS_ERR_IO, false, "Unable to read header for cell!\n"); 159 return false;159 return 0; 160 160 } 161 161 if (!pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CELLS, true, NULL)) { 162 162 psError(PS_ERR_IO, false, "Failed to read concepts for cell.\n"); 163 return false;163 return 0; 164 164 } 165 165 … … 169 169 if (!mdok) { 170 170 psError(PS_ERR_IO, true, "Unable to find NAXIS in header for extension %s\n", hdu->extname); 171 return false; 172 } 171 return 0; 172 } 173 173 174 if (naxis == 0) { 174 175 // No pixels to read 175 176 psError(PS_ERR_IO, true, "No pixels in extension %s.", hdu->extname); 176 return false;177 return 0; 177 178 } 178 179 if (naxis < 2 || naxis > 3) { 179 180 psError(PS_ERR_IO, true, "NAXIS in header of extension %s (= %d) is not valid.\n", 180 181 hdu->extname, naxis); 181 return false;182 return 0; 182 183 } 183 184 int naxis3; // Number of image planes … … 186 187 if (!mdok) { 187 188 psError(PS_ERR_IO, true, "Unable to find NAXIS3 in header for extension %s\n", hdu->extname); 188 return false;189 return 0; 189 190 } 190 191 } else { … … 294 295 static bool readoutMore(pmReadout *readout, // Readout of interest 295 296 psFits *fits, // FITS file 296 int z, // Plane number 297 int z, // Plane number to read 298 int *zMax, // Max plane number in this cell 297 299 int numScans, // Number of scans to read at a time 298 300 fpaReadType type, // Type of image … … 308 310 // N readouts, but numScans set to 0. only the first should report that it requires data, 309 311 // even if all readouts lack the image pointer. 310 if (!image) { 312 if (numScans == 0) { 313 if (!image) { 311 314 return true; 312 } 313 314 // If we have already read an image, this result implies we are done (no more to read) 315 if (numScans == 0) { 316 return false; 315 } else { 316 return false; 317 } 317 318 } 318 319 … … 322 323 return false; 323 324 } 324 int naxis3= cellNumReadouts(cell, fits, config); // Number of planes325 if (z >= naxis3) {325 *zMax = cellNumReadouts(cell, fits, config); // Number of planes 326 if (z >= *zMax) { 326 327 // No more to read 327 328 return false; … … 484 485 psFits *fits, // FITS file 485 486 int z, // Desired image plane 487 int *zMax, // Max plane number in this cell 486 488 int numScans, // Number of scans (row or col depends on CELL.READDIR); 0 for all 487 489 int overlap, // Number of scans (row/col) to overlap between scans … … 509 511 510 512 int naxis3 = cellNumReadouts(cell, fits, config); // Number of image planes 513 if (zMax) *zMax = naxis3; 514 511 515 if (z >= naxis3) { 512 516 psError(PS_ERR_IO, false, "Desired image plane (%d) exceeds available number (%d).", … … 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 -
branches/czw_branch/cleanup/psModules/src/camera/pmFPARead.h
r21363 r24951 21 21 psFits *fits, ///< FITS file from which to read 22 22 int z, ///< Readout number/plane; zero-offset indexing 23 int *zMax, ///< Max plane number in this cell 23 24 int numScans, ///< Number of scans (rows/cols) to read 24 25 pmConfig *config ///< Configuration … … 31 32 psFits *fits, ///< FITS file from which to read 32 33 int z, ///< Readout number/plane; zero-offset indexing 34 int *zMax, ///< Max plane number in this cell 33 35 int numScans, ///< Number of scans (rows/cols) to read 34 36 int overlap, ///< Overlap between consecutive reads … … 98 100 psFits *fits, ///< FITS file from which to read 99 101 int z, ///< Readout number/plane; zero-offset indexing 102 int *zMax, ///< Max plane number in this cell 100 103 int numScans, ///< Number of scans (rows/cols) to read 101 104 pmConfig *config ///< Configuration … … 108 111 psFits *fits, ///< FITS file from which to read 109 112 int z, ///< Readout number/plane; zero-offset indexing 113 int *zMax, ///< Max plane number in this cell 110 114 int numScans, ///< Number of scans (rows/cols) to read 111 115 int overlap, ///< Overlap between consecutive reads … … 150 154 psFits *fits, ///< FITS file from which to read 151 155 int z, ///< Readout number/plane; zero-offset indexing 156 int *zMax, ///< Max plane number in this cell 152 157 int numScans, ///< Number of scans (rows/cols) to read 153 158 pmConfig *config ///< Configuration … … 160 165 psFits *fits, ///< FITS file from which to read 161 166 int z, ///< Readout number/plane; zero-offset indexing 167 int *zMax, ///< Max plane number in this cell 162 168 int numScans, ///< Number of scans (rows/cols) to read 163 169 int overlap, ///< Overlap between consecutive reads -
branches/czw_branch/cleanup/psModules/src/camera/pmFPAWrite.c
r23428 r24951 160 160 psArray **imageArray = appropriateImageArray(hdu, type); // Array of images in the HDU 161 161 162 // XXX detect missing variance & mask images... 163 162 164 // Generate the HDU if needed --- this is required after a pmFPACopy, or similar, which does not 163 165 // generate the HDU, but only copies the structure. 164 if (!blank && !hdu->blankPHU && !*imageArray && (!pmHDUGenerateForCell(cell) || !*imageArray)) { 165 psError(PS_ERR_UNKNOWN, false, "Unable to generate HDU for cell --- likely programming error."); 166 return false; 166 if (!blank && !hdu->blankPHU && !*imageArray) { 167 if (!pmHDUGenerateForCell(cell)) { 168 psError(PS_ERR_UNKNOWN, false, "Unable to generate HDU for cell --- likely programming error."); 169 return false; 170 } 171 if (!*imageArray) { 172 if (type == FPA_WRITE_TYPE_IMAGE) { 173 psError(PS_ERR_UNKNOWN, false, "Expected to write an image, but it is missing...programming error?."); 174 return false; 175 } 176 if (type == FPA_WRITE_TYPE_MASK) { 177 psWarning("No mask image for this cell; skipping"); 178 } 179 if (type == FPA_WRITE_TYPE_VARIANCE) { 180 psWarning("No variance image for this cell; skipping"); 181 } 182 return true; 183 } 167 184 } 168 185 … … 724 741 } 725 742 if (!psFitsCompressionApply(fits, compress)) { 726 psError(PS_ERR_UNKNOWN, false, "Unable to set FITS compression to NONE");743 psError(PS_ERR_UNKNOWN, false, "Unable to restore FITS compression"); 727 744 psFree(compress); 728 745 return false; -
branches/czw_branch/cleanup/psModules/src/camera/pmFPAfileIO.c
r23576 r24951 23 23 #include "pmFPAWrite.h" 24 24 #include "pmFPAfileFitsIO.h" 25 #include "pmFPAfileFringeIO.h" 25 26 #include "pmSpan.h" 26 27 #include "pmFootprint.h" … … 192 193 status = pmFPAviewReadFitsImage(view, file, config); 193 194 if (status) { 194 if (!pmFPAviewReadF itsTable(view, file, "FRINGE")) {195 if (!pmFPAviewReadFringes(view, file)) { 195 196 psError(PS_ERR_UNKNOWN, false, "Unable to read fringe data from %s.\n", file->filename); 196 197 return false; … … 451 452 status = pmFPAviewWriteFitsImage (view, file, config); 452 453 if (status) { 453 if (!pmFPAviewWriteF itsTable(view, file, "FRINGE", config)) {454 if (!pmFPAviewWriteFringes(view, file, config)) { 454 455 psError(PS_ERR_UNKNOWN, false, "Unable to write fringe data from %s.\n", file->filename); 455 456 return false; -
branches/czw_branch/cleanup/psModules/src/camera/pmHDUGenerate.c
r23318 r24951 390 390 if (numReadouts == 0 || (imageType == 0 && maskType == 0 && varianceType == 0)) { 391 391 // Nothing from which to create an HDU 392 psFree(cells);393 ps Error(PS_ERR_IO, true, "Nothing from which to create an HDU\n");394 return false;392 // psError(PS_ERR_IO, true, "Nothing from which to create an HDU\n"); 393 psWarning("Nothing from which to create an HDU, must be empty\n"); 394 return true; 395 395 } 396 396 … … 504 504 psFree(iter); 505 505 } 506 psFree(cells);507 508 506 return true; 509 507 } … … 615 613 return true; 616 614 } 617 618 return generateHDU(hdu, cells); 615 bool status = generateHDU(hdu, cells); 616 psFree (cells); 617 return status; 619 618 } 620 619 case PM_FPA_LEVEL_CHIP: … … 664 663 } 665 664 666 return generateHDU(hdu, cells); 665 bool status = generateHDU(hdu, cells); 666 psFree (cells); 667 return status; 667 668 } 668 669 case PM_FPA_LEVEL_FPA: -
branches/czw_branch/cleanup/psModules/src/camera/pmReadoutStack.c
r21363 r24951 252 252 continue; 253 253 } 254 if (!readout->process) { 255 continue; 256 } 254 257 if (!readout->image) { 255 258 psError(PS_ERR_UNEXPECTED_NULL, true, "Input readout %ld has NULL image.\n", i); … … 260 263 pmCell *cell = readout->parent; // The parent cell 261 264 bool mdok = true; // Status of MD lookup 262 psRegion *trimsec = psMetadataLookupPtr(&mdok, cell->concepts, "CELL.TRIMSEC"); // Trim section265 psRegion *trimsec = cell ? psMetadataLookupPtr(&mdok, cell->concepts, "CELL.TRIMSEC") : NULL; // Trim section 263 266 if (!mdok || !trimsec || psRegionIsNaN(*trimsec)) { 264 psWarning("CELL.TRIMSEC is not set for readout %ld --- ignored.\n", i); 267 psWarning("CELL.TRIMSEC is not set for readout %ld --- attempting to use image size.\n", i); 268 xSize = PS_MAX(xSize, readout->image->numCols); 269 ySize = PS_MAX(ySize, readout->image->numRows); 270 xMin = PS_MIN(xMin, 0); 271 xMax = PS_MAX(xMax, readout->image->numCols - 1); 272 yMin = PS_MIN(yMin, 0); 273 yMax = PS_MAX(yMax, readout->image->numRows - 1); 265 274 } else { 266 275 xSize = PS_MAX(xSize, trimsec->x1 - trimsec->x0);
Note:
See TracChangeset
for help on using the changeset viewer.
