Changeset 3066 for trunk/external-alma
- Timestamp:
- 11/25/15 12:55:08 (9 years ago)
- Location:
- trunk/external-alma/atnf/PKSIO
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/external-alma/atnf/PKSIO/NRODataset.h
r2783 r3066 112 112 const std::string getLOSTM() const { return LOSTM ; } ; 113 113 const std::string getLOETM() const { return LOETM ; } ; 114 constint getARYNM() const { return ARYNM ; } ;115 constint getNSCAN() const { return NSCAN ; } ;114 int getARYNM() const { return ARYNM ; } ; 115 int getNSCAN() const { return NSCAN ; } ; 116 116 const std::string getTITLE() const { return TITLE ; } ; 117 117 const std::string getOBJ() const { return OBJ ; } ; 118 118 const std::string getEPOCH() const { return EPOCH ; } ; 119 constdouble getRA0() const { return RA0 ; } ;120 constdouble getDEC0() const { return DEC0 ; } ;121 constdouble getGLNG0() const { return GLNG0 ; } ;122 constdouble getGLAT0() const { return GLAT0 ; } ;123 constint getNCALB() const { return NCALB ; } ;124 constint getSCNCD() const { return SCNCD ; } ;119 double getRA0() const { return RA0 ; } ; 120 double getDEC0() const { return DEC0 ; } ; 121 double getGLNG0() const { return GLNG0 ; } ; 122 double getGLAT0() const { return GLAT0 ; } ; 123 int getNCALB() const { return NCALB ; } ; 124 int getSCNCD() const { return SCNCD ; } ; 125 125 const std::string getSCMOD() const { return SCMOD ; } ; 126 constdouble getURVEL() const { return URVEL ; } ;126 double getURVEL() const { return URVEL ; } ; 127 127 const std::string getVREF() const { return VREF ; } ; 128 128 const std::string getVDEF() const { return VDEF ; } ; 129 129 const std::string getSWMOD() const { return SWMOD ; } ; 130 const double getFRQSW() const { return FRQSW ; } ;131 const double getDBEAM() const { return DBEAM ; } ;132 const double getMLTOF() const { return MLTOF ; } ;133 const double getCMTQ() const { return CMTQ ; } ;134 constdouble getCMTE() const { return CMTE ; } ;135 constdouble getCMTSOM() const { return CMTSOM ; } ;136 constdouble getCMTNODE() const { return CMTNODE ; } ;137 constdouble getCMTI() const { return CMTI ; } ;130 double getFRQSW() const { return FRQSW ; } ; 131 double getDBEAM() const { return DBEAM ; } ; 132 double getMLTOF() const { return MLTOF ; } ; 133 double getCMTQ() const { return CMTQ ; } ; 134 double getCMTE() const { return CMTE ; } ; 135 double getCMTSOM() const { return CMTSOM ; } ; 136 double getCMTNODE() const { return CMTNODE ; } ; 137 double getCMTI() const { return CMTI ; } ; 138 138 const std::string getCMTTM() const { return CMTTM ; } ; 139 constdouble getSBDX() const { return SBDX ; } ;140 constdouble getSBDY() const { return SBDY ; } ;141 constdouble getSBDZ1() const { return SBDZ1 ; } ;142 constdouble getSBDZ2() const { return SBDZ2 ; } ;143 constdouble getDAZP() const { return DAZP ; } ;144 constdouble getDELP() const { return DELP ; } ;145 constint getCHBIND() const { return CHBIND ; } ;146 constint getNUMCH() const { return NUMCH ; } ;147 constint getCHMIN() const { return CHMIN ; } ;148 constint getCHMAX() const { return CHMAX ; } ;149 constdouble getALCTM() const { return ALCTM ; } ;150 constdouble getIPTIM() const { return IPTIM ; } ;151 constdouble getPA() const { return PA ; } ;152 constint getSCNLEN() const { return SCNLEN ; } ;153 constint getSBIND() const { return SBIND ; } ;154 constint getIBIT() const { return IBIT ; } ;139 double getSBDX() const { return SBDX ; } ; 140 double getSBDY() const { return SBDY ; } ; 141 double getSBDZ1() const { return SBDZ1 ; } ; 142 double getSBDZ2() const { return SBDZ2 ; } ; 143 double getDAZP() const { return DAZP ; } ; 144 double getDELP() const { return DELP ; } ; 145 int getCHBIND() const { return CHBIND ; } ; 146 int getNUMCH() const { return NUMCH ; } ; 147 int getCHMIN() const { return CHMIN ; } ; 148 int getCHMAX() const { return CHMAX ; } ; 149 double getALCTM() const { return ALCTM ; } ; 150 double getIPTIM() const { return IPTIM ; } ; 151 double getPA() const { return PA ; } ; 152 int getSCNLEN() const { return SCNLEN ; } ; 153 int getSBIND() const { return SBIND ; } ; 154 int getIBIT() const { return IBIT ; } ; 155 155 const std::string getSITE() const { return SITE ; } ; 156 156 const std::vector<std::string> getRX() const { return RX ; } ; … … 183 183 const std::string getCDMY1() const { return CDMY1 ; } ; 184 184 const std::vector<double> getDSBFC() const { return DSBFC ;} ; 185 constint getDataSize() const { return datasize_ ; } ;186 constint getRowNum() const { return rowNum_ ; } ;185 int getDataSize() const { return datasize_ ; } ; 186 int getRowNum() const { return rowNum_ ; } ; 187 187 188 188 // get various parameters -
trunk/external-alma/atnf/PKSIO/NROFITSDataset.cc
r2940 r3066 1684 1684 char ctmp[5] ; 1685 1685 std::size_t retval = fread( ctmp, 1, 4, fp_ ) ; 1686 if (retval < 4) { 1687 os << LogIO::SEVERE << "Failed to read array configuration." << LogIO::EXCEPTION; 1688 } 1686 1689 ctmp[4] = '\0' ; 1687 1690 //cout << "ctmp = " << ctmp << endl ; … … 1768 1771 while ( strncmp( buf, name, strlen(name) ) != 0 && strncmp( buf, "END", 3 ) != 0 ) { 1769 1772 std::size_t retval = fread( buf, 1, 80, fp_ ) ; 1773 if (retval < 80) { 1774 LogIO os(LogOrigin("NROFITSDataset", "readHeader(string)", WHERE)); 1775 os << LogIO::SEVERE << "Failed to read header" << LogIO::EXCEPTION; 1776 } 1770 1777 buf[80] = '\0' ; 1771 1778 count++ ; … … 1802 1809 while ( strncmp( buf, name, strlen(name) ) != 0 && strncmp( buf, "END", 3 ) != 0 ) { 1803 1810 std::size_t retval = fread( buf, 1, 80, fp_ ) ; 1811 if (retval < 80) { 1812 LogIO os(LogOrigin("NROFITSDataset", "readHeader(int)", WHERE)); 1813 os << LogIO::SEVERE << "Failed to read header" << LogIO::EXCEPTION; 1814 } 1804 1815 buf[80] = '\0' ; 1805 1816 //char bufo[9] ; … … 1838 1849 while ( strncmp( buf, name, strlen(name) ) != 0 && strncmp( buf, "END", 3 ) != 0 ) { 1839 1850 std::size_t retval = fread( buf, 1, 80, fp_ ) ; 1851 if (retval < 80) { 1852 LogIO os(LogOrigin("NROFITSDataset", "readHeader(float)", WHERE)); 1853 os << LogIO::SEVERE << "Failed to read header" << LogIO::EXCEPTION; 1854 } 1840 1855 buf[80] = '\0' ; 1841 1856 //char bufo[9] ; … … 1872 1887 while ( strncmp( buf, name, strlen(name) ) != 0 && strncmp( buf, "END", 3 ) != 0 ) { 1873 1888 std::size_t retval = fread( buf, 1, 80, fp_ ) ; 1889 if (retval < 80) { 1890 LogIO os(LogOrigin("NROFITSDataset", "readHeader(double)", WHERE)); 1891 os << LogIO::SEVERE << "Failed to read header" << LogIO::EXCEPTION; 1892 } 1874 1893 buf[80] = '\0' ; 1875 1894 char bufo[9] ; … … 1895 1914 } 1896 1915 1897 int NROFITSDataset::readTable( char *v, const char *name, int clen, int idx )1916 int NROFITSDataset::readTable( char *v, const char *name, size_t clen, int idx ) 1898 1917 { 1899 1918 // … … 1909 1928 return -1; 1910 1929 1911 int xsize = iter->second.size;1930 size_t xsize = iter->second.size; 1912 1931 1913 1932 // read data 1914 1933 if ( xsize < clen ) { 1915 1934 std::size_t retval = fread( v, 1, xsize, fp_ ) ; 1935 if (retval < xsize) { 1936 LogIO os(LogOrigin("NROFITSDataset", "readTable(char *)", WHERE)); 1937 os << LogIO::SEVERE << "Failed to read binary table" << LogIO::EXCEPTION; 1938 } 1916 1939 //v[xsize] = '\0' ; 1917 1940 } 1941 else if (clen > 0) { 1942 std::size_t retval = fread( v, 1, clen - 1, fp_ ) ; 1943 if (retval < clen - 1) { 1944 LogIO os(LogOrigin("NROFITSDataset", "readTable(char *)", WHERE)); 1945 os << LogIO::SEVERE << "Failed to read binary table" << LogIO::EXCEPTION; 1946 } 1947 //v[clen-1] = '\0' ; 1948 } 1918 1949 else { 1919 std::size_t retval = fread( v, 1, clen-1, fp_ ) ; 1920 //v[clen-1] = '\0' ; 1950 status = -1; 1921 1951 } 1922 1952 … … 1936 1966 // read data 1937 1967 std::size_t retval = fread( &v, sizeof(int), 1, fp_ ) ; 1968 if (retval < 1) { 1969 LogIO os(LogOrigin("NROFITSDataset", "readTable(int)", WHERE)); 1970 os << LogIO::SEVERE << "Failed to read binary table" << LogIO::EXCEPTION; 1971 } 1938 1972 if ( b == 0 ) 1939 1973 convertEndian( v ) ; … … 1954 1988 // read data 1955 1989 std::size_t retval = fread( &v, sizeof(float), 1, fp_ ) ; 1990 if (retval < 1) { 1991 LogIO os(LogOrigin("NROFITSDataset", "readTable(float)", WHERE)); 1992 os << LogIO::SEVERE << "Failed to read binary table" << LogIO::EXCEPTION; 1993 } 1956 1994 if ( b == 0 ) 1957 1995 convertEndian( v ) ; … … 1972 2010 // read data 1973 2011 std::size_t retval = fread( &v, sizeof(double), 1, fp_ ) ; 2012 if (retval < 1) { 2013 LogIO os(LogOrigin("NROFITSDataset", "readTable(double)", WHERE)); 2014 os << LogIO::SEVERE << "Failed to read binary table" << LogIO::EXCEPTION; 2015 } 1974 2016 if ( b == 0 ) 1975 2017 convertEndian( v ) ; … … 1991 2033 return -1; 1992 2034 1993 int xsize = iter->second.size;2035 size_t xsize = iter->second.size; 1994 2036 1995 2037 for ( unsigned int i = 0 ; i < v.size() ; i++ ) { 1996 int clen = strlen( v[i] ) ;2038 size_t clen = strlen( v[i] ) ; 1997 2039 if ( clen > xsize ) { 1998 2040 std::size_t retval = fread( v[i], 1, xsize, fp_ ) ; 2041 if (retval < xsize) { 2042 LogIO os(LogOrigin("NROFITSDataset", "readTable(vector<char *>)", WHERE)); 2043 os << LogIO::SEVERE << "Failed to read binary table" << LogIO::EXCEPTION; 2044 } 1999 2045 //v[i][xsize] = '\0' ; 2000 2046 } 2001 2047 else { 2002 2048 std::size_t retval = fread( v[i], 1, clen, fp_ ) ; 2049 if (retval < clen) { 2050 LogIO os(LogOrigin("NROFITSDataset", "readTable(vector<char *>)", WHERE)); 2051 os << LogIO::SEVERE << "Failed to read binary table" << LogIO::EXCEPTION; 2052 } 2003 2053 //v[i][clen-1] = '\0' ; 2004 2054 } … … 2019 2069 2020 2070 for ( unsigned int i = 0 ; i < v.size() ; i++ ) { 2021 std::size_t retval = fread( &v[i], 1, sizeof(int), fp_ ) ; 2071 std::size_t retval = fread( &v[i], sizeof(int), 1, fp_ ) ; 2072 if (retval < 1) { 2073 LogIO os(LogOrigin("NROFITSDataset", "readTable(vector<int>)", WHERE)); 2074 os << LogIO::SEVERE << "Failed to read binary table" << LogIO::EXCEPTION; 2075 } 2022 2076 if ( b == 0 ) 2023 2077 convertEndian( v[i] ) ; … … 2038 2092 2039 2093 for ( unsigned int i = 0 ; i < v.size() ; i++ ) { 2040 std::size_t retval = fread( &v[i], 1, sizeof(float), fp_ ) ; 2094 std::size_t retval = fread( &v[i], sizeof(float), 1, fp_ ) ; 2095 if (retval < 1) { 2096 LogIO os(LogOrigin("NROFITSDataset", "readTable(vector<float>)", WHERE)); 2097 os << LogIO::SEVERE << "Failed to read binary table" << LogIO::EXCEPTION; 2098 } 2041 2099 if ( b == 0 ) 2042 2100 convertEndian( v[i] ) ; … … 2057 2115 2058 2116 for ( unsigned int i = 0 ; i < v.size() ; i++ ) { 2059 std::size_t retval = fread( &v[i], 1, sizeof(double), fp_ ) ; 2117 std::size_t retval = fread( &v[i], sizeof(double), 1, fp_ ) ; 2118 if (retval < 1) { 2119 LogIO os(LogOrigin("NROFITSDataset", "readTable(vector<double>)", WHERE)); 2120 os << LogIO::SEVERE << "Failed to read binary table" << LogIO::EXCEPTION; 2121 } 2060 2122 if ( b == 0 ) 2061 2123 convertEndian( v[i] ) ; … … 2080 2142 return -1; 2081 2143 2082 int xsize = iter->second.size;2144 size_t xsize = iter->second.size; 2083 2145 2084 2146 for ( unsigned int i = 0 ; i < v.size() ; i++ ) { … … 2096 2158 char c[xsize+1] ; 2097 2159 std::size_t retval = fread( c, 1, xsize, fp_ ) ; 2160 if (retval < xsize) { 2161 LogIO os(LogOrigin("NROFITSDataset", "readColumn(string)", WHERE)); 2162 os << LogIO::SEVERE << "Failed to read binary table" << LogIO::EXCEPTION; 2163 } 2098 2164 c[xsize] = '\0' ; 2099 2165 v[i] = string( c ) ; … … 2118 2184 int offset = scanLen_ * arrayid_[i] + sizeof(int) * idx ; 2119 2185 fseek( fp_, offset, SEEK_CUR ) ; 2120 std::size_t retval = fread( &v[i], 1, sizeof(int), fp_ ) ; 2186 std::size_t retval = fread( &v[i], sizeof(int), 1, fp_ ) ; 2187 if (retval < 1) { 2188 LogIO os(LogOrigin("NROFITSDataset", "readColumn(int)", WHERE)); 2189 os << LogIO::SEVERE << "Failed to read binary table" << LogIO::EXCEPTION; 2190 } 2121 2191 if ( b == 0 ) 2122 2192 convertEndian( v[i] ) ; … … 2142 2212 fseek( fp_, offset, SEEK_CUR ) ; 2143 2213 std::size_t retval = fread( &v[i], 1, sizeof(float), fp_ ) ; 2214 if (retval < 1) { 2215 LogIO os(LogOrigin("NROFITSDataset", "readColumn(float)", WHERE)); 2216 os << LogIO::SEVERE << "Failed to read binary table" << LogIO::EXCEPTION; 2217 } 2144 2218 if ( b == 0 ) 2145 2219 convertEndian( v[i] ) ; … … 2165 2239 fseek( fp_, offset, SEEK_CUR ) ; 2166 2240 std::size_t retval = fread( &v[i], 1, sizeof(double), fp_ ) ; 2241 if (retval < 1) { 2242 LogIO os(LogOrigin("NROFITSDataset", "readColumn(double)", WHERE)); 2243 os << LogIO::SEVERE << "Failed to read binary table" << LogIO::EXCEPTION; 2244 } 2167 2245 if ( b == 0 ) 2168 2246 convertEndian( v[i] ) ; -
trunk/external-alma/atnf/PKSIO/NROFITSDataset.h
r2812 r3066 101 101 struct FieldProperty { 102 102 //string name; // field name 103 int size;// data size [byte]103 size_t size; // data size [byte] 104 104 //string unit; // unit of the field 105 long offset;// offset from the head of scan record [byte]105 size_t offset; // offset from the head of scan record [byte] 106 106 }; 107 107 … … 111 111 // Read char data 112 112 int readHeader( string &v, const char *name ) ; 113 int readTable( char *v, const char *name, int clen, int idx=0 ) ;113 int readTable( char *v, const char *name, size_t clen, int idx=0 ) ; 114 114 int readTable( vector<char *> &v, const char *name, int idx=0 ) ; 115 115 int readColumn( vector<string> &v, const char *name, int idx=0 ) ; -
trunk/external-alma/atnf/PKSIO/NROReader.cc
r2940 r3066 81 81 // Determine the type of input. 82 82 NROReader *reader = 0; 83 std::size_t retval;84 83 if ( inFile.isRegular() ) { 85 84 FILE *file ; … … 87 86 // read LOFIL0 88 87 char buf[9]; 89 retval = fread( buf, 4, 1, file ) ; 88 size_t retval = fread( buf, 4, 1, file ) ; 89 if (retval < 1) { 90 os << LogIO::SEVERE << "Failed to read data" << LogIO::POST; 91 fclose(file); 92 return 0; 93 } 90 94 buf[4] = '\0' ; 91 95 // DEBUG … … 108 112 delete d ; 109 113 fseek( file, size, SEEK_SET ) ; 110 retval = fread( buf, 8, 1, file ) ; 114 size_t retval = fread( buf, 8, 1, file ) ; 115 if (retval < 1) { 116 os << LogIO::SEVERE << "Failed to read data" << LogIO::POST; 117 fclose(file); 118 return 0; 119 } 111 120 buf[8] = '\0' ; 112 121 // DEBUG … … 124 133 delete d ; 125 134 fseek( file, size, SEEK_SET ) ; 126 retval = fread( buf, 8, 1, file ) ; 135 size_t retval = fread( buf, 8, 1, file ) ; 136 if (retval < 1) { 137 os << LogIO::SEVERE << "Failed to read data" << LogIO::POST; 138 fclose(file); 139 return 0; 140 } 127 141 buf[8] = '\0' ; 128 142 // DEBUG
Note:
See TracChangeset
for help on using the changeset viewer.