Changeset 2033 for trunk/src


Ignore:
Timestamp:
03/10/11 03:01:49 (14 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...

Fixed seg fault that happens when no corresponding rows in SOURCE table
for specified SPECTRAL_WINDOW_ID.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/MSFiller.cpp

    r2028 r2033  
    449449          if ( sdh.poltype == "" ) sdh.poltype = getPolType( corrtype[0] ) ;
    450450          // source information
    451           //os_ << "srcId = " << srcId << ", spwId = " << spwId << LogIO::POST ;
     451//           os_ << "srcId = " << srcId << ", spwId = " << spwId << LogIO::POST ;
    452452          MSSource srctabSel = srctab( srctab.col("SOURCE_ID") == srcId && srctab.col("SPECTRAL_WINDOW_ID") == spwId ) ;
    453453          if ( srctabSel.nrow() == 0 ) {
    454454            srctabSel = srctab( srctab.col("SOURCE_ID") == srcId && srctab.col("SPECTRAL_WINDOW_ID") == -1 ) ;
    455455          }
    456           tcolr = tpoolr->construct( srctabSel, "NAME" ) ;
    457           String srcName = tcolr->asString( 0 ) ;
    458           tpoolr->destroy( tcolr ) ;
     456          String srcName( "" ) ;
     457          Vector<Double> srcPM( 2, 0.0 ) ;
     458          Vector<Double> srcDir( 2, 0.0 ) ;
     459          MDirection md ;
     460          Int numLines = 0 ;
     461          ROArrayColumn<Double> *roArrDCol = 0 ;
     462          if ( srctabSel.nrow() > 0 ) {
     463            // source name
     464            tcolr = tpoolr->construct( srctabSel, "NAME" ) ;
     465            srcName = tcolr->asString( 0 ) ;
     466            tpoolr->destroy( tcolr ) ;
     467
     468            // source proper motion
     469            roArrDCol = new ROArrayColumn<Double>( srctabSel, "PROPER_MOTION" ) ;
     470            srcPM = (*roArrDCol)( 0 ) ;
     471            delete roArrDCol ;
     472           
     473            // source direction
     474            roArrDCol = new ROArrayColumn<Double>( srctabSel, "DIRECTION" ) ;
     475            srcDir = (*roArrDCol)( 0 ) ;
     476            delete roArrDCol ;
     477
     478            // source direction as MDirection object
     479            ROScalarMeasColumn<MDirection> *tmpMeasCol = new ROScalarMeasColumn<MDirection>( srctabSel, "DIRECTION" ) ;
     480            md = (*tmpMeasCol)( 0 ) ;
     481            delete tmpMeasCol ;
     482
     483            // number of lines
     484            tcolr = tpoolr->construct( srctabSel, "NUM_LINES" ) ;
     485            Int numLines = tcolr->asInt( 0 ) ;
     486            tpoolr->destroy( tcolr ) ;
     487
     488          }
     489          else {
     490            md = MDirection( Quantum<Double>(0.0,Unit("rad")), Quantum<Double>(0.0,Unit("rad")) ) ;
     491          }
    459492
    460493          // SRCNAME
     
    462495          *strRF = srcName ;
    463496
    464           //os_ << "srcName = " << srcName << LogIO::POST ;
    465           ROArrayColumn<Double> *roArrDCol = new ROArrayColumn<Double>( srctabSel, "PROPER_MOTION" ) ;
    466           Array<Double> srcPM = (*roArrDCol)( 0 ) ;
    467           delete roArrDCol ;
     497//           os_ << "srcName = " << srcName << LogIO::POST ;
    468498
    469499          // SRCPROPERMOTION
     
    472502
    473503          //os_ << "srcPM = " << srcPM << LogIO::POST ;
    474           roArrDCol = new ROArrayColumn<Double>( srctabSel, "DIRECTION" ) ;
    475           Array<Double> srcDir = (*roArrDCol)( 0 ) ;
    476           delete roArrDCol ;
    477504
    478505          // SRCDIRECTION
     
    481508
    482509          //os_ << "srcDir = " << srcDir << LogIO::POST ;
    483           ROScalarMeasColumn<MDirection> *tmpMeasCol = new ROScalarMeasColumn<MDirection>( srctabSel, "DIRECTION" ) ;
    484           MDirection md = (*tmpMeasCol)( 0 ) ;
    485           delete tmpMeasCol ;
    486510
    487511          // for MOLECULES subtable
    488           tcolr = tpoolr->construct( srctabSel, "NUM_LINES" ) ;
    489           Int numLines = tcolr->asInt( 0 ) ;
    490           tpoolr->destroy( tcolr ) ;
    491512//           os_ << "numLines = " << numLines << LogIO::POST ;
    492513
     
    504525              }
    505526            }
    506             //os_ << "restFreqs = " << restFreqs << LogIO::POST ;
     527//             os_ << "restFreqs = " << restFreqs << LogIO::POST ;
    507528            if ( srctabSel.tableDesc().isColumn( "TRANSITION" ) ) {
    508529              ROArrayColumn<String> transitionCol( srctabSel, "TRANSITION" ) ;
     
    573594          Double increment = (*sharedQDArrCol)( spwId )( refip ).getValue( "Hz" ) ;
    574595          delete sharedQDArrCol ;
    575           //os_ << "nchan = " << nchan << " refchan = " << refchan << "(even=" << even << ") refpix = " << refpix << LogIO::POST ;
     596//           os_ << "nchan = " << nchan << " refchan = " << refchan << "(even=" << even << ") refpix = " << refpix << LogIO::POST ;
    576597          sharedQDArrCol = new ROArrayQuantColumn<Double>( spwtab, "CHAN_FREQ" ) ;
    577598          Vector< Quantum<Double> > chanFreqs = (*sharedQDArrCol)( spwId ) ;
     
    652673            TableIterator iter5( t4, "STATE_ID" ) ;
    653674            while( !iter5.pastEnd() ) {
    654               //time0 = gettimeofday_sec() ;
    655               //os_ << "start 5th iteration: " << time0 << LogIO::POST ;
     675//               time0 = gettimeofday_sec() ;
     676//               os_ << "start 5th iteration: " << time0 << LogIO::POST ;
    656677              Table t5 = iter5.table() ;
    657678              tcolr = tpoolr->construct( t5, "STATE_ID" ) ;
     
    664685
    665686              Int nrow = t5.nrow() ;
    666               //time1 = gettimeofday_sec() ;
    667               //os_ << "end 5th iteration init: " << time1 << " (" << time1-time0 << "sec)" << LogIO::POST ;
     687//               time1 = gettimeofday_sec() ;
     688//               os_ << "end 5th iteration init: " << time1 << " (" << time1-time0 << "sec)" << LogIO::POST ;
    668689
    669690              uInt cycle = 0 ;
     
    882903              tpoolr->destroy( mFlagRowCol ) ;
    883904
    884               //time1 = gettimeofday_sec() ;
    885               //os_ << "end 5th iteration: " << time1 << " (" << time1-time0 << "sec)" << LogIO::POST ;
     905//               time1 = gettimeofday_sec() ;
     906//               os_ << "end 5th iteration: " << time1 << " (" << time1-time0 << "sec)" << LogIO::POST ;
    886907
    887908              iter5.next() ;
Note: See TracChangeset for help on using the changeset viewer.