Changeset 1616 for branches/alma/src


Ignore:
Timestamp:
08/07/09 15:49:27 (15 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: Yes CAS-729, CAS-1147

Ready to Release: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No

Module(s): Module Names change impacts.

Description: Describe your changes here...

Use LogIO instead of std::cout and std::cerr.


Location:
branches/alma/src
Files:
5 edited

Legend:

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

    r1603 r1616  
    3535#include <casa/System/ProgressMeter.h>
    3636#include <atnf/PKSIO/NROReader.h>
     37#include <casa/Logging/LogIO.h>
    3738
    3839#include <time.h>
     
    470471  time( &t0 ) ;
    471472  tm *ttm = localtime( &t0 ) ;
    472  
    473   cout << "STFiller::openNRO()  Start time = " << t0
    474        << " ("
    475        << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
    476        << " "
    477        << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
    478        << ")" << endl ;
     473  LogIO os( LogOrigin( "STFiller", "openNRO()", WHERE ) ) ;
     474//   cout << "STFiller::openNRO()  Start time = " << t0
     475//        << " ("
     476//        << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
     477//        << " "
     478//        << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
     479//        << ")" << endl ;
     480  os << "Start time = " << t0
     481     << " ("
     482     << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
     483     << " "
     484     << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
     485     << ")" << LogIO::POST ;
    479486
    480487  // fill STHeader
     
    498505                                header_->epoch,
    499506                                header_->poltype ) ) {
    500     cout << "STFiller::openNRO()  Failed to get header information." << endl ;
    501     return ;
     507//     cout << "STFiller::openNRO()  Failed to get header information." << endl ;
     508//     return ;
     509    throw( AipsError("Failed to get header information.") ) ;
    502510  }
    503511
     
    526534  }
    527535
    528   // DEBUG
    529   //cout << "STFiller::openNRO()  nIF " << endl ;
    530   //
    531 
    532536  beamOffset_ = 0;
    533537  vector<Bool> beams = nreader_->getBeams() ;
     
    549553  }
    550554
    551   // DEBUG
    552   //cout << "STFiller::openNRO()  nBeam " << endl ;
    553   //
    554 
    555555  header_->nbeam = nBeam_ ;
    556556  header_->nif = nIF_ ;
     
    558558  // set header
    559559  table_->setHeader( *header_ ) ;
    560 
    561   // DEBUG
    562   //cout << "STFiller::openNRO() Velocity Definition = " << nheader->getVDEF() << endl ;
    563560
    564561  // DEBUG
     
    566563  time( &t1 ) ;
    567564  ttm = localtime( &t1 ) ;
    568   cout << "STFiller::openNRO()  End time = " << t1
    569        << " ("
    570        << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
    571        << " "
    572        << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
    573        << ")" << endl ;
    574   cout << "STFiller::openNRO()  Elapsed time = " << t1 - t0 << " sec" << endl ;
     565//   cout << "STFiller::openNRO()  End time = " << t1
     566//        << " ("
     567//        << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
     568//        << " "
     569//        << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
     570//        << ")" << endl ;
     571//   cout << "STFiller::openNRO()  Elapsed time = " << t1 - t0 << " sec" << endl ;
     572  os << "End time = " << t1
     573     << " ("
     574     << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
     575     << " "
     576     << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
     577     << ")" << endl ;
     578  os << "Elapsed time = " << t1 - t0 << " sec" << endl ;
     579  os.post() ;
    575580  //
    576581
     
    584589  time( &t0 ) ;
    585590  tm *ttm = localtime( &t0 ) ;
    586   cout << "STFiller::readNRO()  Start time = " << t0
    587        << " ("
    588        << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
    589        << " "
    590        << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
    591        << ")" << endl ;
     591  LogIO os( LogOrigin( "STFiller", "readNRO()", WHERE ) ) ;
     592//   cout << "STFiller::readNRO()  Start time = " << t0
     593//        << " ("
     594//        << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
     595//        << " "
     596//        << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
     597//        << ")" << endl ;
     598  os << "Start time = " << t0
     599     << " ("
     600     << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
     601     << " "
     602     << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
     603     << ")" << LogIO::POST ;
    592604  //
    593605
     
    630642  Array<Double> scanrate ;
    631643  for ( i = 0 ; i < imax ; i++ ) {
    632 //     if( nreader_->getDataset()->getRecord( i ) == NULL ) {
    633 //       cerr << "STFiller::readNRO()  error while reading row " << i << endl ;
    634 //       return -1 ;
    635 //     }
    636 
    637644    string scanType = nreader_->getScanType( i ) ;
    638645    Int srcType = -1 ;
    639646    if ( scanType.compare( 0, 2, "ON") == 0 ) {
    640       // cout << "ON srcType: " << i << endl ;
     647      // os << "ON srcType: " << i << LogIO::POST ;
    641648      srcType = 0 ;
    642649    }
    643650    else if ( scanType.compare( 0, 3, "OFF" ) == 0 ) {
    644       //cout << "OFF srcType: " << i << endl ;
     651      //os << "OFF srcType: " << i << LogIO::POST ;
    645652      srcType = 1 ;
    646653    }
    647654    else if ( scanType.compare( 0, 4, "ZERO" ) == 0 ) {
    648       //cout << "ZERO srcType: " << i << endl ;
     655      //os << "ZERO srcType: " << i << LogIO::POST ;
    649656      srcType = 2 ;
    650657    }
    651658    else {
    652       //cout << "Undefined srcType: " << i << endl ;
     659      //os << "Undefined srcType: " << i << LogIO::POST ;
    653660      srcType = 3 ;
    654661    }
     
    691698                                  srcdir,
    692699                                  scanrate ) ) {
    693         cerr << "STFiller::readNRO()  Failed to get scan information." << endl ;
    694         return 1 ;
     700//         cerr << "STFiller::readNRO()  Failed to get scan information." << endl ;
     701//         return 1 ;
     702        throw( AipsError("Failed to get scan information.") ) ;
    695703      }
    696704
     
    716724        int iadd = -1 ;
    717725        for ( uInt iif = 0 ; iif < freqs.size() ; iif++ ) {
    718           //cout << "STFiller::readNRO()  freqs[" << iif << "][1] = " << freqs[iif][1] << endl ;
     726          //os << "freqs[" << iif << "][1] = " << freqs[iif][1] << LogIO::POST ;
    719727          double fdiff = abs( freqs[iif][1] - fqs[1] ) / freqs[iif][1] ;
    720           //cout << "STFiller::readNRO()  fdiff = " << fdiff << endl ;
     728          //os << "fdiff = " << fdiff << LogIO::POST ;
    721729          if ( fdiff < 1.0e-8 ) {
    722730            iadd = iif ;
     
    798806    // DEBUG
    799807    //int rownum = nreader_->getRowNum() ;
    800     //cout << "STFiller::readNRO() Finished row " << i << "/" << rownum << endl ;
     808    //os << "Finished row " << i << "/" << rownum << LogIO::POST ;
    801809    //
    802810  }
     
    806814  time( &t1 ) ;
    807815  ttm = localtime( &t1 ) ;
    808   cout << "STFiller::readNRO()  Processed " << i << " rows" << endl ;
    809   cout << "STFiller::readNRO()  Added " << i - count << " rows (ignored "
    810        << count << " \"ZERO\" scans)" << endl ;
    811   cout << "STFiller::readNRO()  End time = " << t1
    812        << " ("
    813        << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
    814        << " "
    815        << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
    816        << ")" << endl ;
    817   cout << "STFiller::readNRO()  Elapsed time = " << t1 - t0 << " sec" << endl ;
     816//   cout << "STFiller::readNRO()  Processed " << i << " rows" << endl ;
     817//   cout << "STFiller::readNRO()  Added " << i - count << " rows (ignored "
     818//        << count << " \"ZERO\" scans)" << endl ;
     819//   cout << "STFiller::readNRO()  End time = " << t1
     820//        << " ("
     821//        << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
     822//        << " "
     823//        << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
     824//        << ")" << endl ;
     825//   cout << "STFiller::readNRO()  Elapsed time = " << t1 - t0 << " sec" << endl ;
     826  os << "Processed " << i << " rows" << endl ;
     827  os << "Added " << i - count << " rows (ignored "
     828     << count << " \"ZERO\" scans)" << endl ;
     829  os.post() ;
     830  os << "End time = " << t1
     831     << " ("
     832     << ttm->tm_year + 1900 << "/" << ttm->tm_mon + 1 << "/" << ttm->tm_mday
     833     << " "
     834     << ttm->tm_hour << ":" << ttm->tm_min << ":" << ttm->tm_sec
     835     << ")" << endl ;
     836  os << "Elapsed time = " << t1 - t0 << " sec" << endl ;
     837  os.post() ;
    818838  //
    819839
  • branches/alma/src/STFitter.cpp

    r1387 r1616  
    3232#include <casa/Arrays/ArrayMath.h>
    3333#include <casa/Arrays/ArrayLogical.h>
     34#include <casa/Logging/LogIO.h>
    3435#include <scimath/Fitting.h>
    3536#include <scimath/Fitting/LinearFit.h>
     
    147148    funcs_[0] = new Polynomial<Float>(ncomp);
    148149  } else {
    149     cerr << " compiled functions not yet implemented" << endl;
     150    //cerr << " compiled functions not yet implemented" << endl;
     151    LogIO os( LogOrigin( "Fitter", "setExpression()", WHERE ) ) ;
     152    os << LogIO::WARN << " compiled functions not yet implemented" << LogIO::POST;
    150153    //funcs_.resize(1);
    151154    //funcs_[0] = new CompiledFunction<Float>();
  • branches/alma/src/STHeader.cpp

    r1603 r1616  
    3737#include <casa/Arrays/IPosition.h>
    3838#include <casa/Quanta/MVTime.h>
     39#include <casa/Logging/LogIO.h>
    3940
    40 
     41#include <sstream>
    4142
    4243#include "STDefs.h"
     
    7980  MVTime mvt(this->utc);
    8081  mvt.setFormat(MVTime::YMD);
    81   cout << "Observer: " << this->observer << endl
    82        << "Project: " << this->project << endl
    83        << "Obstype: " << this->obstype << endl
    84        << "Antenna: " << this->antennaname << endl
    85        << "Ant. Position: " << this->antennaposition << endl
    86        << "Equinox: " << this->equinox << endl
    87        << "Freq. ref.: " << this->freqref << endl
    88        << "Ref. frequency: " << this->reffreq << endl
    89        << "Bandwidth: "  << this->bandwidth << endl
    90        << "Time (utc): "
    91        << mvt
    92        << endl;
     82//   cout << "Observer: " << this->observer << endl
     83//        << "Project: " << this->project << endl
     84//        << "Obstype: " << this->obstype << endl
     85//        << "Antenna: " << this->antennaname << endl
     86//        << "Ant. Position: " << this->antennaposition << endl
     87//        << "Equinox: " << this->equinox << endl
     88//        << "Freq. ref.: " << this->freqref << endl
     89//        << "Ref. frequency: " << this->reffreq << endl
     90//        << "Bandwidth: "  << this->bandwidth << endl
     91//        << "Time (utc): "
     92//        << mvt
     93//        << endl;
     94  LogIO os( LogOrigin( "STHeader", "print()", WHERE ) ) ;
     95  os << "Observer: " << this->observer << endl
     96     << "Project: " << this->project << endl
     97     << "Obstype: " << this->obstype << endl
     98     << "Antenna: " << this->antennaname << endl
     99     << "Ant. Position: " << this->antennaposition << endl
     100     << "Equinox: " << this->equinox << endl
     101     << "Freq. ref.: " << this->freqref << endl
     102     << "Ref. frequency: " << this->reffreq << endl
     103     << "Bandwidth: "  << this->bandwidth << endl
     104     << "Time (utc): "
     105     << mvt
     106     << LogIO::POST ;
    93107  //setprecision(10) << this->utc << endl;
    94108}
     
    129143{
    130144   if (n_>0) {
    131       cerr << "Source    ID" << endl;
    132       for (uInt i=0; i<n_; i++) {
    133          cout << setw(11) << source_(i) << ID_(i) << endl;
    134       }
     145//       cerr << "Source    ID" << endl;
     146//       for (uInt i=0; i<n_; i++) {
     147//          cout << setw(11) << source_(i) << ID_(i) << endl;
     148     LogIO os( LogOrigin( "SDDataDesc", "summary()", WHERE ) ) ;
     149     ostringstream oss ;
     150     oss << "Source    ID" << endl;
     151     for (uInt i=0; i<n_; i++) {
     152       oss << setw(11) << source_(i) << ID_(i) << endl;
     153     }
     154     os << oss.str() << LogIO::POST ;
    135155   }
    136156}
  • branches/alma/src/STMath.cpp

    r1611 r1616  
    4444#include <scimath/Functionals/Polynomial.h>
    4545
     46#include <casa/Logging/LogIO.h>
     47#include <sstream>
     48
    4649#include "MathUtils.h"
    4750#include "RowAccumulator.h"
     
    7477                 const std::string& avmode)
    7578{
     79  LogIO os( LogOrigin( "STMath", "average()", WHERE ) ) ;
    7680  if ( avmode == "SCAN" && in.size() != 1 )
    7781    throw(AipsError("Can't perform 'SCAN' averaging on multiple tables.\n"
     
    8185  // check if OTF observation
    8286  String obstype = in[0]->getHeader().obstype ;
    83   //bool otfscan = false ;
    8487  Double tol = 0.0 ;
    8588  if ( obstype.find( "OTF" ) != String::npos ) {
    86     //cout << "OTF scan" << endl ;
    87     //otfscan = true ;
    8889    tol = TOL_OTF ;
    8990  }
     
    156157    for ( Int i = 0 ; i < length ; i++ ) {
    157158      Vector<Double> t = dircol(i).getAngle(Unit(String("rad"))).getValue() ;
    158       //cout << setw( 3 ) << count++ << ": " ;
    159       //cout << "[" << t[0] << "," << t[1] << "]" <<  endl ;
     159      //os << << count++ << ": " ;
     160      //os << "[" << t[0] << "," << t[1] << "]" << LogIO::POST ;
    160161      bool adddir = true ;
    161162      for ( uInt j = 0 ; j < dirs.size() ; j++ ) {
     
    176177    }
    177178    uInt rowNum = dirs.size() ;
    178     //cout << "dirs.size()=" << dirs.size() << endl ;
    179179    tout.addRow( rowNum ) ;
    180180    for ( uInt i = 0 ; i < rowNum ; i++ ) {
     
    233233        }
    234234      }
    235       //cout << "removeRows.size()=" << removeRows.size() << endl ;
    236235      if ( removeRows.size() != 0 ) {
    237         //cout << "[" ;
    238         //for ( uInt irow=0 ; irow<removeRows.size()-1 ; irow++ )
    239         //cout << removeRows[irow] << "," ;
    240         //cout << removeRows[removeRows.size()-1] << "]" << endl ;
    241236        subt.removeRow( removeRows ) ;
    242237      }
     
    298293  }
    299294  if (rowstodelete.nelements() > 0) {
    300     cout << rowstodelete << endl;
     295    //cout << rowstodelete << endl;
     296    os << rowstodelete << LogIO::POST ;
    301297    tout.removeRow(rowstodelete);
    302298    if (tout.nrow() == 0) {
     
    314310  // check if OTF observation
    315311  String obstype = in->getHeader().obstype ;
    316   //bool otfscan = false ;
    317312  Double tol = 0.0 ;
    318313  if ( obstype.find( "OTF" ) != String::npos ) {
    319     //cout << "OTF scan" << endl ;
    320     //otfscan = true ;
    321314    tol = TOL_OTF ;
    322315  }
     
    428421      Vector<uChar> flags = flagCol.getColumn(Slicer(Slice(0)));
    429422      // mask spectra for different DIRECTION
    430       //cout << "irow=" << outrowCount+irow << ": flagged [" ;
    431423      for ( uInt jrow = 0 ; jrow < subt.nrow() ; jrow++ ) {
    432424        Vector<Double> direction = dircol(jrow).getAngle(Unit(String("rad"))).getValue() ;
     
    437429        //if ( !allNearAbs( t, direction, tol ) ) {
    438430        if ( dd > tol ) {
    439           //cout << jrow << " " ;
    440431          flags[jrow] = userflag ;
    441432        }
    442433      }
    443       //cout << "]" << endl ;
    444       //cout << "flags=" << flags << endl ;
    445434      Vector<Float> outspec(nchan);
    446435      Vector<uChar> outflag(nchan,0);
     
    835824         //Debug
    836825         //if(noff!=ndiff) cerr<<"noff and ndiff is not equal"<<endl;
     826         //LogIO os( LogOrigin( "STMath", "dototalpower()", WHERE ) ) ;
     827         //if(noff!=ndiff) os<<"noff and ndiff is not equal"<<LogIO::POST;
    837828         meanoff = sum(spoff)/noff;
    838829         meandiff = sum(spdiff)/ndiff;
     
    954945      //Debug
    955946      //cerr<<"Tsys used="<<tsysrefscalar<<endl;
     947      //LogIO os( LogOrigin( "STMath", "dosigref", WHERE ) ) ;
     948      //os<<"Tsys used="<<tsysrefscalar<<LogIO::POST;
    956949      // fill the result, replay signal tsys by reference tsys
    957950      outintCol.put(i, resint);
     
    11201113      //Array<Float> avtsys =  Float(0.5) * (tsys1 + tsys2);
    11211114      // cerr<< "Tsys1="<<tsys1<<" Tsys2="<<tsys2<<endl;
     1115      // LogIO os( LogOrigin( "STMath", "donod", WHERE ) ) ;
     1116      // os<< "Tsys1="<<tsys1<<" Tsys2="<<tsys2<<LogIO::POST;
    11221117      tsys1[0] = sqrt(tsyssq1 + tsyssq2);
    11231118      Array<Float> avtsys =  tsys1;
     
    11851180  out2->frequencies().getEntry(rp2, rv2, inc2, freqid2);
    11861181  //cerr << out1->frequencies().table().nrow() << " " << out2->frequencies().table().nrow() << endl ;
     1182  //LogIO os( LogOrigin( "STMath", "dofs()", WHERE ) ) ;
     1183  //os << out1->frequencies().table().nrow() << " " << out2->frequencies().table().nrow() << LogIO::POST ;
    11871184  if (rp1==rp2) {
    11881185    Double foffset = rv1 - rv2;
    11891186    uInt choffset = static_cast<uInt>(foffset/abs(inc2));
    11901187    if (choffset >= nchan) {
    1191       cerr<<"out-band frequency switching, no folding"<<endl;
     1188      //cerr<<"out-band frequency switching, no folding"<<endl;
     1189      LogIO os( LogOrigin( "STMath", "dofs()", WHERE ) ) ;
     1190      os<<"out-band frequency switching, no folding"<<LogIO::POST;
    11921191      nofold = True;
    11931192    }
     
    12301229  // check
    12311230  if ( choffset == 0 ) {
    1232     cerr << "channel offset is zero, no folding" << endl ;
     1231    LogIO os( LogOrigin( "STMath", "dofold()", WHERE ) ) ;
     1232    os << "channel offset is zero, no folding" << LogIO::POST ;
    12331233    return out ;
    12341234  }
    12351235  int nchan = ref->nchan() ;
    12361236  if ( abs(choffset) >= nchan ) {
    1237     cerr << "out-band frequency switching, no folding" << endl ;
     1237    LogIO os( LogOrigin( "STMath", "dofold()", WHERE ) ) ;
     1238    os << "out-band frequency switching, no folding" << LogIO::POST ;
    12381239    return out ;
    12391240  }
     
    23842385  throw ( casa::AipsError )
    23852386{
     2387  LogIO os( LogOrigin( "STMath", "new_average()", WHERE ) ) ;
    23862388  if ( avmode == "SCAN" && in.size() != 1 )
    23872389    throw(AipsError("Can't perform 'SCAN' averaging on multiple tables.\n"
     
    23902392  // check if OTF observation
    23912393  String obstype = in[0]->getHeader().obstype ;
    2392   //bool otfscan = false ;
    23932394  Double tol = 0.0 ;
    23942395  if ( obstype.find( "OTF" ) != String::npos ) {
    2395     //cout << "OTF scan" << endl ;
    2396     //otfscan = true ;
    23972396    tol = TOL_OTF ;
    23982397  }
     
    24072406
    24082407    // TEST: do normal average in each table before IF grouping
    2409     cout << "Do preliminary averaging" << endl ;
     2408    os << "Do preliminary averaging" << LogIO::POST ;
    24102409    vector< CountedPtr<Scantable> > tmpin( insize ) ;
    24112410    for ( uInt itable = 0 ; itable < insize ; itable++ ) {
     
    24152414
    24162415    // warning
    2417     cout << "Average spectra with different spectral resolution" << endl ;
    2418     cout << endl ;
     2416    os << "Average spectra with different spectral resolution" << LogIO::POST ;
    24192417
    24202418    // temporarily set coordinfo
     
    24472445    //          ...
    24482446    //          [min_idn0, max_idn0, min_idn1, max_idn1, ...]]
    2449     //cout << "Check IF settings in each table" << endl ;
     2447    //os << "Check IF settings in each table" << LogIO::POST ;
    24502448    vector< vector<uInt> > freqid( insize );
    24512449    vector< vector<double> > iffreq( insize ) ;
     
    24622460          uInt id = freqIDCol( irow ) ;
    24632461          if ( freqid[itable].size() == 0 || count( freqid[itable].begin(), freqid[itable].end(), id ) == 0 ) {
    2464             //cout << "itable = " << itable << ": IF " << id << " is included in the list" << endl ;
     2462            //os << "itable = " << itable << ": IF " << id << " is included in the list" << LogIO::POST ;
    24652463            vector<double> abcissa = tmpin[itable]->getAbcissa( irow ) ;
    24662464            freqid[itable].push_back( id ) ;
     
    24732471
    24742472    // debug
    2475     //cout << "IF settings summary:" << endl ;
     2473    //os << "IF settings summary:" << endl ;
    24762474    //for ( uInt i = 0 ; i < freqid.size() ; i++ ) {
    2477     //cout << "   Table" << i << endl ;
     2475    //os << "   Table" << i << endl ;
    24782476    //for ( uInt j = 0 ; j < freqid[i].size() ; j++ ) {
    2479     //cout << "      id = " << freqid[i][j] << " (min,max) = (" << iffreq[i][2*j] << "," << iffreq[i][2*j+1] << ")" << endl ;
     2477    //os << "      id = " << freqid[i][j] << " (min,max) = (" << iffreq[i][2*j] << "," << iffreq[i][2*j+1] << ")" << endl ;
    24802478    //}
    24812479    //}
    2482     //cout << endl ;
     2480    //os << endl ;
     2481    //os.post() ;
    24832482
    24842483    // IF grouping based on their frequency coverage
     
    24922491    // ifgfreq[numgrp*2]
    24932492    // ifgfreq: [min0_grp0, max0_grp0, min1_grp1, max1_grp1, ...]
    2494     //cout << "IF grouping based on their frequency coverage" << endl ;
     2493    //os << "IF grouping based on their frequency coverage" << LogIO::POST ;
    24952494    vector< vector<uInt> > ifgrp ;
    24962495    vector<double> ifgfreq ;
     
    25762575
    25772576    // print IF groups
    2578     cout << "IF Group summary: " << endl ;
    2579     cout << "   GROUP_ID [FREQ_MIN, FREQ_MAX]: (TABLE_ID, FREQ_ID)" << endl ;
     2577    ostringstream oss ;
     2578    oss << "IF Group summary: " << endl ;
     2579    oss << "   GROUP_ID [FREQ_MIN, FREQ_MAX]: (TABLE_ID, FREQ_ID)" << endl ;
    25802580    for ( uInt i = 0 ; i < ifgrp.size() ; i++ ) {
    2581       cout << "   GROUP " << setw( 2 ) << i << " [" << ifgfreq[2*i] << "," << ifgfreq[2*i+1] << "]: " ;
     2581      oss << "   GROUP " << setw( 2 ) << i << " [" << ifgfreq[2*i] << "," << ifgfreq[2*i+1] << "]: " ;
    25822582      for ( uInt j = 0 ; j < ifgrp[i].size()/2 ; j++ ) {
    2583         cout << "(" << ifgrp[i][2*j] << "," << ifgrp[i][2*j+1] << ") " ;
    2584       }
    2585       cout << endl ;
    2586     }
    2587     cout << endl ;
     2583        oss << "(" << ifgrp[i][2*j] << "," << ifgrp[i][2*j+1] << ") " ;
     2584      }
     2585      oss << endl ;
     2586    }
     2587    oss << endl ;
     2588    os << oss.str() << LogIO::POST ;
    25882589   
    25892590    // print frequency group
    2590     cout << "Frequency Group summary: " << endl ;
    2591     cout << "   GROUP_ID [FREQ_MIN, FREQ_MAX]: IF_GROUP_ID" << endl ;
     2591    oss.str("") ;
     2592    oss << "Frequency Group summary: " << endl ;
     2593    oss << "   GROUP_ID [FREQ_MIN, FREQ_MAX]: IF_GROUP_ID" << endl ;
    25922594    for ( uInt i = 0 ; i < freqgrp.size() ; i++ ) {
    2593       cout << "   GROUP " << setw( 2 ) << i << " [" << ifgfreq[2*freqgrp[i][0]] << "," << ifgfreq[2*freqgrp[i][freqgrp[i].size()-1]+1] << "]: " ;
     2595      oss << "   GROUP " << setw( 2 ) << i << " [" << ifgfreq[2*freqgrp[i][0]] << "," << ifgfreq[2*freqgrp[i][freqgrp[i].size()-1]+1] << "]: " ;
    25942596      for ( uInt j = 0 ; j < freqgrp[i].size() ; j++ ) {
    2595         cout << freqgrp[i][j] << " " ;
    2596       }
    2597       cout << endl ;
    2598     }
    2599     cout << endl ;
     2597        oss << freqgrp[i][j] << " " ;
     2598      }
     2599      oss << endl ;
     2600    }
     2601    oss << endl ;
     2602    os << oss.str() << LogIO::POST ;
    26002603
    26012604    // membership check
     
    26232626
    26242627    // print membership
     2628    //oss.str("") ;
    26252629    //for ( uInt i = 0 ; i < insize ; i++ ) {
    2626     //cout << "Table " << i << endl ;
     2630    //oss << "Table " << i << endl ;
    26272631    //for ( uInt j = 0 ; j < groups[i].size() ; j++ ) {
    2628     //cout << "   FREQ_ID " <<  setw( 2 ) << freqid[i][j] << ": " ;
     2632    //oss << "   FREQ_ID " <<  setw( 2 ) << freqid[i][j] << ": " ;
    26292633    //for ( uInt k = 0 ; k < groups[i][j].size() ; k++ ) {
    2630     //cout << setw( 2 ) << groups[i][j][k] << " " ;
     2634    //oss << setw( 2 ) << groups[i][j][k] << " " ;
    26312635    //}
    2632     //cout << endl ;
     2636    //oss << endl ;
    26332637    //}
    26342638    //}
     2639    //os << oss.str() << LogIO::POST ;
    26352640
    26362641    // set back coordinfo
     
    26492654    vector<uInt> newifids( insize, 0 ) ;
    26502655    for ( uInt itable = 0 ; itable < insize ; itable++ ) {
    2651       //cout << "Table " << setw(2) << itable << ": " ;
     2656      //os << "Table " << itable << ": " ;
    26522657      for ( uInt ifrow = 0 ; ifrow < groups[itable].size() ; ifrow++ ) {
    26532658        addrow[itable].push_back( groups[itable][ifrow].size()-1 ) ;
    2654         //cout << addrow[itable][ifrow] << " " ;
     2659        //os << addrow[itable][ifrow] << " " ;
    26552660      }
    26562661      addtable[itable] = *max_element( addrow[itable].begin(), addrow[itable].end() ) ;
    2657       //cout << "(" << addtable[itable] << ")" << endl ;
     2662      //os << "(" << addtable[itable] << ")" << LogIO::POST ;
    26582663    }
    26592664    newin.resize( insize ) ;
     
    26812686        }
    26822687        string taql = taqlstream.str() ;
    2683         //cout << "taql = " << taql << endl ;
     2688        //os << "taql = " << taql << LogIO::POST ;
    26842689        STSelector selector = STSelector() ;
    26852690        selector.setTaQL( taql ) ;
     
    27082713
    27092714    // print IF groups again for debug
    2710     //cout << "IF Group summary: " << endl ;
    2711     //cout << "   GROUP_ID [FREQ_MIN, FREQ_MAX]: (TABLE_ID, FREQ_ID)" << endl ;
     2715    //oss.str( "" ) ;
     2716    //oss << "IF Group summary: " << endl ;
     2717    //oss << "   GROUP_ID [FREQ_MIN, FREQ_MAX]: (TABLE_ID, FREQ_ID)" << endl ;
    27122718    //for ( uInt i = 0 ; i < ifgrp.size() ; i++ ) {
    2713     //cout << "   GROUP " << setw( 2 ) << i << " [" << ifgfreq[2*i] << "," << ifgfreq[2*i+1] << "]: " ;
     2719    //oss << "   GROUP " << setw( 2 ) << i << " [" << ifgfreq[2*i] << "," << ifgfreq[2*i+1] << "]: " ;
    27142720    //for ( uInt j = 0 ; j < ifgrp[i].size()/2 ; j++ ) {
    2715     //cout << "(" << ifgrp[i][2*j] << "," << ifgrp[i][2*j+1] << ") " ;
     2721    //oss << "(" << ifgrp[i][2*j] << "," << ifgrp[i][2*j+1] << ") " ;
    27162722    //}
    2717     //cout << endl ;
     2723    //oss << endl ;
    27182724    //}
    2719     //cout << endl ;
     2725    //oss << endl ;
     2726    //os << oss.str() << LogIO::POST ;
    27202727
    27212728    // reset SCANNO and IFNO/FREQ_ID: IF is reset by the result of sortation
    2722     cout << "All scan number is set to 0" << endl ;
    2723     //cout << "All IF number is set to IF group index" << endl ;
    2724     cout << endl ;
     2729    os << "All scan number is set to 0" << LogIO::POST ;
     2730    //os << "All IF number is set to IF group index" << LogIO::POST ;
    27252731    insize = newin.size() ;
    27262732    for ( uInt itable = 0 ; itable < insize ; itable++ ) {
     
    27732779
    27742780    // reset spectra and flagtra: pick up common part of frequency coverage
    2775     //cout << "Pick common frequency range and align resolution" << endl ;
     2781    //os << "Pick common frequency range and align resolution" << LogIO::POST ;
    27762782    for ( uInt itable = 0 ; itable < insize ; itable++ ) {
    27772783      uInt rows = newin[itable]->nrow() ;
     
    27832789        double minfreq = ifgfreq[2*ifno] ;
    27842790        double maxfreq = ifgfreq[2*ifno+1] ;
    2785         //cout << "frequency range: [" << minfreq << "," << maxfreq << "]" << endl ;
     2791        //os << "frequency range: [" << minfreq << "," << maxfreq << "]" << LogIO::POST ;
    27862792        vector<double> abcissa = newin[itable]->getAbcissa( irow ) ;
    27872793        int nchan = abcissa.size() ;
    27882794        double resol = abcissa[1] - abcissa[0] ;
    2789         //cout << "abcissa range  : [" << abcissa[0] << "," << abcissa[nchan-1] << "]" << endl ;
     2795        //os << "abcissa range  : [" << abcissa[0] << "," << abcissa[nchan-1] << "]" << LogIO::POST ;
    27902796        if ( minfreq <= abcissa[0] )
    27912797          nminchan = 0 ;
     
    28022808          nmaxchan = abcissa.size() - 1 - int(cfreq) - ( ( cfreq - int(cfreq) >= 0.5 ) ? 1 : 0 ) ;
    28032809        }
    2804         //cout << "channel range (" << irow << "): [" << nminchan << "," << nmaxchan << "]" << endl ;
     2810        //os << "channel range (" << irow << "): [" << nminchan << "," << nmaxchan << "]" << LogIO::POST ;
    28052811        if ( nmaxchan > nminchan ) {
    28062812          newin[itable]->reshapeSpectrum( nminchan, nmaxchan, irow ) ;
     
    28292835   
    28302836    // reset spectra and flagtra: align spectral resolution
    2831     //cout << "Align spectral resolution" << endl ;
     2837    //os << "Align spectral resolution" << LogIO::POST ;
    28322838    // gmaxdnu: the coarsest frequency resolution in the frequency group
    28332839    // gmemid: member index that have a resolution equal to gmaxdnu
     
    28582864            int nchan = abcissa.size() ;
    28592865            double dnu = abcissa[1] - abcissa[0] ;
    2860             //cout << "GROUP " << igrp << " (" << tableid << "," << rowid << "): nchan = " << nchan << " (minchan = " << minchan << ")" << endl ;
     2866            //os << "GROUP " << igrp << " (" << tableid << "," << rowid << "): nchan = " << nchan << " (minchan = " << minchan << ")" << LogIO::POST ;
    28612867            if ( nchan < minchan ) {
    28622868              minchan = nchan ;
     
    28692875        }
    28702876        // regrid spectra in each group
    2871         cout << "GROUP " << igrp << endl ;
    2872         cout << "   Channel number is adjusted to " << minchan << endl ;
    2873         cout << "   Corresponding frequency resolution is " << maxdnu << "Hz" << endl ;
     2877        os << "GROUP " << igrp << endl ;
     2878        os << "   Channel number is adjusted to " << minchan << endl ;
     2879        os << "   Corresponding frequency resolution is " << maxdnu << "Hz" << LogIO::POST ;
    28742880        for ( uInt imem = 0 ; imem < ifgrp[igrp].size()/2 ; imem++ ) {
    28752881          uInt tableid = ifgrp[igrp][2*imem] ;
    28762882          uInt rowid = ifgrp[igrp][2*imem+1] ;
    28772883          freqIDCol.attach( newin[tableid]->table(), "FREQ_ID" ) ;
    2878           //cout << "tableid = " << tableid << " rowid = " << rowid << ": " << endl ;
    2879           //cout << "   regridChannel applied to " ;
     2884          //os << "tableid = " << tableid << " rowid = " << rowid << ": " << LogIO::POST ;
     2885          //os << "   regridChannel applied to " ;
    28802886          if ( tableid != reftable )
    28812887            refreqid = newin[tableid]->frequencies().addEntry( refpixref, refvalref, refinc ) ;
     
    28832889            uInt tfreqid = freqIdVec[tableid][irow] ;
    28842890            if ( tfreqid == rowid ) {     
    2885               //cout << irow << " " ;
     2891              //os << irow << " " ;
    28862892              newin[tableid]->regridChannel( minchan, maxdnu, irow ) ;
    28872893              freqIDCol.put( irow, refreqid ) ;
     
    28892895            }
    28902896          }
    2891           //cout << endl ;
     2897          //os << LogIO::POST ;
    28922898        }
    28932899      }
     
    29132919      }
    29142920    }
    2915     cout << endl ;
    29162921
    29172922    // set back coordinfo
     
    29382943
    29392944    // combine frequency group
    2940     cout << "Combine spectra based on frequency grouping" << endl ;
    2941     cout << "IFNO is renumbered as frequency group ID (see above)" << endl ;
     2945    os << "Combine spectra based on frequency grouping" << LogIO::POST ;
     2946    os << "IFNO is renumbered as frequency group ID (see above)" << LogIO::POST ;
    29422947    vector<string> coordinfo = tmpout->getCoordInfo() ;
    29432948    oldinfo[0] = coordinfo[0] ;
     
    29552960    }
    29562961    string taql = taqlstream.str() ;
    2957     //cout << "taql = " << taql << endl ;
     2962    //os << "taql = " << taql << LogIO::POST ;
    29582963    STSelector selector = STSelector() ;
    29592964    selector.setTaQL( taql ) ;
     
    30093014      dircol.attach( iter.table(), "DIRECTION" ) ;
    30103015      uInt polno = polnos( 0 ) ;
    3011       //cout << "POLNO iteration: " << polno << endl ;
     3016      //os << "POLNO iteration: " << polno << LogIO::POST ;
    30123017//       for ( uInt igrp = 0 ; igrp < freqgrp.size() ; igrp++ ) {
    30133018//      sizes[igrp].resize( freqgrp[igrp].size() ) ;
     
    30223027//            vector<uChar> fvec ;
    30233028//            flag.tovector( fvec ) ;
    3024 //            //cout << "spec.size() = " << svec.size() << " fvec.size() = " << fvec.size() << endl ;
     3029//            //os << "spec.size() = " << svec.size() << " fvec.size() = " << fvec.size() << LogIO::POST ;
    30253030//            specout[igrp].insert( specout[igrp].end(), svec.begin(), svec.end() ) ;
    30263031//            flagout[igrp].insert( flagout[igrp].end(), fvec.begin(), fvec.end() ) ;
    3027 //            //cout << "specout[" << igrp << "].size() = " << specout[igrp].size() << endl ;
     3032//            //os << "specout[" << igrp << "].size() = " << specout[igrp].size() << LogIO::POST ;
    30283033//            sizes[igrp][imem] = spec.nelements() ;
    30293034//          }
     
    30903095                vector<uChar> fvec ;
    30913096                flag.tovector( fvec ) ;
    3092                 //cout << "spec.size() = " << svec.size() << " fvec.size() = " << fvec.size() << endl ;
     3097                //os << "spec.size() = " << svec.size() << " fvec.size() = " << fvec.size() << LogIO::POST ;
    30933098                specout[igrp].insert( specout[igrp].end(), svec.begin(), svec.end() ) ;
    30943099                flagout[igrp].insert( flagout[igrp].end(), fvec.begin(), fvec.end() ) ;
    3095                 //cout << "specout[" << igrp << "].size() = " << specout[igrp].size() << endl ;
     3100                //os << "specout[" << igrp << "].size() = " << specout[igrp].size() << LogIO::POST ;
    30963101              }
    30973102            }
     
    31193124        if ( ifnoColOut( irow ) == gmemid[igrp] && !updated[igrp] ) {
    31203125          uInt freqidOut = freqidColOut( irow ) ;
    3121           //cout << "freqgrp " << igrp << " freqidOut = " << freqidOut << endl ;
     3126          //os << "freqgrp " << igrp << " freqidOut = " << freqidOut << LogIO::POST ;
    31223127          double refpix ;
    31233128          double refval ;
  • branches/alma/src/Scantable.cpp

    r1610 r1616  
    3131#include <casa/Containers/RecordField.h>
    3232#include <casa/Utilities/GenSort.h>
     33#include <casa/Logging/LogIO.h>
    3334
    3435#include <tables/Tables/TableParse.h>
     
    10671068void Scantable::addFit( const STFitEntry& fit, int row )
    10681069{
    1069   cout << mfitidCol_(uInt(row)) << endl;
     1070  //cout << mfitidCol_(uInt(row)) << endl;
     1071  LogIO os( LogOrigin( "Scantable", "addFit()", WHERE ) ) ;
     1072  os << mfitidCol_(uInt(row)) << LogIO::POST ;
    10701073  uInt id = fitTable_.addEntry(fit, mfitidCol_(uInt(row)));
    10711074  mfitidCol_.put(uInt(row), id);
     
    11011104      Table subt = t( t.col("SCAN") == scanlist[i]+1 );
    11021105      if (subt.nrow()==0) {
    1103         cerr <<"Scan "<<scanlist[i]<<" cannot be found in the scantable."<<endl;
     1106        //cerr <<"Scan "<<scanlist[i]<<" cannot be found in the scantable."<<endl;
     1107        LogIO os( LogOrigin( "Scantable", "checkScanInfo()", WHERE ) ) ;
     1108        os <<LogIO::WARN<<"Scan "<<scanlist[i]<<" cannot be found in the scantable."<<LogIO::POST;
    11041109        ret = 1;
    11051110        break;
     
    11131118          Table subt2 = t( t.col("SCAN") == scanlist[i+1]+1 );
    11141119          if ( subt2.nrow() == 0) {
    1115             cerr<<"Scan "<<scanlist[i+1]<<" cannot be found in the scantable."<<endl;
     1120            LogIO os( LogOrigin( "Scantable", "checkScanInfo()", WHERE ) ) ;
     1121
     1122            //cerr<<"Scan "<<scanlist[i+1]<<" cannot be found in the scantable."<<endl;
     1123            os<<LogIO::WARN<<"Scan "<<scanlist[i+1]<<" cannot be found in the scantable."<<LogIO::POST;
    11161124            ret = 1;
    11171125            break;
     
    11231131          if (scan1seqn == 1 && scan2seqn == 2) {
    11241132            if (laston1 == laston2) {
    1125               cerr<<"A valid scan pair ["<<scanlist[i]<<","<<scanlist[i+1]<<"]"<<endl;
     1133              LogIO os( LogOrigin( "Scantable", "checkScanInfo()", WHERE ) ) ;
     1134              //cerr<<"A valid scan pair ["<<scanlist[i]<<","<<scanlist[i+1]<<"]"<<endl;
     1135              os<<"A valid scan pair ["<<scanlist[i]<<","<<scanlist[i+1]<<"]"<<LogIO::POST;
    11261136              i +=1;
    11271137            }
    11281138            else {
    1129               cerr<<"Incorrect scan pair ["<<scanlist[i]<<","<<scanlist[i+1]<<"]"<<endl;
     1139              LogIO os( LogOrigin( "Scantable", "checkScanInfo()", WHERE ) ) ;
     1140              //cerr<<"Incorrect scan pair ["<<scanlist[i]<<","<<scanlist[i+1]<<"]"<<endl;
     1141              os<<LogIO::WARN<<"Incorrect scan pair ["<<scanlist[i]<<","<<scanlist[i+1]<<"]"<<LogIO::POST;
    11301142            }
    11311143          }
    11321144          else if (scan1seqn==2 && scan2seqn == 1) {
    11331145            if (laston1 == laston2) {
    1134               cerr<<"["<<scanlist[i]<<","<<scanlist[i+1]<<"] is a valid scan pair but in incorrect order."<<endl;
     1146              LogIO os( LogOrigin( "Scantable", "checkScanInfo()", WHERE ) ) ;
     1147              //cerr<<"["<<scanlist[i]<<","<<scanlist[i+1]<<"] is a valid scan pair but in incorrect order."<<endl;
     1148              os<<LogIO::WARN<<"["<<scanlist[i]<<","<<scanlist[i+1]<<"] is a valid scan pair but in incorrect order."<<LogIO::POST;
    11351149              ret = 1;
    11361150              break;
     
    11381152          }
    11391153          else {
    1140             cerr<<"The other scan for  "<<scanlist[i]<<" appears to be missing. Check the input scan numbers."<<endl;
     1154            LogIO os( LogOrigin( "Scantable", "checkScanInfo()", WHERE ) ) ;
     1155            //cerr<<"The other scan for  "<<scanlist[i]<<" appears to be missing. Check the input scan numbers."<<endl;
     1156            os<<LogIO::WARN<<"The other scan for  "<<scanlist[i]<<" appears to be missing. Check the input scan numbers."<<LogIO::POST;
    11411157            ret = 1;
    11421158            break;
     
    11451161      }
    11461162      else {
    1147         cerr<<"The scan does not appear to be standard obsevation."<<endl;
     1163        LogIO os( LogOrigin( "Scantable", "checkScanInfo()", WHERE ) ) ;
     1164        //cerr<<"The scan does not appear to be standard obsevation."<<endl;
     1165        os<<LogIO::WARN<<"The scan does not appear to be standard obsevation."<<LogIO::POST;
    11481166      }
    11491167    //if ( i >= nscan ) break;
     
    11511169  }
    11521170  else {
    1153     cerr<<"No reference to GBT_GO table."<<endl;
     1171    LogIO os( LogOrigin( "Scantable", "checkScanInfo()", WHERE ) ) ;
     1172    //cerr<<"No reference to GBT_GO table."<<endl;
     1173    os<<LogIO::WARN<<"No reference to GBT_GO table."<<LogIO::POST;
    11541174    ret = 1;
    11551175  }
     
    11851205    nmax = nmin ;
    11861206    nmin = tmp ;
    1187     cout << "Swap values. Applied range is ["
    1188          << nmin << ", " << nmax << "]" << endl ;
     1207    LogIO os( LogOrigin( "Scantable", "reshapeSpectrum()", WHERE ) ) ;
     1208    os << "Swap values. Applied range is ["
     1209       << nmin << ", " << nmax << "]" << LogIO::POST ;
    11891210  }
    11901211 
     
    11981219    if ( nmin == 0 ) {
    11991220      // nothing to do
    1200       cout << "Whole range is selected. Nothing to do." << endl ;
     1221      LogIO os( LogOrigin( "Scantable", "reshapeSpectrum()", WHERE ) ) ;
     1222      os << "Whole range is selected. Nothing to do." << LogIO::POST ;
    12011223      return ;
    12021224    }
    12031225    else {
    1204       cout << "Specified maximum exceeds nChan. Applied range is ["
    1205            << nmin << ", " << nChan-1 << "]." << endl ;
     1226      LogIO os( LogOrigin( "Scantable", "reshapeSpectrum()", WHERE ) ) ;
     1227      os << "Specified maximum exceeds nChan. Applied range is ["
     1228         << nmin << ", " << nChan-1 << "]." << LogIO::POST ;
    12061229      nmax = nChan - 1 ;
    12071230    }
     
    12561279void asap::Scantable::regridChannel( int nChan, double dnu )
    12571280{
    1258   cout << "Regrid abcissa with channel number " << nChan << " and spectral resoultion " << dnu << "Hz." << endl ;
     1281  LogIO os( LogOrigin( "Scantable", "regridChannel()", WHERE ) ) ;
     1282  os << "Regrid abcissa with channel number " << nChan << " and spectral resoultion " << dnu << "Hz." << LogIO::POST ;
    12591283  // assumed that all rows have same nChan
    12601284  Vector<Float> arr = specCol_( 0 ) ;
     
    12631287  // if oldsize == nChan, nothing to do
    12641288  if ( oldsize == nChan ) {
    1265     cout << "Specified channel number is same as current one. Nothing to do." << endl ;
     1289    os << "Specified channel number is same as current one. Nothing to do." << LogIO::POST ;
    12661290    return ;
    12671291  }
     
    12691293  // if oldChan < nChan, unphysical operation
    12701294  if ( oldsize < nChan ) {
    1271     cout << "Unphysical operation. Nothing to do." << endl ;
     1295    os << "Unphysical operation. Nothing to do." << LogIO::POST ;
    12721296    return ;
    12731297  }
Note: See TracChangeset for help on using the changeset viewer.