Changeset 1988
- Timestamp:
- 02/03/11 20:46:00 (14 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/MSFiller.cpp
r1987 r1988 49 49 #include "MSFiller.h" 50 50 #include "STHeader.h" 51 52 #include <ctime> 53 #include <sys/time.h> 54 55 double gettimeofday_sec() 56 { 57 struct timeval tv ; 58 gettimeofday( &tv, NULL ) ; 59 return tv.tv_sec + (double)tv.tv_usec*1.0e-6 ; 60 } 51 61 52 62 using namespace casa ; … … 81 91 { 82 92 os_.origin( LogOrigin( "MSFiller", "open()", WHERE ) ) ; 83 //os_ << "start MSFiller::open()" << LogIO::POST ; 93 //double startSec = gettimeofday_sec() ; 94 //os_ << "start MSFiller::open() startsec=" << startSec << LogIO::POST ; 84 95 //os_ << " filename = " << filename << endl ; 85 96 … … 123 134 isData_ = mstable_.tableDesc().isColumn( "DATA" ) ; 124 135 125 //os_ << "end MSFiller::open()" << LogIO::POST ; 136 //double endSec = gettimeofday_sec() ; 137 //os_ << "end MSFiller::open() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ; 126 138 return true ; 127 139 } … … 130 142 { 131 143 os_.origin( LogOrigin( "MSFiller", "fill()", WHERE ) ) ; 132 //os_ << "start MSFiller::fill()" << LogIO::POST ; 144 //double startSec = gettimeofday_sec() ; 145 //os_ << "start MSFiller::fill() startSec=" << startSec << LogIO::POST ; 133 146 134 147 // Initialize header … … 198 211 // SUBTABLES: TCAL 199 212 if ( isSysCal_ ) 200 fillTcal( tpoolr ) ;213 fillTcal( tpoolr, tpoolw ) ; 201 214 202 215 // SUBTABLES: FIT … … 832 845 833 846 //os_ << "field: " << fieldId << " scan: " << scanNum << " obs: " << obsId << " state: " << stateId << " ddid: " << ddId << endl ; 834 //os_ << "addednr = " << addednr << endl ;847 os_ << "addednr = " << addednr << endl ; 835 848 added5 += addednr ; 836 849 iter5.next() ; … … 845 858 scannoCol->putScalar( irow, (uInt)scanNum ) ; 846 859 847 //os_ << "added5 = " << added5 << endl ;860 os_ << "added5 = " << added5 << endl ; 848 861 added4 += added5 ; 849 862 iter4.next() ; … … 878 891 srcvelCol->putScalar( irow, sysVel ) ; 879 892 880 //os_ << "added4 = " << added4 << endl ;893 os_ << "added4 = " << added4 << endl ; 881 894 added3 += added4 ; 882 895 iter3.next() ; … … 888 901 fieldnameCol->putScalar( irow, fieldName ) ; 889 902 890 //os_ << "added3 = " << added3 << endl ;903 os_ << "added3 = " << added3 << endl ; 891 904 added2 += added3 ; 892 905 iter2.next() ; … … 904 917 focusidCol->putScalar( irow, focusId ) ; 905 918 906 //os_ << "added2 = " << added2 << endl ;919 os_ << "added2 = " << added2 << endl ; 907 920 added1 += added2 ; 908 921 iter1.next() ; … … 910 923 if ( sdh.nbeam < nbeam ) sdh.nbeam = nbeam ; 911 924 912 //os_ << "added1 = " << added1 << endl ;925 os_ << "added1 = " << added1 << endl ; 913 926 added0 += added1 ; 914 927 iter0.next() ; 915 928 } 916 929 917 //os_ << "added0 = " << added0 << endl ;930 os_ << "added0 = " << added0 << endl ; 918 931 919 932 // REFBEAMNO … … 1016 1029 table_->table().rwKeywordSet().define( "GBT_GO", goTabName ) ; 1017 1030 } 1018 //os_ << "end MSFiller::fill()" << LogIO::POST ; 1031 //double endSec = gettimeofday_sec() ; 1032 //os_ << "end MSFiller::fill() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ; 1019 1033 } 1020 1034 … … 1029 1043 Int MSFiller::getSrcType( Int stateId, boost::object_pool<ROTableColumn> *tpool ) 1030 1044 { 1031 //os_ << "start MSFiller::getSrcType()" << LogIO::POST ; 1045 //double startSec = gettimeofday_sec() ; 1046 //os_ << "start MSFiller::getSrcType() startSec=" << startSec << LogIO::POST ; 1032 1047 1033 1048 MSState statetab = mstable_.state() ; … … 1135 1150 1136 1151 //os_ << "srcType = " << srcType << LogIO::POST ; 1137 //os_ << "end MSFiller::getSrcType()" << LogIO::POST ; 1152 //double endSec = gettimeofday_sec() ; 1153 //os_ << "end MSFiller::getSrcType() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ; 1138 1154 return srcType ; 1139 1155 } … … 1141 1157 Vector<uInt> MSFiller::getPolNo( Int corrType ) 1142 1158 { 1143 //os_ << "start MSFiller::getPolNo()" << LogIO::POST ; 1159 //double startSec = gettimeofday_sec() ; 1160 //os_ << "start MSFiller::getPolNo() startSec=" << startSec << LogIO::POST ; 1144 1161 Vector<uInt> polno( 1 ) ; 1145 1162 … … 1171 1188 } 1172 1189 //os_ << "polno = " << polno << LogIO::POST ; 1173 //os_ << "end MSFiller::getPolNo()" << LogIO::POST ; 1190 //double endSec = gettimeofday_sec() ; 1191 //os_ << "end MSFiller::getPolNo() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ; 1174 1192 1175 1193 return polno ; … … 1178 1196 String MSFiller::getPolType( Int corrType ) 1179 1197 { 1180 //os_ << "start MSFiller::getPolType()" << LogIO::POST ; 1198 //double startSec = gettimeofday_sec() ; 1199 //os_ << "start MSFiller::getPolType() startSec=" << startSec << LogIO::POST ; 1181 1200 String poltype = "" ; 1182 1201 … … 1190 1209 poltype = "linpol" ; 1191 1210 1192 //os_ << "end MSFiller::getPolType()" << LogIO::POST ; 1211 //double endSec = gettimeofday_sec() ; 1212 //os_ << "end MSFiller::getPolType() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ; 1193 1213 return poltype ; 1194 1214 } … … 1196 1216 void MSFiller::fillWeather() 1197 1217 { 1198 //os_ << "start MSFiller::fillWeather()" << LogIO::POST ; 1218 //double startSec = gettimeofday_sec() ; 1219 //os_ << "start MSFiller::fillWeather() startSec=" << startSec << LogIO::POST ; 1199 1220 Table mWeather = mstable_.weather() ; 1200 1221 //Table mWeatherSel = mWeather( mWeather.col("ANTENNA_ID") == antenna_ ).sort("TIME") ; … … 1271 1292 mwInterval_ *= 86400.0 ; 1272 1293 //os_ << "mwTime[0] = " << mwTime_[0] << " mwInterval[0] = " << mwInterval_[0] << LogIO::POST ; 1273 //os_ << "end MSFiller::fillWeather()" << LogIO::POST ; 1294 //double endSec = gettimeofday_sec() ; 1295 //os_ << "end MSFiller::fillWeather() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ; 1274 1296 } 1275 1297 1276 1298 void MSFiller::fillFocus() 1277 1299 { 1278 //os_ << "start MSFiller::fillFocus()" << LogIO::POST ; 1300 //double startSec = gettimeofday_sec() ; 1301 //os_ << "start MSFiller::fillFocus() startSec=" << startSec << LogIO::POST ; 1279 1302 // tentative 1280 1303 Table tab = table_->focus().table() ; … … 1282 1305 ScalarColumn<uInt> idCol( tab, "ID" ) ; 1283 1306 idCol.put( 0, 0 ) ; 1284 //os_ << "end MSFiller::fillFocus()" << LogIO::POST ; 1307 //double endSec = gettimeofday_sec() ; 1308 //os_ << "end MSFiller::fillFocus() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ; 1285 1309 } 1286 1310 1287 void MSFiller::fillTcal( boost::object_pool<ROTableColumn> *tpool ) 1311 void MSFiller::fillTcal( boost::object_pool<ROTableColumn> *tpoolr, 1312 boost::object_pool<TableColumn> *tpoolw ) 1288 1313 { 1289 //os_ << "start MSFiller::fillTcal()" << LogIO::POST ; 1314 //double startSec = gettimeofday_sec() ; 1315 //os_ << "start MSFiller::fillTcal() startSec=" << startSec << LogIO::POST ; 1290 1316 1291 1317 //MSSysCal sctab = mstable_.sysCal() ; … … 1296 1322 } 1297 1323 Bool isSp = sctab.tableDesc().isColumn( "TCAL_SPECTRUM" ) ; 1298 //MSSysCal sctabsel = sctab( sctab.col("ANTENNA_ID") == antenna_ ) ;1299 1324 //Table sctabsel = sctab( sctab.col("ANTENNA_ID") == antenna_ ) ; 1300 1325 Table sctabsel( sctab( sctab.col("ANTENNA_ID") == antenna_ ) ) ; … … 1308 1333 //os_ << "fillTcal(): npol = " << npol << LogIO::POST ; 1309 1334 Table tab = table_->tcal().table() ; 1310 ScalarColumn<uInt> idCol( tab, "ID" ) ;1311 ScalarColumn<String> timeCol( tab, "TIME" ) ;1335 TableColumn *idCol = tpoolw->construct( tab, "ID" ) ; 1336 TableColumn *timeCol = tpoolw->construct( tab, "TIME" ) ; 1312 1337 ArrayColumn<Float> tcalCol( tab, "TCAL" ) ; 1313 1338 ROTableColumn *sharedCol ; 1339 ROArrayColumn<Float> scTcalCol ; 1314 1340 uInt oldnr = 0 ; 1315 1341 uInt newnr = 0 ; … … 1317 1343 while( !iter0.pastEnd() ) { 1318 1344 Table t0 = iter0.table() ; 1319 sharedCol = tpool ->construct( t0, "FEED_ID" ) ;1345 sharedCol = tpoolr->construct( t0, "FEED_ID" ) ; 1320 1346 Int feedId = sharedCol->asInt( 0 ) ; 1321 tpool ->destroy( sharedCol ) ;1347 tpoolr->destroy( sharedCol ) ; 1322 1348 String ffield = "FEED" + String::toString( feedId ) ; 1323 Record rec;1349 //Record rec0 ; 1324 1350 TableIterator iter1( t0, "SPECTRAL_WINDOW_ID" ) ; 1325 1351 while( !iter1.pastEnd() ) { 1326 MSSysCal t1( iter1.table().sort("TIME") ) ; 1327 uInt nrow = t1.nrow() ; 1328 sharedCol = tpool->construct( t1, "SPECTRAL_WINDOW_ID" ) ; 1352 Table t1 = iter1.table() ; 1353 sharedCol = tpoolr->construct( t1, "SPECTRAL_WINDOW_ID" ) ; 1329 1354 Int spwId = sharedCol->asInt( 0 ) ; 1330 tpool ->destroy( sharedCol ) ;1355 tpoolr->destroy( sharedCol ) ; 1331 1356 String spwfield = "SPW" + String::toString( spwId ) ; 1332 ROScalarQuantColumn<Double> scTimeCol( t1, "TIME" ) ; 1333 ROArrayColumn<Float> scTcalCol ; 1334 IPosition newShape( 2, 1, nrow ) ; 1335 if ( isSp ) { 1336 scTcalCol.attach( t1, "TCAL_SPECTRUM" ) ; 1337 newShape[0] = scTcalCol.shape(0)(1) ; 1357 //Record rec1 ; 1358 TableIterator iter2( t1, "TIME" ) ; 1359 while( !iter2.pastEnd() ) { 1360 Table t2 = iter2.table() ; 1361 uInt nrow = t2.nrow() ; // must be 1 1362 //os_ << "fillTcal::t2.nrow = " << nrow << LogIO::POST ; 1363 ROScalarQuantColumn<Double> scTimeCol( t2, "TIME" ) ; 1364 IPosition newShape( 2, 1, nrow ) ; 1365 if ( isSp ) { 1366 scTcalCol.attach( t2, "TCAL_SPECTRUM" ) ; 1367 newShape[0] = scTcalCol.shape(0)(1) ; 1368 } 1369 else { 1370 scTcalCol.attach( t1, "TCAL" ) ; 1371 } 1372 tab.addRow( nrow*npol ) ; 1373 newnr += nrow*npol ; 1374 String sTime = MVTime( scTimeCol(0) ).string( MVTime::YMD ) ; 1375 for ( uInt ipol = 0 ; ipol < npol ; ipol++ ) { 1376 timeCol->putScalar( oldnr+ipol, sTime ) ; 1377 } 1378 uInt idx = oldnr ; 1379 for ( uInt ipol = 0 ; ipol < npol ; ipol++ ) { 1380 idCol->putScalar( oldnr+ipol, idx++ ) ; 1381 } 1382 Vector<uInt> idminmax( 2, oldnr ) ; 1383 Matrix<Float> subtcal = scTcalCol( 0 ) ; 1384 for ( uInt ipol = 0 ; ipol < npol ; ipol++ ) { 1385 tcalCol.put( oldnr+ipol, subtcal.row( ipol ) ) ; 1386 } 1387 idminmax[1] = newnr - 1 ; 1388 oldnr = newnr ; 1389 1390 String key = ffield+":"+spwfield+":"+sTime ; 1391 tcalrec_.define( key, idminmax ) ; 1392 //rec1.define( sTime, idminmax ) ; 1393 iter2++ ; 1338 1394 } 1339 else { 1340 scTcalCol.attach( t1, "TCAL" ) ; 1341 } 1342 tab.addRow( nrow*npol ) ; 1343 newnr += nrow*npol ; 1344 for ( uInt irow = 0 ; irow < nrow ; irow++ ) { 1345 String sTime = MVTime( scTimeCol(irow) ).string( MVTime::YMD ) ; 1346 for ( uInt ipol = 0 ; ipol < npol ; ipol++ ) { 1347 timeCol.put( oldnr+irow+ipol*nrow, sTime ) ; 1348 } 1349 } 1350 uInt idx = oldnr ; 1351 for ( uInt ipol = 0 ; ipol < npol ; ipol++ ) { 1352 for ( uInt irow = 0 ; irow < nrow ; irow++ ) { 1353 idCol.put( oldnr+ipol*nrow+irow, idx++ ) ; 1354 } 1355 } 1356 Vector<uInt> idminmax( 2, oldnr ) ; 1357 for ( uInt irow = 0 ; irow < nrow ; irow++ ) { 1358 Matrix<Float> subtcal = scTcalCol( irow ) ; 1359 for ( uInt ipol = 0 ; ipol < npol ; ipol++ ) { 1360 tcalCol.put( oldnr+ipol*nrow+irow, subtcal.row( ipol ) ) ; 1361 } 1362 } 1363 idminmax[1] = newnr - 1 ; 1364 oldnr = newnr ; 1365 rec.define( spwfield, idminmax ) ; 1395 //rec0.defineRecord( spwfield, rec1 ) ; 1366 1396 iter1++ ; 1367 1397 } 1368 tcalrec_.defineRecord( ffield, rec) ;1398 //tcalrec_.defineRecord( ffield, rec0 ) ; 1369 1399 iter0++ ; 1370 1400 } 1371 1401 1402 tpoolw->destroy( idCol ) ; 1403 tpoolw->destroy( timeCol ) ; 1372 1404 1373 1405 //tcalrec_.print( std::cout ) ; 1374 //os_ << "end MSFiller::fillFocus()" << LogIO::POST ; 1406 //double endSec = gettimeofday_sec() ; 1407 //os_ << "end MSFiller::fillTcal() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ; 1375 1408 } 1376 1409 1377 1410 uInt MSFiller::getWeatherId( uInt idx, Double wtime ) 1378 1411 { 1379 //os_ << "start MSFiller::getWeatherId()" << LogIO::POST ; 1412 //double startSec = gettimeofday_sec() ; 1413 //os_ << "start MSFiller::getWeatherId() startSec=" << startSec << LogIO::POST ; 1380 1414 uInt nrow = mwTime_.size() ; 1381 1415 if ( nrow == 0 ) … … 1406 1440 //os_ << LogIO::WARN << "Couldn't find correct WEATHER_ID for time " << wtime << LogIO::POST ; 1407 1441 1408 //os_ << "end MSFiller::getWeatherId()" << LogIO::POST ; 1442 //double endSec = gettimeofday_sec() ; 1443 //os_ << "end MSFiller::getWeatherId() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ; 1409 1444 return wid ; 1410 1445 } … … 1412 1447 Vector<Double> MSFiller::getSysCalTime( MSSysCal &tab, MEpoch::ROScalarColumn &tcol ) 1413 1448 { 1414 //os_ << "start MSFiller::getSysCalTime()" << LogIO::POST ; 1449 //double startSec = gettimeofday_sec() ; 1450 //os_ << "start MSFiller::getSysCalTime() startSec=" << startSec << LogIO::POST ; 1415 1451 uInt nrow = tcol.table().nrow() ; 1416 1452 Vector<Double> tstr( nrow, -1.0 ) ; … … 1442 1478 } 1443 1479 } 1444 //os_ << "end MSFiller::getSysCalTime()" << LogIO::POST ; 1480 //double endSec = gettimeofday_sec() ; 1481 //os_ << "end MSFiller::getSysCalTime() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ; 1445 1482 return tstr ; 1446 1483 } … … 1448 1485 uInt MSFiller::getTsys( uInt idx, Matrix<Float> &tsys, MSSysCal &tab, Double t ) 1449 1486 { 1450 //os_ << "start MSFiller::getTsys()" << LogIO::POST ; 1487 //double startSec = gettimeofday_sec() ; 1488 //os_ << "start MSFiller::getTsys() startSec=" << startSec << LogIO::POST ; 1451 1489 uInt nrow = tab.nrow() ; 1452 1490 if ( nrow == 0 ) { … … 1473 1511 } 1474 1512 //os_ << "MSFiller::getTsys() idx = " << idx << " tsys = " << tsys << LogIO::POST ; 1475 //os_ << "end MSFiller::getTsys()" << LogIO::POST ; 1513 //double endSec = gettimeofday_sec() ; 1514 //os_ << "end MSFiller::getTsys() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ; 1476 1515 return idx ; 1477 1516 } … … 1479 1518 Vector<uInt> MSFiller::getTcalId( Int fid, Int spwid, Double t ) 1480 1519 { 1481 //os_ << "start MSFiller::getTcalId()" << LogIO::POST ; 1520 //double startSec = gettimeofday_sec() ; 1521 //os_ << "start MSFiller::getTcalId() startSec=" << startSec << LogIO::POST ; 1522 if ( table_->tcal().table().nrow() == 0 ) { 1523 os_ << "No TCAL rows" << LogIO::POST ; 1524 Vector<uInt> tcalids( 0 ) ; 1525 return tcalids ; 1526 } 1482 1527 String feed = "FEED" + String::toString(fid) ; 1483 1528 String spw = "SPW" + String::toString(spwid) ; 1484 1529 String sctime = MVTime( Quantum<Double>(t,"s") ).string(MVTime::YMD) ; 1485 Table ttab = table_->tcal().table() ; 1486 if ( ttab.nrow() == 0 ) { 1530 String key = feed + ":" + spw + ":" + sctime ; 1531 //Record rec = tcalrec_.asRecord(feed).asRecord(spw) ; 1532 //if ( !rec.isDefined( sctime ) ) { 1533 if ( !tcalrec_.isDefined( key ) ) { 1487 1534 os_ << "No TCAL rows" << LogIO::POST ; 1488 1535 Vector<uInt> tcalids( 0 ) ; 1489 return tcalids ;1490 }1491 Vector<uInt> ids = tcalrec_.asRecord(feed).asArrayuInt(spw) ;1492 //Table ttabsel = ttab( ttab.col("TIME") == sctime && ttab.col("ID") >= ids[0] && ttab.col("ID") <= ids[1] ).sort("ID") ;1493 Table ttabsel( ttab( ttab.col("TIME") == sctime && ttab.col("ID") >= ids[0] && ttab.col("ID") <= ids[1] ).sort("ID")) ;1494 uInt nrow = ttabsel.nrow() ;1495 Vector<uInt> tcalids( nrow ) ;1496 if ( nrow == 0 ) {1497 os_ << "No TCAL rows" << LogIO::POST ;1498 1536 return tcalids ; 1499 1537 } 1500 ROScalarColumn<uInt> idCol( ttabsel, "ID" ) ; 1501 tcalids[0] = idCol(0) ; 1502 if ( nrow == 2 ) { 1503 tcalids[1] = idCol(1) ; 1504 } 1505 else if ( nrow == 3 ) { 1506 tcalids[1] = idCol(2) ; 1507 tcalids[2] = idCol(1) ; 1508 } 1509 else if ( nrow == 4 ) { 1510 tcalids[1] = idCol(3) ; 1511 tcalids[2] = idCol(1) ; 1512 tcalids[3] = idCol(2) ; 1513 } 1514 1515 //os_ << "end MSFiller::getTcalId()" << LogIO::POST ; 1538 //Vector<uInt> ids = rec.asArrayuInt(sctime) ; 1539 Vector<uInt> ids = tcalrec_.asArrayuInt( key ) ; 1540 uInt npol = ids[1] - ids[0] + 1 ; 1541 Vector<uInt> tcalids( npol ) ; 1542 tcalids[0] = ids[0] ; 1543 tcalids[1] = ids[1] ; 1544 for ( uInt ipol = 2 ; ipol < npol ; ipol++ ) 1545 tcalids[ipol] = ids[0] + ipol - 1 ; 1546 1547 //double endSec = gettimeofday_sec() ; 1548 //os_ << "end MSFiller::getTcalId() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ; 1516 1549 return tcalids ; 1517 1550 } … … 1519 1552 uInt MSFiller::getDirection( uInt idx, Vector<Double> &dir, Vector<Double> &srate, String &ref, MSPointing &tab, Double t ) 1520 1553 { 1521 //os_ << "start MSFiller::getDirection()" << LogIO::POST ; 1554 //double startSec = gettimeofday_sec() ; 1555 //os_ << "start MSFiller::getDirection() startSec=" << startSec << LogIO::POST ; 1522 1556 // assume that cols is sorted by TIME 1523 1557 Bool doInterp = False ; … … 1593 1627 } 1594 1628 1595 //os_ << "end MSFiller::getDirection()" << LogIO::POST ; 1629 //double endSec = gettimeofday_sec() ; 1630 //os_ << "end MSFiller::getDirection() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ; 1596 1631 return idx ; 1597 1632 } -
trunk/src/MSFiller.h
r1987 r1988 65 65 //void fillHistory() ; 66 66 //void fillFit() ; 67 void fillTcal( boost::object_pool<casa::ROTableColumn> *pool ) ; 67 void fillTcal( boost::object_pool<casa::ROTableColumn> *poolr, 68 boost::object_pool<casa::TableColumn> *poolw ) ; 68 69 69 70 // get SRCTYPE from STATE_ID
Note:
See TracChangeset
for help on using the changeset viewer.