Ignore:
File:
1 edited

Legend:

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

    r2442 r2203  
    620620  }
    621621  // DEBUG
    622 //   nro_debug_output( "RX", ARYNM, RX ) ;
     622//   for ( int i = 0 ; i < ARYNM ; i++ ) {
     623//     if ( i == 0 ) {
     624//       cout << "RX      " ;
     625//     }
     626//     else if ( ( i % 5 ) == 0 ) {
     627//       cout << endl << "        " ;
     628//     }
     629//     cout << "\'" << RX[i] << "\' " ;
     630//   }
     631//   cout << endl ;
    623632  //
    624633  if ( readColumn( HPBW, "HPBW", sameEndian ) != 0 ) {
     
    627636  }
    628637  // DEBUG
    629 //   nro_debug_output( "HPBW", ARYNM, HPBW ) ;
     638//   for ( int i = 0 ; i < ARYNM ; i++ ) {
     639//     if ( i == 0 ) {
     640//       //cout << "HPBW    " ;
     641//     }
     642//     else if ( ( i % 5 ) == 0 ) {
     643//       //cout << endl << "        " ;
     644//     }
     645//     //cout << HPBW[i] << " " ;
     646//   }
     647//   //cout << endl ;
    630648  //
    631649  if ( readColumn( EFFA, "EFFA", sameEndian ) != 0 ) {
     
    634652  }
    635653  // DEBUG
    636 //   nro_debug_output( "EFFA", ARYNM, EFFA ) ;
     654//   for ( int i = 0 ; i < ARYNM ; i++ ) {
     655//     if ( i == 0 ) {
     656//       //cout << "EFFA    " ;
     657//     }
     658//     else if ( ( i % 5 ) == 0 ) {
     659//       //cout << endl << "        " ;
     660//     }
     661//     //cout << EFFA[i] << " " ;
     662//   }
     663//   //cout << endl ;
    637664  //
    638665  if ( readColumn( EFFB, "EFFB", sameEndian ) != 0 ) {
     
    641668  }
    642669  // DEBUG
    643 //   nro_debug_output( "EFFB", ARYNM, EFFB ) ;
     670//   for ( int i = 0 ; i < ARYNM ; i++ ) {
     671//     if ( i == 0 ) {
     672//       //cout << "EFFB    " ;
     673//     }
     674//     else if ( ( i % 5 ) == 0 ) {
     675//       //cout << endl << "        " ;
     676//     }
     677//     //cout << EFFB[i] << " " ;
     678//   }
     679//   //cout << endl ;
    644680  //
    645681  if ( readColumn( EFFL, "EFFL", sameEndian ) != 0 ) {
     
    648684  }
    649685  // DEBUG
    650 //   nro_debug_output( "EFFL", ARYNM, EFFL ) ;
     686//   for ( int i = 0 ; i < ARYNM ; i++ ) {
     687//     if ( i == 0 ) {
     688//       //cout << "EFFL    " ;
     689//     }
     690//     else if ( ( i % 5 ) == 0 ) {
     691//       //cout << endl << "        " ;
     692//     }
     693//     //cout << EFFL[i] << " " ;
     694//   }
     695//   //cout << endl ;
    651696  //
    652697  if ( readColumn( EFSS, "EFSS", sameEndian ) != 0 ) {
     
    655700  }
    656701  // DEBUG
    657 //   nro_debug_output( "EFSS", ARYNM, EFSS ) ;
     702//   for ( int i = 0 ; i < ARYNM ; i++ ) {
     703//     if ( i == 0 ) {
     704//       //cout << "EFSS    " ;
     705//     }
     706//     else if ( ( i % 5 ) == 0 ) {
     707//       //cout << endl << "        " ;
     708//     }
     709//     //cout << EFSS[i] << " " ;
     710//   }
     711//   //cout << endl ;
    658712  //
    659713  if ( readColumn( GAIN, "GAIN", sameEndian ) != 0 ) {
     
    662716  }
    663717  // DEBUG
    664 //   nro_debug_output( "GAIN", ARYNM, GAIN ) ;
     718//   for ( int i = 0 ; i < ARYNM ; i++ ) {
     719//     if ( i == 0 ) {
     720//       //cout << "GAIN    " ;
     721//     }
     722//     else if ( ( i % 5 ) == 0 ) {
     723//       //cout << endl << "        " ;
     724//     }
     725//     //cout << GAIN[i] << " " ;
     726//   }
     727//   //cout << endl ;
    665728  //
    666729  if ( readColumn( HORN, "HORN" ) != 0 ) {
     
    669732  }
    670733  // DEBUG
    671 //   nro_debug_output( "HORN", ARYNM, HORN ) ;
     734//   for ( int i = 0 ; i < ARYNM ; i++ ) {
     735//     if ( i == 0 ) {
     736//       //cout << "HORN    " ;
     737//     }
     738//     else if ( ( i % 5 ) == 0 ) {
     739//       //cout << endl << "        " ;
     740//     }
     741//     //cout << "\'" << HORN[i] << "\' " ;
     742//   }
     743//   //cout << endl ;
    672744  //
    673745  if ( readColumn( POLTP, "POLTP" ) != 0 ) {
     
    676748  }
    677749  // DEBUG
    678 //   nro_debug_output( "POLTP", ARYNM, POLTP ) ;
     750//   for ( int i = 0 ; i < ARYNM ; i++ ) {
     751//     if ( i == 0 ) {
     752//       //cout << "POLTP   " ;
     753//     }
     754//     else if ( ( i % 5 ) == 0 ) {
     755//       //cout << endl << "        " ;
     756//     }
     757//     //cout << "\'" << POLTP[i] << "\' " ;
     758//   }
     759//   //cout << endl ;
    679760  //
    680761  vector<int> ipoldr( ARYNM, 0 ) ;
     
    686767    POLDR[i] = (double)ipoldr[i] ;
    687768  // DEBUG
    688 //   nro_debug_output( "POLDR", ARYNM, POLDR ) ;
     769//   for ( int i = 0 ; i < ARYNM ; i++ ) {
     770//     if ( i == 0 ) {
     771//       //cout << "POLDR   " ;
     772//     }
     773//     else if ( ( i % 5 ) == 0 ) {
     774//       //cout << endl << "        " ;
     775//     }
     776//     //cout << POLDR[i] << " " ;
     777//   }
     778//   //cout << endl ;
    689779  //
    690780  if ( readColumn( POLAN, "POLAN", sameEndian ) != 0 ) {
     
    693783  }
    694784  // DEBUG
    695 //   nro_debug_output( "POLAN", ARYNM, POLAN ) ;
     785//   for ( int i = 0 ; i < ARYNM ; i++ ) {
     786//     if ( i == 0 ) {
     787//       //cout << "POLAN   " ;
     788//     }
     789//     else if ( ( i % 5 ) == 0 ) {
     790//       //cout << endl << "        " ;
     791//     }
     792//     //cout << POLAN[i] << " " ;
     793//   }
     794//   //cout << endl ;
    696795  //
    697796  if ( readColumn( DFRQ, "DFRQ", sameEndian ) != 0 ) {
     
    700799  }
    701800  // DEBUG
    702 //   nro_debug_output( "DFRQ", ARYNM, DFRQ ) ;
     801//   for ( int i = 0 ; i < ARYNM ; i++ ) {
     802//     if ( i == 0 ) {
     803//       //cout << "DFRQ    " ;
     804//     }
     805//     else if ( ( i % 5 ) == 0 ) {
     806//       //cout << endl << "        " ;
     807//     }
     808//     //cout << DFRQ[i] << " " ;
     809//   }
     810//   //cout << endl ;
    703811  //
    704812  if ( readColumn( SIDBD, "SIDBD" ) != 0 ) {
     
    707815  }
    708816  // DEBUG
    709 //   nro_debug_output( "SIDBD", ARYNM, SIDBD ) ;
     817//   for ( int i = 0 ; i < ARYNM ; i++ ) {
     818//     if ( i == 0 ) {
     819//       //cout << "SIDBD   " ;
     820//     }
     821//     else if ( ( i % 5 ) == 0 ) {
     822//       //cout << endl << "        " ;
     823//     }
     824//     //cout << "\'" << SIDBD[i] << "\' " ;
     825//   }
     826//   //cout << endl ;
    710827  //
    711828  if ( readColumn( REFN, "REFN", sameEndian ) != 0 ) {
     
    714831  }
    715832  // DEBUG
    716 //   nro_debug_output( "REFN", ARYNM, REFN ) ;
     833//   for ( int i = 0 ; i < ARYNM ; i++ ) {
     834//     if ( i == 0 ) {
     835//       //cout << "REFN    " ;
     836//     }
     837//     else if ( ( i % 5 ) == 0 ) {
     838//       //cout << endl << "        " ;
     839//     }
     840//     //cout << REFN[i] << " " ;
     841//   }
     842//   //cout << endl ;
    717843  //
    718844  if ( readColumn( IPINT, "IPINT", sameEndian ) != 0 ) {
     
    721847  }
    722848  // DEBUG
    723 //   nro_debug_output( "IPINT", ARYNM, IPINT ) ;
     849//   for ( int i = 0 ; i < ARYNM ; i++ ) {
     850//     if ( i == 0 ) {
     851//       //cout << "IPINT   " ;
     852//     }
     853//     else if ( ( i % 5 ) == 0 ) {
     854//       //cout << endl << "        " ;
     855//     }
     856//     //cout << IPINT[i] << " " ;
     857//   }
     858//   //cout << endl ;
    724859  //
    725860  if ( readColumn( MULTN, "MULTN", sameEndian ) != 0 ) {
     
    728863  }
    729864  // DEBUG
    730 //   nro_debug_output( "MULTN", ARYNM, MULTN ) ;
     865//   for ( int i = 0 ; i < ARYNM ; i++ ) {
     866//     if ( i == 0 ) {
     867//       //cout << "MULTN   " ;
     868//     }
     869//     else if ( ( i % 5 ) == 0 ) {
     870//       //cout << endl << "        " ;
     871//     }
     872//     //cout << MULTN[i] << " " ;
     873//   }
     874//   //cout << endl ;
    731875  //
    732876  if ( readColumn( MLTSCF, "MLTSCF", sameEndian ) != 0 ) {
     
    735879  }
    736880  // DEBUG
    737 //   nro_debug_output( "MLTSCF", ARYNM, MLTSCF ) ;
     881//   for ( int i = 0 ; i < ARYNM ; i++ ) {
     882//     if ( i == 0 ) {
     883//       //cout << "MLTSCF  " ;
     884//     }
     885//     else if ( ( i % 5 ) == 0 ) {
     886//       //cout << endl << "        " ;
     887//     }
     888//     //cout << MLTSCF[i] << " " ;
     889//   }
     890//   //cout << endl ;
    738891  //
    739892  if ( readColumn( LAGWIND, "LAGWIN" ) != 0 ) {
     
    742895  }
    743896  // DEBUG
    744 //   nro_debug_output( "LAGWIND", ARYNM, LAGWIND ) ;
     897//   for ( int i = 0 ; i < ARYNM ; i++ ) {
     898//     if ( i == 0 ) {
     899//       //cout << "LAGWIND " ;
     900//     }
     901//     else if ( ( i % 5 ) == 0 ) {
     902//       //cout << endl << "        " ;
     903//     }
     904//     //cout << "\'" << LAGWIND[i] << "\' " ;
     905//   }
     906//   //cout << endl ;
    745907  //
    746908  if ( readColumn( BEBW, "BEBW", sameEndian ) != 0 ) {
     
    749911  }
    750912  // DEBUG
    751 //   nro_debug_output( "BEBW", ARYNM, BEBW ) ;
     913//   for ( int i = 0 ; i < ARYNM ; i++ ) {
     914//     if ( i == 0 ) {
     915//       //cout << "BEBW    " ;
     916//     }
     917//     else if ( ( i % 5 ) == 0 ) {
     918//       //cout << endl << "        " ;
     919//     }
     920//     //cout << BEBW[i] << " " ;
     921//   } 
     922//   //cout << endl ;
    752923  //
    753924  if ( readColumn( BERES, "BERES", sameEndian ) != 0 ) {
     
    756927  }
    757928  // DEBUG
    758 //   nro_debug_output( "BERES", ARYNM, BERES ) ;
     929//   for ( int i = 0 ; i < ARYNM ; i++ ) {
     930//     if ( i == 0 ) {
     931//       //cout << "BERES   " ;
     932//     }
     933//     else if ( ( i % 5 ) == 0 ) {
     934//       //cout << endl << "        " ;
     935//     }
     936//     //cout << BERES[i] << " " ;
     937//   }
     938//   //cout << endl ;
    759939  //
    760940  if ( readColumn( CHWID, "CHWID", sameEndian ) != 0 ) {
     
    762942    return -1 ;
    763943  }
    764   // DEBUG
    765 //   nro_debug_output( "CHWID", ARYNM, CHWID ) ;
     944    // DEBUG
     945//   for ( int i = 0 ; i < ARYNM ; i++ ) {
     946//     if ( i == 0 ) {
     947//       //cout << "CHWID   " ;
     948//     }
     949//     else if ( ( i % 5 ) == 0 ) {
     950//       //cout << endl << "        " ;
     951//     }
     952//     //cout << CHWID[i] << " " ;
     953//   }
     954//   //cout << endl ;
    766955  //
    767956  if ( readARRY() != 0 ) {
     
    770959  }
    771960  // DEBUG
    772 //   nro_debug_output( "ARRY", NRO_FITS_ARYMAX, ARRY ) ;
     961//   for ( int i = 0 ; i < NRO_FITS_ARYMAX ; i++ ) {
     962//     if ( i == 0 ) {
     963//       //cout << "ARRY    " ;
     964//     }
     965//     else if ( ( i % 20 ) == 0 ) {
     966//       //cout << endl << "        " ;
     967//     }
     968//     //cout << ARRY[i] << " " ;
     969//   }
     970//   //cout << endl ;
    773971  //
    774972  if ( readColumn( NFCAL, "NFCAL", sameEndian ) != 0 ) {
     
    776974    return -1 ;
    777975  }
    778   // DEBUG
    779 //   nro_debug_output( "NFCAL", ARYNM, NFCAL ) ;
     976    // DEBUG
     977//   for ( int i = 0 ; i < ARYNM ; i++ ) {
     978//     if ( i == 0 ) {
     979//       //cout << "NFCAL   " ;
     980//     }
     981//     else if ( ( i % 5 ) == 0 ) {
     982//       //cout << endl << "        " ;
     983//     }
     984//     //cout << NFCAL[i] << " " ;
     985//   }
     986//   //cout << endl ;
    780987  //
    781988  if ( readColumn( F0CAL, "F0CAL", sameEndian ) != 0 ) {
     
    783990    return -1 ;
    784991  }
    785   // DEBUG
    786 //   nro_debug_output( "F0CAL", ARYNM, F0CAL ) ;
     992    // DEBUG
     993//   for ( int i = 0 ; i < ARYNM ; i++ ) {
     994//     if ( i == 0 ) {
     995//       //cout << "F0CAL   " ;
     996//     }
     997//     else if ( ( i % 5 ) == 0 ) {
     998//       //cout << endl << "        " ;
     999//     }
     1000//     //cout << F0CAL[i] << " " ;
     1001//   }
     1002//   //cout << endl ;
    7871003  //
    7881004  for ( int i= 0 ; i < 10 ; i++) {
     
    7971013  }
    7981014  // DEBUG
    799 //   nro_debug_output( "FQCAL", ARYNM, 10, FQCAL ) ;
     1015//   for ( int i = 0 ; i < ARYNM ; i++ ) {
     1016//     for ( int j = 0 ; j < 10 ; j++ ) {
     1017//       if ( j == 0 ) {
     1018//         if ( i < 10 )
     1019//           //cout << "FQCAL0" << i << " " ;
     1020//         else
     1021//           //cout << "FQCAL" << i << " " ;
     1022//       }
     1023//       else if ( ( j % 5 ) == 0 ) {
     1024//         //cout << endl << "        " ;
     1025//       }
     1026//       //cout << FQCAL[i][j] << " " ;
     1027//     }
     1028//     //cout << endl ;
     1029//   }
    8001030  //
    8011031  for ( int i= 0 ; i < 10 ; i++) {
     
    8101040  }
    8111041  // DEBUG
    812 //   nro_debug_output( "CHCAL", ARYNM, 10, CHCAL ) ;
     1042//   for ( int i = 0 ; i < ARYNM ; i++ ) {
     1043//     for ( int j = 0 ; j < 10 ; j++ ) {
     1044//       if ( j == 0 ) {
     1045//         if ( i < 10 )
     1046//           //cout << "CHCAL0" << i << " " ;
     1047//         else
     1048//           //cout << "CHCAL" << i << " " ;
     1049//       }
     1050//       else if ( ( j % 5 ) == 0 ) {
     1051//         //cout << endl << "        " ;
     1052//       }
     1053//      //cout << CHCAL[i][j] << " " ;
     1054//    }
     1055//    //cout << endl ;
     1056//   }
    8131057  //
    8141058  for ( int i= 0 ; i < 10 ; i++) {
     
    8231067  }
    8241068  // DEBUG
    825 //   nro_debug_output( "CWCAL", ARYNM, 10, CWCAL ) ;
     1069//   for ( int i = 0 ; i < ARYNM ; i++ ) {
     1070//     for ( int j = 0 ; j < 10 ; j++ ) {
     1071//       if ( j == 0 ) {
     1072//         if ( i < 10 )
     1073//           //cout << "CWCAL0" << i << " " ;
     1074//         else
     1075//           //cout << "CWCAL" << i << " " ;
     1076//       }
     1077//       else if ( ( j % 5 ) == 0 ) {
     1078//         //cout << endl << "        " ;
     1079//       }
     1080//       //cout << CWCAL[i][j] << " " ;
     1081//     }
     1082//     //cout << endl ;
     1083//   }
    8261084  //
    8271085  if ( readHeader( SCNLEN, "NAXIS1", sameEndian ) != 0 ) {
     
    8591117  }
    8601118  // DEBUG
    861 //   nro_debug_output( "DSBFC", ARYNM, DSBFC ) ;
     1119//   for ( int i = 0 ; i < ARYNM ; i++ ) {
     1120//     if ( i == 0 ) {
     1121//       //cout << "DSBFC   " ;
     1122//     }
     1123//     else if ( ( i % 5 ) == 0 ) {
     1124//       //cout << endl << "        " ;
     1125//     }
     1126//     //cout << DSBFC[i] << " " ;
     1127//   }
     1128//   //cout << endl ;
    8621129  //
    8631130
     
    19302197}
    19312198
     2199int NROFITSDataset::readTable( char *v, char *name )
     2200{
     2201  //
     2202  // Read 'name' attribute defined as char from the 0-th row
     2203  // of the FITS Scan Record
     2204  //
     2205  int status = readTable( v, name, (int)strlen( v ), 0 ) ;
     2206
     2207  return status ;
     2208}
     2209
    19322210int NROFITSDataset::readTable( char *v, char *name, int clen, int idx )
    19332211{
     
    19362214  // of the FITS Scan Record
    19372215  //
    1938   int status = movePointer( name, idx ) ;
    1939   if ( status < 0 )
    1940     return status ;
     2216  int status = 0 ;
     2217
     2218  // skip header
     2219  fseek( fp_, FITS_HEADER_SIZE, SEEK_SET ) ;
     2220
     2221  // find offset
     2222  int offset = getOffset( name ) ;
     2223  if ( offset == -1 ) {
     2224    //cerr << "Error, " << name << " is not found in the name list." << endl ;
     2225    return -1 ;
     2226  }
     2227  offset += idx * scanLen_ ;
     2228  //cout << "offset for " << name << " is " << offset << " bytes." << endl ;
     2229  fseek( fp_, offset, SEEK_CUR ) ;
    19412230
    19422231  // get length of char
     
    19652254}
    19662255
     2256int NROFITSDataset::readTable( int &v, char *name, int b )
     2257{
     2258  //
     2259  // Read 'name' attribute defined as int from the 0-th row
     2260  // of the FITS Scan Record
     2261  //
     2262  int status = readTable( v, name, b, 0 ) ;
     2263
     2264  return status ;
     2265}
     2266
    19672267int NROFITSDataset::readTable( int &v, char *name, int b, int idx )
    19682268{
     
    19712271  // of the FITS Scan Record
    19722272  //
    1973   int status = movePointer( name, idx ) ;
    1974   if ( status < 0 )
    1975     return status ;
     2273  int status = 0 ;
     2274  // skip header
     2275  fseek( fp_, FITS_HEADER_SIZE, SEEK_SET ) ;
     2276
     2277  // find offset
     2278  int offset = getOffset( name ) ;
     2279  if ( offset == -1 ) {
     2280    //cerr << "Error, " << name << " is not found in the name list." << endl ;
     2281    return -1 ;
     2282  }
     2283  offset += idx * scanLen_ ;
     2284  //cout << "offset for " << name << " is " << offset << " bytes." << endl ;
     2285  fseek( fp_, offset, SEEK_CUR ) ;
    19762286
    19772287  // read data
     
    19832293}
    19842294
     2295int NROFITSDataset::readTable( float &v, char *name, int b )
     2296{
     2297  //
     2298  // Read 'name' attribute defined as float from the 0-th row
     2299  // of the FITS Scan Record
     2300  //
     2301  int status = readTable( v, name, b, 0 ) ;
     2302
     2303  return status ;
     2304}
     2305
    19852306int NROFITSDataset::readTable( float &v, char *name, int b, int idx )
    19862307{
     
    19892310  // of the FITS Scan Record
    19902311  //
    1991   int status = movePointer( name, idx ) ;
    1992   if ( status < 0 )
    1993     return status ;
     2312  int status = 0 ;
     2313
     2314  // skip header
     2315  fseek( fp_, FITS_HEADER_SIZE, SEEK_SET ) ;
     2316
     2317  // find offset
     2318  int offset = getOffset( name ) ;
     2319  if ( offset == -1 ) {
     2320    //cerr << "Error, " << name << " is not found in the name list." << endl ;
     2321    return -1 ;
     2322  }
     2323  offset += idx * scanLen_ ;
     2324  //cout << "offset for " << name << " is " << offset << " bytes." << endl ;
     2325  fseek( fp_, offset, SEEK_CUR ) ;
    19942326
    19952327  // read data
     
    20012333}
    20022334
     2335int NROFITSDataset::readTable( double &v, char *name, int b )
     2336{
     2337  //
     2338  // Read 'name' attribute defined as double from the 0-th row
     2339  // of the FITS Scan Record
     2340  //
     2341  int status = readTable( v, name, b, 0 ) ;
     2342
     2343  return status ;
     2344}
     2345
    20032346int NROFITSDataset::readTable( double &v, char *name, int b, int idx )
    20042347{
     
    20072350  // of the FITS Scan Record
    20082351  //
    2009   int status = movePointer( name, idx ) ;
    2010   if ( status < 0 )
    2011     return status ;
     2352  int status = 0 ;
     2353
     2354  // skip header
     2355  fseek( fp_, FITS_HEADER_SIZE, SEEK_SET ) ;
     2356
     2357  // find offset
     2358  int offset = getOffset( name ) ;
     2359  if ( offset == -1 ) {
     2360    //cerr << "Error, " << name << " is not found in the name list." << endl ;
     2361    return -1 ;
     2362  }
     2363  offset += idx * scanLen_ ;
     2364  //cout << "offset for " << name << " is " << offset << " bytes." << endl ;
     2365  fseek( fp_, offset, SEEK_CUR ) ;
    20122366
    20132367  // read data
     
    20242378  // Read 'name' attribute defined as char array from the FITS Scan Record
    20252379  //
    2026   int status = movePointer( name, idx ) ;
    2027   if ( status < 0 )
    2028     return status ;
     2380  int status = 0 ;
     2381 
     2382  // skip header
     2383  fseek( fp_, FITS_HEADER_SIZE, SEEK_SET ) ;
     2384
     2385  // find offset
     2386  int offset = getOffset( name ) ;
     2387  if ( offset == -1 ) {
     2388    //cerr << "Error, " << name << " is not found in the name list." << endl ;
     2389    return -1 ;
     2390  }
     2391  offset += idx * scanLen_ ;
     2392  //cout << "offset for " << name << " is " << offset << " bytes." << endl ;
     2393  fseek( fp_, offset, SEEK_CUR ) ;
    20292394
    20302395  // get length of char
     
    20612426  // Read 'name' attribute defined as int array from the FITS Scan Record
    20622427  //
    2063   int status = movePointer( name, idx ) ;
    2064   if ( status < 0 )
    2065     return status ;
     2428  int status = 0 ;
     2429 
     2430  // skip header
     2431  fseek( fp_, FITS_HEADER_SIZE, SEEK_SET ) ;
     2432
     2433  // find offset
     2434  int offset = getOffset( name ) ;
     2435  if ( offset == -1 ) {
     2436    //cerr << "Error, " << name << " is not found in the name list." << endl ;
     2437    return -1 ;
     2438  }
     2439  offset += idx * scanLen_ ;
     2440  //cout << "offset for " << name << " is " << offset << " bytes." << endl ;
     2441  fseek( fp_, offset, SEEK_CUR ) ;
    20662442
    20672443  for ( unsigned int i = 0 ; i < v.size() ; i++ ) {
     
    20802456  // Read 'name' attribute defined as float array from the FITS Scan Record
    20812457  //
    2082   int status = movePointer( name, idx ) ;
    2083   if ( status < 0 )
    2084     return status ;
     2458  int status = 0 ;
     2459 
     2460  // skip header
     2461  fseek( fp_, FITS_HEADER_SIZE, SEEK_SET ) ;
     2462
     2463  // find offset
     2464  int offset = getOffset( name ) ;
     2465  if ( offset == -1 ) {
     2466    //cerr << "Error, " << name << " is not found in the name list." << endl ;
     2467    return -1 ;
     2468  }
     2469  offset += idx * scanLen_ ;
     2470  //cout << "offset for " << name << " is " << offset << " bytes." << endl ;
     2471  fseek( fp_, offset, SEEK_CUR ) ;
    20852472
    20862473  for ( unsigned int i = 0 ; i < v.size() ; i++ ) {
     
    20992486  // Read 'name' attribute defined as double array from the FITS Scan Record
    21002487  //
    2101   int status = movePointer( name, idx ) ;
    2102   if ( status < 0 )
    2103     return status ;
     2488  int status = 0 ;
     2489 
     2490  // skip header
     2491  fseek( fp_, FITS_HEADER_SIZE, SEEK_SET ) ;
     2492
     2493  // find offset
     2494  int offset = getOffset( name ) ;
     2495  if ( offset == -1 ) {
     2496    //cerr << "Error, " << name << " is not found in the name list." << endl ;
     2497    return -1 ;
     2498  }
     2499  offset += idx * scanLen_ ;
     2500  //cout << "offset for " << name << " is " << offset << " bytes." << endl ;
     2501  fseek( fp_, offset, SEEK_CUR ) ;
    21042502
    21052503  for ( unsigned int i = 0 ; i < v.size() ; i++ ) {
     
    21132511}
    21142512
     2513int NROFITSDataset::readColumn( vector<string> &v, char *name )
     2514{
     2515  //
     2516  // Read 0-th column of ARRYTP-dependent 'name' attributes
     2517  // defined as char array from the FITS Scan Record
     2518  //
     2519  int status = readColumn( v, name, 0 ) ;
     2520
     2521  return status ;
     2522}
     2523
    21152524int NROFITSDataset::readColumn( vector<string> &v, char *name, int idx )
    21162525{
     
    21192528  // defined as char array from the FITS Scan Record
    21202529  //
    2121   int status = movePointer( name ) ;
    2122   if ( status < 0 )
    2123     return status ;
     2530  int status = 0 ;
     2531
     2532  // skip header
     2533  fseek( fp_, FITS_HEADER_SIZE, SEEK_SET ) ;
     2534
     2535  // find offset
     2536  int offset = getOffset( name ) ;
     2537  if ( offset == -1 ) {
     2538    //cerr << "Error, " << name << " is not found in the name list." << endl ;
     2539    return -1 ;
     2540  }
     2541  //cout << "offset for " << name << " is " << offset << " bytes." << endl ;
     2542  fseek( fp_, offset, SEEK_CUR ) ;
    21242543
    21252544  // get length of char
     
    21362555
    21372556  for ( unsigned int i = 0 ; i < v.size() ; i++ ) {
    2138     int offset = scanLen_ * arrayid_[i] + xsize * idx ;
     2557    offset = scanLen_ * arrayid_[i] + xsize * idx ;
    21392558    fseek( fp_, offset, SEEK_CUR ) ;
    21402559//     int clen = (int)strlen( v[i] ) ;
     
    21582577}
    21592578
     2579int NROFITSDataset::readColumn( vector<int> &v, char *name, int b )
     2580{
     2581  //
     2582  // Read 0-th column of ARRYTP-dependent 'name' attributes
     2583  // defined as int array from the FITS Scan Record
     2584  //
     2585  int status = readColumn( v, name, b, 0 ) ;
     2586
     2587  return status ;
     2588}
     2589
    21602590int NROFITSDataset::readColumn( vector<int> &v, char *name, int b, int idx )
    21612591{
     
    21642594  // defined as int array from the FITS Scan Record
    21652595  //
    2166   int status = movePointer( name ) ;
    2167   if ( status < 0 )
    2168     return status ;
     2596  int status = 0 ;
     2597
     2598  // skip header
     2599  fseek( fp_, FITS_HEADER_SIZE, SEEK_SET ) ;
     2600
     2601  // find offset
     2602  int offset = getOffset( name ) ;
     2603  if ( offset == -1 ) {
     2604    //cerr << "Error, " << name << " is not found in the name list." << endl ;
     2605    return -1 ;
     2606  }
     2607  //cout << "offset for " << name << " is " << offset << " bytes." << endl ;
     2608  fseek( fp_, offset, SEEK_CUR ) ;
    21692609
    21702610  for ( unsigned int i = 0 ; i < v.size() ; i++ ) {
    2171     int offset = scanLen_ * arrayid_[i] + sizeof(int) * idx ;
     2611    offset = scanLen_ * arrayid_[i] + sizeof(int) * idx ;
    21722612    fseek( fp_, offset, SEEK_CUR ) ;
    21732613    fread( &v[i], 1, sizeof(int), fp_ ) ;
     
    21812621}
    21822622
     2623int NROFITSDataset::readColumn( vector<float> &v, char *name, int b )
     2624{
     2625  //
     2626  // Read 0-th column of ARRYTP-dependent 'name' attributes
     2627  // defined as float array from the FITS Scan Record
     2628  //
     2629  int status = readColumn( v, name, b, 0 ) ;
     2630
     2631  return status ;
     2632}
     2633
    21832634int NROFITSDataset::readColumn( vector<float> &v, char *name, int b, int idx )
    21842635{
     
    21872638  // defined as float array from the FITS Scan Record
    21882639  //
    2189   int status = movePointer( name ) ;
    2190   if ( status < 0 )
    2191     return status ;
     2640  int status = 0 ;
     2641
     2642  // skip header
     2643  fseek( fp_, FITS_HEADER_SIZE, SEEK_SET ) ;
     2644
     2645  // find offset
     2646  int offset = getOffset( name ) ;
     2647  if ( offset == -1 ) {
     2648    //cerr << "Error, " << name << " is not found in the name list." << endl ;
     2649    return -1 ;
     2650  }
     2651  //cout << "offset for " << name << " is " << offset << " bytes." << endl ;
     2652  fseek( fp_, offset, SEEK_CUR ) ;
    21922653
    21932654  for ( unsigned int i = 0 ; i < v.size() ; i++ ) {
    2194     int offset = scanLen_ * arrayid_[i] + sizeof(float) * idx ;
     2655    offset = scanLen_ * arrayid_[i] + sizeof(float) * idx ;
    21952656    fseek( fp_, offset, SEEK_CUR ) ;
    21962657    fread( &v[i], 1, sizeof(float), fp_ ) ;
     
    22042665}
    22052666
     2667int NROFITSDataset::readColumn( vector<double> &v, char *name, int b )
     2668{
     2669  //
     2670  // Read 0-th column of ARRYTP-dependent 'name' attributes
     2671  // defined as double array from the FITS Scan Record
     2672  //
     2673  int status = readColumn( v, name, b, 0 ) ;
     2674
     2675  return status ;
     2676}
     2677
    22062678int NROFITSDataset::readColumn( vector<double> &v, char *name, int b, int idx )
    22072679{
     
    22102682  // defined as double array from the FITS Scan Record
    22112683  //
    2212   int status = movePointer( name ) ;
    2213   if ( status < 0 )
    2214     return status ;
     2684  int status = 0 ;
     2685
     2686  // skip header
     2687  fseek( fp_, FITS_HEADER_SIZE, SEEK_SET ) ;
     2688
     2689  // find offset
     2690  int offset = getOffset( name ) ;
     2691  if ( offset == -1 ) {
     2692    //cerr << "Error, " << name << " is not found in the name list." << endl ;
     2693    return -1 ;
     2694  }
     2695  //cout << "offset for " << name << " is " << offset << " bytes." << endl ;
     2696  fseek( fp_, offset, SEEK_CUR ) ;
    22152697
    22162698  for ( unsigned int i = 0 ; i < v.size() ; i++ ) {
    2217     int offset = scanLen_ * arrayid_[i] + sizeof(double) * idx ;
     2699    offset = scanLen_ * arrayid_[i] + sizeof(double) * idx ;
    22182700    fseek( fp_, offset, SEEK_CUR ) ;
    22192701    fread( &v[i], 1, sizeof(double), fp_ ) ;
     
    22602742}
    22612743
    2262 uInt NROFITSDataset::getPolNo( int irow )
    2263 {
    2264   char rx[9] ;
    2265   readTable( rx, "RX", 8, irow ) ;
    2266   rx[8] = '\0' ;
    2267   //cout << rx << endl ;
    2268   return polNoFromRX( rx ) ;
    2269 }
    2270 
    2271 int NROFITSDataset::movePointer( char *name, int idx )
    2272 {
    2273   // find offset
    2274   int offset = getOffset( name ) ;
    2275   if ( offset == -1 ) {
    2276     //cerr << "Error, " << name << " is not found in the name list." << endl ;
    2277     return -1 ;
    2278   }
    2279 
    2280   offset += idx * scanLen_ ;
    2281 
    2282   //cout << "offset for " << name << " is " << offset << " bytes." << endl ;
    2283   fseek( fp_, FITS_HEADER_SIZE+offset, SEEK_SET ) ;
    2284 
    2285   return 0 ;
    2286 }
    2287 
    22882744// double NROFITSDataset::toLSR( double v, double t, double x, double y )
    22892745// {
Note: See TracChangeset for help on using the changeset viewer.