Changeset 7230
- Timestamp:
- May 26, 2006, 3:50:33 PM (20 years ago)
- Location:
- trunk/psLib/src/fits
- Files:
-
- 2 edited
-
psFitsTable.c (modified) (7 diffs)
-
psFitsTable.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/fits/psFitsTable.c
r6767 r7230 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $10 * @date $Date: 2006-0 4-04 19:52:42$9 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2006-05-27 01:50:33 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 13 13 */ 14 14 15 #include "config.h" 15 16 #include "psFits.h" 16 17 #include "string.h" … … 23 24 #include "psTrace.h" 24 25 #include "psVector.h" 25 #include "config.h" 26 #include "psFitsTable.h" 27 #include "psFitsHeader.h" 26 28 27 29 #define MAX_STRING_LENGTH 256 // maximum length string for FITS routines … … 603 605 604 606 bool psFitsWriteTable(psFits* fits, 605 const psMetadata* header, 606 const psArray* table) 607 psMetadata* header, 608 const psArray* table, 609 const char *extname) 607 610 { 611 psFitsMoveLast(fits); 612 return psFitsInsertTable(fits, header, table, extname, true); 613 614 #if 0 615 608 616 int status = 0; 609 617 … … 710 718 } 711 719 712 psString extname = NULL; 713 if (header != NULL) { 714 extname = psMetadataLookupStr(NULL, header, "EXTNAME"); 715 if ( extname == NULL) { 716 extname = psMetadataLookupStr(NULL, header, "HDUNAME"); 717 } 718 } 719 720 // Create the table 720 721 fits_create_tbl(fits->fd, 721 722 BINARY_TBL, … … 727 728 extname, // extension name 728 729 &status); 729 730 730 psFree(columnNames); 731 731 psFree(columnTypes); 732 733 // Write header 734 if (header && !psFitsWriteHeader(header, fits)) { 735 psError(PS_ERR_IO, false, "Unable to write FITS header.\n"); 736 return false; 737 } 732 738 733 739 // fill in the table elements with data … … 810 816 811 817 return true; 818 #endif 812 819 } 813 820 814 821 bool psFitsInsertTable(psFits* fits, 815 constpsMetadata* header,822 psMetadata* header, 816 823 const psArray* table, 824 const char *extname, 817 825 bool after) 818 826 { … … 921 929 } 922 930 923 psString extname = NULL; 924 if (header != NULL) { 925 extname = psMetadataLookupStr(NULL, header, "EXTNAME"); 926 if ( extname == NULL) { 927 extname = psMetadataLookupStr(NULL, header, "HDUNAME"); 928 } 929 } 930 931 if (! after) { 932 if (psFitsGetExtNum(fits) == 0) { 933 // set status to signal fits_insert_img to insert a new primary HDU 934 status = PREPEND_PRIMARY; 935 } else { 936 // move back one to perform an insert after the previous HDU 937 psFitsMoveExtNum(fits, -1, true); 938 } 939 } 940 941 fits_insert_btbl(fits->fd, 942 table->n, // number of rows in table 943 columns->n, // number of columns in table 944 (char**)columnNames->data, // names of the columns 945 (char**)columnTypes->data, // format of the columns 946 NULL, // physical unit of columns 947 extname, // extension name 948 0, 949 &status); 950 931 // Create the table HDU 932 int hdus = psFitsGetSize(fits); // Number of HDUs in file 933 if (hdus == 0) { 934 // We're creating the first extension 935 fits_create_tbl(fits->fd, 936 BINARY_TBL, 937 table->n, // number of rows in table 938 columns->n, // number of columns in table 939 (char**)columnNames->data, // names of the columns 940 (char**)columnTypes->data, // format of the columns 941 NULL, // physical unit of columns 942 (char*)extname, // extension name; casting away const because cfitsio is horrible 943 &status); 944 } else { 945 if (!after) { 946 if (psFitsGetExtNum(fits) == 0) { 947 // We're creating a replacement primary HDU. 948 // Set status to signal fits_insert_img to insert a new primary HDU 949 status = PREPEND_PRIMARY; 950 } else { 951 // Move back one to perform an insert after the previous HDU 952 psFitsMoveExtNum(fits, -1, true); 953 } 954 } 955 // Insert the table 956 fits_insert_btbl(fits->fd, 957 table->n, // number of rows in table 958 columns->n, // number of columns in table 959 (char**)columnNames->data, // names of the columns 960 (char**)columnTypes->data, // format of the columns 961 NULL, // physical unit of columns 962 (char*)extname, // extension name; casting away const because cfitsio is horrible 963 0, 964 &status); 965 } 951 966 psFree(columnNames); 952 967 psFree(columnTypes); 953 968 969 // Write header 970 if (header && !psFitsWriteHeader(header, fits)) { 971 psError(PS_ERR_IO, false, "Unable to write FITS header.\n"); 972 return false; 973 } 954 974 955 975 // fill in the table elements with data -
trunk/psLib/src/fits/psFitsTable.h
r6767 r7230 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $10 * @date $Date: 2006-0 4-04 19:52:42$9 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2006-05-27 01:50:33 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 82 82 bool psFitsWriteTable( 83 83 psFits* fits, ///< the psFits object 84 constpsMetadata* header, ///< header items for the new HDU. Can be NULL.85 const psArray* table 86 ///< Array of psMetadata items, which contains the output data items of each row.84 psMetadata* header, ///< header items for the new HDU. Can be NULL. 85 const psArray* table, ///< Array of psMetadata items, which contains the output data items of each row. 86 const char *extname ///< Extension name 87 87 ); 88 88 … … 96 96 bool psFitsInsertTable( 97 97 psFits* fits, ///< the psFits object 98 const psMetadata* header, ///< header items for the new HDU. Can be NULL. 99 const psArray* table, 100 ///< Array of psMetadata items, which contains the output data items of each row. 101 bool after 102 ///< TRUE if insert is done after CHDU, otherwise table is inserted before CHDU 98 psMetadata* header, ///< header items for the new HDU. Can be NULL. 99 const psArray* table, ///< Array of psMetadata items, which contains the output data items of each row. 100 const char *extname, ///< Extension name 101 bool after ///< TRUE if insert is done after CHDU, otherwise table is inserted before CHDU 103 102 ); 104 103
Note:
See TracChangeset
for help on using the changeset viewer.
