Changeset 2004


Ignore:
Timestamp:
02/22/11 20:24:33 (13 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: Yes .CAS-2718

Ready for Test: 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...

The MSFiller is called instead of PKSFiller when input data is MS.
I have tested all task regressions as well as sdsave unit test and passed.

A few modification was needed for STMath::dototalpower() and
STWriter::write().


Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/scantable.py

    r1994 r2004  
    1010from asap.env import is_casapy
    1111from asap._asap import Scantable
    12 from asap._asap import filler
     12from asap._asap import filler, msfiller
    1313from asap.parameters import rcParams
    1414from asap.logging import asaplog, asaplog_post_dec
     
    232232        if format2 == 'ASAP':
    233233            self._save(name)
     234##         elif format2 == 'MS2':
     235##             msopt = {'ms': {'overwrite': overwrite } }
     236##             from asap._asap import mswriter
     237##             writer = mswriter( self )
     238##             writer.write( name, msopt )
    234239        else:
    235240            from asap._asap import stwriter as stw
     
    26872692    def _check_ifs(self):
    26882693        #nchans = [self.nchan(i) for i in range(self.nif(-1))]
    2689         #nchans = filter(lambda t: t > 0, nchans)
    26902694        nchans = [self.nchan(i) for i in self.getifnos()]
     2695        nchans = filter(lambda t: t > 0, nchans)
    26912696        return (sum(nchans)/len(nchans) == nchans[0])
    26922697
     
    27082713        for name in fullnames:
    27092714            tbl = Scantable(stype)
    2710             r = filler(tbl)
    2711             rx = rcParams['scantable.reference']
    2712             r.setreferenceexpr(rx)
     2715            if is_ms( name ):
     2716                r = msfiller( tbl )
     2717            else:
     2718                r = filler( tbl )
     2719                rx = rcParams['scantable.reference']
     2720                r.setreferenceexpr(rx)
     2721            #r = filler(tbl)
     2722            #rx = rcParams['scantable.reference']
     2723            #r.setreferenceexpr(rx)
    27132724            msg = "Importing %s..." % (name)
    27142725            asaplog.push(msg, False)
  • trunk/src/MSFiller.cpp

    r2003 r2004  
    9494{
    9595  os_.origin( LogOrigin( "MSFiller", "open()", WHERE ) ) ;
    96   double startSec = gettimeofday_sec() ;
    97   os_ << "start MSFiller::open() startsec=" << startSec << LogIO::POST ;
     96//   double startSec = gettimeofday_sec() ;
     97//   os_ << "start MSFiller::open() startsec=" << startSec << LogIO::POST ;
    9898  //os_ << "   filename = " << filename << endl ;
    9999
     
    137137  isData_ = mstable_.tableDesc().isColumn( "DATA" ) ;
    138138
    139   double endSec = gettimeofday_sec() ;
    140   os_ << "end MSFiller::open() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
     139//   double endSec = gettimeofday_sec() ;
     140//   os_ << "end MSFiller::open() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
    141141  return true ;
    142142}
     
    145145{
    146146  os_.origin( LogOrigin( "MSFiller", "fill()", WHERE ) ) ;
    147   double startSec = gettimeofday_sec() ;
    148   os_ << "start MSFiller::fill() startSec=" << startSec << LogIO::POST ;
    149 
    150   double time0 = gettimeofday_sec() ;
    151   os_ << "start init fill: " << time0 << LogIO::POST ;
     147//   double startSec = gettimeofday_sec() ;
     148//   os_ << "start MSFiller::fill() startSec=" << startSec << LogIO::POST ;
     149
     150//   double time0 = gettimeofday_sec() ;
     151//   os_ << "start init fill: " << time0 << LogIO::POST ;
    152152
    153153  // Initialize header
     
    175175  const TableRecord msrec = mstable_.keywordSet() ;
    176176  isDoppler_ = msrec.isDefined( "DOPPLER" ) ;
     177  if ( isDoppler_ )
     178    if ( mstable_.doppler().nrow() == 0 )
     179      isDoppler_ = False ;
    177180  isFlagCmd_ = msrec.isDefined( "FLAG_CMD" ) ;
     181  if ( isFlagCmd_ )
     182    if ( mstable_.flagCmd().nrow() == 0 )
     183      isFlagCmd_ = False ;
    178184  isFreqOffset_ = msrec.isDefined( "FREQ_OFFSET" ) ;
     185  if ( isFreqOffset_ )
     186    if ( mstable_.freqOffset().nrow() == 0 )
     187      isFreqOffset_ = False ;
    179188  isHistory_ = msrec.isDefined( "HISTORY" ) ;
     189  if ( isHistory_ )
     190    if ( mstable_.history().nrow() == 0 )
     191      isHistory_ = False ;
    180192  isProcessor_ = msrec.isDefined( "PROCESSOR" ) ;
     193  if ( isProcessor_ )
     194    if ( mstable_.processor().nrow() == 0 )
     195      isProcessor_ = False ;
    181196  isSysCal_ = msrec.isDefined( "SYSCAL" ) ;
     197  if ( isSysCal_ )
     198    if ( mstable_.sysCal().nrow() == 0 )
     199      isSysCal_ = False ;
    182200  isWeather_ = msrec.isDefined( "WEATHER" ) ;
    183  
     201  if ( isWeather_ )
     202    if ( mstable_.weather().nrow() == 0 )
     203      isWeather_ = False ;
     204
    184205  // Access to MS subtables
    185206  MSField fieldtab = mstable_.field() ;
     
    198219      colTsys_ = "TSYS" ;
    199220  }
    200   //colTcal_ = "TCAL" ;
    201   //colTsys_ = "TSYS" ;
     221//   colTcal_ = "TCAL" ;
     222//   colTsys_ = "TSYS" ;
    202223  MSPointing pointtab = mstable_.pointing() ;
    203224  if ( mstable_.weather().nrow() == 0 )
     
    216237
    217238  // SUBTABLES: WEATHER
    218   if ( isWeather_ )
    219     fillWeather() ;
     239  fillWeather() ;
    220240
    221241  // SUBTABLES: FOCUS
     
    223243
    224244  // SUBTABLES: TCAL
    225   if ( isSysCal_ )
    226     fillTcal( tpoolr ) ;
     245  fillTcal( tpoolr ) ;
    227246
    228247  // SUBTABLES: FIT
     
    257276  String telescopeName = "" ;
    258277
    259   double time1 = gettimeofday_sec() ;
    260   os_ << "end fill init: " << time1 << " (" << time1-time0 << "sec)" << LogIO::POST ;
     278  //double time1 = gettimeofday_sec() ;
     279  //os_ << "end fill init: " << time1 << " (" << time1-time0 << "sec)" << LogIO::POST ;
    261280
    262281  // row based
     
    297316  TableIterator iter0( mstable_, "OBSERVATION_ID" ) ;
    298317  while( !iter0.pastEnd() ) {
    299     time0 = gettimeofday_sec() ;
    300     os_ << "start 0th iteration: " << time0 << LogIO::POST ;
     318    //time0 = gettimeofday_sec() ;
     319    //os_ << "start 0th iteration: " << time0 << LogIO::POST ;
    301320    Table t0 = iter0.table() ;
    302321    tcolr = tpoolr->construct( t0, "OBSERVATION_ID" ) ;
     
    325344    }
    326345    Int nbeam = 0 ;
    327     time1 = gettimeofday_sec() ;
    328     os_ << "end 0th iteration init: " << time1 << " (" << time1-time0 << "sec)" << LogIO::POST ;
     346    //time1 = gettimeofday_sec() ;
     347    //os_ << "end 0th iteration init: " << time1 << " (" << time1-time0 << "sec)" << LogIO::POST ;
    329348    //
    330349    // ITERATION: FEED1
     
    332351    TableIterator iter1( t0, "FEED1" ) ;
    333352    while( !iter1.pastEnd() ) {
    334       time0 = gettimeofday_sec() ;
    335       os_ << "start 1st iteration: " << time0 << LogIO::POST ;
     353      //time0 = gettimeofday_sec() ;
     354      //os_ << "start 1st iteration: " << time0 << LogIO::POST ;
    336355      Table t1 = iter1.table() ;
    337356      // assume FEED1 == FEED2
     
    349368      *uintRF = 0 ;
    350369
    351       time1 = gettimeofday_sec() ;
    352       os_ << "end 1st iteration init: " << time1 << " (" << time1-time0 << "sec)" << LogIO::POST ;
     370      //time1 = gettimeofday_sec() ;
     371      //os_ << "end 1st iteration init: " << time1 << " (" << time1-time0 << "sec)" << LogIO::POST ;
    353372      //
    354373      // ITERATION: FIELD_ID
     
    356375      TableIterator iter2( t1, "FIELD_ID" ) ;
    357376      while( !iter2.pastEnd() ) {
    358         time0 = gettimeofday_sec() ;
    359         os_ << "start 2nd iteration: " << time0 << LogIO::POST ;
     377        //time0 = gettimeofday_sec() ;
     378        //os_ << "start 2nd iteration: " << time0 << LogIO::POST ;
    360379        Table t2 = iter2.table() ;
    361380        tcolr = tpoolr->construct( t2, "FIELD_ID" ) ;
     
    368387        String fieldName = tcolr->asString( fieldId ) + "__" + String::toString(fieldId) ;
    369388        tpoolr->destroy( tcolr ) ;
     389        ROArrayMeasColumn<MDirection> *delayDirCol = new ROArrayMeasColumn<MDirection>( fieldtab, "DELAY_DIR" ) ;
     390        Vector<MDirection> delayDir = (*delayDirCol)( fieldId ) ;
     391        delete delayDirCol ;
     392        Vector<Double> defaultScanrate( 2, 0.0 ) ;
     393        Vector<Double> defaultDir = delayDir[0].getAngle( "rad" ).getValue() ;
     394        if ( delayDir.nelements() > 1 )
     395          defaultScanrate = delayDir[1].getAngle( "rad" ).getValue() ;
     396         
    370397
    371398        // FIELDNAME
     
    374401
    375402
    376         time1 = gettimeofday_sec() ;
    377         os_ << "end 2nd iteration init: " << time1 << " (" << time1-time0 << "sec)" << LogIO::POST ;
     403        //time1 = gettimeofday_sec() ;
     404        //os_ << "end 2nd iteration init: " << time1 << " (" << time1-time0 << "sec)" << LogIO::POST ;
    378405        //
    379406        // ITERATION: DATA_DESC_ID
     
    381408        TableIterator iter3( t2, "DATA_DESC_ID" ) ;
    382409        while( !iter3.pastEnd() ) {
    383           time0 = gettimeofday_sec() ;
    384           os_ << "start 3rd iteration: " << time0 << LogIO::POST ;
     410          //time0 = gettimeofday_sec() ;
     411          //os_ << "start 3rd iteration: " << time0 << LogIO::POST ;
    385412          Table t3 = iter3.table() ;
    386413          tcolr = tpoolr->construct( t3, "DATA_DESC_ID" ) ;
     
    393420          Int spwId = tcolr->asInt( ddId ) ;
    394421          tpoolr->destroy( tcolr ) ;
     422          // TODO: This must be updated if writer will be replaced from STWriter to MSWriter
     423          sdh.nif = max( sdh.nif, spwId ) ;
    395424
    396425          // IFNO
     
    410439          if ( sdh.poltype == "" ) sdh.poltype = getPolType( corrtype[0] ) ;
    411440          // source information
    412           MSSource srctabSel( srctab( srctab.col("SOURCE_ID") == srcId && srctab.col("SPECTRAL_WINDOW_ID") == spwId ) ) ;
    413           os_ << "srcId = " << srcId << " spwId = " << spwId << " nrow = " << srctabSel.nrow() << LogIO::POST ;
     441          //os_ << "srcId = " << srcId << ", spwId = " << spwId << LogIO::POST ;
     442          MSSource srctabSel = srctab( srctab.col("SOURCE_ID") == srcId && srctab.col("SPECTRAL_WINDOW_ID") == spwId ) ;
     443          if ( srctabSel.nrow() == 0 ) {
     444            srctabSel = srctab( srctab.col("SOURCE_ID") == srcId && srctab.col("SPECTRAL_WINDOW_ID") == -1 ) ;
     445          }
    414446          tcolr = tpoolr->construct( srctabSel, "NAME" ) ;
    415447          String srcName = tcolr->asString( 0 ) ;
     
    479511            //os_ << "restFreqs = " << restFreqs << LogIO::POST ;
    480512            if ( srctabSel.tableDesc().isColumn( "TRANSITION" ) ) {
    481               tcolr = tpoolr->construct( srctabSel, "TRANSITION" ) ;
    482               transitionName = tcolr->asString( 0 ) ;
    483               tpoolr->destroy( tcolr ) ;
    484               //os_ << "transitionNameCol.nrow() = " << transitionNameCol.nrow() << LogIO::POST ;
     513              ROArrayColumn<String> transitionCol( srctabSel, "TRANSITION" ) ;
     514              if ( transitionCol.isDefined( 0 ) )
     515                transitionName = transitionCol( 0 ) ;
     516              //os_ << "transitionNameCol.nrow() = " << transitionCol.nrow() << LogIO::POST ;
    485517            }
    486518          }
     
    567599
    568600          // for TSYS and TCAL
    569           MSSysCal caltabsel( caltab( caltab.col("ANTENNA_ID") == antenna_ && caltab.col("FEED_ID") == feedId && caltab.col("SPECTRAL_WINDOW_ID") == spwId ).sort("TIME") ) ;
    570           ROScalarMeasColumn<MEpoch> scTimeCol( caltabsel, "TIME" ) ;
    571           Vector<MEpoch> scTime( caltabsel.nrow() ) ;
    572           for ( uInt irow = 0 ; irow < caltabsel.nrow() ; irow++ )
    573             scTime[irow] = scTimeCol( irow ) ;
    574           ROScalarColumn<Double> *scIntervalCol = new ROScalarColumn<Double>( caltabsel, "INTERVAL" ) ;
    575           Vector<Double> scInterval = scIntervalCol->getColumn() ;
    576           delete scIntervalCol ;
    577           ROArrayColumn<Float> scTsysCol( caltabsel, "TSYS" ) ;
    578           time1 = gettimeofday_sec() ;
    579           os_ << "end 3rd iteration init: " << time1 << " (" << time1-time0 << "sec)" << LogIO::POST ;
     601          Vector<MEpoch> scTime ;
     602          Vector<Double> scInterval ;
     603          ROArrayColumn<Float> scTsysCol ;
     604          MSSysCal caltabsel ;
     605          if ( isSysCal_ ) {
     606            caltabsel = caltab( caltab.col("ANTENNA_ID") == antenna_ && caltab.col("FEED_ID") == feedId && caltab.col("SPECTRAL_WINDOW_ID") == spwId ).sort("TIME") ;
     607            ROScalarMeasColumn<MEpoch> scTimeCol( caltabsel, "TIME" ) ;
     608            scTime.resize( caltabsel.nrow() ) ;
     609            for ( uInt irow = 0 ; irow < caltabsel.nrow() ; irow++ )
     610              scTime[irow] = scTimeCol( irow ) ;
     611            ROScalarColumn<Double> *scIntervalCol = new ROScalarColumn<Double>( caltabsel, "INTERVAL" ) ;
     612            scInterval = scIntervalCol->getColumn() ;
     613            delete scIntervalCol ;
     614            scTsysCol.attach( caltabsel, colTsys_ ) ;
     615          }
     616          //time1 = gettimeofday_sec() ;
     617          //os_ << "end 3rd iteration init: " << time1 << " (" << time1-time0 << "sec)" << LogIO::POST ;
    580618          //
    581619          // ITERATION: SCAN_NUMBER
     
    583621          TableIterator iter4( t3, "SCAN_NUMBER" ) ;
    584622          while( !iter4.pastEnd() ) {
    585             time0 = gettimeofday_sec() ;
    586             os_ << "start 4th iteration: " << time0 << LogIO::POST ;
     623            //time0 = gettimeofday_sec() ;
     624            //os_ << "start 4th iteration: " << time0 << LogIO::POST ;
    587625            Table t4 = iter4.table() ;
    588626            tcolr = tpoolr->construct( t4, "SCAN_NUMBER" ) ;
     
    594632            *uintRF = scanNum - 1 ;
    595633
    596             uInt cycle = 0 ;
    597             time1 = gettimeofday_sec() ;
    598             os_ << "end 4th iteration init: " << time1 << " (" << time1-time0 << "sec)" << LogIO::POST ;
     634            //time1 = gettimeofday_sec() ;
     635            //os_ << "end 4th iteration init: " << time1 << " (" << time1-time0 << "sec)" << LogIO::POST ;
    599636            //
    600637            // ITERATION: STATE_ID
     
    602639            TableIterator iter5( t4, "STATE_ID" ) ;
    603640            while( !iter5.pastEnd() ) {
    604               time0 = gettimeofday_sec() ;
    605               os_ << "start 5th iteration: " << time0 << LogIO::POST ;
     641              //time0 = gettimeofday_sec() ;
     642              //os_ << "start 5th iteration: " << time0 << LogIO::POST ;
    606643              Table t5 = iter5.table() ;
    607644              tcolr = tpoolr->construct( t5, "STATE_ID" ) ;
     
    614651
    615652              Int nrow = t5.nrow() ;
    616               time1 = gettimeofday_sec() ;
    617               os_ << "end 5th iteration init: " << time1 << " (" << time1-time0 << "sec)" << LogIO::POST ;
     653              //time1 = gettimeofday_sec() ;
     654              //os_ << "end 5th iteration init: " << time1 << " (" << time1-time0 << "sec)" << LogIO::POST ;
     655
     656              uInt cycle = 0 ;
    618657
    619658              Cube<Float> spArr ;
     
    632671              else if ( isData_ ) {
    633672                spArr.resize( npol, nchan, nrow ) ;
     673                flArr.resize( npol, nchan, nrow ) ;
    634674                ROArrayColumn<Bool> mFlagCol( t5, "FLAG" ) ;
    635675                ROArrayColumn<Complex> mDataCol( t5, "DATA" ) ;
     
    638678                  Matrix<Complex> sp = mDataCol( irow ) ;
    639679                  Matrix<Bool> fl = mFlagCol( irow ) ;
     680                  Matrix<Float> spxy = spArr.xyPlane( irow ) ;
     681                  Matrix<Bool> flxy = flArr.xyPlane( irow ) ;
    640682                  for ( Int ipol = 0 ; ipol < npol ; ipol++ ) {
    641683                    if ( corrtype[ipol] == Stokes::XY || corrtype[ipol] == Stokes::YX
    642684                         || corrtype[ipol] == Stokes::RL || corrtype[ipol] == Stokes::LR ) {
    643685                      if ( !crossOK ) {
    644                         spArr( Slicer(Slice(ipol,1),Slice(0,nchan),Slice(irow,1)) ) = real( sp.row( ipol ) ) ;
    645                         flArr( Slicer(Slice(ipol,1),Slice(0,nchan),Slice(irow,1)) ) = fl.row( ipol ) ;
     686                        spxy.row( ipol ) = real( sp.row( ipol ) ) ;
     687                        flxy.row( ipol ) = fl.row( ipol ) ;
    646688                        if ( corrtype[ipol] == Stokes::XY || corrtype[ipol] == Stokes::RL ) {
    647                           spArr( Slicer(Slice(ipol+1,1),Slice(0,nchan),Slice(irow,1)) ) = imag( sp.row( ipol ) ) ;
    648                           flArr( Slicer(Slice(ipol+1,1),Slice(0,nchan),Slice(irow,1)) ) = fl.row( ipol ) ;
     689                          spxy.row( ipol+1 ) = imag( sp.row( ipol ) ) ;
     690                          flxy.row( ipol+1 ) = fl.row( ipol ) ;
    649691                        }                       
    650692                        else {
    651                           spArr( Slicer(Slice(ipol+1,1),Slice(0,nchan),Slice(irow,1)) ) = imag( conj( sp.row( ipol ) ) ) ;
    652                           flArr( Slicer(Slice(ipol+1,1),Slice(0,nchan),Slice(irow,1)) ) = fl.row( ipol ) ;
     693                          spxy.row( ipol+1 ) = imag( conj( sp.row( ipol ) ) ) ;
     694                          flxy.row( ipol+1 ) = fl.row( ipol ) ;
    653695                        }
     696                        crossOK = True ;
    654697                      }
    655698                    }
    656699                    else {
    657                       spArr( Slicer(Slice(ipol,1),Slice(0,nchan),Slice(irow,1)) ) = real( sp.row( ipol ) ) ;
    658                       flArr( Slicer(Slice(ipol,1),Slice(0,nchan),Slice(irow,1)) ) = fl.row( ipol ) ;
     700                      spxy.row( ipol ) = real( sp.row( ipol ) ) ;
     701                      flxy.row( ipol ) = fl.row( ipol ) ;
    659702                    }
    660703                  }
     
    672715              ROTableColumn *mIntervalCol = tpoolr->construct( t5, "INTERVAL" ) ;
    673716              ROTableColumn *mFlagRowCol = tpoolr->construct( t5, "FLAG_ROW" ) ;
    674               //Vector<Double> sysCalTime( nrow, -1.0 ) ;
    675717              Block<Double> sysCalTime( nrow, -1.0 ) ;
    676718              Block<Int> sysCalIdx( nrow, -1 ) ;
    677719              if ( isSysCal_ ) {
    678                 //getSysCalTime( caltabsel, mTimeB, sysCalTime, sysCalIdx ) ;
    679720                getSysCalTime( scTime, scInterval, mTimeB, sysCalTime, sysCalIdx ) ;
    680721              }
    681722              delete mTimeCol ;
    682723              Matrix<Float> defaulttsys( npol, 1, 1.0 ) ;
    683               //uInt calidx = 0 ;
    684724              Int srcType = getSrcType( stateId, tpoolr ) ;
    685               Vector<Double> defaultScanrate( 2, 0.0 ) ;
    686725              uInt diridx = 0 ;
    687726              MDirection::Types dirType ;
     
    720759
    721760                // SPECTRA, FLAG
    722                 //Matrix<Float> sp = mFloatDataCol( irow ) ;
    723                 //Matrix<Bool> flb = mFlagCol( irow ) ;
    724761                Matrix<Float> sp = spArr.xyPlane( irow ) ;
    725762                Matrix<Bool> flb = flArr.xyPlane( irow ) ;
     
    728765
    729766                // TIME
    730                 *timeRF = mTimeB[irow].get("s").getValue() ;
     767                *timeRF = mTimeB[irow].get("d").getValue() ;
    731768
    732769                // INTERVAL
     
    735772                // TSYS
    736773                Matrix<Float> tsys ;
    737                 //calidx = getTsys( calidx, tsys, caltabsel, sysCalTime[irow] ) ;
    738 //                 calidx = getTsys( calidx, tsys, scTsysCol, scTime, sysCalTime[irow] ) ;
    739 //                 if ( tsys.nelements() == 0 )
    740 //                   tsys = defaulttsys ;
    741774                if ( sysCalIdx[irow] != -1 )
    742775                  tsys = scTsysCol( irow ) ;
     
    745778
    746779                // TCAL_ID
    747                 Block<uInt> tcalids = getTcalId( feedId, spwId, sysCalTime[irow] ) ;
    748                 if ( tcalids.size() == 0 ) {
    749                   tcalids.resize( npol ) ;
    750                   tcalids = 0 ;
     780                Block<uInt> tcalids( npol, 0 ) ;
     781                if ( sysCalIdx[irow] != -1 ) {
     782                  tcalids = getTcalId( feedId, spwId, scTime[sysCalIdx[irow]] ) ;
    751783                }
    752784
     
    798830                else {
    799831                  String ref = md.getRefString() ;
    800                   Vector<Double> defaultDir = srcDir ;
     832                  //Vector<Double> defaultDir = srcDir ;
    801833                  MDirection::getType( dirType, "J2000" ) ;
    802834                  if ( ref != "J2000" ) {
     
    829861                  row.put( stab.nrow()-1 ) ;
    830862                }
     863
     864                cycle++ ;
    831865              }
    832               //delete mTimeCol ;
    833866              tpoolr->destroy( mIntervalCol ) ;
    834867              tpoolr->destroy( mFlagRowCol ) ;
    835868
    836               time1 = gettimeofday_sec() ;
    837               os_ << "end 5th iteration: " << time1 << " (" << time1-time0 << "sec)" << LogIO::POST ;
     869              //time1 = gettimeofday_sec() ;
     870              //os_ << "end 5th iteration: " << time1 << " (" << time1-time0 << "sec)" << LogIO::POST ;
    838871
    839872              iter5.next() ;
     
    865898
    866899  // Table Keywords
    867   sdh.nif = ifmap.size() ;
     900  // TODO: This must be updated if writer will be replaced from STWriter to MSWriter
     901//   sdh.nif = ifmap.size() ;
     902  sdh.nif++ ;
    868903  if ( ( telescopeName == "" ) || ( antennaName == telescopeName ) ) {
    869904    sdh.antennaname = antennaName ;
     
    910945    stab.rwKeywordSet().define( "GBT_GO", goTabName ) ;
    911946  }
    912   double endSec = gettimeofday_sec() ;
    913   os_ << "end MSFiller::fill() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
     947//   double endSec = gettimeofday_sec() ;
     948//   os_ << "end MSFiller::fill() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
    914949}
    915950
     
    924959Int MSFiller::getSrcType( Int stateId, boost::object_pool<ROTableColumn> *tpool )
    925960{
    926   double startSec = gettimeofday_sec() ;
    927   os_ << "start MSFiller::getSrcType() startSec=" << startSec << LogIO::POST ;
     961//   double startSec = gettimeofday_sec() ;
     962//   os_ << "start MSFiller::getSrcType() startSec=" << startSec << LogIO::POST ;
    928963
    929964  MSState statetab = mstable_.state() ;
     
    10311066   
    10321067  //os_ << "srcType = " << srcType << LogIO::POST ;
    1033   double endSec = gettimeofday_sec() ;
    1034   os_ << "end MSFiller::getSrcType() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
     1068//   double endSec = gettimeofday_sec() ;
     1069//   os_ << "end MSFiller::getSrcType() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
    10351070  return srcType ;
    10361071}
     
    10391074Block<uInt> MSFiller::getPolNo( Int corrType )
    10401075{
    1041   double startSec = gettimeofday_sec() ;
    1042   os_ << "start MSFiller::getPolNo() startSec=" << startSec << LogIO::POST ;
     1076//   double startSec = gettimeofday_sec() ;
     1077//   os_ << "start MSFiller::getPolNo() startSec=" << startSec << LogIO::POST ;
    10431078  Block<uInt> polno( 1 ) ;
    10441079
     
    10701105  }
    10711106  //os_ << "polno = " << polno << LogIO::POST ;
    1072   double endSec = gettimeofday_sec() ;
    1073   os_ << "end MSFiller::getPolNo() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
     1107//   double endSec = gettimeofday_sec() ;
     1108//   os_ << "end MSFiller::getPolNo() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
    10741109 
    10751110  return polno ;
     
    10781113String MSFiller::getPolType( Int corrType )
    10791114{
    1080   double startSec = gettimeofday_sec() ;
    1081   os_ << "start MSFiller::getPolType() startSec=" << startSec << LogIO::POST ;
     1115//   double startSec = gettimeofday_sec() ;
     1116//   os_ << "start MSFiller::getPolType() startSec=" << startSec << LogIO::POST ;
    10821117  String poltype = "" ;
    10831118
     
    10911126    poltype = "linpol" ;
    10921127
    1093   double endSec = gettimeofday_sec() ;
    1094   os_ << "end MSFiller::getPolType() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
     1128//   double endSec = gettimeofday_sec() ;
     1129//   os_ << "end MSFiller::getPolType() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
    10951130  return poltype ;
    10961131}
     
    10981133void MSFiller::fillWeather()
    10991134{
    1100   double startSec = gettimeofday_sec() ;
    1101   os_ << "start MSFiller::fillWeather() startSec=" << startSec << LogIO::POST ;
     1135//   double startSec = gettimeofday_sec() ;
     1136//   os_ << "start MSFiller::fillWeather() startSec=" << startSec << LogIO::POST ;
     1137
     1138  if ( !isWeather_ ) {
     1139    // add dummy row
     1140    table_->weather().table().addRow(1,True) ;
     1141    return ;
     1142  }
     1143
    11021144  Table mWeather = mstable_.weather()  ;
    11031145  //Table mWeatherSel = mWeather( mWeather.col("ANTENNA_ID") == antenna_ ).sort("TIME") ;
     
    11741216    mwInterval_ *= 86400.0 ;
    11751217  //os_ << "mwTime[0] = " << mwTime_[0] << " mwInterval[0] = " << mwInterval_[0] << LogIO::POST ;
    1176   double endSec = gettimeofday_sec() ;
    1177   os_ << "end MSFiller::fillWeather() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
     1218//   double endSec = gettimeofday_sec() ;
     1219//   os_ << "end MSFiller::fillWeather() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
    11781220}
    11791221
    11801222void MSFiller::fillFocus()
    11811223{
    1182   double startSec = gettimeofday_sec() ;
    1183   os_ << "start MSFiller::fillFocus() startSec=" << startSec << LogIO::POST ;
     1224//   double startSec = gettimeofday_sec() ;
     1225//   os_ << "start MSFiller::fillFocus() startSec=" << startSec << LogIO::POST ;
    11841226  // tentative
    11851227  Table tab = table_->focus().table() ;
     
    11871229  ScalarColumn<uInt> idCol( tab, "ID" ) ;
    11881230  idCol.put( 0, 0 ) ;
    1189   double endSec = gettimeofday_sec() ;
    1190   os_ << "end MSFiller::fillFocus() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
     1231//   double endSec = gettimeofday_sec() ;
     1232//   os_ << "end MSFiller::fillFocus() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
    11911233}
    11921234
    11931235void MSFiller::fillTcal( boost::object_pool<ROTableColumn> *tpoolr )
    11941236{
    1195   double startSec = gettimeofday_sec() ;
    1196   os_ << "start MSFiller::fillTcal() startSec=" << startSec << LogIO::POST ;
     1237//   double startSec = gettimeofday_sec() ;
     1238//   os_ << "start MSFiller::fillTcal() startSec=" << startSec << LogIO::POST ;
     1239
     1240  if ( !isSysCal_ ) {
     1241    // add dummy row
     1242    os_ << "No SysCal rows" << LogIO::POST ;
     1243    table_->tcal().table().addRow(1,True) ;
     1244    return ;
     1245  }
    11971246
    11981247  Table sctab = mstable_.sysCal() ;
     
    12641313
    12651314  //tcalrec_.print( std::cout ) ;
    1266   double endSec = gettimeofday_sec() ;
    1267   os_ << "end MSFiller::fillTcal() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
     1315//   double endSec = gettimeofday_sec() ;
     1316//   os_ << "end MSFiller::fillTcal() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
    12681317}
    12691318
    12701319uInt MSFiller::getWeatherId( uInt idx, Double wtime )
    12711320{
    1272   double startSec = gettimeofday_sec() ;
    1273   os_ << "start MSFiller::getWeatherId() startSec=" << startSec << LogIO::POST ;
     1321//   double startSec = gettimeofday_sec() ;
     1322//   os_ << "start MSFiller::getWeatherId() startSec=" << startSec << LogIO::POST ;
    12741323  uInt nrow = mwTime_.size() ;
    12751324  if ( nrow == 0 )
     
    13001349  //os_ << LogIO::WARN << "Couldn't find correct WEATHER_ID for time " << wtime << LogIO::POST ;
    13011350
    1302   double endSec = gettimeofday_sec() ;
    1303   os_ << "end MSFiller::getWeatherId() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
     1351//   double endSec = gettimeofday_sec() ;
     1352//   os_ << "end MSFiller::getWeatherId() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
    13041353  return wid ;
    13051354}
     
    13071356void MSFiller::getSysCalTime( Vector<MEpoch> &scTime, Vector<Double> &scInterval, Block<MEpoch> &tcol, Block<Double> &tstr, Block<Int> &tidx )
    13081357{
    1309   double startSec = gettimeofday_sec() ;
    1310   os_ << "start MSFiller::getSysCalTime() startSec=" << startSec << LogIO::POST ;
     1358//   double startSec = gettimeofday_sec() ;
     1359//   os_ << "start MSFiller::getSysCalTime() startSec=" << startSec << LogIO::POST ;
     1360
     1361  if ( !isSysCal_ )
     1362    return ;
     1363
    13111364  uInt nrow = tstr.nelements() ;
    13121365  if ( scTime.nelements() == 0 )
     
    13211374  for ( uInt i = 0 ; i < nrow ; i++ ) {
    13221375    Double t = tcol[i].get( "s" ).getValue() ;
    1323     os_ << "getSysCalTime()  irow = " << i << " idx = " << idx << LogIO::POST ;
    13241376    for ( uInt j = idx ; j < scnrow-1 ; j++ ) {
    13251377      Double tsc1 = scTime[j].get( "s" ).getValue() ;
     
    13431395    }
    13441396  }
    1345   double endSec = gettimeofday_sec() ;
    1346   os_ << "end MSFiller::getSysCalTime() endSec=" << endSec << " (" << endSec-startSec << "sec) scnrow = " << scnrow << " tcol.nelements = " << tcol.nelements() << LogIO::POST ;
     1397//   double endSec = gettimeofday_sec() ;
     1398//   os_ << "end MSFiller::getSysCalTime() endSec=" << endSec << " (" << endSec-startSec << "sec) scnrow = " << scnrow << " tcol.nelements = " << tcol.nelements() << LogIO::POST ;
    13471399  return ;
    13481400}
    13491401
    1350 // uInt MSFiller::getTsys( uInt idx, Matrix<Float> &tsys, ROArrayColumn<Float> &mTsysCol, Block<MEpoch> &scTimeCol, Double t )
    1351 // {
     1402Block<uInt> MSFiller::getTcalId( Int fid, Int spwid, MEpoch &t )
     1403{
    13521404//   double startSec = gettimeofday_sec() ;
    1353 //   os_ << "start MSFiller::getTsys() startSec=" << startSec << LogIO::POST ;
    1354 //   uInt nrow = mTsysCol.nrow() ;
    1355 //   if ( nrow == 0 ) {
    1356 //     os_ << "No SysCal rows" << LogIO::POST ;
    1357 //     tsys.resize( IPosition(0) ) ;
    1358 //     return 0 ;
    1359 //   }
    1360 //   for ( uInt i = idx ; i < nrow ; i++ ) {
    1361 //     Double tref = scTimeCol[i].get("s").getValue() ;
    1362 //     if ( t == tref ) {
    1363 //       tsys.reference( mTsysCol( i ) ) ;
    1364 //       idx = i ;
    1365 //       break ;
    1366 //     }
    1367 //   }
    1368 //   //os_ << "MSFiller::getTsys() idx = " << idx << " tsys = " << tsys << LogIO::POST ;
    1369 //   double endSec = gettimeofday_sec() ;
    1370 //   os_ << "end MSFiller::getTsys() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
    1371 //   return idx ;
    1372 // }
    1373 
    1374 Block<uInt> MSFiller::getTcalId( Int fid, Int spwid, Double t )
    1375 {
    1376   double startSec = gettimeofday_sec() ;
    1377   os_ << "start MSFiller::getTcalId() startSec=" << startSec << LogIO::POST ;
    1378   if ( table_->tcal().table().nrow() == 0 ) {
     1405//   os_ << "start MSFiller::getTcalId() startSec=" << startSec << LogIO::POST ;
     1406  //if ( table_->tcal().table().nrow() == 0 ) {
     1407  if ( !isSysCal_ ) {
    13791408    os_ << "No TCAL rows" << LogIO::POST ;
    13801409    Block<uInt> tcalids( 0 ) ;
    13811410    return  tcalids ;
    13821411  }   
    1383   String sctime = MVTime( Quantum<Double>(t,"s") ).string(MVTime::YMD) ;
     1412  //String sctime = MVTime( Quantum<Double>(t,"s") ).string(MVTime::YMD) ;
     1413  String sctime = MVTime( t.getValue() ).string(MVTime::YMD) ;
    13841414  String key = keyTcal( fid, spwid, sctime ) ;
    13851415  if ( !tcalrec_.isDefined( key ) ) {
     
    13961426    tcalids[ipol] = ids[0] + ipol - 1 ;
    13971427
    1398   double endSec = gettimeofday_sec() ;
    1399   os_ << "end MSFiller::getTcalId() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
     1428//   double endSec = gettimeofday_sec() ;
     1429//   os_ << "end MSFiller::getTcalId() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
    14001430  return tcalids ;
    14011431}
     
    14031433uInt MSFiller::getDirection( uInt idx, Vector<Double> &dir, Vector<Double> &srate, String &ref, MSPointing &tab, Double t )
    14041434{
    1405   double startSec = gettimeofday_sec() ;
    1406   os_ << "start MSFiller::getDirection() startSec=" << startSec << LogIO::POST ;
     1435//   double startSec = gettimeofday_sec() ;
     1436//   os_ << "start MSFiller::getDirection() startSec=" << startSec << LogIO::POST ;
    14071437  // assume that cols is sorted by TIME
    14081438  Bool doInterp = False ;
     
    14171447  if ( idx == 0 ) {
    14181448    uInt nrowb = 75000 ;
    1419     if ( nrow > nblock ) {
     1449    if ( nrow > nrowb ) {
    14201450      uInt nblock = nrow / nrowb + 1 ;
    14211451      for ( uInt iblock = 0 ; iblock < nblock ; iblock++ ) {
    1422         uInt high = min( nblock, nrow-iblock*nblock ) ;
     1452        uInt high = min( nrowb, nrow-iblock*nrowb ) ;
    14231453
    14241454        if ( tcol( high-1 ).get( "s" ).getValue() < t ) {
    1425           idx = iblock * nblock ;
     1455          idx = iblock * nrowb ;
    14261456          continue ;
    14271457        }
     
    14291459        Vector<MEpoch> tarr( high ) ;
    14301460        for ( uInt irow = 0 ; irow < high ; irow++ ) {
    1431           tarr[irow] = tcol( iblock*nblock+irow ) ;
     1461          tarr[irow] = tcol( iblock*nrowb+irow ) ;
    14321462        }
    14331463
    14341464        uInt bidx = binarySearch( tarr, t ) ;
    14351465
    1436         idx = iblock * nblock + bidx ;
     1466        idx = iblock * nrowb + bidx ;
    14371467        break ;
    14381468      }
     
    15101540  }
    15111541
    1512   double endSec = gettimeofday_sec() ;
    1513   os_ << "end MSFiller::getDirection() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
     1542//   double endSec = gettimeofday_sec() ;
     1543//   os_ << "end MSFiller::getDirection() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
    15141544  return idx ;
    15151545}
  • trunk/src/MSFiller.h

    r2003 r2004  
    8686  void getSysCalTime( casa::Vector<casa::MEpoch> &scTimeIn, casa::Vector<casa::Double> &scInterval, casa::Block<casa::MEpoch> &tcol, casa::Block<casa::Double> &scTimeOut, casa::Block<casa::Int> &tidx ) ;
    8787
    88   // get tsys by time stamp
    89   // assume that tab is selected by ANTENNA_ID, FEED_ID, SPECTRAL_WINDOW_ID
    90   // and sorted by TIME
    91 //   casa::uInt getTsys( casa::uInt idx, casa::Matrix<casa::Float> &tsys, casa::ROArrayColumn<casa::Float> &tsysCol, casa::Block<casa::MEpoch> &scTime, casa::Double t ) ;
    92 
    9388  // get TCAL_ID
    94   casa::Block<casa::uInt> getTcalId( casa::Int feedId, casa::Int spwId, casa::Double t ) ;
     89  casa::Block<casa::uInt> getTcalId( casa::Int feedId, casa::Int spwId, casa::MEpoch &t ) ;
    9590
    9691  // get direction for DIRECTION, AZIMUTH, and ELEVATION columns
  • trunk/src/STMath.cpp

    r1967 r2004  
    10471047      if ( tcal <= 0.0 ) {
    10481048        caloff->tcal().getEntry(tcalt, tcalout, tcalId);
    1049         if (polno<=3) {
    1050           tcalUsed = tcalout[polno];
    1051         }
     1049//         if (polno<=3) {
     1050//           tcalUsed = tcalout[polno];
     1051//         }
     1052//         else {
     1053//           tcalUsed = tcalout[0];
     1054//         }
     1055        if ( tcalout.size() == 1 )
     1056          tcalUsed = tcalout[0] ;
     1057        else if ( tcalout.size() == nchan )
     1058          tcalUsed = mean(tcalout) ;
    10521059        else {
    1053           tcalUsed = tcalout[0];
     1060          uInt ipol = polno ;
     1061          if ( ipol > 3 ) ipol = 0 ;
     1062          tcalUsed = tcalout[ipol] ;
    10541063        }
    10551064      }
  • trunk/src/STWriter.cpp

    r1819 r2004  
    228228          inst->molecules().getEntry(pksrec.restFreq,stmp0,stmp1,
    229229                                   rec.asuInt("MOLECULE_ID"));
    230           inst->tcal().getEntry(pksrec.tcalTime, pksrec.tcal,
    231                               rec.asuInt("TCAL_ID"));
     230//           inst->tcal().getEntry(pksrec.tcalTime, pksrec.tcal,
     231//                               rec.asuInt("TCAL_ID"));
    232232          inst->weather().getEntry(pksrec.temperature, pksrec.pressure,
    233233                                 pksrec.humidity, pksrec.windSpeed,
     
    240240          // dummy data
    241241          uInt npol = pksrec.spectra.ncolumn();
     242
     243          // TCAL
     244          inst->tcal().getEntry( pksrec.tcalTime, pksrec.tcal,
     245                                 rec.asuInt("TCAL_ID") ) ;
     246          if ( pksrec.tcal.nelements() == 1 ) {
     247            ROScalarColumn<uInt> uintCol( itable, "TCAL_ID" ) ;
     248            Vector<uInt> tcalids = uintCol.getColumn() ;
     249            pksrec.tcal.resize( npol ) ;
     250            Vector<Float> dummyA ;
     251            String dummyS ;
     252            for ( uInt ipol = 0 ; ipol < npol ; ipol++ ) {
     253              inst->tcal().getEntry( dummyS, dummyA, tcalids[ipol] ) ;
     254              pksrec.tcal[ipol] = dummyA[0] ;
     255            }
     256          }
     257          else if ( pksrec.tcal.nelements() == nchan ) {
     258            ROScalarColumn<uInt> uintCol( itable, "TCAL_ID" ) ;
     259            Vector<uInt> tcalids = uintCol.getColumn() ;
     260            pksrec.tcal.resize( npol ) ;
     261            Vector<Float> dummyA ;
     262            String dummyS ;
     263            for ( uInt ipol = 0 ; ipol < npol ; ipol++ ) {
     264              inst->tcal().getEntry( dummyS, dummyA, tcalids[ipol] ) ;
     265              pksrec.tcal[ipol] = mean( dummyA ) ;
     266            }
     267          }
     268          //LogIO os ;
     269          //os << "npol = " << npol << " pksrec.tcal = " << pksrec.tcal << LogIO::POST ;
    242270
    243271          pksrec.mjd       = rec.asDouble("TIME");
Note: See TracChangeset for help on using the changeset viewer.