Changeset 11793
- Timestamp:
- Feb 14, 2007, 2:34:00 PM (19 years ago)
- Location:
- trunk/psModules/src/camera
- Files:
-
- 7 edited
-
pmFPARead.c (modified) (7 diffs)
-
pmFPARead.h (modified) (2 diffs)
-
pmFPAfile.c (modified) (1 diff)
-
pmFPAfile.h (modified) (2 diffs)
-
pmFPAfileFitsIO.c (modified) (1 diff)
-
pmFPAfileFitsIO.h (modified) (2 diffs)
-
pmFPAfileIO.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPARead.c
r11687 r11793 26 26 FPA_READ_TYPE_IMAGE, // Read image 27 27 FPA_READ_TYPE_MASK, // Read mask 28 FPA_READ_TYPE_WEIGHT // Read weight map 28 FPA_READ_TYPE_WEIGHT, // Read weight map 29 FPA_READ_TYPE_HEADER // Read header 29 30 } fpaReadType; 30 31 … … 35 36 // Carve a readout from the image pixels 36 37 static bool readoutCarve(pmReadout *readout, // Readout to be carved up 37 psImage **target, // Target pointer for the carved image38 38 psImage *image, // Image that will be carved 39 39 const psRegion *trimsec, // Trim section 40 const psList *biassecs // Bias sections 40 const psList *biassecs, // Bias sections 41 fpaReadType type 41 42 ) 42 43 { … … 59 60 PS_MIN(trimsec->y1 - readout->row0, image->numRows) // y1 60 61 ); 61 if (readout->image) { 62 psFree(readout->image); // Make way! 63 } 64 *target = psMemIncrRefCounter(psImageSubset(image, region)); 65 62 63 // place the image subset in the appropriate target location, freeing if needed 64 // XXX why psMemIncrRefCounter on psImageSubset?? 65 switch (type) { 66 case FPA_READ_TYPE_IMAGE: 67 if (readout->image) { 68 psFree (readout->image); 69 } 70 readout->image = psMemIncrRefCounter(psImageSubset(image, region)); 71 break; 72 case FPA_READ_TYPE_MASK: 73 if (readout->mask) { 74 psFree (readout->mask); 75 } 76 readout->mask = psMemIncrRefCounter(psImageSubset(image, region)); 77 break; 78 case FPA_READ_TYPE_WEIGHT: 79 if (readout->weight) { 80 psFree (readout->weight); 81 } 82 readout->weight = psMemIncrRefCounter(psImageSubset(image, region)); 83 break; 84 default: 85 psAbort("Unknown read type: %x\n", type); 86 } 87 66 88 // Get the list of overscans 89 // XXX should this step only be performed for IMAGE, not MASK and WEIGHT types? 90 // XXX that would allow us to overlay a MASK and WEIGHT which have been trimmed... 67 91 if (readout->bias->n != 0) { 68 92 // Make way! … … 184 208 } 185 209 210 // check if we have read the desired data, read it if needed 186 211 bool (*hduReadFunc)(pmHDU*, psFits*) = NULL; // Function to use to read the HDU 187 psArray **imageArray = NULL; // Array of images in the HDU 188 psElemType imageType = PS_TYPE_F32; // Expected type for image 212 void *dataPointer = NULL; // pointer to location of desired data 189 213 switch (type) { 190 case FPA_READ_TYPE_IMAGE:214 case FPA_READ_TYPE_IMAGE: 191 215 hduReadFunc = pmHDURead; 192 imageArray = &hdu->images; 193 imageType = PS_TYPE_F32; 216 dataPointer = hdu->images; 194 217 break; 195 case FPA_READ_TYPE_MASK: 218 case FPA_READ_TYPE_HEADER: 219 hduReadFunc = pmHDUReadHeader; 220 dataPointer = hdu->header; 221 break; 222 case FPA_READ_TYPE_MASK: 196 223 hduReadFunc = pmHDUReadMask; 197 imageArray = &hdu->masks; 198 imageType = PS_TYPE_MASK; 224 dataPointer = hdu->masks; 199 225 break; 200 case FPA_READ_TYPE_WEIGHT:226 case FPA_READ_TYPE_WEIGHT: 201 227 hduReadFunc = pmHDUReadWeight; 202 imageArray = &hdu->weights; 203 imageType = PS_TYPE_F32; 228 dataPointer = hdu->weights; 204 229 break; 205 default:230 default: 206 231 psAbort("Unknown read type: %x\n", type); 207 232 } 208 233 209 if (!(*imageArray) && !hduReadFunc(hdu, fits)) { 210 psError(PS_ERR_UNKNOWN, false, "Unable to read HDU for cell.\n"); 211 return false; 212 } 213 234 // do we have the data we want (image, header, or etc). 235 if (!dataPointer) { 236 // attempt to read in the desired data 237 if (!hduReadFunc(hdu, fits)) { 238 psError(PS_ERR_UNKNOWN, false, "Unable to read HDU for cell.\n"); 239 return false; 240 } 241 } 242 243 // load in the concept information for this cell 214 244 if (!pmConceptsReadCell(cell, PM_CONCEPT_SOURCE_HEADER, true, NULL)) { 215 245 //psError(PS_ERR_UNKNOWN, false, "Failed to read concepts for cell"); 216 246 //return false; 217 247 psWarning("Difficulty reading concepts for cell; attempting to proceed."); 248 } 249 250 // skip the image arrays completely for the header-only files 251 if (type == FPA_READ_TYPE_HEADER) { 252 pmCellSetDataStatus(cell, true); 253 return true; 254 } 255 256 // set up pointers for the different possible image arrays 257 psArray *imageArray = NULL; // Array of images in the HDU 258 psElemType imageType = PS_TYPE_F32; // Expected type for image 259 switch (type) { 260 case FPA_READ_TYPE_IMAGE: 261 imageArray = hdu->images; 262 imageType = PS_TYPE_F32; 263 break; 264 case FPA_READ_TYPE_MASK: 265 imageArray = hdu->masks; 266 imageType = PS_TYPE_MASK; 267 break; 268 case FPA_READ_TYPE_WEIGHT: 269 imageArray = hdu->weights; 270 imageType = PS_TYPE_F32; 271 break; 272 default: 273 psAbort("Unknown read type: %x\n", type); 218 274 } 219 275 … … 228 284 // Iterate over each of the image planes, converting type if necessary, and extracting the bits that 229 285 // matter (CELL.TRIMSEC, CELL.BIASSEC) into readouts with readoutCarve. 230 for (int i = 0; i < (*imageArray)->n; i++) {231 psImage *source = (*imageArray)->data[i]; // Source image, from the i-th plane286 for (int i = 0; i < imageArray->n; i++) { 287 psImage *source = imageArray->data[i]; // Source image, from the i-th plane 232 288 233 289 // Type conversion here to support the modules, which don't have multiple type support yet 234 290 if (source->type.type != imageType) { 235 291 psImage *temp = psImageCopy(NULL, source, imageType); // Temporary image 236 psFree( (*imageArray)->data[i]);237 (*imageArray)->data[i] = temp;292 psFree(imageArray->data[i]); 293 imageArray->data[i] = temp; 238 294 source = temp; 239 295 } … … 246 302 } 247 303 248 psImage **target = NULL; // Place in readout to put carved image 249 switch (type) { 250 case FPA_READ_TYPE_IMAGE: 251 target = &readout->image; 252 break; 253 case FPA_READ_TYPE_MASK: 254 target = &readout->mask; 255 break; 256 case FPA_READ_TYPE_WEIGHT: 257 target = &readout->weight; 258 break; 259 default: 260 psAbort("Unknown read type: %x\n", type); 261 } 262 263 if (!readoutCarve(readout, target, source, trimsec, biassecs)) { 304 if (!readoutCarve(readout, source, trimsec, biassecs, type)) { 264 305 psError(PS_ERR_UNEXPECTED_NULL, false, 265 306 "Unable to carve readout into image and bias sections for %d the plane.", i); … … 594 635 595 636 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 637 // Reading the image header 638 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 639 640 bool pmCellReadHeaderSet(pmCell *cell, psFits *fits, psDB *db) 641 { 642 PS_ASSERT_PTR_NON_NULL(cell, false); 643 PS_ASSERT_PTR_NON_NULL(fits, false); 644 645 return cellRead(cell, fits, db, FPA_READ_TYPE_HEADER); 646 } 647 648 bool pmChipReadHeaderSet(pmChip *chip, psFits *fits, psDB *db) 649 { 650 PS_ASSERT_PTR_NON_NULL(chip, false); 651 PS_ASSERT_PTR_NON_NULL(fits, false); 652 653 return chipRead(chip, fits, db, FPA_READ_TYPE_HEADER); 654 } 655 656 bool pmFPAReadHeaderSet(pmFPA *fpa, psFits *fits, psDB *db) 657 { 658 PS_ASSERT_PTR_NON_NULL(fpa, false); 659 PS_ASSERT_PTR_NON_NULL(fits, false); 660 661 return fpaRead(fpa, fits, db, FPA_READ_TYPE_HEADER); 662 } 663 664 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 596 665 // Reading FITS tables 597 666 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// -
trunk/psModules/src/camera/pmFPARead.h
r11253 r11793 4 4 * @author Paul Price, IfA 5 5 * 6 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $7 * @date $Date: 2007-0 1-24 02:54:14$6 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2007-02-15 00:34:00 $ 8 8 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii 9 9 */ … … 107 107 ); 108 108 109 /// Read cell headers 110 /// 111 /// Same as pmCellRead, but reads only the headers of the readouts. 112 bool pmCellReadHeaderSet(pmCell *cell, // Cell to read into 113 psFits *fits, // FITS file from which to read 114 psDB *db // Database handle, for "concepts" ingest 115 ); 116 117 /// Read chip headers 118 /// 119 /// Same as pmChipRead, but reads only the headers of the readouts. 120 bool pmChipReadHeaderSet(pmChip *chip, // Chip to read into 121 psFits *fits, // FITS file from which to read 122 psDB *db // Database handle, for "concepts" ingest 123 ); 124 125 /// Read FPA headers 126 /// 127 /// Same as pmFPARead, but reads only the headers of the readouts. 128 bool pmFPAReadHeaderSet(pmFPA *fpa, // FPA to read into 129 psFits *fits, // FITS file from which to read 130 psDB *db // Database handle, for "concepts" ingest 131 ); 132 109 133 /// Read a FITS table into the cell 110 134 /// -
trunk/psModules/src/camera/pmFPAfile.c
r11376 r11793 408 408 return PM_FPA_FILE_FRINGE; 409 409 } 410 if (!strcasecmp (type, "HEADER")) { 411 return PM_FPA_FILE_HEADER; 412 } 410 413 411 414 return PM_FPA_FILE_NONE; -
trunk/psModules/src/camera/pmFPAfile.h
r11253 r11793 4 4 * @author EAM, IfA 5 5 * 6 * @version $Revision: 1.1 2$ $Name: not supported by cvs2svn $7 * @date $Date: 2007-0 1-24 02:54:14$6 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2007-02-15 00:34:00 $ 8 8 * Copyright 2004-2005 Institute for Astronomy, University of Hawaii 9 9 */ … … 40 40 PM_FPA_FILE_WEIGHT, 41 41 PM_FPA_FILE_FRINGE, 42 PM_FPA_FILE_HEADER, 42 43 } pmFPAfileType; 43 44 -
trunk/psModules/src/camera/pmFPAfileFitsIO.c
r11687 r11793 218 218 } 219 219 220 bool pmFPAviewReadFitsHeaderSet(const pmFPAview *view, pmFPAfile *file) 221 { 222 PS_ASSERT_PTR_NON_NULL(view, false); 223 PS_ASSERT_PTR_NON_NULL(file, false); 224 return fpaViewReadFitsImage(view, file, pmFPAReadHeaderSet, pmChipReadHeaderSet, pmCellReadHeaderSet); 225 } 226 220 227 // given an already-opened fits file, write the components corresponding 221 228 // to the specified view. when the file was opened, pmFPA/Chip/CellWrite was -
trunk/psModules/src/camera/pmFPAfileFitsIO.h
r11339 r11793 5 5 * @author PAP, IfA 6 6 * 7 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $8 * @date $Date: 2007-0 1-27 03:33:37$7 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2007-02-15 00:34:00 $ 9 9 * Copyright 2004-2005 Institute for Astronomy, University of Hawaii 10 10 */ … … 29 29 pmFPAfile *file ///< FPA file into which to read 30 30 ); 31 32 /// Read an image header into the current view 33 bool pmFPAviewReadFitsHeaderSet(const pmFPAview *view, ///< View specifying level of interest 34 pmFPAfile *file ///< FPA file into which to read 35 ); 31 36 32 37 /// Write the image for the specified view -
trunk/psModules/src/camera/pmFPAfileIO.c
r11687 r11793 251 251 252 252 switch (file->type) { 253 // open the FITS types: 254 case PM_FPA_FILE_IMAGE: 255 case PM_FPA_FILE_MASK: 256 case PM_FPA_FILE_WEIGHT: 257 case PM_FPA_FILE_FRINGE: 253 // open the FITS types: 254 case PM_FPA_FILE_IMAGE: 255 case PM_FPA_FILE_MASK: 256 case PM_FPA_FILE_WEIGHT: 257 case PM_FPA_FILE_HEADER: 258 case PM_FPA_FILE_FRINGE: 258 259 psTrace ("pmFPAfile", 5, "opening %s (type: %d)\n", file->filename, file->type); 259 260 if (!openImage(file, view, mode, config)) { … … 263 264 break; 264 265 // open the FITS object files 265 case PM_FPA_FILE_CMF:266 case PM_FPA_FILE_CMF: 266 267 psTrace ("pmFPAfile", 5, "opening %s (type: %d)\n", file->filename, file->type); 267 268 file->fits = psFitsOpen (file->filename, mode); … … 273 274 break; 274 275 275 // defer opening TEXT types:276 case PM_FPA_FILE_SX:277 case PM_FPA_FILE_OBJ:278 case PM_FPA_FILE_CMP:279 case PM_FPA_FILE_RAW:280 case PM_FPA_FILE_PSF:281 case PM_FPA_FILE_JPEG:282 case PM_FPA_FILE_KAPA:283 case PM_FPA_FILE_MANAPLOT:276 // defer opening TEXT types: 277 case PM_FPA_FILE_SX: 278 case PM_FPA_FILE_OBJ: 279 case PM_FPA_FILE_CMP: 280 case PM_FPA_FILE_RAW: 281 case PM_FPA_FILE_PSF: 282 case PM_FPA_FILE_JPEG: 283 case PM_FPA_FILE_KAPA: 284 case PM_FPA_FILE_MANAPLOT: 284 285 psTrace ("pmFPAfile", 5, "defer opening %s\n", file->filename); 285 286 break; 286 287 287 default:288 default: 288 289 psError(PS_ERR_IO, true, "type mismatch for %s : %d\n", file->filename, file->type); 289 290 return false; … … 357 358 case PM_FPA_FILE_WEIGHT: 358 359 if (!pmFPAviewReadFitsWeight(view, file)) { 360 psError(PS_ERR_UNKNOWN, false, "skipping %s (type: %d)\n", file->filename, file->type); 361 return false; 362 } 363 psTrace ("pmFPAfile", 5, "reading %s (type: %d)\n", file->filename, file->type); 364 break; 365 case PM_FPA_FILE_HEADER: 366 if (!pmFPAviewReadFitsHeaderSet(view, file)) { 359 367 psError(PS_ERR_UNKNOWN, false, "skipping %s (type: %d)\n", file->filename, file->type); 360 368 return false; … … 432 440 case PM_FPA_FILE_MASK: 433 441 case PM_FPA_FILE_WEIGHT: 442 case PM_FPA_FILE_HEADER: 434 443 case PM_FPA_FILE_FRINGE: 435 444 if (pmFPAviewFreeData(view, file)) { … … 525 534 pmFPAviewWriteFitsWeight(view, file, config); 526 535 psTrace ("pmFPAfile", 5, "wrote weight %s (fpa: %p)\n", file->filename, file->fpa); 536 break; 537 case PM_FPA_FILE_HEADER: 538 // pmFPAviewWriteFitsWeight(view, file, config); 539 // psTrace ("pmFPAfile", 5, "wrote weight %s (fpa: %p)\n", file->filename, file->fpa); 540 psAbort ("no HEADER write functions defined"); 527 541 break; 528 542 case PM_FPA_FILE_FRINGE: … … 616 630 case PM_FPA_FILE_WEIGHT: 617 631 case PM_FPA_FILE_FRINGE: { 618 // create FPA structure component based on view 619 #if 0 620 psMetadata *format = file->format; // Camera format configuration 621 if (!format) { 622 // It's likely a mosaic, for which we don't yet know the appropriate format 623 const psMetadata *camera = file->fpa->camera; // Camera configuration 624 psMetadata *formats = psMetadataLookupMetadata(NULL, camera, "FORMATS"); // The FORMATS 625 if (!formats) { 626 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find FORMATS in camera configuration.\n"); 627 return false; 628 } 629 format = psMetadataLookupMetadata(NULL, formats, config->formatName); 630 if (!format) { 631 psError(PS_ERR_UNEXPECTED_NULL, false, 632 "Unable to find format %s in camera configuration.\n", config->formatName); 633 return false; 634 } 635 file->format = psMemIncrRefCounter(format); 636 } 637 #endif 638 pmFPAAddSourceFromView (file->fpa, view, file->format); 639 psTrace ("pmFPAfile", 5, "created fpa data elements for %s (fpa: %p)\n", file->name, file->fpa); 640 break; 641 } 632 // create FPA structure component based on view 633 // XXX drop this ifdef'ed out code?? 634 #if 0 635 psMetadata *format = file->format; // Camera format configuration 636 if (!format) { 637 // It's likely a mosaic, for which we don't yet know the appropriate format 638 const psMetadata *camera = file->fpa->camera; // Camera configuration 639 psMetadata *formats = psMetadataLookupMetadata(NULL, camera, "FORMATS"); // The FORMATS 640 if (!formats) { 641 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find FORMATS in camera configuration.\n"); 642 return false; 643 } 644 format = psMetadataLookupMetadata(NULL, formats, config->formatName); 645 if (!format) { 646 psError(PS_ERR_UNEXPECTED_NULL, false, 647 "Unable to find format %s in camera configuration.\n", config->formatName); 648 return false; 649 } 650 file->format = psMemIncrRefCounter(format); 651 } 652 #endif 653 pmFPAAddSourceFromView (file->fpa, view, file->format); 654 psTrace ("pmFPAfile", 5, "created fpa data elements for %s (fpa: %p)\n", file->name, file->fpa); 655 break; 656 } 657 case PM_FPA_FILE_HEADER: 658 psAbort ("Create not defined for HEADER"); 659 break; 642 660 case PM_FPA_FILE_SX: 643 661 case PM_FPA_FILE_RAW: … … 691 709 case PM_FPA_FILE_MASK: 692 710 case PM_FPA_FILE_WEIGHT: 711 case PM_FPA_FILE_HEADER: 693 712 case PM_FPA_FILE_FRINGE: 694 713 case PM_FPA_FILE_CMF:
Note:
See TracChangeset
for help on using the changeset viewer.
