Changeset 1977
- Timestamp:
- 01/24/11 17:41:48 (14 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/MSWriter.cpp
r1975 r1977 34 34 #include "STFrequencies.h" 35 35 #include "STMolecules.h" 36 #include "STTcal.h" 36 37 37 38 using namespace casa ; … … 105 106 // SOURCE 106 107 fillSource() ; 108 109 // WEATHER 110 fillWeather() ; 107 111 108 112 // MAIN … … 162 166 os_ << "scanNo = " << scanNo << LogIO::POST ; 163 167 // 164 // ITERATION: CYCLENO168 // ITERATION: IFNO 165 169 // 166 170 Int added3 = 0 ; 167 171 Int current3 = mstable_->nrow() ; 168 TableIterator iter3( t2, " CYCLENO" ) ;172 TableIterator iter3( t2, "IFNO" ) ; 169 173 while( !iter3.pastEnd() ) { 170 174 Table t3( iter3.table() ) ; 175 ROScalarColumn<uInt> ifNoCol( t3, "IFNO" ) ; 176 uInt ifNo = ifNoCol( 0 ) ; 177 os_ << "ifNo = " << ifNo << LogIO::POST ; 178 ROScalarColumn<uInt> freqIdCol( t3, "FREQ_ID" ) ; 179 uInt freqId = freqIdCol( 0 ) ; 180 os_ << "freqId = " << freqId << LogIO::POST ; 181 Int subscan = 0 ; 171 182 // 172 // ITERATION: IFNO183 // ITERATION: CYCLENO 173 184 // 174 185 Int added4 = 0 ; 175 186 Int current4 = mstable_->nrow() ; 176 TableIterator iter4( t3, " IFNO" ) ;187 TableIterator iter4( t3, "CYCLENO" ) ; 177 188 while( !iter4.pastEnd() ) { 178 189 Table t4( iter4.table() ) ; 179 ROScalarColumn<uInt> ifNoCol( t4, "IFNO" ) ;180 uInt ifNo = ifNoCol( 0 ) ;181 os_ << "ifNo = " << ifNo << LogIO::POST ;182 ROScalarColumn<uInt> freqIdCol( t4, "FREQ_ID" ) ;183 uInt freqId = freqIdCol( 0 ) ;184 os_ << "freqId = " << freqId << LogIO::POST ;185 190 // 186 191 // ITERATION: TIME … … 205 210 // LOOP: POLNO 206 211 // 207 for ( Int ipol = 0 ; ipol < nrow ; ipol++ ) { 212 ROArrayColumn<Float> specCol( t5, "SPECTRA" ) ; 213 ROArrayColumn<uChar> flagCol( t5, "FLAGTRA" ) ; 214 ROScalarColumn<uInt> flagRowCol( t5, "FLAGROW" ) ; 215 uInt nchan = specCol( 0 ).size() ; 216 IPosition newshape( 2,1,nchan ) ; 217 IPosition cellshape( 2, nrow, nchan ) ; 218 if ( useFloatData_ ) { 219 // FLOAT_DATA 220 Array<Float> dataArr( cellshape ) ; 221 Array<Bool> flagArr( cellshape ) ; 222 for ( Int ipol = 0 ; ipol < nrow ; ipol++ ) { 223 Slicer slicer( Slice(ipol), Slice(0,nchan,1) ) ; 224 dataArr( slicer ) = specCol( ipol ).reform( newshape ) ; 225 Array<uChar> tmpUC = flagCol( ipol ).reform( newshape ) ; 226 Array<Bool> tmpB( tmpUC.shape() ) ; 227 //convertArray( flagArr( slicer ), flagCol( ipol ).reform( newshape ) ) ; 228 convertArray( tmpB, tmpUC ) ; 229 flagArr( slicer ) = tmpB ; 230 } 231 ArrayColumn<Float> msDataCol( *mstable_, "FLOAT_DATA" ) ; 232 msDataCol.put( prevnr, dataArr ) ; 233 234 // FLAG 235 ArrayColumn<Bool> msFlagCol( *mstable_, "FLAG" ) ; 236 msFlagCol.put( prevnr, flagArr ) ; 208 237 } 238 else if ( useData_ ) { 239 // DATA 240 // assume nrow = 4 241 Array<Complex> dataArr( cellshape ) ; 242 Vector<Float> zeroIm( nchan, 0 ) ; 243 Array<Float> dummy( IPosition( 2, 2, nchan ) ) ; 244 Slicer slicer0( Slice(0), Slice(0,nchan,1) ) ; 245 Slicer slicer1( Slice(1), Slice(0,nchan,1) ) ; 246 Slicer slicer2( Slice(2), Slice(0,nchan,1) ) ; 247 Slicer slicer3( Slice(3), Slice(0,nchan,1) ) ; 248 dummy( slicer0 ) = specCol( 0 ).reform( newshape ) ; 249 dummy( slicer1 ) = zeroIm.reform( newshape ) ; 250 dataArr( slicer0 ) = RealToComplex( dummy ) ; 251 dummy( slicer0 ) = specCol( 1 ).reform( newshape ) ; 252 dataArr( slicer3 ) = RealToComplex( dummy ) ; 253 dummy( slicer0 ) = specCol( 2 ).reform( newshape ) ; 254 dummy( slicer1 ) = specCol( 3 ).reform( newshape ) ; 255 dataArr( slicer1 ) = RealToComplex( dummy ) ; 256 dataArr( slicer2 ) = conj( RealToComplex( dummy ) ) ; 257 ArrayColumn<Complex> msDataCol( *mstable_, "DATA" ) ; 258 msDataCol.put( prevnr, dataArr ) ; 259 260 // FLAG 261 Array<Bool> flagArr( cellshape ) ; 262 Array<uChar> tmpUC = flagCol( 0 ).reform( newshape ) ; 263 Array<Bool> tmpB( tmpUC.shape() ) ; 264 convertArray( tmpB, tmpUC ) ; 265 flagArr( slicer0 ) = tmpB ; 266 tmpUC = flagCol( 3 ).reform( newshape ) ; 267 convertArray( tmpB, tmpUC ) ; 268 flagArr( slicer3 ) = tmpB ; 269 Vector<uChar> bitOr = flagCol( 2 ) | flagCol( 3 ) ; 270 tmpUC = bitOr.reform( newshape ) ; 271 convertArray( tmpB, tmpUC ) ; 272 flagArr( slicer1 ) = tmpB ; 273 flagArr( slicer2 ) = tmpB ; 274 ArrayColumn<Bool> msFlagCol( *mstable_, "FLAG" ) ; 275 msFlagCol.put( prevnr, flagArr ) ; 276 } 277 278 // FLAG_ROW 279 ScalarColumn<Bool> msFlagRowCol( *mstable_, "FLAG_ROW" ) ; 280 msFlagRowCol.put( prevnr, anyNE( flagRowCol.getColumn(), (uInt)0 ) ) ; 209 281 210 282 // TIME and TIME_CENTROID 211 283 ROScalarMeasColumn<MEpoch> timeCol( t5, "TIME" ) ; 284 MEpoch mTime = timeCol( 0 ) ; 212 285 ScalarMeasColumn<MEpoch> msTimeCol( *mstable_, "TIME" ) ; 213 msTimeCol.put( prevnr, timeCol( 0 )) ;286 msTimeCol.put( prevnr, mTime ) ; 214 287 msTimeCol.attach( *mstable_, "TIME_CENTROID" ) ; 215 msTimeCol.put( prevnr, timeCol( 0 )) ;288 msTimeCol.put( prevnr, mTime ) ; 216 289 217 290 // INTERVAL and EXPOSURE 218 291 ROScalarColumn<Double> intervalCol( t5, "INTERVAL" ) ; 292 Double interval = intervalCol( 0 ) ; 219 293 ScalarColumn<Double> msIntervalCol( *mstable_, "INTERVAL" ) ; 220 msIntervalCol.put( prevnr, interval Col( 0 )) ;294 msIntervalCol.put( prevnr, interval ) ; 221 295 msIntervalCol.attach( *mstable_, "EXPOSURE" ) ; 222 msIntervalCol.put( prevnr, intervalCol( 0 ) ) ; 296 msIntervalCol.put( prevnr, interval ) ; 297 298 // WEIGHT and SIGMA 299 // always 1 at the moment 300 Vector<Float> wArr( nrow, 1.0 ) ; 301 ArrayColumn<Float> wArrCol( *mstable_, "WEIGHT" ) ; 302 wArrCol.put( prevnr, wArr ) ; 303 wArrCol.attach( *mstable_, "SIGMA" ) ; 304 wArrCol.put( prevnr, wArr ) ; 223 305 224 306 // add DATA_DESCRIPTION row … … 228 310 ddIdCol.put( prevnr, ddid ) ; 229 311 312 // for SYSCAL table 313 ROScalarColumn<uInt> tcalIdCol( t5, "TCAL_ID" ) ; 314 Vector<uInt> tcalIdArr = tcalIdCol.getColumn() ; 315 os_ << "tcalIdArr = " << tcalIdArr << LogIO::POST ; 316 String key = String::toString( tcalIdArr[0] ) ; 317 if ( !tcalIdRec_.isDefined( key ) ) { 318 tcalIdRec_.define( key, tcalIdArr ) ; 319 } 320 321 // fill STATE_ID 322 ROScalarColumn<Int> srcTypeCol( t5, "SRCTYPE" ) ; 323 Int srcType = srcTypeCol( 0 ) ; 324 Int stateId = addState( srcType, subscan ) ; 325 ScalarColumn<Int> msStateIdCol( *mstable_, "STATE_ID" ) ; 326 msStateIdCol.put( prevnr, stateId ) ; 327 328 // for POINTING table 329 Matrix<Double> msDir( 2, 2 ) ; 330 ROArrayColumn<Double> dirCol( t5, "DIRECTION" ) ; 331 msDir.column( 0 ) = dirCol( 0 ) ; 332 dirCol.attach( t5, "SCANRATE" ) ; 333 msDir.column( 1 ) = dirCol( 0 ) ; 334 addPointing( fieldName, mTime, interval, msDir ) ; 335 230 336 added5 += 1 ; 231 337 os_ << "added5 = " << added5 << " current5 = " << current5 << LogIO::POST ; 232 338 iter5.next() ; 233 }234 235 // add SPECTRAL_WINDOW row236 if ( allNE( processedFreqId, freqId ) ) {237 uInt vsize = processedFreqId.size() ;238 processedFreqId.resize( vsize+1, True ) ;239 processedFreqId[vsize] = freqId ;240 addSpectralWindow( ifNo, freqId ) ;241 339 } 242 340 … … 245 343 iter4.next() ; 246 344 } 345 346 // add SPECTRAL_WINDOW row 347 if ( allNE( processedFreqId, freqId ) ) { 348 uInt vsize = processedFreqId.size() ; 349 processedFreqId.resize( vsize+1, True ) ; 350 processedFreqId[vsize] = freqId ; 351 addSpectralWindow( ifNo, freqId ) ; 352 } 353 247 354 added3 += added4 ; 248 355 os_ << "added3 = " << added3 << " current3 = " << current3 << LogIO::POST ; … … 313 420 sharedIntCol.putColumn( sharedIntArr ) ; 314 421 422 423 // SYSCAL 424 fillSysCal() ; 425 315 426 return True ; 316 427 } … … 326 437 // FLOAT_DATA? or DATA? 327 438 if ( header_.npol > 2 ) { 328 isFloatData_ = False ;329 isData_ = True ;439 useFloatData_ = False ; 440 useData_ = True ; 330 441 } 331 442 else { 332 isFloatData_ = True ;333 isData_ = False ;443 useFloatData_ = True ; 444 useData_ = False ; 334 445 } 335 446 … … 349 460 polType_ = "notype" ; 350 461 462 // Are TCAL_SPECTRUM and TSYS_SPECTRUM necessary? 463 tcalSpec_ = False ; 464 tsysSpec_ = False ; 465 if ( header_.nchan != 1 ) { 466 // examine TCAL subtable 467 Table tcaltab = table_->tcal().table() ; 468 ROArrayColumn<Float> tcalCol( tcaltab, "TCAL" ) ; 469 for ( uInt irow = 0 ; irow < tcaltab.nrow() ; irow++ ) { 470 if ( tcalCol( irow ).size() != 1 ) 471 tcalSpec_ = True ; 472 } 473 // examine spectral data 474 TableIterator iter0( table_->table(), "IFNO" ) ; 475 while( !iter0.pastEnd() ) { 476 Table t0( iter0.table() ) ; 477 ROArrayColumn<Float> sharedFloatArrCol( t0, "SPECTRA" ) ; 478 uInt len = sharedFloatArrCol( 0 ).size() ; 479 if ( len != 1 ) { 480 sharedFloatArrCol.attach( t0, "TSYS" ) ; 481 if ( sharedFloatArrCol( 0 ).size() != 1 ) 482 tsysSpec_ = True ; 483 } 484 iter0.next() ; 485 } 486 } 351 487 } 352 488 … … 357 493 358 494 TableDesc msDesc = MeasurementSet::requiredTableDesc() ; 359 360 // any additional columns? 361 // TODO: add FLOAT_DATA column if npol == 2 otherwise add DATA column 495 if ( useFloatData_ ) 496 MeasurementSet::addColumnToDesc( msDesc, MSMainEnums::FLOAT_DATA, 2 ) ; 497 else if ( useData_ ) 498 MeasurementSet::addColumnToDesc( msDesc, MSMainEnums::DATA, 2 ) ; 362 499 363 500 SetupNewTable newtab( filename_, msDesc, Table::New ) ; … … 431 568 // TODO: add TCAL_SPECTRUM and TSYS_SPECTRUM if necessary 432 569 TableDesc sysCalDesc = MSSysCal::requiredTableDesc() ; 570 MSSysCal::addColumnToDesc( sysCalDesc, MSSysCalEnums::TCAL, 2 ) ; 571 MSSysCal::addColumnToDesc( sysCalDesc, MSSysCalEnums::TSYS, 2 ) ; 572 if ( tcalSpec_ ) 573 MSSysCal::addColumnToDesc( sysCalDesc, MSSysCalEnums::TCAL_SPECTRUM, 2 ) ; 574 if ( tsysSpec_ ) 575 MSSysCal::addColumnToDesc( sysCalDesc, MSSysCalEnums::TSYS_SPECTRUM, 2 ) ; 433 576 SetupNewTable sysCalTab( mstable_->sysCalTableName(), sysCalDesc, Table::New ) ; 434 577 mstable_->rwKeywordSet().defineTable( MeasurementSet::keywordName( MeasurementSet::SYSCAL ), Table( sysCalTab ) ) ; 435 578 436 579 TableDesc weatherDesc = MSWeather::requiredTableDesc() ; 580 MSWeather::addColumnToDesc( weatherDesc, MSWeatherEnums::TEMPERATURE ) ; 581 MSWeather::addColumnToDesc( weatherDesc, MSWeatherEnums::PRESSURE ) ; 582 MSWeather::addColumnToDesc( weatherDesc, MSWeatherEnums::REL_HUMIDITY ) ; 583 MSWeather::addColumnToDesc( weatherDesc, MSWeatherEnums::WIND_SPEED ) ; 584 MSWeather::addColumnToDesc( weatherDesc, MSWeatherEnums::WIND_DIRECTION ) ; 437 585 SetupNewTable weatherTab( mstable_->weatherTableName(), weatherDesc, Table::New ) ; 438 586 mstable_->rwKeywordSet().defineTable( MeasurementSet::keywordName( MeasurementSet::WEATHER ), Table( weatherTab ) ) ; … … 660 808 } 661 809 810 void MSWriter::fillWeather() 811 { 812 os_ << "set up WEATHER subtable" << LogIO::POST ; 813 814 // access to MS WEATHER subtable 815 MSWeather msw = mstable_->weather() ; 816 817 // access to WEATHER subtable 818 Table stw = table_->weather().table() ; 819 uInt nrow = stw.nrow() ; 820 821 if ( nrow == 0 ) 822 return ; 823 824 msw.addRow( nrow, True ) ; 825 MSWeatherColumns mswCols( msw ) ; 826 827 // ANTENNA_ID is always 0 828 Vector<Int> antIdArr( nrow, 0 ) ; 829 mswCols.antennaId().putColumn( antIdArr ) ; 830 831 // fill weather status 832 ROScalarColumn<Float> sharedFloatCol( stw, "TEMPERATURE" ) ; 833 mswCols.temperature().putColumn( sharedFloatCol ) ; 834 sharedFloatCol.attach( stw, "PRESSURE" ) ; 835 mswCols.pressure().putColumn( sharedFloatCol ) ; 836 sharedFloatCol.attach( stw, "HUMIDITY" ) ; 837 mswCols.relHumidity().putColumn( sharedFloatCol ) ; 838 sharedFloatCol.attach( stw, "WINDSPEED" ) ; 839 mswCols.windSpeed().putColumn( sharedFloatCol ) ; 840 sharedFloatCol.attach( stw, "WINDAZ" ) ; 841 mswCols.windDirection().putColumn( sharedFloatCol ) ; 842 843 // fill TIME and INTERVAL 844 MEpoch me ; 845 Double interval ; 846 Vector<Double> intervalArr( nrow, 0.0 ) ; 847 TableIterator iter( table_->table(), "WEATHER_ID" ) ; 848 while( !iter.pastEnd() ) { 849 Table tab( iter.table() ) ; 850 851 ROScalarColumn<uInt> widCol( tab, "WEATHER_ID" ) ; 852 uInt wid = widCol( 0 ) ; 853 854 getValidTimeRange( me, interval, tab ) ; 855 mswCols.timeMeas().put( wid, me ) ; 856 intervalArr[wid] = interval ; 857 858 iter.next() ; 859 } 860 mswCols.interval().putColumn( intervalArr ) ; 861 } 862 863 void MSWriter::fillSysCal() 864 { 865 os_ << "set up SYSCAL subtable" << LogIO::POST ; 866 867 tcalIdRec_.print( cout ) ; 868 869 // access to MS SYSCAL subtable 870 MSSysCal mssc = mstable_->sysCal() ; 871 872 // access to TCAL subtable 873 STTcal stt = table_->tcal() ; 874 uInt nrow = stt.table().nrow() ; 875 876 if ( nrow == 0 ) 877 return ; 878 879 nrow = tcalIdRec_.nfields() ; 880 881 MEpoch me ; 882 Double interval ; 883 String timeStr ; 884 // 885 // ITERATION: BEAMNO 886 // 887 Int added0 = 0 ; 888 Int current0 = mssc.nrow() ; 889 TableIterator iter0( table_->table(), "BEAMNO" ) ; 890 while( !iter0.pastEnd() ) { 891 Table t0( iter0.table() ) ; 892 ROScalarColumn<uInt> beamNoCol( t0, "BEAMNO" ) ; 893 uInt beamNo = beamNoCol( 0 ) ; 894 // 895 // ITERATION: IFNO 896 // 897 Int added1 = 0 ; 898 Int current1 = mssc.nrow() ; 899 TableIterator iter1( t0, "IFNO" ) ; 900 while( !iter1.pastEnd() ) { 901 Table t1( iter1.table() ) ; 902 ROScalarColumn<uInt> ifNoCol( t1, "IFNO" ) ; 903 uInt ifNo = ifNoCol( 0 ) ; 904 uInt prevnr = mssc.nrow() ; 905 906 // 907 // LOOP: TCAL_ID 908 // 909 Int added2 = 0 ; 910 Int current2 = mssc.nrow() ; 911 for ( uInt irow = 0 ; irow < nrow ; irow++ ) { 912 Vector<uInt> ids = tcalIdRec_.asArrayuInt( irow ) ; 913 uInt npol = ids.size() ; 914 Table tsel = t1( t1.col("TCAL_ID").in(ids) ) ; 915 os_ << "nrow = " << tsel.nrow() << "@TCAL_ID " << tcalIdRec_.asArrayuInt(irow) << " beamno " << beamNo << "ifno " << ifNo << LogIO::POST ; 916 if ( tsel.nrow() != 0 ) { 917 uInt idx = current2 + added2 ; 918 919 // TIME and INTERVAL 920 mssc.addRow( 1, True ) ; 921 getValidTimeRange( me, interval, t1 ) ; 922 os_ << "me = " << me.get("s").getValue() << " interval = " << interval << LogIO::POST ; 923 ScalarMeasColumn<MEpoch> timeMeasCol( mssc, "TIME" ) ; 924 timeMeasCol.put( idx, me ) ; 925 ScalarColumn<Double> intervalCol( mssc, "INTERVAL" ) ; 926 intervalCol.put( idx, interval ) ; 927 928 // TCAL and TSYS 929 Array<Float> tcal ; 930 Array<Float> tsys ; 931 Vector<Float> dummyC ; 932 stt.getEntry( timeStr, dummyC, ids[0] ) ; 933 os_ << "dummyC[0] = " << dummyC[0] << LogIO::POST ; 934 uInt nchanC = dummyC.size() ; 935 os_ << "nchanC = " << nchanC << LogIO::POST ; 936 tcal.resize( IPosition(2,npol,nchanC) ) ; 937 IPosition shapeC( 2, 1, nchanC ) ; 938 tcal( Slicer(Slice(0),Slice(0,nchanC,1)) ) = dummyC.reform( shapeC ) ; 939 Table tsel1 = tsel( tsel.col("TCAL_ID") == ids[0] ) ; 940 ROArrayColumn<Float> tsysCol( tsel1, "TSYS" ) ; 941 Vector<Float> dummyS = tsysCol( 0 ) ; 942 os_ << "dummyS[0] = " << dummyS[0] << LogIO::POST ; 943 uInt nchanS = dummyS.size() ; 944 os_ << "nchanS = " << nchanS << LogIO::POST ; 945 IPosition shapeS( 2, 1, nchanS ) ; 946 tsys.resize( IPosition(2,npol,nchanS) ) ; 947 tsys( Slicer(Slice(0),Slice(0,nchanS,1)) ) = dummyS.reform( shapeS ) ; 948 os_ << "tsys = " << tsys << LogIO::POST ; 949 for ( uInt iid = 1 ; iid < npol ; iid++ ) { 950 // get TCAL and TSYS 951 stt.getEntry( timeStr, dummyC, ids[iid] ) ; 952 tcal( Slicer(Slice(iid),Slice(0,nchanC,1)) ) = dummyC.reform( shapeC ) ; 953 tsel1 = tsel( tsel.col("TCAL_ID") == ids[iid] ) ; 954 tsysCol.attach( tsel1, "TSYS" ) ; 955 tsys( Slicer(Slice(iid),Slice(0,nchanS,1)) ) = tsysCol( 0 ).reform( shapeS ) ; 956 } 957 os_ << "tsys = " << tsys << LogIO::POST ; 958 ArrayColumn<Float> sharedFloatArrCol ; 959 if ( tcalSpec_ ) { 960 // put TCAL_SPECTRUM 961 sharedFloatArrCol.attach( mssc, "TCAL_SPECTRUM" ) ; 962 sharedFloatArrCol.put( idx, tcal ) ; 963 // set TCAL (mean of TCAL_SPECTRUM) 964 Vector<Float> tcalMean( npol ) ; 965 for ( uInt iid = 0 ; iid < npol ; iid++ ) { 966 tcalMean[iid] = mean( tcal(Slicer(Slice(iid),Slice(0,nchanC,1))) ) ; 967 } 968 tcal.assign( tcalMean.reform(IPosition(2,npol,1)) ) ; 969 } 970 os_ << "tcal = " << tcal << LogIO::POST ; 971 // put TCAL 972 sharedFloatArrCol.attach( mssc, "TCAL" ) ; 973 sharedFloatArrCol.put( idx, tcal ) ; 974 975 if ( tsysSpec_ ) { 976 // put TSYS_SPECTRUM 977 sharedFloatArrCol.attach( mssc, "TSYS_SPECTRUM" ) ; 978 sharedFloatArrCol.put( idx, tsys ) ; 979 // set TSYS (mean of TSYS_SPECTRUM) 980 Vector<Float> tsysMean( npol ) ; 981 for ( uInt iid = 0 ; iid < npol ; iid++ ) { 982 tsysMean[iid] = mean( tsys(Slicer(Slice(iid),Slice(0,nchanS,1))) ) ; 983 } 984 tsys.assign( tsysMean.reform(IPosition(2,npol,1)) ) ; 985 } 986 os_ << "tsys = " << tsys << LogIO::POST ; 987 // put TSYS 988 sharedFloatArrCol.attach( mssc, "TSYS" ) ; 989 sharedFloatArrCol.put( idx, tsys ) ; 990 991 added2++ ; 992 } 993 } 994 995 // SPECTRAL_WINDOW_ID 996 RefRows rows2( current2, current2+added2-1 ) ; 997 ScalarColumn<Int> spwIdCol( mssc, "SPECTRAL_WINDOW_ID" ) ; 998 Vector<Int> ifNoArr( added2, ifNo ) ; 999 spwIdCol.putColumnCells( rows2, ifNoArr ) ; 1000 1001 added1 += added2 ; 1002 iter1.next() ; 1003 } 1004 1005 // FEED_ID 1006 RefRows rows1( current1, current1+added1-1 ) ; 1007 Vector<Int> beamNoArr( added1, beamNo ) ; 1008 ScalarColumn<Int> feedIdCol( mssc, "FEED_ID" ) ; 1009 feedIdCol.putColumnCells( rows1, beamNoArr ) ; 1010 1011 added0 += added1 ; 1012 iter0.next() ; 1013 } 1014 1015 // ANTENNA_ID 1016 Vector<Int> id( added0, 0 ) ; 1017 ScalarColumn<Int> antennaIdCol( mssc, "ANTENNA_ID" ) ; 1018 antennaIdCol.putColumn( id ) ; 1019 1020 } 1021 662 1022 void MSWriter::addFeed( Int id ) 663 1023 { … … 769 1129 } 770 1130 1131 void MSWriter::addPointing( String &name, MEpoch &me, Double &interval, Matrix<Double> &dir ) 1132 { 1133 os_ << "set up POINTING subtable" << LogIO::POST ; 1134 1135 // access to POINTING subtable 1136 MSPointing msp = mstable_->pointing() ; 1137 uInt nrow = msp.nrow() ; 1138 1139 // add row 1140 msp.addRow( 1, True ) ; 1141 1142 // fill row 1143 MSPointingColumns mspCols( msp ) ; 1144 mspCols.antennaId().put( nrow, 0 ) ; 1145 mspCols.timeMeas().put( nrow, me ) ; 1146 mspCols.interval().put( nrow, interval ) ; 1147 mspCols.name().put( nrow, name ) ; 1148 mspCols.numPoly().put( nrow, 1 ) ; 1149 mspCols.timeOriginMeas().put( nrow, me ) ; 1150 mspCols.direction().put( nrow, dir ) ; 1151 mspCols.target().put( nrow, dir ) ; 1152 mspCols.tracking().put( nrow, True ) ; 1153 } 1154 771 1155 Int MSWriter::addPolarization( Vector<Int> polnos ) 772 1156 { … … 829 1213 Int MSWriter::addDataDescription( Int polid, Int spwid ) 830 1214 { 831 os_ << "set up SPECTRAL_WINDOWsubtable" << LogIO::POST ;1215 os_ << "set up DATA_DESCRIPTION subtable" << LogIO::POST ; 832 1216 833 1217 MSDataDescription msDataDesc = mstable_->dataDescription() ; … … 852 1236 853 1237 return ddid ; 1238 } 1239 1240 Int MSWriter::addState( Int st, Int &subscan ) 1241 { 1242 os_ << "set up STATE subtable" << LogIO::POST ; 1243 1244 // access to STATE subtable 1245 MSState msState = mstable_->state() ; 1246 uInt nrow = msState.nrow() ; 1247 1248 String obsMode ; 1249 Bool isSignal ; 1250 queryType( st, obsMode, isSignal ) ; 1251 os_ << "obsMode = " << obsMode << " isSignal = " << isSignal << LogIO::POST ; 1252 1253 MSState msStatSel = msState( msState.col("OBS_MODE")==obsMode 1254 && msState.col("SIG")==isSignal 1255 && msState.col("REF")!=isSignal 1256 && msState.col("SUB_SCAN") == subscan ) ; 1257 uInt nrowSel = msStatSel.nrow() ; 1258 1259 Int idx = -1 ; 1260 if ( nrowSel == 0 ) { 1261 msState.addRow( 1, True ) ; 1262 ScalarColumn<String> obsModeCol( msState, "OBS_MODE" ) ; 1263 obsModeCol.put( nrow, obsMode ) ; 1264 ScalarColumn<Bool> sharedBCol( msState, "SIG" ) ; 1265 sharedBCol.put( nrow, isSignal ) ; 1266 sharedBCol.attach( msState, "REF" ) ; 1267 sharedBCol.put( nrow, !isSignal ) ; 1268 ScalarColumn<Int> subscanCol( msState, "SUB_SCAN" ) ; 1269 subscanCol.put( nrow, subscan ) ; 1270 idx = nrow ; 1271 } 1272 else { 1273 ScalarColumn<String> obsModeCol( msState, "OBS_MODE" ) ; 1274 ScalarColumn<Bool> sigCol( msState, "SIG" ) ; 1275 ScalarColumn<Bool> refCol( msState, "REF" ) ; 1276 ScalarColumn<Int> subscanCol( msState, "SUB_SCAN" ) ; 1277 for ( uInt irow = 0 ; irow < nrow ; irow++ ) { 1278 if ( obsModeCol(irow) == obsMode 1279 && sigCol(irow) == isSignal 1280 && refCol(irow) != isSignal 1281 && subscanCol(irow) == subscan ) { 1282 idx = irow ; 1283 break ; 1284 } 1285 } 1286 } 1287 subscan++ ; 1288 return idx ; 854 1289 } 855 1290 … … 960 1395 } 961 1396 962 } 1397 void MSWriter::queryType( Int type, String &stype, Bool &b ) 1398 { 1399 switch ( type ) { 1400 case SrcType::PSON: 1401 stype = "POSITION_SWITCH.OBSERVE_TARGET.ON_SOURCE" ; 1402 b = True ; 1403 break ; 1404 case SrcType::PSOFF: 1405 stype = "POSITION_SWITCH.OBSERVE_TARGET.OFF_SOURCE" ; 1406 b = False ; 1407 break ; 1408 case SrcType::NOD: 1409 stype = "NOD.OBSERVE_TARGET.ON_SOURCE" ; 1410 b = True ; 1411 break ; 1412 case SrcType::FSON: 1413 stype = "FREQUENCY_SWITCH.OBSERVE_TARGET.ON_SOURCE" ; 1414 b = True ; 1415 break ; 1416 case SrcType::FSOFF: 1417 stype = "FREQUENCY_SWITCH.OBSERVE_TARGET.ON_SOURCE" ; 1418 b = False ; 1419 break ; 1420 case SrcType::SKY: 1421 stype = "UNSPECIFIED.CALIBRATE_TEMPERATURE.OFF_SOURCE" ; 1422 b = False ; 1423 break ; 1424 case SrcType::HOT: 1425 stype = "UNSPECIFIED.CALIBRATE_TEMPERATURE.OFF_SOURCE" ; 1426 b = False ; 1427 break ; 1428 case SrcType::WARM: 1429 stype = "UNSPECIFIED.CALIBRATE_TEMPERATURE.OFF_SOURCE" ; 1430 b = False ; 1431 break ; 1432 case SrcType::COLD: 1433 stype = "UNSPECIFIED.CALIBRATE_TEMPERATURE.OFF_SOURCE" ; 1434 b = False ; 1435 break ; 1436 case SrcType::PONCAL: 1437 stype = "POSITION_SWITCH.CALIBRATE_TEMPERATURE.ON_SOURCE" ; 1438 b = True ; 1439 break ; 1440 case SrcType::POFFCAL: 1441 stype = "POSITION_SWITCH.CALIBRATE_TEMPERATURE.OFF_SOURCE" ; 1442 b = False ; 1443 break ; 1444 case SrcType::NODCAL: 1445 stype = "NOD.CALIBRATE_TEMPERATURE.ON_SOURCE" ; 1446 b = True ; 1447 break ; 1448 case SrcType::FONCAL: 1449 stype = "FREQUENCY_SWITCH.CALIBRATE_TEMPERATURE.ON_SOURCE" ; 1450 b = True ; 1451 break ; 1452 case SrcType::FOFFCAL: 1453 stype = "FREQUENCY_SWITCH.CALIBRATE_TEMPERATURE.OFF_SOURCE" ; 1454 b = False ; 1455 break ; 1456 case SrcType::FSLO: 1457 stype = "FREQUENCY_SWITCH.OBSERVE_TARGET.ON_SOURCE" ; 1458 b = True ; 1459 break ; 1460 case SrcType::FLOOFF: 1461 stype = "FREQUENCY_SWITCH.OBSERVE_TARGET.OFF_SOURCE" ; 1462 b = False ; 1463 break ; 1464 case SrcType::FLOSKY: 1465 stype = "FREQUENCY_SWITCH.CALIBRATE_TEMPERATURE.OFF_SOURCE" ; 1466 b = False ; 1467 break ; 1468 case SrcType::FLOHOT: 1469 stype = "FREQUENCY_SWITCH.CALIBRATE_TEMPERATURE.OFF_SOURCE" ; 1470 b = False ; 1471 break ; 1472 case SrcType::FLOWARM: 1473 stype = "FREQUENCY_SWITCH.CALIBRATE_TEMPERATURE.OFF_SOURCE" ; 1474 b = False ; 1475 break ; 1476 case SrcType::FLOCOLD: 1477 stype = "FREQUENCY_SWITCH.CALIBRATE_TEMPERATURE.OFF_SOURCE" ; 1478 b = False ; 1479 break ; 1480 case SrcType::FSHI: 1481 stype = "FREQUENCY_SWITCH.OBSERVE_TARGET.ON_SOURCE" ; 1482 b = True ; 1483 break ; 1484 case SrcType::FHIOFF: 1485 stype = "FREQUENCY_SWITCH.CALIBRATE_TEMPERATURE.OFF_SOURCE" ; 1486 b = False ; 1487 break ; 1488 case SrcType::FHISKY: 1489 stype = "FREQUENCY_SWITCH.CALIBRATE_TEMPERATURE.OFF_SOURCE" ; 1490 b = False ; 1491 break ; 1492 case SrcType::FHIHOT: 1493 stype = "FREQUENCY_SWITCH.CALIBRATE_TEMPERATURE.OFF_SOURCE" ; 1494 b = False ; 1495 break ; 1496 case SrcType::FHIWARM: 1497 stype = "FREQUENCY_SWITCH.CALIBRATE_TEMPERATURE.OFF_SOURCE" ; 1498 b = False ; 1499 break ; 1500 case SrcType::FHICOLD: 1501 stype = "FREQUENCY_SWITCH.CALIBRATE_TEMPERATURE.OFF_SOURCE" ; 1502 b = False ; 1503 break ; 1504 case SrcType::SIG: 1505 stype = "UNSPECIFIED.OBSERVE_TARGET.ON_SOURCE" ; 1506 b = True ; 1507 break ; 1508 case SrcType::REF: 1509 stype = "UNSPECIFIED.OBSERVE_TARGET.ON_SOURCE" ; 1510 b = False ; 1511 break ; 1512 default: 1513 stype = "UNSPECIFIED" ; 1514 b = True ; 1515 break ; 1516 } 1517 } 1518 } -
trunk/src/MSWriter.h
r1975 r1977 20 20 #include <casa/Utilities/CountedPtr.h> 21 21 #include <casa/Arrays/Vector.h> 22 #include <casa/Arrays/Matrix.h> 22 23 #include <casa/Logging/LogIO.h> 24 #include <casa/Containers/Record.h> 23 25 24 26 #include <tables/Tables/Table.h> … … 29 31 30 32 #include <measures/Measures/MEpoch.h> 33 34 #include <atnf/PKSIO/SrcType.h> 31 35 32 36 #include "Scantable.h" … … 60 64 void fillProcessor() ; 61 65 void fillSource() ; 66 void fillWeather() ; 67 void fillSysCal() ; 62 68 63 69 // add rows to subtables … … 65 71 void addSpectralWindow( casa::Int spwid, casa::Int freqid ) ; 66 72 void addField( casa::Int fid, casa::String fieldname, casa::String srcname, casa::Double t, casa::Vector<casa::Double> scanrate ) ; 73 void addPointing( casa::String &name, casa::MEpoch &me, casa::Double &interval, casa::Matrix<casa::Double> &dir ) ; 67 74 casa::Int addPolarization( casa::Vector<casa::Int> polnos ) ; 68 75 casa::Int addDataDescription( casa::Int polid, casa::Int spwid ) ; 76 casa::Int addState( casa::Int type, casa::Int &subscan ) ; 69 77 70 78 // utility 71 79 casa::Vector<casa::Int> toCorrType( casa::Vector<casa::Int> polnos ) ; 72 80 void getValidTimeRange( casa::MEpoch &me, casa::Double &interval, casa::Table &tab ) ; 81 void queryType( casa::Int type, casa::String &stype, casa::Bool &b ) ; 73 82 74 83 casa::CountedPtr<Scantable> table_ ; … … 76 85 casa::CountedPtr<casa::MeasurementSet> mstable_ ; 77 86 78 casa::Bool isFloatData_ ; 79 casa::Bool isData_ ; 87 casa::Bool useFloatData_ ; 88 casa::Bool useData_ ; 89 casa::Bool tcalSpec_ ; 90 casa::Bool tsysSpec_ ; 91 80 92 casa::String polType_ ; 81 93 … … 83 95 84 96 casa::LogIO os_ ; 97 98 casa::Record tcalIdRec_ ; 85 99 86 100 MSWriter();
Note:
See TracChangeset
for help on using the changeset viewer.