Changeset 1810 for branches/newfiller


Ignore:
Timestamp:
08/02/10 11:49:42 (14 years ago)
Author:
Malte Marquarding
Message:

fix nchan handling. pksrec.nchan not implemented in MB reader

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/newfiller/src/STFiller.cpp

    r1757 r1810  
    8282  close();
    8383}
    84  
     84
    8585void STFiller::open( const std::string& filename, const std::string& antenna, int whichIF, int whichBeam, casa::Bool getPt )
    8686{
     
    230230  //For MS, add the location of POINTING of the input MS so one get
    231231  //pointing data from there, if necessary.
    232   //Also find nrow in MS 
     232  //Also find nrow in MS
    233233  nInDataRow = 0;
    234234  if (format == "MS2") {
    235     Path datapath(inName); 
     235    Path datapath(inName);
    236236    String ptTabPath = datapath.absoluteName();
    237237    Table inMS(ptTabPath);
     
    246246  }
    247247  String freqFrame = header_->freqref;
    248   //translate frequency reference frame back to 
    249   //MS style (as PKSMS2reader converts the original frame 
     248  //translate frequency reference frame back to
     249  //MS style (as PKSMS2reader converts the original frame
    250250  //in FITS standard style)
    251251  if (freqFrame == "TOPOCENT") {
     
    282282  int status = 0;
    283283
    284   // 
     284  //
    285285  // for NRO data
    286286  //
     
    326326    }
    327327    fclose( fp ) ;
    328   } 
     328  }
    329329  while ( status == 0 ) {
    330330    status = reader_->read(pksrec);
     
    389389    RecordFieldPtr<uInt> ifCol(rec, "IFNO");
    390390    *ifCol = pksrec.IFno-ifOffset_- 1;
    391     uInt id;
    392     /// @todo this has to change when nchan isn't global anymore
    393     //id = table_->frequencies().addEntry(Double(header_->nchan/2),
    394     //                                    pksrec.refFreq, pksrec.freqInc);
    395     if ( pksrec.nchan == 1 ) {
    396       id = table_->frequencies().addEntry(Double(0),
    397                                           pksrec.refFreq, pksrec.freqInc);
    398     }
    399     else {
    400       id = table_->frequencies().addEntry(Double(pksrec.nchan/2),
    401                                           pksrec.refFreq, pksrec.freqInc);
    402     }
     391    uInt id = table_->frequencies().addEntry(Double(pksrec.spectra.nrow()/2),
     392                                             pksrec.refFreq, pksrec.freqInc);
    403393    RecordFieldPtr<uInt> mfreqidCol(rec, "FREQ_ID");
    404394    *mfreqidCol = id;
     
    419409
    420410    RecordFieldPtr<uInt> mfocusidCol(rec, "FOCUS_ID");
    421     id = table_->focus().addEntry(pksrec.parAngle, pksrec.focusAxi, 
     411    id = table_->focus().addEntry(pksrec.parAngle, pksrec.focusAxi,
    422412                                  pksrec.focusTan, pksrec.focusRot);
    423413    *mfocusidCol = id;
     
    503493  tm *ttm = localtime( &t0 ) ;
    504494  LogIO os( LogOrigin( "STFiller", "openNRO()", WHERE ) ) ;
    505 //   cout << "STFiller::openNRO()  Start time = " << t0 
    506 //        << " (" 
    507 //        << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday 
    508 //        << " " 
    509 //        << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec 
     495//   cout << "STFiller::openNRO()  Start time = " << t0
     496//        << " ("
     497//        << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
     498//        << " "
     499//        << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
    510500//        << ")" << endl ;
    511   os << "Start time = " << t0 
    512      << " (" 
    513      << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday 
    514      << " " 
    515      << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec 
     501  os << "Start time = " << t0
     502     << " ("
     503     << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
     504     << " "
     505     << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
    516506     << ")" << LogIO::POST ;
    517507
     
    551541  if ( whichIF >= 0 ) {
    552542    if ( whichIF >= 0 && whichIF < nIF_ ) {
    553       for ( int i = 0 ; i < nIF_ ; i++ ) 
     543      for ( int i = 0 ; i < nIF_ ; i++ )
    554544        ifs[i] = False ;
    555545      ifs[whichIF] = True ;
     
    570560  if (whichBeam>=0) {
    571561    if (whichBeam>=0 && whichBeam<nBeam_) {
    572       for ( int i = 0 ; i < nBeam_ ; i++ ) 
     562      for ( int i = 0 ; i < nBeam_ ; i++ )
    573563        beams[i] = False ;
    574564      beams[whichBeam] = True;
     
    595585  time( &t1 ) ;
    596586  ttm = localtime( &t1 ) ;
    597 //   cout << "STFiller::openNRO()  End time = " << t1 
    598 //        << " (" 
    599 //        << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday 
    600 //        << " " 
    601 //        << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec 
     587//   cout << "STFiller::openNRO()  End time = " << t1
     588//        << " ("
     589//        << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
     590//        << " "
     591//        << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
    602592//        << ")" << endl ;
    603593//   cout << "STFiller::openNRO()  Elapsed time = " << t1 - t0 << " sec" << endl ;
    604   os << "End time = " << t1 
    605      << " (" 
    606      << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday 
    607      << " " 
    608      << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec 
     594  os << "End time = " << t1
     595     << " ("
     596     << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
     597     << " "
     598     << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
    609599     << ")" << endl ;
    610600  os << "Elapsed time = " << t1 - t0 << " sec" << endl ;
     
    622612  tm *ttm = localtime( &t0 ) ;
    623613  LogIO os( LogOrigin( "STFiller", "readNRO()", WHERE ) ) ;
    624 //   cout << "STFiller::readNRO()  Start time = " << t0 
    625 //        << " (" 
    626 //        << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday 
    627 //        << " " 
    628 //        << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec 
     614//   cout << "STFiller::readNRO()  Start time = " << t0
     615//        << " ("
     616//        << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
     617//        << " "
     618//        << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
    629619//        << ")" << endl ;
    630   os << "Start time = " << t0 
    631      << " (" 
    632      << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday 
    633      << " " 
    634      << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec 
     620  os << "Start time = " << t0
     621     << " ("
     622     << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
     623     << " "
     624     << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
    635625     << ")" << LogIO::POST ;
    636626  //
     
    692682      srcType = 3 ;
    693683    }
    694  
     684
    695685    // if srcType is 2 (ZERO scan), ignore scan
    696     if ( srcType != 2 && srcType != -1 && srcType != 3 ) { 
     686    if ( srcType != 2 && srcType != -1 && srcType != 3 ) {
    697687      TableRow row( table_->table() ) ;
    698688      TableRecord& rec = row.record();
     
    789779      *srcnCol = srcname ;
    790780      RecordFieldPtr<Int> srctCol(rec, "SRCTYPE") ;
    791       *srctCol = srcType ;     
    792       RecordFieldPtr<String> fieldnCol(rec, "FIELDNAME"); 
     781      *srctCol = srcType ;
     782      RecordFieldPtr<String> fieldnCol(rec, "FIELDNAME");
    793783      *fieldnCol = fieldname ;
    794784      RecordFieldPtr< Array<Float> > specCol(rec, "SPECTRA") ;
     
    820810                                       windvel,
    821811                                       winddir ) ;
    822       *mweatheridCol = id ;         
     812      *mweatheridCol = id ;
    823813      RecordFieldPtr<Double> svelCol(rec, "SRCVELOCITY") ;
    824814      *svelCol = srcvel ;
     
    847837  ttm = localtime( &t1 ) ;
    848838//   cout << "STFiller::readNRO()  Processed " << i << " rows" << endl ;
    849 //   cout << "STFiller::readNRO()  Added " << i - count << " rows (ignored " 
     839//   cout << "STFiller::readNRO()  Added " << i - count << " rows (ignored "
    850840//        << count << " \"ZERO\" scans)" << endl ;
    851 //   cout << "STFiller::readNRO()  End time = " << t1 
    852 //        << " (" 
    853 //        << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday 
    854 //        << " " 
    855 //        << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec 
     841//   cout << "STFiller::readNRO()  End time = " << t1
     842//        << " ("
     843//        << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
     844//        << " "
     845//        << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
    856846//        << ")" << endl ;
    857847//   cout << "STFiller::readNRO()  Elapsed time = " << t1 - t0 << " sec" << endl ;
    858848  os << "Processed " << i << " rows" << endl ;
    859   os << "Added " << i - count << " rows (ignored " 
     849  os << "Added " << i - count << " rows (ignored "
    860850     << count << " \"ZERO\" scans)" << endl ;
    861851  os.post() ;
    862   os << "End time = " << t1 
    863      << " (" 
    864      << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday 
    865      << " " 
    866      << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec 
     852  os << "End time = " << t1
     853     << " ("
     854     << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
     855     << " "
     856     << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
    867857     << ")" << endl ;
    868858  os << "Elapsed time = " << t1 - t0 << " sec" << endl ;
     
    871861
    872862  return 0 ;
    873 } 
     863}
    874864
    875865Bool STFiller::fileCheck()
     
    881871  if ( inFile.isDirectory() )
    882872    return bval ;
    883  
     873
    884874  // if beginning of header data is "RW", return true
    885   // otherwise, return false ; 
     875  // otherwise, return false ;
    886876  FILE *fp = fopen( filename_.c_str(), "r" ) ;
    887877  char buf[9] ;
Note: See TracChangeset for help on using the changeset viewer.