Changeset 2440 for trunk/external-alma/atnf
- Timestamp:
- 03/22/12 19:25:06 (13 years ago)
- Location:
- trunk/external-alma/atnf/PKSIO
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/external-alma/atnf/PKSIO/NROFITSDataset.cc
r2436 r2440 1947 1947 // of the FITS Scan Record 1948 1948 // 1949 int status = 0 ; 1950 1951 // skip header 1952 fseek( fp_, FITS_HEADER_SIZE, SEEK_SET ) ; 1953 1954 // find offset 1955 int offset = getOffset( name ) ; 1956 if ( offset == -1 ) { 1957 //cerr << "Error, " << name << " is not found in the name list." << endl ; 1958 return -1 ; 1959 } 1960 offset += idx * scanLen_ ; 1961 //cout << "offset for " << name << " is " << offset << " bytes." << endl ; 1962 fseek( fp_, offset, SEEK_CUR ) ; 1949 int status = movePointer( name, idx ) ; 1950 if ( status < 0 ) 1951 return status ; 1963 1952 1964 1953 // get length of char … … 2004 1993 // of the FITS Scan Record 2005 1994 // 2006 int status = 0 ; 2007 // skip header 2008 fseek( fp_, FITS_HEADER_SIZE, SEEK_SET ) ; 2009 2010 // find offset 2011 int offset = getOffset( name ) ; 2012 if ( offset == -1 ) { 2013 //cerr << "Error, " << name << " is not found in the name list." << endl ; 2014 return -1 ; 2015 } 2016 offset += idx * scanLen_ ; 2017 //cout << "offset for " << name << " is " << offset << " bytes." << endl ; 2018 fseek( fp_, offset, SEEK_CUR ) ; 1995 int status = movePointer( name, idx ) ; 1996 if ( status < 0 ) 1997 return status ; 2019 1998 2020 1999 // read data … … 2043 2022 // of the FITS Scan Record 2044 2023 // 2045 int status = 0 ; 2046 2047 // skip header 2048 fseek( fp_, FITS_HEADER_SIZE, SEEK_SET ) ; 2049 2050 // find offset 2051 int offset = getOffset( name ) ; 2052 if ( offset == -1 ) { 2053 //cerr << "Error, " << name << " is not found in the name list." << endl ; 2054 return -1 ; 2055 } 2056 offset += idx * scanLen_ ; 2057 //cout << "offset for " << name << " is " << offset << " bytes." << endl ; 2058 fseek( fp_, offset, SEEK_CUR ) ; 2024 int status = movePointer( name, idx ) ; 2025 if ( status < 0 ) 2026 return status ; 2059 2027 2060 2028 // read data … … 2083 2051 // of the FITS Scan Record 2084 2052 // 2085 int status = 0 ; 2086 2087 // skip header 2088 fseek( fp_, FITS_HEADER_SIZE, SEEK_SET ) ; 2089 2090 // find offset 2091 int offset = getOffset( name ) ; 2092 if ( offset == -1 ) { 2093 //cerr << "Error, " << name << " is not found in the name list." << endl ; 2094 return -1 ; 2095 } 2096 offset += idx * scanLen_ ; 2097 //cout << "offset for " << name << " is " << offset << " bytes." << endl ; 2098 fseek( fp_, offset, SEEK_CUR ) ; 2053 int status = movePointer( name, idx ) ; 2054 if ( status < 0 ) 2055 return status ; 2099 2056 2100 2057 // read data … … 2111 2068 // Read 'name' attribute defined as char array from the FITS Scan Record 2112 2069 // 2113 int status = 0 ; 2114 2115 // skip header 2116 fseek( fp_, FITS_HEADER_SIZE, SEEK_SET ) ; 2117 2118 // find offset 2119 int offset = getOffset( name ) ; 2120 if ( offset == -1 ) { 2121 //cerr << "Error, " << name << " is not found in the name list." << endl ; 2122 return -1 ; 2123 } 2124 offset += idx * scanLen_ ; 2125 //cout << "offset for " << name << " is " << offset << " bytes." << endl ; 2126 fseek( fp_, offset, SEEK_CUR ) ; 2070 int status = movePointer( name, idx ) ; 2071 if ( status < 0 ) 2072 return status ; 2127 2073 2128 2074 // get length of char … … 2159 2105 // Read 'name' attribute defined as int array from the FITS Scan Record 2160 2106 // 2161 int status = 0 ; 2162 2163 // skip header 2164 fseek( fp_, FITS_HEADER_SIZE, SEEK_SET ) ; 2165 2166 // find offset 2167 int offset = getOffset( name ) ; 2168 if ( offset == -1 ) { 2169 //cerr << "Error, " << name << " is not found in the name list." << endl ; 2170 return -1 ; 2171 } 2172 offset += idx * scanLen_ ; 2173 //cout << "offset for " << name << " is " << offset << " bytes." << endl ; 2174 fseek( fp_, offset, SEEK_CUR ) ; 2107 int status = movePointer( name, idx ) ; 2108 if ( status < 0 ) 2109 return status ; 2175 2110 2176 2111 for ( unsigned int i = 0 ; i < v.size() ; i++ ) { … … 2189 2124 // Read 'name' attribute defined as float array from the FITS Scan Record 2190 2125 // 2191 int status = 0 ; 2192 2193 // skip header 2194 fseek( fp_, FITS_HEADER_SIZE, SEEK_SET ) ; 2195 2196 // find offset 2197 int offset = getOffset( name ) ; 2198 if ( offset == -1 ) { 2199 //cerr << "Error, " << name << " is not found in the name list." << endl ; 2200 return -1 ; 2201 } 2202 offset += idx * scanLen_ ; 2203 //cout << "offset for " << name << " is " << offset << " bytes." << endl ; 2204 fseek( fp_, offset, SEEK_CUR ) ; 2126 int status = movePointer( name, idx ) ; 2127 if ( status < 0 ) 2128 return status ; 2205 2129 2206 2130 for ( unsigned int i = 0 ; i < v.size() ; i++ ) { … … 2219 2143 // Read 'name' attribute defined as double array from the FITS Scan Record 2220 2144 // 2221 int status = 0 ; 2222 2223 // skip header 2224 fseek( fp_, FITS_HEADER_SIZE, SEEK_SET ) ; 2225 2226 // find offset 2227 int offset = getOffset( name ) ; 2228 if ( offset == -1 ) { 2229 //cerr << "Error, " << name << " is not found in the name list." << endl ; 2230 return -1 ; 2231 } 2232 offset += idx * scanLen_ ; 2233 //cout << "offset for " << name << " is " << offset << " bytes." << endl ; 2234 fseek( fp_, offset, SEEK_CUR ) ; 2145 int status = movePointer( name, idx ) ; 2146 if ( status < 0 ) 2147 return status ; 2235 2148 2236 2149 for ( unsigned int i = 0 ; i < v.size() ; i++ ) { … … 2261 2174 // defined as char array from the FITS Scan Record 2262 2175 // 2263 int status = 0 ; 2264 2265 // skip header 2266 fseek( fp_, FITS_HEADER_SIZE, SEEK_SET ) ; 2267 2268 // find offset 2269 int offset = getOffset( name ) ; 2270 if ( offset == -1 ) { 2271 //cerr << "Error, " << name << " is not found in the name list." << endl ; 2272 return -1 ; 2273 } 2274 //cout << "offset for " << name << " is " << offset << " bytes." << endl ; 2275 fseek( fp_, offset, SEEK_CUR ) ; 2176 int status = movePointer( name ) ; 2177 if ( status < 0 ) 2178 return status ; 2276 2179 2277 2180 // get length of char … … 2288 2191 2289 2192 for ( unsigned int i = 0 ; i < v.size() ; i++ ) { 2290 offset = scanLen_ * arrayid_[i] + xsize * idx ;2193 int offset = scanLen_ * arrayid_[i] + xsize * idx ; 2291 2194 fseek( fp_, offset, SEEK_CUR ) ; 2292 2195 // int clen = (int)strlen( v[i] ) ; … … 2327 2230 // defined as int array from the FITS Scan Record 2328 2231 // 2329 int status = 0 ; 2330 2331 // skip header 2332 fseek( fp_, FITS_HEADER_SIZE, SEEK_SET ) ; 2333 2334 // find offset 2335 int offset = getOffset( name ) ; 2336 if ( offset == -1 ) { 2337 //cerr << "Error, " << name << " is not found in the name list." << endl ; 2338 return -1 ; 2339 } 2340 //cout << "offset for " << name << " is " << offset << " bytes." << endl ; 2341 fseek( fp_, offset, SEEK_CUR ) ; 2232 int status = movePointer( name ) ; 2233 if ( status < 0 ) 2234 return status ; 2342 2235 2343 2236 for ( unsigned int i = 0 ; i < v.size() ; i++ ) { 2344 offset = scanLen_ * arrayid_[i] + sizeof(int) * idx ;2237 int offset = scanLen_ * arrayid_[i] + sizeof(int) * idx ; 2345 2238 fseek( fp_, offset, SEEK_CUR ) ; 2346 2239 fread( &v[i], 1, sizeof(int), fp_ ) ; … … 2371 2264 // defined as float array from the FITS Scan Record 2372 2265 // 2373 int status = 0 ; 2374 2375 // skip header 2376 fseek( fp_, FITS_HEADER_SIZE, SEEK_SET ) ; 2377 2378 // find offset 2379 int offset = getOffset( name ) ; 2380 if ( offset == -1 ) { 2381 //cerr << "Error, " << name << " is not found in the name list." << endl ; 2382 return -1 ; 2383 } 2384 //cout << "offset for " << name << " is " << offset << " bytes." << endl ; 2385 fseek( fp_, offset, SEEK_CUR ) ; 2266 int status = movePointer( name ) ; 2267 if ( status < 0 ) 2268 return status ; 2386 2269 2387 2270 for ( unsigned int i = 0 ; i < v.size() ; i++ ) { 2388 offset = scanLen_ * arrayid_[i] + sizeof(float) * idx ;2271 int offset = scanLen_ * arrayid_[i] + sizeof(float) * idx ; 2389 2272 fseek( fp_, offset, SEEK_CUR ) ; 2390 2273 fread( &v[i], 1, sizeof(float), fp_ ) ; … … 2415 2298 // defined as double array from the FITS Scan Record 2416 2299 // 2417 int status = 0 ; 2418 2419 // skip header 2420 fseek( fp_, FITS_HEADER_SIZE, SEEK_SET ) ; 2421 2422 // find offset 2423 int offset = getOffset( name ) ; 2424 if ( offset == -1 ) { 2425 //cerr << "Error, " << name << " is not found in the name list." << endl ; 2426 return -1 ; 2427 } 2428 //cout << "offset for " << name << " is " << offset << " bytes." << endl ; 2429 fseek( fp_, offset, SEEK_CUR ) ; 2300 int status = movePointer( name ) ; 2301 if ( status < 0 ) 2302 return status ; 2430 2303 2431 2304 for ( unsigned int i = 0 ; i < v.size() ; i++ ) { 2432 offset = scanLen_ * arrayid_[i] + sizeof(double) * idx ;2305 int offset = scanLen_ * arrayid_[i] + sizeof(double) * idx ; 2433 2306 fseek( fp_, offset, SEEK_CUR ) ; 2434 2307 fread( &v[i], 1, sizeof(double), fp_ ) ; … … 2484 2357 } 2485 2358 2359 int NROFITSDataset::movePointer( char *name, int idx ) 2360 { 2361 // skip header 2362 fseek( fp_, FITS_HEADER_SIZE, SEEK_SET ) ; 2363 2364 // find offset 2365 int offset = getOffset( name ) ; 2366 if ( offset == -1 ) { 2367 //cerr << "Error, " << name << " is not found in the name list." << endl ; 2368 return -1 ; 2369 } 2370 2371 offset += idx * scanLen_ ; 2372 2373 //cout << "offset for " << name << " is " << offset << " bytes." << endl ; 2374 fseek( fp_, offset, SEEK_CUR ) ; 2375 2376 return 0 ; 2377 } 2378 2486 2379 // double NROFITSDataset::toLSR( double v, double t, double x, double y ) 2487 2380 // { -
trunk/external-alma/atnf/PKSIO/NROFITSDataset.h
r2434 r2440 156 156 int getOffset( char *name ) ; 157 157 158 // move pointer to target position 159 int movePointer( char *name, int idx=0 ) ; 160 158 161 // convert frequency frame 159 162 // virtual double toLSR( double v, double t, double x, double y ) ;
Note:
See TracChangeset
for help on using the changeset viewer.