Changeset 2440 for trunk/external-alma


Ignore:
Timestamp:
03/22/12 19:25:06 (13 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: sdsave unit test

Put in Release Notes: Yes

Module(s): Module Names change impacts.

Description: Describe your changes here...

Refactoring


Location:
trunk/external-alma/atnf/PKSIO
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/external-alma/atnf/PKSIO/NROFITSDataset.cc

    r2436 r2440  
    19471947  // of the FITS Scan Record
    19481948  //
    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 ;
    19631952
    19641953  // get length of char
     
    20041993  // of the FITS Scan Record
    20051994  //
    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 ;
    20191998
    20201999  // read data
     
    20432022  // of the FITS Scan Record
    20442023  //
    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 ;
    20592027
    20602028  // read data
     
    20832051  // of the FITS Scan Record
    20842052  //
    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 ;
    20992056
    21002057  // read data
     
    21112068  // Read 'name' attribute defined as char array from the FITS Scan Record
    21122069  //
    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 ;
    21272073
    21282074  // get length of char
     
    21592105  // Read 'name' attribute defined as int array from the FITS Scan Record
    21602106  //
    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 ;
    21752110
    21762111  for ( unsigned int i = 0 ; i < v.size() ; i++ ) {
     
    21892124  // Read 'name' attribute defined as float array from the FITS Scan Record
    21902125  //
    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 ;
    22052129
    22062130  for ( unsigned int i = 0 ; i < v.size() ; i++ ) {
     
    22192143  // Read 'name' attribute defined as double array from the FITS Scan Record
    22202144  //
    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 ;
    22352148
    22362149  for ( unsigned int i = 0 ; i < v.size() ; i++ ) {
     
    22612174  // defined as char array from the FITS Scan Record
    22622175  //
    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 ;
    22762179
    22772180  // get length of char
     
    22882191
    22892192  for ( unsigned int i = 0 ; i < v.size() ; i++ ) {
    2290     offset = scanLen_ * arrayid_[i] + xsize * idx ;
     2193    int offset = scanLen_ * arrayid_[i] + xsize * idx ;
    22912194    fseek( fp_, offset, SEEK_CUR ) ;
    22922195//     int clen = (int)strlen( v[i] ) ;
     
    23272230  // defined as int array from the FITS Scan Record
    23282231  //
    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 ;
    23422235
    23432236  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 ;
    23452238    fseek( fp_, offset, SEEK_CUR ) ;
    23462239    fread( &v[i], 1, sizeof(int), fp_ ) ;
     
    23712264  // defined as float array from the FITS Scan Record
    23722265  //
    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 ;
    23862269
    23872270  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 ;
    23892272    fseek( fp_, offset, SEEK_CUR ) ;
    23902273    fread( &v[i], 1, sizeof(float), fp_ ) ;
     
    24152298  // defined as double array from the FITS Scan Record
    24162299  //
    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 ;
    24302303
    24312304  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 ;
    24332306    fseek( fp_, offset, SEEK_CUR ) ;
    24342307    fread( &v[i], 1, sizeof(double), fp_ ) ;
     
    24842357}
    24852358
     2359int 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
    24862379// double NROFITSDataset::toLSR( double v, double t, double x, double y )
    24872380// {
  • trunk/external-alma/atnf/PKSIO/NROFITSDataset.h

    r2434 r2440  
    156156  int getOffset( char *name ) ;
    157157
     158  // move pointer to target position
     159  int movePointer( char *name, int idx=0 ) ;
     160
    158161  // convert frequency frame
    159162//   virtual double toLSR( double v, double t, double x, double y ) ;
Note: See TracChangeset for help on using the changeset viewer.