Changeset 9949
- Timestamp:
- Nov 13, 2006, 12:15:05 PM (19 years ago)
- Location:
- trunk/psModules/src/camera
- Files:
-
- 4 edited
-
pmFPARead.c (modified) (1 diff)
-
pmFPARead.h (modified) (2 diffs)
-
pmFPAWrite.c (modified) (1 diff)
-
pmFPAWrite.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPARead.c
r9599 r9949 614 614 } 615 615 616 617 int pmCellReadTable(pmCell *cell, psFits *fits, const char *name) 618 { 619 PS_ASSERT_PTR_NON_NULL(cell, 0); 620 PS_ASSERT_PTR_NON_NULL(fits, 0); 621 PS_ASSERT_STRING_NON_EMPTY(name, 0); 622 623 const char *chipName = psMetadataLookupStr(NULL, cell->parent->concepts, "CHIP.NAME"); // Name of chip 624 const char *cellName = psMetadataLookupStr(NULL, cell->concepts, "CELL.NAME"); // Name of cell 625 psString extname = NULL; // Extension name 626 psStringAppend(&extname, "%s_%s_%s", name, chipName, cellName); 627 628 // XXX Could do a table lookup from the camera format, in case the input file isn't laid out with 629 // NAME_CHIP_CELL extension names --- use these as keys, and the value as the proper extension name. 630 // Allow interpolation of concepts, e.g., "{CHIP.NAME}" --> "ccd13". 631 632 if (!psFitsMoveExtName(fits, extname)) { 633 psError(PS_ERR_IO, false, "Unable to move to extension %s\n", extname); 634 psFree(extname); 635 return 0; 636 } 637 638 psMetadata *header = psFitsReadHeader(NULL, fits); // The FITS header 639 if (!header) { 640 psError(PS_ERR_IO, false, "Unable to read header for extension %s\n", extname); 641 psFree(extname); 642 psFree(header); 643 return 0; 644 } 645 646 psString headerName = NULL; // Name for header 647 psStringAppend(&headerName, "%s.HEADER", name); 648 if (!psMetadataAdd(cell->analysis, PS_LIST_TAIL, headerName, PS_DATA_METADATA, 649 "FITS table header", header)) { 650 psError(PS_ERR_UNKNOWN, false, "Unable to add header from extension %s to analysis metadata " 651 "for chip %s, cell %s\n", extname, chipName, cellName); 652 psFree(headerName); 653 psFree(header); 654 psFree(extname); 655 return 0; 656 } 657 psFree(headerName); 658 psFree(header); 659 660 psArray *table = psFitsReadTable(fits); // The table 661 if (!psMetadataAdd(cell->analysis, PS_LIST_TAIL, name, PS_DATA_ARRAY, "FITS table", table)) { 662 psError(PS_ERR_UNKNOWN, false, "Unable to add table from extension %s to analysis metadata " 663 "for chip %s, cell %s\n", extname, chipName, cellName); 664 psFree(table); 665 psFree(extname); 666 return 0; 667 } 668 669 psFree(extname); 670 psFree(table); // Dropping reference 671 672 return 1; 673 } 674 675 676 int pmChipReadTable(pmChip *chip, psFits *fits, const char *name) 677 { 678 PS_ASSERT_PTR_NON_NULL(chip, 0); 679 PS_ASSERT_PTR_NON_NULL(fits, 0); 680 PS_ASSERT_STRING_NON_EMPTY(name, 0); 681 682 int numRead = 0; // Number of reads 683 psArray *cells = chip->cells; // Array of cells 684 for (int i = 0; i < cells->n; i++) { 685 pmCell *cell = cells->data[i]; // Cell of interest 686 numRead += pmCellReadTable(cell, fits, name); 687 } 688 689 return numRead; 690 } 691 692 693 int pmFPAReadTable(pmFPA *fpa, psFits *fits, const char *name) 694 { 695 PS_ASSERT_PTR_NON_NULL(fpa, 0); 696 PS_ASSERT_PTR_NON_NULL(fits, 0); 697 PS_ASSERT_STRING_NON_EMPTY(name, 0); 698 699 int numRead = 0; // Number of reads 700 psArray *chips = fpa->chips; // Array of chips 701 for (int i = 0; i < chips->n; i++) { 702 pmChip *chip = chips->data[i]; // Chip of interest 703 numRead += pmChipReadTable(chip, fits, name); 704 } 705 706 return numRead; 707 } -
trunk/psModules/src/camera/pmFPARead.h
r9600 r9949 7 7 /// @author Paul Price, IfA 8 8 /// 9 /// @version $Revision: 1. 4$ $Name: not supported by cvs2svn $10 /// @date $Date: 2006-1 0-17 03:01:24$9 /// @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 10 /// @date $Date: 2006-11-13 22:15:05 $ 11 11 /// 12 12 /// Copyright 2005-2006 Institute for Astronomy, University of Hawaii … … 108 108 ); 109 109 110 /// Read a FITS table into the cell 111 /// 112 /// Given a name, which is combined with the chip and cell to identify the extension name ("NAME_CHIP_CELL"), 113 /// read the FITS table into the cell analysis metadata (with key being the provided name). The header is 114 /// also read and included in the cell analysis metadata under "name.HEADER". 115 int pmCellReadTable(pmCell *cell, ///< Cell for which to read table 116 psFits *fits, ///< FITS file from which the table 117 const char *name ///< Specifies the extension name, and target in the analysis metadata 118 ); 119 120 /// Read a FITS table into the component cells 121 /// 122 /// Iterates over component cells, calling pmCellReadTable. 123 int pmChipReadTable(pmChip *chip, ///< Cell for which to read table 124 psFits *fits, ///< FITS file from which the table 125 const char *name ///< Specifies the extension name, and target in the analysis metadata 126 ); 127 128 /// Read a FITS table into the component cells 129 /// 130 /// Iterates over component chips, calling pmChipReadTable. 131 int pmFPAReadTable(pmFPA *fpa, ///< Cell for which to read table 132 psFits *fits, ///< FITS file from which the table 133 const char *name ///< Specifies the extension name, and target in the analysis metadata 134 ); 135 110 136 #endif -
trunk/psModules/src/camera/pmFPAWrite.c
r9602 r9949 239 239 return true; 240 240 } 241 242 243 244 int pmCellWriteTable(psFits *fits, const pmCell *cell, const char *name) 245 { 246 PS_ASSERT_PTR_NON_NULL(cell, 0); 247 PS_ASSERT_PTR_NON_NULL(fits, 0); 248 PS_ASSERT_STRING_NON_EMPTY(name, 0); 249 250 const char *chipName = psMetadataLookupStr(NULL, cell->parent->concepts, "CHIP.NAME"); // Name of chip 251 const char *cellName = psMetadataLookupStr(NULL, cell->concepts, "CELL.NAME"); // Name of cell 252 253 psArray *table = psMetadataLookupPtr(NULL, cell->analysis, name); // The FITS table 254 if (!table) { 255 // We wrote everything we could find 256 return 0; 257 } 258 259 psString headerName = NULL; // Name for header in analysis metadata 260 psStringAppend(&headerName, "%s.HEADER", name); 261 psMetadata *header = psMetadataLookupMetadata(NULL, cell->analysis, headerName); // The FITS header 262 psFree(headerName); 263 264 psString extname = NULL; // Extension name 265 psStringAppend(&extname, "%s_%s_%s", name, chipName, cellName); 266 267 // XXX Could do a table lookup from the camera format, in case the input file isn't laid out with 268 // NAME_CHIP_CELL extension names --- use these as keys, and the value as the proper extension name. 269 // Allow interpolation of concepts, e.g., "{CHIP.NAME}" --> "ccd13". 270 271 if (!psFitsWriteTable(fits, header, table, extname)) { 272 psError(PS_ERR_UNKNOWN, false, "Unable to write table from chip %s, cell %s to extension %s\n", 273 chipName, cellName, extname); 274 psFree(extname); 275 return 0; 276 } 277 278 psFree(extname); 279 return 1; 280 } 281 282 283 int pmChipWriteTable(psFits *fits, const pmChip *chip, const char *name) 284 { 285 PS_ASSERT_PTR_NON_NULL(chip, 0); 286 PS_ASSERT_PTR_NON_NULL(fits, 0); 287 PS_ASSERT_STRING_NON_EMPTY(name, 0); 288 289 int numWrite = 0; // Number of reads 290 psArray *cells = chip->cells; // Array of cells 291 for (int i = 0; i < cells->n; i++) { 292 pmCell *cell = cells->data[i]; // Cell of interest 293 numWrite += pmCellWriteTable(fits, cell, name); 294 } 295 296 return numWrite; 297 } 298 299 300 int pmFPAWriteTable(psFits *fits, const pmFPA *fpa, const char *name) 301 { 302 PS_ASSERT_PTR_NON_NULL(fpa, 0); 303 PS_ASSERT_PTR_NON_NULL(fits, 0); 304 PS_ASSERT_STRING_NON_EMPTY(name, 0); 305 306 int numWrite = 0; // Number of reads 307 psArray *chips = fpa->chips; // Array of chips 308 for (int i = 0; i < chips->n; i++) { 309 pmChip *chip = chips->data[i]; // Chip of interest 310 numWrite += pmChipWriteTable(fits, chip, name); 311 } 312 313 return numWrite; 314 } -
trunk/psModules/src/camera/pmFPAWrite.h
r9717 r9949 7 7 /// @author Paul Price, IfA 8 8 /// 9 /// @version $Revision: 1. 4$ $Name: not supported by cvs2svn $10 /// @date $Date: 2006-1 0-24 00:23:46$9 /// @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 10 /// @date $Date: 2006-11-13 22:15:05 $ 11 11 /// 12 12 /// Copyright 2005-2006 Institute for Astronomy, University of Hawaii … … 67 67 ); 68 68 69 /// Write a FITS table from the cell's analysis metadata. 70 /// 71 /// The FITS table (a psArray of psMetadatas) from the cell's analysis metadata (under "name") is written to 72 /// the FITS file, at an extension specified by the name, chip name and cell name ("NAME_CHIP_CELL"). If a 73 /// header is present in the analysis metadata ("name.HEADER"), then it is written also. 74 int pmCellWriteTable(psFits *fits, ///< FITS file to which to write 75 const pmCell *cell, ///< Cell containing FITS table in the analysis metadata 76 const char *name ///< Name for the table data, and the extension name 77 ); 78 79 int pmChipWriteTable(psFits *fits, ///< FITS file to which to write 80 const pmChip *chip, ///< Chip containing cells with tables to write 81 const char *name ///< Name for the table data, and the extension name 82 ); 83 84 int pmFPAWriteTable(psFits *fits, ///< FITS file to which to write 85 const pmFPA *fpa, ///< FPA containing cells with tables to write 86 const char *name ///< Name for the table data, and the extension name 87 ); 88 69 89 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
