Changeset 16365
- Timestamp:
- Feb 7, 2008, 5:16:12 PM (18 years ago)
- Location:
- trunk/psModules/src/camera
- Files:
-
- 2 edited
-
pmFPARead.c (modified) (31 diffs)
-
pmFPARead.h (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPARead.c
r16230 r16365 32 32 } fpaReadType; 33 33 34 // Desired type for pixels; the index corresponds to the fpaReadType, above. 35 static psElemType pixelTypes[] = { 36 PS_TYPE_F32, 37 PS_TYPE_MASK, 38 PS_TYPE_F32, 39 0 40 }; 41 34 42 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 35 43 // File-static functions 36 44 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 45 46 // Determine number of readouts in the FITS file 47 // In the process, reads the header and concepts 48 static bool cellNumReadouts(pmCell *cell, // Cell of interest 49 psFits *fits // FITS file 50 ) 51 { 52 assert(cell); 53 assert(fits); 54 55 // Get the HDU and read the header 56 pmHDU *hdu = pmHDUFromCell(cell); // The HDU 57 if (!hdu || hdu->blankPHU) { 58 psError(PS_ERR_IO, true, "Unable to find HDU"); 59 return false; 60 } 61 if (!pmCellReadHeader(cell, fits)) { 62 psError(PS_ERR_IO, false, "Unable to read header for cell!\n"); 63 return false; 64 } 65 if (!pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CELLS | 66 PM_CONCEPT_SOURCE_DEFAULTS, true, NULL)) { 67 psError(PS_ERR_IO, false, "Failed to read concepts for cell.\n"); 68 return false; 69 } 70 71 // Get the size of the third dimension 72 bool mdok; // Status of MD lookup 73 int naxis = psMetadataLookupS32(&mdok, hdu->header, "NAXIS"); // The number of axes 74 if (!mdok) { 75 psError(PS_ERR_IO, true, "Unable to find NAXIS in header for extension %s\n", hdu->extname); 76 return false; 77 } 78 if (naxis == 0) { 79 // No pixels to read 80 psError(PS_ERR_IO, true, "No pixels in extension %s.", hdu->extname); 81 return false; 82 } 83 if (naxis < 2 || naxis > 3) { 84 psError(PS_ERR_IO, true, "NAXIS in header of extension %s (= %d) is not valid.\n", 85 hdu->extname, naxis); 86 return false; 87 } 88 int naxis3; // Number of image planes 89 if (naxis == 3) { 90 naxis3 = psMetadataLookupS32(&mdok, hdu->header, "NAXIS3"); 91 if (!mdok) { 92 psError(PS_ERR_IO, true, "Unable to find NAXIS3 in header for extension %s\n", hdu->extname); 93 return false; 94 } 95 } else { 96 naxis3 = 1; 97 } 98 99 return naxis3; 100 } 101 102 103 // Determine readout scan properties: the next and last scans 104 // Requires that cellNumReadouts() has been called before (for header and concepts to have been read) 105 // In the process, adjusts the TRIMSEC 106 static bool readoutScanProperties(int *next, // Index of next scan 107 int *last, // Index of last scan 108 pmReadout *readout, // Readout of interest 109 int numScans, // Number of scans to read at a time 110 fpaReadType type // Type of image 111 ) 112 { 113 assert(next); 114 assert(last); 115 assert(readout); 116 117 psImage *image; // Appropriate image from readout 118 switch (type) { 119 case FPA_READ_TYPE_IMAGE: 120 image = readout->image; 121 break; 122 case FPA_READ_TYPE_MASK: 123 image = readout->mask; 124 break; 125 case FPA_READ_TYPE_WEIGHT: 126 image = readout->weight; 127 break; 128 default: 129 psAbort("Unknown read type: %x\n", type); 130 } 131 132 // Header and concepts have been read by a call to cellNumReadouts(), so we can just assume they're there. 133 134 // Get the trim and bias sections 135 pmCell *cell = readout->parent; // Parent cell 136 PS_ASSERT_PTR_NON_NULL(cell, false); 137 pmHDU *hdu = pmHDUFromCell(cell); // HDU for data 138 bool mdok = true; // Status of MD lookup 139 psRegion *trimsec = psMetadataLookupPtr(&mdok, cell->concepts, "CELL.TRIMSEC"); // Trim sections 140 if (!mdok || !trimsec || psRegionIsNaN(*trimsec)) { 141 psError(PS_ERR_IO, true, "CELL.TRIMSEC is not set.\n"); 142 return false; 143 } 144 int readdir = psMetadataLookupS32(&mdok, cell->concepts, "CELL.READDIR"); // Read direction 145 if (!mdok || readdir == 0 || (readdir != 1 && readdir != 2)) { 146 psError(PS_ERR_IO, true, "CELL.READDIR is not set to -1 or +1.\n"); 147 return false; 148 } 149 150 // Rationalize trimsec against naxis1, naxis2: valid range for trimsec is 1-Nx,1-Ny 151 if (trimsec->x1 < 1) { 152 int naxis1 = psMetadataLookupS32(&mdok, hdu->header, "NAXIS1"); // The number of columns 153 if (!mdok) { 154 psError(PS_ERR_IO, true, "Unable to find NAXIS1 in header for extension %s\n", hdu->extname); 155 return false; 156 } 157 trimsec->x1 = naxis1 + trimsec->x1; 158 } 159 if (trimsec->y1 < 1) { 160 int naxis2 = psMetadataLookupS32(&mdok, hdu->header, "NAXIS2"); // The number of columns 161 if (!mdok) { 162 psError(PS_ERR_IO, true, "Unable to find NAXIS2 in header for extension %s\n", hdu->extname); 163 return false; 164 } 165 trimsec->y1 = naxis2 + trimsec->y1; 166 } 167 168 169 // Calculate the segment offset and upper limit 170 if (readdir == 1) { 171 // Reading rows 172 if (numScans == 0) { 173 *next = trimsec->x0; 174 } else { 175 *next = image ? readout->row0 + numScans : 0; 176 } 177 *last = trimsec->y1; 178 } else { 179 // Reading cols 180 if (numScans == 0) { 181 *next = trimsec->y0; 182 } else { 183 *next = image ? readout->row0 + numScans : 0; 184 } 185 *last = trimsec->x1; 186 } 187 188 return true; 189 } 190 191 static psImage **readoutImageByType(pmReadout *readout, // Readout of interest 192 fpaReadType type // Type of image 193 ) 194 { 195 switch (type) { 196 case FPA_READ_TYPE_IMAGE: 197 return &readout->image; 198 case FPA_READ_TYPE_MASK: 199 return &readout->mask; 200 case FPA_READ_TYPE_WEIGHT: 201 return &readout->weight; 202 default: 203 psAbort("Unknown read type: %x\n", type); 204 } 205 } 206 207 208 static bool readoutMore(pmReadout *readout, // Readout of interest 209 psFits *fits, // FITS file 210 int z, // Plane number 211 int numScans, // Number of scans to read at a time 212 fpaReadType type // Type of image 213 ) 214 { 215 assert(readout); 216 assert(fits); 217 218 psImage *image = *readoutImageByType(readout, type); 219 220 if (!image) { 221 return true; 222 } else if (numScans == 0) { 223 // Can only read the entire image once 224 return false; 225 } 226 227 pmCell *cell = readout->parent; // Parent cell 228 if (!cell) { 229 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find parent cell."); 230 return false; 231 } 232 int naxis3 = cellNumReadouts(cell, fits); // Number of planes 233 if (z < naxis3) { 234 return false; 235 } 236 237 int next; // Next position 238 int last; // Last position 239 if (!readoutScanProperties(&next, &last, readout, numScans, type)) { 240 psError(PS_ERR_UNKNOWN, false, "Unable to determine readout properties."); 241 return false; 242 } 243 244 return (next < last); 245 } 37 246 38 247 // Carve a readout from the image pixels … … 41 250 const psRegion *trimsec, // Trim section 42 251 const psList *biassecs, // Bias sections 43 fpaReadType type 252 fpaReadType type // Type of image 44 253 ) 45 254 { … … 63 272 ); 64 273 65 // place the image subset in the appropriate target location, freeing if needed 66 switch (type) { 67 case FPA_READ_TYPE_IMAGE: 68 if (readout->image) { 69 psFree (readout->image); 70 } 71 readout->image = psImageSubset(image, region); 72 break; 73 case FPA_READ_TYPE_MASK: 74 if (readout->mask) { 75 psFree (readout->mask); 76 } 77 readout->mask = psImageSubset(image, region); 78 break; 79 case FPA_READ_TYPE_WEIGHT: 80 if (readout->weight) { 81 psFree (readout->weight); 82 } 83 readout->weight = psImageSubset(image, region); 84 break; 85 default: 86 psAbort("Unknown read type: %x\n", type); 87 } 88 89 // Get the list of overscans 90 // XXX should this step only be performed for IMAGE, not MASK and WEIGHT types? 91 // XXX that would allow us to overlay a MASK and WEIGHT which have been trimmed... 92 if (readout->bias->n != 0) { 93 // Make way! 94 psFree(readout->bias); 95 readout->bias = psListAlloc(NULL); 96 } 97 psListIterator *iter = psListIteratorAlloc((psList*)biassecs, PS_LIST_HEAD, false); // Iterator 98 psRegion *biassec = NULL; // A BIASSEC region from the list 99 while ((biassec = psListGetAndIncrement(iter))) { 100 if (psRegionIsNaN(*biassec)) { 101 psString regionString = psRegionToString(*biassec); 102 psError(PS_ERR_IO, true, "Invalid bias section: %s\n", regionString); 103 psFree(regionString); 104 psFree(readout); 105 return false; 106 } 107 psRegion region = psRegionSet(PS_MAX(biassec->x0 - readout->col0, 0), // x0 108 PS_MIN(biassec->x1 - readout->col0, image->numCols), // x1 109 PS_MAX(biassec->y0 - readout->row0, 0), // y0 110 PS_MIN(biassec->y1 - readout->row0, image->numRows) // y1 111 ); 112 psImage *overscan = psImageSubset(image, region); 113 psListAdd(readout->bias, PS_LIST_TAIL, overscan); 114 psFree(overscan); 115 } 116 psFree(iter); 274 // Place the image subset in the appropriate target location, freeing if needed 275 psImage **target = readoutImageByType(readout, type); // Target image 276 if (*target) { 277 psFree(*target); 278 } 279 *target = psImageSubset(image, region); 280 281 // Get the list of overscans: only for IMAGE types (no overscan for MASK and WEIGHT) 282 if (type == FPA_READ_TYPE_IMAGE) { 283 if (readout->bias->n != 0) { 284 // Make way! 285 psFree(readout->bias); 286 readout->bias = psListAlloc(NULL); 287 } 288 psListIterator *iter = psListIteratorAlloc((psList*)biassecs, PS_LIST_HEAD, false); // Iterator 289 psRegion *biassec = NULL; // A BIASSEC region from the list 290 while ((biassec = psListGetAndIncrement(iter))) { 291 if (psRegionIsNaN(*biassec)) { 292 psString regionString = psRegionToString(*biassec); 293 psError(PS_ERR_IO, true, "Invalid bias section: %s\n", regionString); 294 psFree(regionString); 295 psFree(readout); 296 return false; 297 } 298 psRegion region = psRegionSet(PS_MAX(biassec->x0 - readout->col0, 0), // x0 299 PS_MIN(biassec->x1 - readout->col0, image->numCols), // x1 300 PS_MAX(biassec->y0 - readout->row0, 0), // y0 301 PS_MIN(biassec->y1 - readout->row0, image->numRows) // y1 302 ); 303 psImage *overscan = psImageSubset(image, region); 304 psListAdd(readout->bias, PS_LIST_TAIL, overscan); 305 psFree(overscan); 306 } 307 psFree(iter); 308 } 117 309 118 310 return true; … … 123 315 // out the edges of the region with 'bad' pixels. The output image always has max-min rows. 124 316 // The region represents the maximum bounds of the full image 125 126 317 static psImage *readoutReadComponent(psImage *image, // Image into which to read 127 318 psFits *fits, // FITS file from which to read … … 131 322 int max, // Maximum row/col number to read 132 323 int z, // Image plane to read 133 float bad // Bad value 324 float bad, // Bad value 325 psElemType type // Expected type for image 134 326 ) 135 327 { … … 138 330 assert((readdir == 1) || (readdir == 2)); 139 331 140 int nRead = 0; 141 int nScans = max - min; 142 assert (nScans > 0);332 int nRead = 0; // Number of scans read 333 int nScans = max - min; // Number of scans desired 334 assert(nScans > 0); 143 335 144 336 psRegion toRead = *fullImage; // full image region 145 337 146 int dX = 0; 147 int dY = 0; 148 int nX = 0; 149 int nY = 0; 338 int dX = 0, dY = 0; // Offset from image in FITS file to lower left corner of what's read 339 int nX = 0, nY = 0; // Size of region to read 150 340 151 341 if (readdir == 1) { 152 toRead.y0 = PS_MAX (toRead.y0, min);153 toRead.y1 = PS_MIN (toRead.y1, max);342 toRead.y0 = PS_MAX(toRead.y0, min); 343 toRead.y1 = PS_MIN(toRead.y1, max); 154 344 nRead = toRead.y1 - toRead.y0; 155 345 if (min < fullImage->y0) { … … 159 349 nY = nScans; 160 350 } else { 161 toRead.x0 = PS_MAX (toRead.x0, min);162 toRead.x1 = PS_MIN (toRead.x1, max);351 toRead.x0 = PS_MAX(toRead.x0, min); 352 toRead.x1 = PS_MIN(toRead.x1, max); 163 353 nRead = toRead.x1 - toRead.x0; 164 354 if (min < fullImage->x0) { … … 174 364 psTrace("psModules.camera", 7, "Image is %dx%d\n", image->numCols, image->numRows); 175 365 176 // XXX: We only support F32 for now177 if (image->type.type != PS_TYPE_F32) {178 psImage *temp = psImageCopy(NULL, image, PS_TYPE_F32);366 // Ensure the pixel type corresponds to what we desire 367 if (image->type.type != type) { 368 psImage *temp = psImageCopy(NULL, image, type); 179 369 psFree(image); 180 370 image = temp; 181 371 } 182 372 373 // Resize the image so that it matches the number of scans requested 183 374 // XXX this modification is not carried back up stream: it affects readout->row0,col0 375 // 376 // XXXXX Do we really want to do this??? Why??? 184 377 if (nRead < nScans) { 185 378 // The region of interest is smaller than the number of pixels we want. … … 195 388 } 196 389 390 // Read a chunk of a readout (or the whole lot) 391 static bool readoutReadChunk(pmReadout *readout, // Readout into which to read 392 psFits *fits, // FITS file 393 int z, // Desired image plane 394 int numScans, // Number of scans (row or col depends on CELL.READDIR); 0 for all 395 fpaReadType type // Type of image 396 ) 397 { 398 assert(readout); 399 assert(fits); 400 assert(z >= 0); 401 assert(numScans >= 0); 402 403 psImage **imagePtr = readoutImageByType(readout, type); // Pointer to the image of interest 404 if (*imagePtr && numScans == 0) { 405 psError(PS_ERR_UNKNOWN, true, "Already read entire image --- won't clobber."); 406 return false; 407 } 408 409 pmCell *cell = readout->parent; // The parent cell 410 if (!cell) { 411 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find parent cell."); 412 return false; 413 } 414 415 int naxis3 = cellNumReadouts(cell, fits); // Number of image planes 416 if (z >= naxis3) { 417 psError(PS_ERR_IO, false, "Desired image plane (%d) exceeds available number (%d).", 418 z, naxis3); 419 return false; 420 } 421 422 int next; // Next position 423 int last; // Last position 424 if (!readoutScanProperties(&next, &last, readout, numScans, type)) { 425 psError(PS_ERR_UNKNOWN, false, "Unable to determine readout properties."); 426 return false; 427 } 428 if (next >= last) { 429 psError(PS_ERR_IO, true, "No more of the readout to read."); 430 return false; 431 } 432 433 pmHDU *hdu = pmHDUFromCell(cell); // The HDU 434 assert(hdu && !hdu->blankPHU); // Checked by cellNumReadouts() 435 436 bool mdok; // Status of MD lookup 437 int readdir = psMetadataLookupS32(&mdok, cell->concepts, "CELL.READDIR"); // Read direction 438 if (!mdok || readdir == 0 || (readdir != 1 && readdir != 2)) { 439 psError(PS_ERR_IO, true, "CELL.READDIR is not set to -1 or +1.\n"); 440 return false; 441 } 442 float bad = psMetadataLookupF32(&mdok, cell->concepts, "CELL.BAD"); // Bad level 443 if (!mdok) { 444 psLogMsg(__func__, PS_LOG_WARN, "CELL.BAD is not set --- assuming zero.\n"); 445 bad = 0.0; 446 } 447 psRegion *trimsec = psMetadataLookupPtr(&mdok, cell->concepts, "CELL.TRIMSEC"); // Trim sections 448 if (!mdok || !trimsec || psRegionIsNaN(*trimsec)) { 449 psError(PS_ERR_IO, true, "CELL.TRIMSEC is not set.\n"); 450 return false; 451 } 452 453 // Check the third dimension 454 int naxis = psMetadataLookupS32(&mdok, hdu->header, "NAXIS"); // The number of axes 455 if (!mdok) { 456 psError(PS_ERR_IO, true, "Unable to find NAXIS in header for extension %s\n", hdu->extname); 457 return false; 458 } 459 if (naxis == 0) { 460 // No pixels to read 461 psError(PS_ERR_IO, true, "No pixels in extension %s.", hdu->extname); 462 return false; 463 } 464 if (naxis < 2 || naxis > 3) { 465 psError(PS_ERR_IO, true, "NAXIS in header of extension %s (= %d) is not valid.\n", 466 hdu->extname, naxis); 467 return false; 468 } 469 470 // Calculate limits, adjust readout->row0,col0 471 if (readdir == 1) { 472 // Reading rows 473 readout->row0 = next; 474 readout->col0 = trimsec->x0; 475 } else { 476 // Reading cols 477 readout->col0 = next; 478 readout->row0 = trimsec->y0; 479 } 480 int upper = next + numScans; // Upper limit to next section 481 482 // Blow away existing data. 483 // Do this before returning, so that we're not returning data from a previous read 484 psImage **image = readoutImageByType(readout, type); 485 psFree(*image); 486 *image = NULL; 487 *image = readoutReadComponent(*image, fits, trimsec, readdir, next, upper, z, bad, pixelTypes[type]); 488 489 // Read overscans only for "image" type --- weights and masks shouldn't record overscans 490 if (type == FPA_READ_TYPE_IMAGE) { 491 // Blow away existing data 492 while (readout->bias->n > 0) { 493 psListRemove(readout->bias, PS_LIST_HEAD); 494 } 495 496 // Get the new bias sections 497 psList *biassecs = psMetadataLookupPtr(&mdok, cell->concepts, "CELL.BIASSEC"); // Bias sections 498 if (!mdok || !biassecs) { 499 psError(PS_ERR_IO, true, "CELL.BIASSEC is not set.\n"); 500 return false; 501 } 502 psListIterator *biassecsIter = psListIteratorAlloc(biassecs, PS_LIST_HEAD, false); // Iterator 503 psRegion *biassec = NULL; // Bias section from iteration 504 while ((biassec = psListGetAndIncrement(biassecsIter))) { 505 psImage *bias = readoutReadComponent(NULL, fits, biassec, readdir, next, upper, z, 506 bad, pixelTypes[type]); // The bias 507 psListAdd(readout->bias, PS_LIST_TAIL, bias); 508 psFree(bias); // Drop reference 509 } 510 psFree(biassecsIter); 511 } 512 513 return true; 514 } 197 515 198 516 // Read into an cell; this is the engine for pmCellRead, pmCellReadMask, pmCellReadWeight … … 260 578 // set up pointers for the different possible image arrays 261 579 psArray *imageArray = NULL; // Array of images in the HDU 262 psElemType imageType = PS_TYPE_F32; // Expected type for image580 psElemType imageType = pixelTypes[type]; // Expected type for image 263 581 switch (type) { 264 582 case FPA_READ_TYPE_IMAGE: 265 583 imageArray = hdu->images; 266 imageType = PS_TYPE_F32;267 584 break; 268 585 case FPA_READ_TYPE_MASK: 269 586 imageArray = hdu->masks; 270 imageType = PS_TYPE_MASK;271 587 break; 272 588 case FPA_READ_TYPE_WEIGHT: 273 589 imageArray = hdu->weights; 274 imageType = PS_TYPE_F32;275 590 break; 276 591 default: … … 387 702 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 388 703 389 // XXX need to pass back the error conditions as well as the 'keep going' state 704 // pmReadoutReadNext is maintained here (for now) to maintain backwards compatibility. 705 // pmReadoutReadNext has been replaced by pmReadoutRead, pmReadoutReadChunk, pmReadoutMore 390 706 bool pmReadoutReadNext(bool *status, pmReadout *readout, psFits *fits, int z, int numScans) 391 707 { … … 405 721 if (!hdu || hdu->blankPHU) { 406 722 // XXX is this an error condition? 407 psTrace("psModules.camera", 7, "no HDU or pixel-less PHU: skipping\n");408 723 *status = true; 409 724 return false; … … 453 768 if (naxis == 0) { 454 769 // No pixels to read, as for a PHU. 455 psTrace("psModules.camera", 7, "pixel-less HDU: skipping\n");456 770 *status = true; 457 771 return false; … … 472 786 if (z >= naxis3) { 473 787 // Nothing to see here. Move along. 474 psTrace("psModules.camera", 7, "requested plane off edge of cube: skipping\n");475 788 *status = true; 476 789 return false; … … 547 860 548 861 // Get the new the trim section 549 readout->image = readoutReadComponent(readout->image, fits, trimsec, readdir, offset, upper, z, bad); // The image 862 readout->image = readoutReadComponent(readout->image, fits, trimsec, readdir, offset, upper, z, bad, 863 PS_TYPE_F32); // The image 550 864 551 865 // Get the new bias sections … … 553 867 psRegion *biassec = NULL; // Bias section from iteration 554 868 while ((biassec = psListGetAndIncrement(biassecsIter))) { 555 psImage *bias = readoutReadComponent(NULL, fits, biassec, readdir, offset, upper, z, bad); // The bias 869 psImage *bias = readoutReadComponent(NULL, fits, biassec, readdir, offset, upper, z, bad, 870 PS_TYPE_F32); // The bias 556 871 psListAdd(readout->bias, PS_LIST_TAIL, bias); 557 872 psFree(bias); // Drop reference … … 564 879 565 880 881 882 bool pmReadoutMore(pmReadout *readout, psFits *fits, int z, int numScans) 883 { 884 PS_ASSERT_PTR_NON_NULL(readout, false); 885 PS_ASSERT_FITS_NON_NULL(fits, false); 886 887 return readoutMore(readout, fits, z, numScans, FPA_READ_TYPE_IMAGE); 888 } 889 890 bool pmReadoutReadChunk(pmReadout *readout, psFits *fits, int z, int numScans) 891 { 892 PS_ASSERT_PTR_NON_NULL(readout, false); 893 PS_ASSERT_FITS_NON_NULL(fits, false); 894 PS_ASSERT_INT_NONNEGATIVE(z, false); 895 PS_ASSERT_INT_NONNEGATIVE(numScans, false); 896 897 return readoutReadChunk(readout, fits, z, numScans, FPA_READ_TYPE_IMAGE); 898 } 899 900 bool pmReadoutRead(pmReadout *readout, psFits *fits, int z) 901 { 902 PS_ASSERT_PTR_NON_NULL(readout, false); 903 PS_ASSERT_FITS_NON_NULL(fits, false); 904 905 return readoutReadChunk(readout, fits, z, 0, FPA_READ_TYPE_IMAGE); 906 } 907 908 int pmCellNumReadouts(pmCell *cell, psFits *fits) 909 { 910 PS_ASSERT_PTR_NON_NULL(cell, false); 911 PS_ASSERT_FITS_NON_NULL(fits, false); 912 913 return cellNumReadouts(cell, fits); 914 } 915 566 916 bool pmCellRead(pmCell *cell, psFits *fits, psDB *db) 567 917 { 568 918 PS_ASSERT_PTR_NON_NULL(cell, false); 569 PS_ASSERT_ PTR_NON_NULL(fits, false);919 PS_ASSERT_FITS_NON_NULL(fits, false); 570 920 571 921 return cellRead(cell, fits, db, FPA_READ_TYPE_IMAGE); … … 575 925 { 576 926 PS_ASSERT_PTR_NON_NULL(chip, false); 577 PS_ASSERT_ PTR_NON_NULL(fits, false);927 PS_ASSERT_FITS_NON_NULL(fits, false); 578 928 579 929 return chipRead(chip, fits, db, FPA_READ_TYPE_IMAGE); … … 583 933 { 584 934 PS_ASSERT_PTR_NON_NULL(fpa, false); 585 PS_ASSERT_ PTR_NON_NULL(fits, false);935 PS_ASSERT_FITS_NON_NULL(fits, false); 586 936 587 937 return fpaRead(fpa, fits, db, FPA_READ_TYPE_IMAGE); … … 593 943 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 594 944 945 bool pmReadoutReadMask(pmReadout *readout, psFits *fits, int z) 946 { 947 PS_ASSERT_PTR_NON_NULL(readout, false); 948 PS_ASSERT_FITS_NON_NULL(fits, false); 949 950 return readoutReadChunk(readout, fits, z, 0, FPA_READ_TYPE_MASK); 951 } 952 595 953 bool pmCellReadMask(pmCell *cell, psFits *fits, psDB *db) 596 954 { 597 955 PS_ASSERT_PTR_NON_NULL(cell, false); 598 PS_ASSERT_ PTR_NON_NULL(fits, false);956 PS_ASSERT_FITS_NON_NULL(fits, false); 599 957 600 958 return cellRead(cell, fits, db, FPA_READ_TYPE_MASK); … … 604 962 { 605 963 PS_ASSERT_PTR_NON_NULL(chip, false); 606 PS_ASSERT_ PTR_NON_NULL(fits, false);964 PS_ASSERT_FITS_NON_NULL(fits, false); 607 965 608 966 return chipRead(chip, fits, db, FPA_READ_TYPE_MASK); … … 612 970 { 613 971 PS_ASSERT_PTR_NON_NULL(fpa, false); 614 PS_ASSERT_ PTR_NON_NULL(fits, false);972 PS_ASSERT_FITS_NON_NULL(fits, false); 615 973 616 974 return fpaRead(fpa, fits, db, FPA_READ_TYPE_MASK); … … 621 979 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 622 980 981 bool pmReadoutReadWeight(pmReadout *readout, psFits *fits, int z) 982 { 983 PS_ASSERT_PTR_NON_NULL(readout, false); 984 PS_ASSERT_FITS_NON_NULL(fits, false); 985 986 return readoutReadChunk(readout, fits, z, 0, FPA_READ_TYPE_WEIGHT); 987 } 988 623 989 bool pmCellReadWeight(pmCell *cell, psFits *fits, psDB *db) 624 990 { 625 991 PS_ASSERT_PTR_NON_NULL(cell, false); 626 PS_ASSERT_ PTR_NON_NULL(fits, false);992 PS_ASSERT_FITS_NON_NULL(fits, false); 627 993 628 994 return cellRead(cell, fits, db, FPA_READ_TYPE_WEIGHT); … … 632 998 { 633 999 PS_ASSERT_PTR_NON_NULL(chip, false); 634 PS_ASSERT_ PTR_NON_NULL(fits, false);1000 PS_ASSERT_FITS_NON_NULL(fits, false); 635 1001 636 1002 return chipRead(chip, fits, db, FPA_READ_TYPE_WEIGHT); … … 640 1006 { 641 1007 PS_ASSERT_PTR_NON_NULL(fpa, false); 642 PS_ASSERT_ PTR_NON_NULL(fits, false);1008 PS_ASSERT_FITS_NON_NULL(fits, false); 643 1009 644 1010 return fpaRead(fpa, fits, db, FPA_READ_TYPE_WEIGHT); … … 652 1018 { 653 1019 PS_ASSERT_PTR_NON_NULL(cell, false); 654 PS_ASSERT_ PTR_NON_NULL(fits, false);1020 PS_ASSERT_FITS_NON_NULL(fits, false); 655 1021 656 1022 return cellRead(cell, fits, db, FPA_READ_TYPE_HEADER); … … 660 1026 { 661 1027 PS_ASSERT_PTR_NON_NULL(chip, false); 662 PS_ASSERT_ PTR_NON_NULL(fits, false);1028 PS_ASSERT_FITS_NON_NULL(fits, false); 663 1029 664 1030 return chipRead(chip, fits, db, FPA_READ_TYPE_HEADER); … … 668 1034 { 669 1035 PS_ASSERT_PTR_NON_NULL(fpa, false); 670 PS_ASSERT_ PTR_NON_NULL(fits, false);1036 PS_ASSERT_FITS_NON_NULL(fits, false); 671 1037 672 1038 return fpaRead(fpa, fits, db, FPA_READ_TYPE_HEADER); … … 680 1046 { 681 1047 PS_ASSERT_PTR_NON_NULL(cell, 0); 682 PS_ASSERT_ PTR_NON_NULL(fits, 0);1048 PS_ASSERT_FITS_NON_NULL(fits, 0); 683 1049 PS_ASSERT_STRING_NON_EMPTY(name, 0); 684 1050 … … 739 1105 { 740 1106 PS_ASSERT_PTR_NON_NULL(chip, 0); 741 PS_ASSERT_ PTR_NON_NULL(fits, 0);1107 PS_ASSERT_FITS_NON_NULL(fits, 0); 742 1108 PS_ASSERT_STRING_NON_EMPTY(name, 0); 743 1109 … … 756 1122 { 757 1123 PS_ASSERT_PTR_NON_NULL(fpa, 0); 758 PS_ASSERT_ PTR_NON_NULL(fits, 0);1124 PS_ASSERT_FITS_NON_NULL(fits, 0); 759 1125 PS_ASSERT_STRING_NON_EMPTY(name, 0); 760 1126 -
trunk/psModules/src/camera/pmFPARead.h
r13768 r16365 4 4 * @author Paul Price, IfA 5 5 * 6 * @version $Revision: 1. 9$ $Name: not supported by cvs2svn $7 * @date $Date: 200 7-06-12 22:22:33$6 * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2008-02-08 03:16:12 $ 8 8 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii 9 9 */ … … 15 15 /// @{ 16 16 17 /// Read a readout incrementally 17 /// Check to see if there is more to read when reading a readout incrementally 18 bool pmReadoutMore(pmReadout *readout, ///< Readout of interest 19 psFits *fits, ///< FITS file from which to read 20 int z, ///< Readout number/plane; zero-offset indexing 21 int numScans ///< Number of scans (rows/cols) to read 22 ); 23 24 /// Read a chunk of a readout. 25 /// 26 /// Allows reading the readout incrementally 27 bool pmReadoutReadChunk(pmReadout *readout, ///< Readout of interest 28 psFits *fits, ///< FITS file from which to read 29 int z, ///< Readout number/plane; zero-offset indexing 30 int numScans ///< Number of scans (rows/cols) to read 31 ); 32 33 /// Read the entire readout 34 bool pmReadoutRead(pmReadout *readout, ///< Readout of interest 35 psFits *fits, ///< FITS file from which to read 36 int z ///< Readout number/plane; zero-offset indexing 37 ); 38 39 /// Read a readout incrementally --- this is maintained temporarily only for backwards compatibility; it has 40 /// been replaced by pmReadoutRead, pmReadoutReadChunk and pmReadoutMore. 18 41 /// 19 42 /// Multiple calls to this function moves through a readout within a cell incrementally. It is required to … … 25 48 /// Use pmReadoutWriteNext to write the data that's read by this function. This function is intended for 26 49 /// reading in many readouts into memory at once (e.g., for stacking) where the input is not written out. 27 bool pmReadoutReadNext(bool *status, // non-error exit condition?28 pmReadout *readout, // Readout into which to read50 bool pmReadoutReadNext(bool *status, // non-error exit condition? 51 pmReadout *readout, // Readout into which to read 29 52 psFits *fits, // FITS file from which to read 30 53 int z, // Readout number/plane; zero-offset indexing 31 54 int numRows // The number of rows to read 32 55 ); 56 57 /// Return the number of readouts within a cell 58 /// 59 /// This function is type-independent (doesn't matter if you are interested in the image/mask/weight). 60 int pmCellNumReadouts(pmCell *cell, psFits *fits); 33 61 34 62 /// Read an entire cell … … 57 85 ); 58 86 87 // Mask functions follow 88 89 /// Check to see if there is more to read when reading a readout incrementally into the mask 90 bool pmReadoutMoreMask(pmReadout *readout, ///< Readout of interest 91 psFits *fits, ///< FITS file from which to read 92 int z, ///< Readout number/plane; zero-offset indexing 93 int numScans ///< Number of scans (rows/cols) to read 94 ); 95 96 /// Read a chunk of a readout into the mask 97 /// 98 /// Allows reading the readout incrementally 99 bool pmReadoutReadChunkMask(pmReadout *readout, ///< Readout of interest 100 psFits *fits, ///< FITS file from which to read 101 int z, ///< Readout number/plane; zero-offset indexing 102 int numScans ///< Number of scans (rows/cols) to read 103 ); 104 105 /// Read the entire readout into the mask 106 bool pmReadoutReadMask(pmReadout *readout, ///< Readout of interest 107 psFits *fits, ///< FITS file from which to read 108 int z ///< Readout number/plane; zero-offset indexing 109 ); 110 59 111 /// Read an entire cell into the mask 60 112 /// 61 113 /// Same as pmCellRead, but reads into the mask element of the readouts. 62 bool pmCellReadMask(pmCell *cell, // Cell to read into63 psFits *fits, // FITS file from which to read64 psDB *db // Database handle, for "concepts" ingest114 bool pmCellReadMask(pmCell *cell, // Cell to read into 115 psFits *fits, // FITS file from which to read 116 psDB *db // Database handle, for "concepts" ingest 65 117 ); 66 118 … … 68 120 /// 69 121 /// Same as pmChipRead, but reads into the mask element of the readouts. 70 bool pmChipReadMask(pmChip *chip, // Chip to read into71 psFits *fits, // FITS file from which to read72 psDB *db // Database handle, for "concepts" ingest122 bool pmChipReadMask(pmChip *chip, // Chip to read into 123 psFits *fits, // FITS file from which to read 124 psDB *db // Database handle, for "concepts" ingest 73 125 ); 74 126 … … 76 128 /// 77 129 /// Same as pmFPARead, but reads into the mask element of the readouts. 78 bool pmFPAReadMask(pmFPA *fpa, // FPA to read into79 psFits *fits, // FITS file from which to read80 psDB *db // Database handle, for "concepts" ingest130 bool pmFPAReadMask(pmFPA *fpa, // FPA to read into 131 psFits *fits, // FITS file from which to read 132 psDB *db // Database handle, for "concepts" ingest 81 133 ); 134 135 // Weight functions follow 136 137 /// Check to see if there is more to read when reading a readout incrementally into the weight 138 bool pmReadoutMoreWeight(pmReadout *readout, ///< Readout of interest 139 psFits *fits, ///< FITS file from which to read 140 int z, ///< Readout number/plane; zero-offset indexing 141 int numScans ///< Number of scans (rows/cols) to read 142 ); 143 144 /// Read a chunk of a readout into the weight 145 /// 146 /// Allows reading the readout incrementally 147 bool pmReadoutReadChunkWeight(pmReadout *readout, ///< Readout of interest 148 psFits *fits, ///< FITS file from which to read 149 int z, ///< Readout number/plane; zero-offset indexing 150 int numScans ///< Number of scans (rows/cols) to read 151 ); 152 153 /// Read the entire readout into the weight 154 bool pmReadoutReadWeight(pmReadout *readout, ///< Readout of interest 155 psFits *fits, ///< FITS file from which to read 156 int z ///< Readout number/plane; zero-offset indexing 157 ); 82 158 83 159 /// Read an entire cell into the weight … … 109 185 /// Same as pmCellRead, but reads only the headers of the readouts. 110 186 bool pmCellReadHeaderSet(pmCell *cell, // Cell to read into 111 psFits *fits, // FITS file from which to read112 psDB *db // Database handle, for "concepts" ingest187 psFits *fits, // FITS file from which to read 188 psDB *db // Database handle, for "concepts" ingest 113 189 ); 114 190 … … 125 201 /// Same as pmFPARead, but reads only the headers of the readouts. 126 202 bool pmFPAReadHeaderSet(pmFPA *fpa, // FPA to read into 127 psFits *fits, // FITS file from which to read128 psDB *db // Database handle, for "concepts" ingest203 psFits *fits, // FITS file from which to read 204 psDB *db // Database handle, for "concepts" ingest 129 205 ); 130 206
Note:
See TracChangeset
for help on using the changeset viewer.
