Changeset 2234


Ignore:
Timestamp:
07/19/11 12:48:26 (13 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: No

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...

Consider weather station when filling weather table.


Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/MSFiller.cpp

    r2232 r2234  
    853853
    854854                // WEATHER_ID
    855                 if ( isWeather_ )
     855                if ( isWeather_ ) {
    856856                  wid = getWeatherId( wid, mTimeB[irow].get("s").getValue() ) ;
    857                 *widRF = wid ;
     857                  *widRF = mwIndex_[wid] ;
     858                }
     859                else {
     860                  *widRF = wid ;
     861                }
    858862                 
    859863
     
    13141318  wtab.addRow( wnrow ) ;
    13151319
     1320  Bool stationInfoExists = mWeatherSel.tableDesc().isColumn( "NS_WX_STATION_ID" ) ;
     1321  Int stationId = -1 ;
     1322  if ( stationInfoExists ) {
     1323    // determine which station is closer
     1324    ROScalarColumn<Int> stationCol( mWeatherSel, "NS_WX_STATION_ID" ) ;
     1325    ROArrayColumn<Double> stationPosCol( mWeatherSel, "NS_WX_STATION_POSITION" ) ;
     1326    Vector<Int> stationIds = stationCol.getColumn() ;
     1327    Vector<Int> stationIdList( 0 ) ;
     1328    Matrix<Double> stationPosList( 0, 3, 0.0 ) ;
     1329    uInt numStation = 0 ;
     1330    for ( uInt i = 0 ; i < stationIds.size() ; i++ ) {
     1331      if ( !anyEQ( stationIdList, stationIds[i] ) ) {
     1332        numStation++ ;
     1333        stationIdList.resize( numStation, True ) ;
     1334        stationIdList[numStation-1] = stationIds[i] ;
     1335        stationPosList.resize( numStation, 3, True ) ;
     1336        stationPosList.row( numStation-1 ) = stationPosCol( i ) ;
     1337      }
     1338    }
     1339    //os_ << "staionIdList = " << stationIdList << endl ;
     1340    Table mAntenna = mstable_.antenna() ;
     1341    ROArrayColumn<Double> antposCol( mAntenna, "POSITION" ) ;
     1342    Vector<Double> antpos = antposCol( antenna_ ) ;
     1343    Double minDiff = -1.0 ;
     1344    for ( uInt i = 0 ; i < stationIdList.size() ; i++ ) {
     1345      Double diff = sum( square( antpos - stationPosList.row( i ) ) ) ;
     1346      if ( minDiff < 0.0 || minDiff > diff ) {
     1347        minDiff = diff ;
     1348        stationId = stationIdList[i] ;
     1349      }
     1350    }
     1351  }
     1352  //os_ << "stationId = " << stationId << endl ;
     1353 
    13161354  ScalarColumn<Float> *fCol ;
    13171355  ROScalarColumn<Float> *sharedFloatCol ;
     
    13581396  ROScalarColumn<Double> tCol( mWeatherSel, "TIME" ) ;
    13591397  String tUnit = tqCol.getUnits() ;
    1360   mwTime_ = tCol.getColumn() ;
     1398  Vector<Double> mwTime = tCol.getColumn() ;
    13611399  if ( tUnit == "d" )
    1362     mwTime_ *= 86400.0 ;
     1400    mwTime *= 86400.0 ;
    13631401  tqCol.attach( mWeatherSel, "INTERVAL" ) ;
    13641402  tCol.attach( mWeatherSel, "INTERVAL" ) ;
    13651403  String iUnit = tqCol.getUnits() ;
    1366   mwInterval_ = tCol.getColumn() ;
     1404  Vector<Double> mwInterval = tCol.getColumn() ;
    13671405  if ( iUnit == "d" )
    1368     mwInterval_ *= 86400.0 ;
     1406    mwInterval *= 86400.0 ;
     1407
     1408  if ( stationId > 0 ) {
     1409    ROScalarColumn<Int> stationCol( mWeatherSel, "NS_WX_STATION_ID" ) ;
     1410    Vector<Int> stationVec = stationCol.getColumn() ;
     1411    uInt wsnrow = ntrue( stationVec == stationId ) ;
     1412    mwTime_.resize( wsnrow ) ;
     1413    mwInterval_.resize( wsnrow ) ;
     1414    mwIndex_.resize( wsnrow ) ;
     1415    uInt wsidx = 0 ;
     1416    for ( uInt irow = 0 ; irow < wnrow ; irow++ ) {
     1417      if ( stationId == stationVec[irow] ) {
     1418        mwTime_[wsidx] = mwTime[irow] ;
     1419        mwInterval_[wsidx] = mwInterval[irow] ;
     1420        mwIndex_[wsidx] = irow ;
     1421        wsidx++ ;
     1422      }
     1423    }
     1424  }
     1425  else {
     1426    mwTime_ = mwTime ;
     1427    mwInterval_ = mwInterval ;
     1428    mwIndex_.resize( mwTime_.size() ) ;
     1429    indgen( mwIndex_ ) ;
     1430  }
    13691431  //os_ << "mwTime[0] = " << mwTime_[0] << " mwInterval[0] = " << mwInterval_[0] << LogIO::POST ;
    13701432//   double endSec = gettimeofday_sec() ;
     
    15051567    return 0 ;
    15061568  uInt wid = nrow ;
     1569  if ( idx == 0 ) {
     1570    wid = 0 ;
     1571    Double tStart = mwTime_[wid]-0.5*mwInterval_[wid] ;
     1572    if ( wtime < tStart )
     1573      return wid ;
     1574  }
    15071575  for ( uInt i = idx ; i < nrow-1 ; i++ ) {
    15081576    Double tStart = mwTime_[i]-0.5*mwInterval_[i] ;
  • trunk/src/MSFiller.h

    r2217 r2234  
    129129  casa::Vector<casa::Double> mwTime_ ;
    130130  casa::Vector<casa::Double> mwInterval_ ;
     131  casa::Vector<casa::uInt> mwIndex_ ;
    131132
    132133  // Record for TCAL_ID
Note: See TracChangeset for help on using the changeset viewer.