Changeset 2018


Ignore:
Timestamp:
02/28/11 19:41:13 (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...

Performance of fillSysCal() greatly improved.


Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/MSWriter.cpp

    r2016 r2018  
    420420              os_ << "tcalIdArr = " << tcalIdArr << LogIO::POST ;
    421421              String key = String::toString( tcalIdArr[0] ) ;
    422               if ( !tcalIdRec_.isDefined( key ) ) //{
     422              if ( !tcalIdRec_.isDefined( key ) ) {
    423423                tcalIdRec_.define( key, tcalIdArr ) ;
    424 //                 tcalRowRec_.define( key, t5.rowNumbers() ) ;
    425 //               }
    426 //               else {
    427 //                 Vector<uInt> pastrows = tcalRowRec_.asArrayuInt( key ) ;
    428 //                 tcalRowRec_.define( concatenateArray( pastrows, t5.rowNumbers() ) ) ;
    429 //               }
     424                tcalRowRec_.define( key, t5.rowNumbers() ) ;
     425              }
     426              else {
     427                Vector<uInt> pastrows = tcalRowRec_.asArrayuInt( key ) ;
     428                tcalRowRec_.define( key, concatenateArray( pastrows, t5.rowNumbers() ) ) ;
     429              }
    430430             
    431431              // fill STATE_ID
     
    981981
    982982  // access to MAIN table
    983 //   Table tab = table_->table() ;
    984   Block<String> cols( 5 ) ;
     983  Block<String> cols( 6 ) ;
    985984  cols[0] = "TIME" ;
    986985  cols[1] = "TCAL_ID" ;
     
    988987  cols[3] = "BEAMNO" ;
    989988  cols[4] = "IFNO" ;
     989  cols[5] = "INTERVAL" ;
    990990  Table tab = table_->table().project( cols ) ;
    991991
     
    994994
    995995  nrow = tcalIdRec_.nfields() ;
    996 
    997   os_ << "fillSysCal() nrow = " << nrow << LogIO::POST ;
    998996
    999997  Double midTime ;
     
    10241022  ROArrayColumn<Float> tcalCol( sortedstt, "TCAL" ) ;
    10251023  ROTableColumn idCol( sortedstt, "ID" ) ;
    1026   ROArrayColumn<Float> tsysCol ;
    1027   //Block<Bool> rowmask( tab.nrow(), True ) ;
    1028   //Table tab2 = tab( rowmask ) ;
     1024  ROArrayColumn<Float> tsysCol( tab, "TSYS" ) ;
     1025  ROTableColumn tcalidCol( tab, "TCAL_ID" ) ;
     1026  ROTableColumn timeCol( tab, "TIME" ) ;
     1027  ROTableColumn intervalCol( tab, "INTERVAL" ) ;
     1028  ROTableColumn beamnoCol( tab, "BEAMNO" ) ;
     1029  ROTableColumn ifnoCol( tab, "IFNO" ) ;
    10291030  for ( uInt irow = 0 ; irow < nrow ; irow++ ) {
    10301031    double t1 = gettimeofday_sec() ;
     
    10321033    os_ << "ids = " << ids << LogIO::POST ;
    10331034    uInt npol = ids.size() ;
    1034     Table tsel = tab( tab.col("TCAL_ID").in(ids) ) ;
    1035     //Table tsel = tab( tab.col("TCAL_ID").in(ids) ).sort( "TCAL_ID" ) ;
    1036     //Table tsel = tab2( tab2.col("TCAL_ID").in(ids) ).sort( "TCAL_ID" ) ;
    1037     uInt nrowsel = tsel.nrow() ;
    1038     //Vector<uInt> selectedcols = tsel.rowNumbers() ;
    1039     Vector<uInt> selectedcols = tsel.rowNumbers( tab, True ) ;
    1040     os_ << "selectedcols = " << selectedcols << LogIO::POST ;
    1041     Block<Bool> rowmask( tab.nrow(), True ) ;
    1042     for ( uInt icol = 0 ; icol < selectedcols.nelements() ; icol++ )
    1043       rowmask[selectedcols[icol]] = False ;
    1044     //tab2 = tab( rowmask ) ;
    1045     tab = tab( rowmask ) ;
    1046     os_ << "tab.nrow() = " << tab.nrow() << LogIO::POST ;
    1047     tsel = tsel.sort( "TCAL_ID" ) ;
     1035    Vector<uInt> rows = tcalRowRec_.asArrayuInt( irow ) ;
     1036    os_ << "rows = " << rows << LogIO::POST ;
     1037    Vector<Double> atime( rows.nelements() ) ;
     1038    Vector<Double> ainterval( rows.nelements() ) ;
     1039    Vector<uInt> atcalid( rows.nelements() ) ;
     1040    for( uInt jrow = 0 ; jrow < rows.nelements() ; jrow++ ) {
     1041      atime[jrow] = (Double)timeCol.asdouble( rows[jrow] ) ;
     1042      ainterval[jrow] = (Double)intervalCol.asdouble( rows[jrow] ) ;
     1043      atcalid[jrow] = tcalidCol.asuInt( rows[jrow] ) ;
     1044    }
     1045    Vector<Float> dummy = tsysCol( rows[0] ) ;
     1046    Matrix<Float> tsys( npol,dummy.nelements() ) ;
     1047    tsys.row( 0 ) = dummy ;
     1048    for ( uInt jrow = 1 ; jrow < npol ; jrow++ )
     1049      tsys.row( jrow ) = tsysCol( rows[jrow] ) ;
    10481050
    10491051    // FEED_ID
    1050     ROScalarColumn<uInt> uintCol( tsel, "BEAMNO" ) ;
    1051     *feedRF = uintCol( 0 ) ;
     1052    *feedRF = beamnoCol.asuInt( rows[0] ) ;
    10521053
    10531054    // SPECTRAL_WINDOW_ID
    1054     uintCol.attach( tsel, "IFNO" ) ;
    1055     *spwRF = uintCol( 0 ) ;
     1055    *spwRF = ifnoCol.asuInt( rows[0] ) ;
    10561056
    10571057    // TIME and INTERVAL
    1058     Table tsel1 = tsel( tsel.col("TCAL_ID") == ids[0] ) ;
    1059     os_ << "tsel.nrow = " << tsel.nrow() << " tsel1.nrow = " << tsel1.nrow() << LogIO::POST ;
    1060     getValidTimeRange( midTime, interval, tsel1 ) ;
     1058    getValidTimeRange( midTime, interval, atime, ainterval ) ;
    10611059    *timeRF = midTime ;
    10621060    *intervalRF = interval ;
     
    10781076      tcal.row( 0 ) = dummyC ;
    10791077    }
    1080     tsysCol.attach( tsel, "TSYS" ) ;
    1081     Vector<Float> dummyS = tsysCol( 0 ) ;
    1082     Matrix<Float> tsys( npol, dummyS.size() ) ;
    1083     tsys.row( 0 ) = dummyS ;
    1084     // get TSYS and TCAL
    10851078    if ( npol == 2 ) {
    10861079      if ( idCol.asuInt( ids[1] ) == ids[1] ) {
     
    10941087        tcal.row( 1 ) = tcalCol( 1 ) ;
    10951088      }
    1096       tsys.row( 1 ) = tsysCol( nrowsel-1 ) ;
    10971089    }
    10981090    else if ( npol == 3 ) {
     
    11111103        tcal.row( 2 ) = tcalCol( 0 ) ;
    11121104      }
    1113       tsys.row( 1 ) = tsysCol( nrowsel/npol ) ;
    1114       tsys.row( 2 ) = tsysCol( nrowsel-1 ) ;
    11151105    }
    11161106    else if ( npol == 4 ) {
     
    11361126        tcal.row( 3 ) = tcalCol( 0 ) ;
    11371127      }
    1138       tsys.row( 1 ) = tsysCol( nrowsel/3 ) ;
    1139       tsys.row( 2 ) = tsys.row( 1 ) ;
    1140       tsys.row( 3 ) = tsysCol( nrowsel-1 ) ;
    11411128    }
    11421129    if ( tcalSpec_ ) {
     
    16391626}
    16401627
     1628void MSWriter::getValidTimeRange( Double &me, Double &interval, Vector<Double> &atime, Vector<Double> &ainterval )
     1629{
     1630  double startSec = gettimeofday_sec() ;
     1631  os_ << "start MSWriter::getVaridTimeRange() startSec=" << startSec << LogIO::POST ;
     1632
     1633  // sort table
     1634  //Table stab = tab.sort( "TIME" ) ;
     1635
     1636  Double minTime ;
     1637  Double maxTime ;
     1638  minMax( minTime, maxTime, atime ) ;
     1639  Double midTime = 0.5 * ( minTime + maxTime ) * 86400.0 ;
     1640  // unit for TIME
     1641  // Scantable: "d"
     1642  // MS: "s"
     1643  me = midTime ;
     1644  interval = ( maxTime - minTime ) * 86400.0 ;
     1645
     1646  double endSec = gettimeofday_sec() ;
     1647  os_ << "end MSWriter::getValidTimeRange() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
     1648}
     1649
    16411650//void MSWriter::queryType( Int type, String &stype, Bool &b )
    16421651void MSWriter::queryType( Int type, String &stype, Bool &b, Double &t, Double &l )
  • trunk/src/MSWriter.h

    r2016 r2018  
    7979  casa::Vector<casa::Int> toCorrType( casa::Vector<casa::Int> polnos ) ;
    8080  void getValidTimeRange( casa::Double &me, casa::Double &interval, casa::Table &tab ) ;
     81  void getValidTimeRange( casa::Double &me, casa::Double &interval, casa::Vector<casa::Double> &atime, casa::Vector<casa::Double> &ainterval ) ;
    8182  //void queryType( casa::Int type, casa::String &stype, casa::Bool &b ) ;
    8283  void queryType( casa::Int type, casa::String &stype, casa::Bool &b, casa::Double &t, Double &l ) ;
Note: See TracChangeset for help on using the changeset viewer.