- Timestamp:
- 02/21/11 16:09:55 (14 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/MSFiller.cpp
r2002 r2003 569 569 MSSysCal caltabsel( caltab( caltab.col("ANTENNA_ID") == antenna_ && caltab.col("FEED_ID") == feedId && caltab.col("SPECTRAL_WINDOW_ID") == spwId ).sort("TIME") ) ; 570 570 ROScalarMeasColumn<MEpoch> scTimeCol( caltabsel, "TIME" ) ; 571 Block<MEpoch> scTime( caltabsel.nrow() ) ;571 Vector<MEpoch> scTime( caltabsel.nrow() ) ; 572 572 for ( uInt irow = 0 ; irow < caltabsel.nrow() ; irow++ ) 573 573 scTime[irow] = scTimeCol( irow ) ; … … 1305 1305 } 1306 1306 1307 void MSFiller::getSysCalTime( Block<MEpoch> &scTime, Vector<Double> &scInterval, Block<MEpoch> &tcol, Block<Double> &tstr, Block<Int> &tidx )1307 void MSFiller::getSysCalTime( Vector<MEpoch> &scTime, Vector<Double> &scInterval, Block<MEpoch> &tcol, Block<Double> &tstr, Block<Int> &tidx ) 1308 1308 { 1309 1309 double startSec = gettimeofday_sec() ; … … 1315 1315 uInt idx = 0 ; 1316 1316 const Double half = 0.5e0 ; 1317 // execute binary search 1318 idx = binarySearch( scTime, tcol[0].get( "s" ).getValue() ) ; 1319 if ( idx != 0 ) 1320 idx -= 1 ; 1317 1321 for ( uInt i = 0 ; i < nrow ; i++ ) { 1318 1322 Double t = tcol[i].get( "s" ).getValue() ; … … 1340 1344 } 1341 1345 double endSec = gettimeofday_sec() ; 1342 os_ << "end MSFiller::getSysCalTime() endSec=" << endSec << " (" << endSec-startSec << "sec) scnrow = " << scnrow << " tcol.nelements()= " << tcol.nelements() << LogIO::POST ;1346 os_ << "end MSFiller::getSysCalTime() endSec=" << endSec << " (" << endSec-startSec << "sec) scnrow = " << scnrow << " tcol.nelements = " << tcol.nelements() << LogIO::POST ; 1343 1347 return ; 1344 1348 } … … 1410 1414 ROArrayMeasColumn<MDirection> dmcol( tab, "DIRECTION" ) ; 1411 1415 ROArrayColumn<Double> dcol( tab, "DIRECTION" ) ; 1416 // binary search if idx == 0 1417 if ( idx == 0 ) { 1418 uInt nrowb = 75000 ; 1419 if ( nrow > nblock ) { 1420 uInt nblock = nrow / nrowb + 1 ; 1421 for ( uInt iblock = 0 ; iblock < nblock ; iblock++ ) { 1422 uInt high = min( nblock, nrow-iblock*nblock ) ; 1423 1424 if ( tcol( high-1 ).get( "s" ).getValue() < t ) { 1425 idx = iblock * nblock ; 1426 continue ; 1427 } 1428 1429 Vector<MEpoch> tarr( high ) ; 1430 for ( uInt irow = 0 ; irow < high ; irow++ ) { 1431 tarr[irow] = tcol( iblock*nblock+irow ) ; 1432 } 1433 1434 uInt bidx = binarySearch( tarr, t ) ; 1435 1436 idx = iblock * nblock + bidx ; 1437 break ; 1438 } 1439 } 1440 else { 1441 Vector<MEpoch> tarr( nrow ) ; 1442 for ( uInt irow = 0 ; irow < nrow ; irow++ ) { 1443 tarr[irow] = tcol( irow ) ; 1444 } 1445 idx = binarySearch( tarr, t ) ; 1446 } 1447 } 1412 1448 // ensure that tcol(idx) < t 1413 1449 //os_ << "tcol(idx) = " << tcol(idx).get("s").getValue() << " t = " << t << " diff = " << tcol(idx).get("s").getValue()-t << endl ; … … 1486 1522 } 1487 1523 1524 uInt MSFiller::binarySearch( Vector<MEpoch> &timeList, Double target ) 1525 { 1526 Int low = 0 ; 1527 Int high = timeList.nelements() ; 1528 uInt idx = 0 ; 1529 1530 while ( low <= high ) { 1531 idx = (Int)( 0.5 * ( low + high ) ) ; 1532 Double t = timeList[idx].get( "s" ).getValue() ; 1533 if ( t < target ) 1534 low = idx + 1 ; 1535 else if ( t > target ) 1536 high = idx - 1 ; 1537 else 1538 return idx ; 1539 } 1540 1541 idx = max( 0, min( low, high ) ) ; 1542 1543 return idx ; 1544 1545 } 1546 1488 1547 } ; 1489 1548 -
trunk/src/MSFiller.h
r2002 r2003 84 84 // assume that tab is selected by ANTENNA_ID, FEED_ID, SPECTRAL_WINDOW_ID 85 85 // and sorted by TIME 86 void getSysCalTime( casa:: Block<casa::MEpoch> &scTimeIn, casa::Vector<casa::Double> &scInterval, casa::Block<casa::MEpoch> &tcol, casa::Block<casa::Double> &scTimeOut, casa::Block<casa::Int> &tidx ) ;86 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 ) ; 87 87 88 88 // get tsys by time stamp … … 99 99 // create key for TCAL table 100 100 casa::String keyTcal( casa::Int feedid, casa::Int spwid, casa::String stime ) ; 101 102 // binary search 103 casa::uInt binarySearch( casa::Vector<casa::MEpoch> &timeList, casa::Double target ) ; 101 104 102 105 casa::CountedPtr<Scantable> table_ ;
Note:
See TracChangeset
for help on using the changeset viewer.