Changeset 2019


Ignore:
Timestamp:
03/01/11 17:13:36 (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...

Bug fix

1) supporting variable shaped array input to some column (SPECTRAL DATA, TSYS, and TCAL)

2) put [1.0] instead of empty array as default TCAL in NROFiller

3) Check if some subtables have any effective rows in MSWriter


Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/MSFiller.cpp

    r2017 r2019  
    849849                  *polnoRF = polnos[ipol] ;
    850850
    851                   *spRF = sp.row( ipol ) ;
    852                   *ucarrRF = fl.row( ipol ) ;
    853                   *tsysRF = tsys.row( ipol ) ;
     851                  //*spRF = sp.row( ipol ) ;
     852                  //*ucarrRF = fl.row( ipol ) ;
     853                  //*tsysRF = tsys.row( ipol ) ;
     854                  spRF.define( sp.row( ipol ) ) ;
     855                  ucarrRF.define( fl.row( ipol ) ) ;
     856                  tsysRF.define( tsys.row( ipol ) ) ;
    854857                  *tcalidRF = tcalids[ipol] ;
    855858
     
    12881291        for ( uInt ipol = 0 ; ipol < npol ; ipol++ ) {
    12891292          *idRF = idx++ ;
    1290           *tcalRF = subtcal.row( ipol ) ;
     1293          //*tcalRF = subtcal.row( ipol ) ;
     1294          tcalRF.define( subtcal.row( ipol ) ) ;
    12911295
    12921296          // commit row
     
    13191323//   os_ << "start MSFiller::getWeatherId() startSec=" << startSec << LogIO::POST ;
    13201324  uInt nrow = mwTime_.size() ;
    1321   if ( nrow == 0 )
     1325  if ( nrow < 2 )
    13221326    return 0 ;
    13231327  uInt wid = nrow ;
     
    13621366  if ( scTime.nelements() == 0 )
    13631367    return ;
     1368  else if ( scTime.nelements() == 1 ) {
     1369    tidx[0] = 0 ;
     1370    return ;
     1371  }
    13641372  uInt scnrow = scTime.nelements() ;
    13651373  uInt idx = 0 ;
  • trunk/src/MSWriter.cpp

    r2018 r2019  
    5858MSWriter::MSWriter(CountedPtr<Scantable> stable)
    5959  : table_(stable),
     60    isTcal_(False),
     61    isWeather_(False),
     62    tcalSpec_(False),
     63    tsysSpec_(False),
    6064    ptTabName_("")
    6165{
     
    134138
    135139  // WEATHER
    136   fillWeather() ;
     140  if ( isWeather_ )
     141    fillWeather() ;
    137142
    138143  // MAIN
     
    304309            TableIterator iter5( t4, cols ) ;
    305310            while( !iter5.pastEnd() ) {
    306               Table t5 =  iter5.table()  ;
     311              Table t5 =  iter5.table().sort("POLNO") ;
    307312              //sharedCol.attach( t5, "CYCLENO" ) ;
    308313              //uInt cycleNo = sharedCol.asuInt( 0 ) ;
     
    324329                Matrix<Float> dataArr( cellshape ) ;
    325330                Matrix<Bool> flagArr( cellshape ) ;
    326                 Vector<uChar> tmpUC ;
    327331                Vector<Bool> tmpB ;
    328332                for ( Int ipol = 0 ; ipol < nrow ; ipol++ ) {
    329333                  dataArr.row( ipol ) = specCol( ipol ) ;
    330                   tmpUC = flagCol( ipol ) ;
    331                   tmpB = flagArr.row( ipol ) ;
    332                   convertArray( tmpB, tmpUC ) ;
     334                  tmpB.reference( flagArr.row( ipol ) ) ;
     335                  convertArray( tmpB, flagCol( ipol ) ) ;
    333336                }
    334                 *(*((RecordFieldPtr< Array<Float> > *)dataRF)) = dataArr ;
     337                //*(*((RecordFieldPtr< Array<Float> > *)dataRF)) = dataArr ;
     338                ((RecordFieldPtr< Array<Float> > *)dataRF)->define( dataArr ) ;
    335339               
    336340                // FLAG
    337                 *flagRF = flagArr ;
     341                //*flagRF = flagArr ;
     342                flagRF.define( flagArr ) ;
    338343              }
    339344              else if ( useData_ ) {
     
    352357                dataArr.row( 1 ) = RealToComplex( dummy ) ;
    353358                dataArr.row( 2 ) = conj( dataArr.row( 1 ) ) ;
    354                 *(*((RecordFieldPtr< Array<Complex> > *)dataRF)) = dataArr ;
     359                //*(*((RecordFieldPtr< Array<Complex> > *)dataRF)) = dataArr ;
     360                ((RecordFieldPtr< Array<Complex> > *)dataRF)->define( dataArr ) ;
    355361               
    356362               
    357363                // FLAG
    358364                Matrix<Bool> flagArr( cellshape ) ;
    359                 Matrix<uChar> tmpUC = flagCol( 0 ) ;
    360                 Matrix<Bool> tmpB = flagArr.row( 0 ) ;
    361                 convertArray( tmpB, tmpUC ) ;
    362                 tmpUC = flagCol( 3 ) ;
    363                 tmpB = flagArr.row( 3 ) ;
    364                 convertArray( tmpB, tmpUC ) ;
    365                 tmpUC = flagCol( 2 ) | flagCol( 3 ) ;
    366                 tmpB = flagArr.row( 1 ) ;
    367                 convertArray( tmpB, tmpUC ) ;
    368                 tmpB = flagArr.row( 2 ) ;
    369                 convertArray( tmpB, tmpUC ) ;
    370                 *flagRF = flagArr ;
     365                Vector<Bool> tmpB ;
     366                tmpB.reference( flagArr.row( 0 ) ) ;
     367                convertArray( tmpB, flagCol( 0 ) ) ;
     368                tmpB.reference( flagArr.row( 3 ) ) ;
     369                convertArray( tmpB, flagCol( 3 ) ) ;
     370                tmpB.reference( flagArr.row( 1 ) ) ;
     371                convertArray( tmpB, ( flagCol( 2 ) | flagCol( 3 ) ) ) ;
     372                flagArr.row( 2 ) = flagArr.row( 1 ) ;
     373                //*flagRF = flagArr ;
     374                flagRF.define( flagArr ) ;
    371375              }
    372              
     376
    373377              // FLAG_ROW
    374378//               tcol = tpoolr->construct( t5, "FLAGROW" ) ;
     
    380384//               tpoolr->destroy( tcol ) ;
    381385              *flagrowRF = anyNE( flagRowArr, (uInt)0 ) ;
    382              
     386
    383387              // TIME and TIME_CENTROID
    384388//               tcol = tpoolr->construct( t5, "TIME" ) ;
     
    389393              *timeRF = mTimeV ;
    390394              *timecRF = mTimeV ;
    391              
     395
    392396              // INTERVAL and EXPOSURE
    393397//               tcol = tpoolr->construct( t5, "INTERVAL" ) ;
     
    452456              // FLAG_CATEGORY is tentatively set
    453457              RecordFieldPtr< Array<Bool> > flagcatRF( trec, "FLAG_CATEGORY" ) ;
    454               *flagcatRF = Cube<Bool>( nrow, nchan, 1, False ) ;
     458              //*flagcatRF = Cube<Bool>( nrow, nchan, 1, False ) ;
     459              flagcatRF.define( Cube<Bool>( nrow, nchan, 1, False ) ) ;
    455460             
    456461              // add row
     
    494499
    495500  // SYSCAL
    496   fillSysCal() ;
     501  if ( isTcal_ )
     502    fillSysCal() ;
    497503
    498504  // replace POINTING table with original one if exists
     
    544550    polType_ = "notype" ;
    545551
     552  // Check if some subtables are exists
     553  if ( table_->tcal().table().nrow() != 0 ) {
     554    ROTableColumn col( table_->tcal().table(), "TCAL" ) ;
     555    if ( col.isDefined( 0 ) ) {
     556      os_ << "nrow=" << table_->tcal().table().nrow() << ": TCAL table exists" << LogIO::POST ;
     557      isTcal_ = True ;
     558    }
     559    else {
     560      os_ << "no TCAL rows" << LogIO::POST ;
     561    }
     562  }
     563  else {
     564    os_ << "no TCAL rows" << LogIO::POST ;
     565  }
     566  if ( table_->weather().table().nrow() != 0 ) {
     567    ROTableColumn col( table_->weather().table(), "TEMPERATURE" ) ;
     568    if ( col.isDefined( 0 ) ) {
     569      os_ << "nrow=" << table_->weather().table().nrow() << ": WEATHER table exists" << LogIO::POST ;
     570      isWeather_ =True ;
     571    }
     572    else {
     573      os_ << "no WEATHER rows" << LogIO::POST ;
     574    }
     575  }
     576  else {
     577    os_ << "no WEATHER rows" << LogIO::POST ;
     578  }
     579
    546580  // Are TCAL_SPECTRUM and TSYS_SPECTRUM necessary?
    547   tcalSpec_ = False ;
    548   tsysSpec_ = False ;
    549   if ( header_.nchan != 1 ) {
     581  if ( isTcal_ && header_.nchan != 1 ) {
    550582    // examine TCAL subtable
    551583    Table tcaltab = table_->tcal().table() ;
     
    859891
    860892      // TRANSITION
    861       *transitionRF = fMolName ;
     893      //*transitionRF = fMolName ;
     894      Vector<String> transition ;
     895      if ( fMolName.size() != 0 ) {
     896        transition = fMolName ;
     897      }
     898      else if ( molName.size() != 0 ) {
     899        transition = molName ;
     900      }
     901      else {
     902        transition.resize( numFreq ) ;
     903        transition = "" ;
     904      }
     905      *transitionRF = transition ;
    862906
    863907      // SYSVEL
     
    11291173    if ( tcalSpec_ ) {
    11301174      // put TCAL_SPECTRUM
    1131       *tcalspRF = tcal ;
     1175      //*tcalspRF = tcal ;
     1176      tcalspRF.define( tcal ) ;
    11321177      // set TCAL (mean of TCAL_SPECTRUM)
    11331178      Matrix<Float> tcalMean( npol, 1 ) ;
     
    11451190    if ( tsysSpec_ ) {
    11461191      // put TSYS_SPECTRUM
    1147       *tsysspRF = tsys ;
     1192      //*tsysspRF = tsys ;
     1193      tsysspRF.define( tsys ) ;
    11481194      // set TSYS (mean of TSYS_SPECTRUM)
    11491195      Matrix<Float> tsysMean( npol, 1 ) ;
     
    13421388  // only 1 POLARIZATION row for 1 scantable
    13431389  if ( nrow > 0 )
    1344     return 1 ;
     1390    return 0 ;
    13451391 
    13461392  Vector<Int> corrType = toCorrType( polnos ) ;
  • trunk/src/MSWriter.h

    r2018 r2019  
    9191  casa::MeasurementSet *mstable_ ;
    9292
     93  casa::Bool isTcal_ ;
     94  casa::Bool isWeather_ ;
     95
    9396  casa::Bool useFloatData_ ;
    9497  casa::Bool useData_ ;
  • trunk/src/NROFiller.cpp

    r1904 r2019  
    2121#include "STHeader.h"
    2222#include <casa/Containers/Record.h>
     23#include <casa/Quanta/MVTime.h>
    2324#include <atnf/PKSIO/SrcType.h>
    2425
     
    122123  STHeader header = table_->getHeader() ;
    123124  String obsType = header.obstype.substr( 0, 3 ) ;
     125  Vector<Float> defaultTcal( 1, 1.0 ) ;
     126  String tcalTime = MVTime( header.utc ).string( MVTime::YMD ) ;
    124127  for ( Int irow = 0 ; irow < (Int)nRow ; irow++ ) {
    125128    // check scan intent
     
    198201    // TCAL subtable row
    199202    // use default since NRO input is calibrated data
    200     setTcal() ;
     203    setTcal( tcalTime, defaultTcal ) ;
    201204   
    202205
Note: See TracChangeset for help on using the changeset viewer.