Changeset 2743
- Timestamp:
- 01/23/13 16:46:51 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/MSWriter.cpp
r2741 r2743 90 90 ret[1] = polmap[2] ; 91 91 ret[2] = polmap[3] ; 92 ret[ 4] = polmap[1] ;92 ret[3] = polmap[1] ; 93 93 } 94 94 else { … … 217 217 } 218 218 virtual ~DataHolder() {} 219 virtual void post() = 0 ; 219 void post() 220 { 221 postData() ; 222 postFlag() ; 223 postFlagRow() ; 224 postAuxiliary() ; 225 } 220 226 virtual void reset() 221 227 { … … 223 229 flagRow = False ; 224 230 npol = 0 ; 231 for ( uInt i = 0 ; i < 4 ; i++ ) 232 isFilled[i] = False ; 225 233 } 226 234 virtual void accumulate( uInt id, Vector<Float> &sp, Vector<Bool> &fl, Bool &flr ) … … 230 238 accumulateFlag( id, fl ) ; 231 239 accumulateFlagRow( id, flr ) ; 240 isFilled[id] = True; 232 241 } 233 242 uInt nPol() { return npol ; } … … 275 284 { 276 285 data.row( id ) = sp ; 286 } 287 uInt filledIndex() 288 { 289 uInt idx = 0; 290 while( !isFilled[idx] && idx < 4 ) ++idx; 291 return idx; 277 292 } 278 293 virtual void postData() = 0 ; … … 290 305 Matrix<Float> data ; 291 306 Vector<Float> sigmaTemplate ; 307 Bool isFilled[4] ; 292 308 private: 293 309 void makeCorrTypeHandler( String &polType ) … … 328 344 } 329 345 virtual ~FloatDataHolder() {} 330 virtual void post()331 {332 postData() ;333 postFlag() ;334 postFlagRow() ;335 postAuxiliary() ;336 }337 346 protected: 338 347 virtual void postFlag() 339 348 { 340 flagRF.define( flag( IPosition( 2, 0, 0 ), IPosition( 2, npol-1, nchan-1 ) ) ) ; 349 if ( npol == 2 ) { 350 flagRF.define( flag( IPosition( 2, 0, 0 ), IPosition( 2, npol-1, nchan-1 ) ) ) ; 351 } 352 else { 353 // should be npol == 1 354 uInt idx = filledIndex() ; 355 flagRF.define( flag( IPosition( 2, idx, 0 ), IPosition( 2, idx, nchan-1 ) ) ) ; 356 } 341 357 } 342 358 virtual void postData() 343 359 { 344 dataRF.define( data( IPosition( 2, 0, 0 ), IPosition( 2, npol-1, nchan-1 ) ) ) ; 360 if ( npol == 2 ) { 361 dataRF.define( data( IPosition( 2, 0, 0 ), IPosition( 2, npol-1, nchan-1 ) ) ) ; 362 } 363 else { 364 // should be npol == 1 365 uInt idx = filledIndex() ; 366 dataRF.define( data( IPosition( 2, idx, 0 ), IPosition( 2, idx, nchan-1 ) ) ) ; 367 } 345 368 } 346 369 private: … … 360 383 } 361 384 virtual ~ComplexDataHolder() {} 362 virtual void accumulate( uInt id, Vector<Float> &sp, Vector<Bool> &fl, Bool &flr )363 {364 DataHolder::accumulate( id, sp, fl, flr ) ;365 isFilled[id] = True ;366 }367 virtual void post()368 {369 postData() ;370 postFlag() ;371 postFlagRow() ;372 postAuxiliary() ;373 }374 virtual void reset()375 {376 DataHolder::reset() ;377 for ( uInt i = 0 ; i < 4 ; i++ )378 isFilled[i] = False ;379 }380 385 protected: 381 386 virtual void postFlag() … … 388 393 flagRF.define( flag ) ; 389 394 } 395 else if ( npol == 2 ) { 396 flagRF.define( flag( IPosition( 2, 0, 0 ), IPosition( 2, npol-1, nchan-1 ) ) ) ; 397 } 390 398 else { 391 flagRF.define( flag( IPosition( 2, 0, 0 ), IPosition( 2, npol-1, nchan-1 ) ) ) ; 399 // should be npol == 1 400 uInt idx = filledIndex() ; 401 flagRF.define( flag( IPosition( 2, idx, 0 ), IPosition( 2, idx, nchan-1 ) ) ) ; 392 402 } 393 403 } … … 418 428 } 419 429 RecordFieldPtr< Matrix<Complex> > dataRF; 420 Bool isFilled[4] ;421 430 }; 422 431 … … 440 449 } 441 450 442 virtual void enterFieldName(const uInt recordNo, const String &columnValue) {443 } 444 virtual void leaveFieldName(const uInt recordNo, const String &columnValue) {445 } 446 virtual void enterBeamNo(const uInt recordNo, uInt columnValue) { }447 virtual void leaveBeamNo(const uInt recordNo, uInt columnValue) { }448 virtual void enterScanNo(const uInt recordNo, uInt columnValue) { }449 virtual void leaveScanNo(const uInt recordNo, uInt columnValue) { }450 virtual void enterIfNo(const uInt recordNo, uInt columnValue) { }451 virtual void leaveIfNo(const uInt recordNo, uInt columnValue) { }452 virtual void enterSrcType(const uInt recordNo, Int columnValue) { }453 virtual void leaveSrcType(const uInt recordNo, Int columnValue) { }454 virtual void enterCycleNo(const uInt recordNo, uInt columnValue) { }455 virtual void leaveCycleNo(const uInt recordNo, uInt columnValue) { }456 virtual void enterTime(const uInt recordNo, Double columnValue) { }457 virtual void leaveTime(const uInt recordNo, Double columnValue) { }458 virtual void enterPolNo(const uInt recordNo, uInt columnValue) { }459 virtual void leavePolNo(const uInt recordNo, uInt columnValue) { }460 461 virtual Bool visitRecord(const uInt recordNo,462 const String & fieldName,463 const uInt beamNo,464 const uInt scanNo,465 const uInt ifNo,466 const Int srcType,467 const uInt cycleNo,468 const Double time,469 const uInt polNo) { return True ;}451 virtual void enterFieldName(const uInt /*recordNo*/, const String &/*columnValue*/) { 452 } 453 virtual void leaveFieldName(const uInt /*recordNo*/, const String &/*columnValue*/) { 454 } 455 virtual void enterBeamNo(const uInt /*recordNo*/, uInt /*columnValue*/) { } 456 virtual void leaveBeamNo(const uInt /*recordNo*/, uInt /*columnValue*/) { } 457 virtual void enterScanNo(const uInt /*recordNo*/, uInt /*columnValue*/) { } 458 virtual void leaveScanNo(const uInt /*recordNo*/, uInt /*columnValue*/) { } 459 virtual void enterIfNo(const uInt /*recordNo*/, uInt /*columnValue*/) { } 460 virtual void leaveIfNo(const uInt /*recordNo*/, uInt /*columnValue*/) { } 461 virtual void enterSrcType(const uInt /*recordNo*/, Int /*columnValue*/) { } 462 virtual void leaveSrcType(const uInt /*recordNo*/, Int /*columnValue*/) { } 463 virtual void enterCycleNo(const uInt /*recordNo*/, uInt /*columnValue*/) { } 464 virtual void leaveCycleNo(const uInt /*recordNo*/, uInt /*columnValue*/) { } 465 virtual void enterTime(const uInt /*recordNo*/, Double /*columnValue*/) { } 466 virtual void leaveTime(const uInt /*recordNo*/, Double /*columnValue*/) { } 467 virtual void enterPolNo(const uInt /*recordNo*/, uInt /*columnValue*/) { } 468 virtual void leavePolNo(const uInt /*recordNo*/, uInt /*columnValue*/) { } 469 470 virtual Bool visitRecord(const uInt /*recordNo*/, 471 const String &/*fieldName*/, 472 const uInt /*beamNo*/, 473 const uInt /*scanNo*/, 474 const uInt /*ifNo*/, 475 const Int /*srcType*/, 476 const uInt /*cycleNo*/, 477 const Double /*time*/, 478 const uInt /*polNo*/) { return True ;} 470 479 471 480 virtual Bool visit(Bool isFirst, const uInt recordNo, … … 693 702 } 694 703 695 virtual void enterFieldName(const uInt recordNo, const String & columnValue) {704 virtual void enterFieldName(const uInt recordNo, const String &/*columnValue*/) { 696 705 //printf("%u: FieldName: %s\n", recordNo, columnValue.c_str()); 697 706 fieldName = fieldNameCol.asString( recordNo ) ; … … 715 724 *fieldIdRF = fieldId ; 716 725 } 717 virtual void leaveFieldName(const uInt recordNo, const String &columnValue) {718 } 719 virtual void enterBeamNo(const uInt recordNo, uInt columnValue) {726 virtual void leaveFieldName(const uInt /*recordNo*/, const String &/*columnValue*/) { 727 } 728 virtual void enterBeamNo(const uInt /*recordNo*/, uInt columnValue) { 720 729 //printf("%u: BeamNo: %u\n", recordNo, columnValue); 721 730 … … 726 735 *feed2RF = feedId ; 727 736 } 728 virtual void leaveBeamNo(const uInt recordNo, uInt columnValue) {729 } 730 virtual void enterScanNo(const uInt recordNo, uInt columnValue) {737 virtual void leaveBeamNo(const uInt /*recordNo*/, uInt /*columnValue*/) { 738 } 739 virtual void enterScanNo(const uInt /*recordNo*/, uInt columnValue) { 731 740 //printf("%u: ScanNo: %u\n", recordNo, columnValue); 732 741 … … 735 744 *scanNumberRF = (Int)columnValue + 1 ; 736 745 } 737 virtual void leaveScanNo(const uInt recordNo, uInt columnValue) {746 virtual void leaveScanNo(const uInt /*recordNo*/, uInt /*columnValue*/) { 738 747 subscan = 1 ; 739 748 } … … 752 761 addFeed( feedId, spwId ) ; 753 762 } 754 virtual void leaveIfNo(const uInt recordNo, uInt columnValue) {755 } 756 virtual void enterSrcType(const uInt recordNo, Int columnValue) {763 virtual void leaveIfNo(const uInt /*recordNo*/, uInt /*columnValue*/) { 764 } 765 virtual void enterSrcType(const uInt /*recordNo*/, Int columnValue) { 757 766 //printf("%u: SrcType: %d\n", recordNo, columnValue); 758 767 … … 762 771 *stateIdRF = stateId ; 763 772 } 764 virtual void leaveSrcType(const uInt recordNo, Int columnValue) {765 } 766 virtual void enterCycleNo(const uInt recordNo, uInt columnValue) {773 virtual void leaveSrcType(const uInt /*recordNo*/, Int /*columnValue*/) { 774 } 775 virtual void enterCycleNo(const uInt /*recordNo*/, uInt /*columnValue*/) { 767 776 //printf("%u: CycleNo: %u\n", recordNo, columnValue); 768 777 } 769 virtual void leaveCycleNo(const uInt recordNo, uInt columnValue) {778 virtual void leaveCycleNo(const uInt /*recordNo*/, uInt /*columnValue*/) { 770 779 } 771 780 virtual void enterTime(const uInt recordNo, Double columnValue) { … … 797 806 *exposureRF = interval ; 798 807 } 799 virtual void leaveTime(const uInt recordNo, Double columnValue) {808 virtual void leaveTime(const uInt /*recordNo*/, Double /*columnValue*/) { 800 809 if ( holder->nPol() > 0 ) { 801 810 Int polId = addPolarization() ; … … 814 823 } 815 824 } 816 virtual void enterPolNo(const uInt recordNo, uInt columnValue) {825 virtual void enterPolNo(const uInt /*recordNo*/, uInt /*columnValue*/) { 817 826 //printf("%u: PolNo: %d\n", recordNo, columnValue); 818 827 } 819 virtual void leavePolNo(const uInt recordNo, uInt columnValue) {828 virtual void leavePolNo(const uInt /*recordNo*/, uInt /*columnValue*/) { 820 829 } 821 830 822 831 virtual Bool visitRecord(const uInt recordNo, 823 const String & fieldName,824 const uInt beamNo,825 const uInt scanNo,826 const uInt ifNo,827 const Int srcType,828 const uInt cycleNo,829 const Double time,832 const String &/*fieldName*/, 833 const uInt /*beamNo*/, 834 const uInt /*scanNo*/, 835 const uInt /*ifNo*/, 836 const Int /*srcType*/, 837 const uInt /*cycleNo*/, 838 const Double /*time*/, 830 839 const uInt polNo) { 831 840 //printf("%u: %s, %u, %u, %u, %d, %u, %f, %d\n", recordNo, … … 975 984 976 985 Int numCorr = holder->nPol() ; 977 Matrix<Int> corrProduct = corrProductTemplate[numCorr] ; 986 Matrix<Int> corrProduct = corrProductTemplate[numCorr].copy() ; 987 if ( numCorr == 1 && (corrType[0] == Stokes::YY || corrType[0] == Stokes::LL ) ) { 988 corrProduct = 1; 989 } 978 990 979 991 if ( idx == -1 ) { … … 1183 1195 void attachSubtables() 1184 1196 { 1185 const TableRecord &keys = table.keywordSet() ;1197 //const TableRecord &keys = table.keywordSet() ; 1186 1198 TableRecord &mskeys = ms.rwKeywordSet() ; 1187 1199 … … 1222 1234 1223 1235 // constant values 1224 Int id = 0 ;1236 //Int id = 0 ; 1225 1237 RecordFieldPtr<Int> intRF( r, "OBSERVATION_ID" ) ; 1226 1238 *intRF = 0 ; … … 1490 1502 } 1491 1503 1492 virtual void enterBeamNo(const uInt recordNo, uInt columnValue) { }1493 virtual void leaveBeamNo(const uInt recordNo, uInt columnValue) { }1494 virtual void enterIfNo(const uInt recordNo, uInt columnValue) { }1495 virtual void leaveIfNo(const uInt recordNo, uInt columnValue) { }1496 virtual void enterPolNo(const uInt recordNo, uInt columnValue) { }1497 virtual void leavePolNo(const uInt recordNo, uInt columnValue) { }1498 virtual void enterTime(const uInt recordNo, Double columnValue) { }1499 virtual void leaveTime(const uInt recordNo, Double columnValue) { }1500 1501 virtual Bool visitRecord(const uInt recordNo,1502 const uInt beamNo,1503 const uInt ifNo,1504 const uInt polNo,1505 const Double time) { return True ;}1504 virtual void enterBeamNo(const uInt /*recordNo*/, uInt /*columnValue*/) { } 1505 virtual void leaveBeamNo(const uInt /*recordNo*/, uInt /*columnValue*/) { } 1506 virtual void enterIfNo(const uInt /*recordNo*/, uInt /*columnValue*/) { } 1507 virtual void leaveIfNo(const uInt /*recordNo*/, uInt /*columnValue*/) { } 1508 virtual void enterPolNo(const uInt /*recordNo*/, uInt /*columnValue*/) { } 1509 virtual void leavePolNo(const uInt /*recordNo*/, uInt /*columnValue*/) { } 1510 virtual void enterTime(const uInt /*recordNo*/, Double /*columnValue*/) { } 1511 virtual void leaveTime(const uInt /*recordNo*/, Double /*columnValue*/) { } 1512 1513 virtual Bool visitRecord(const uInt /*recordNo*/, 1514 const uInt /*beamNo*/, 1515 const uInt /*ifNo*/, 1516 const uInt /*polNo*/, 1517 const Double /*time*/) { return True ;} 1506 1518 1507 1519 virtual Bool visit(Bool isFirst, const uInt recordNo, … … 1728 1740 : BaseMSSysCalVisitor( from ), 1729 1741 sctab( to ), 1730 rowidx( 0 ) 1742 rowidx( 0 ), 1743 polno_() 1731 1744 { 1732 1745 scrow = TableRow( sctab ) ; … … 1779 1792 } 1780 1793 1781 virtual void enterBeamNo(const uInt recordNo, uInt columnValue)1794 virtual void enterBeamNo(const uInt /*recordNo*/, uInt columnValue) 1782 1795 { 1783 1796 *feedIdRF = (Int)columnValue ; 1784 1797 } 1785 virtual void leaveBeamNo(const uInt recordNo, uInt columnValue)1798 virtual void leaveBeamNo(const uInt /*recordNo*/, uInt /*columnValue*/) 1786 1799 { 1787 1800 } … … 1796 1809 *specWinIdRF = (Int)columnValue ; 1797 1810 } 1798 virtual void leaveIfNo(const uInt recordNo, uInt columnValue)1811 virtual void leaveIfNo(const uInt /*recordNo*/, uInt /*columnValue*/) 1799 1812 { 1800 1813 //cout << "leaveIfNo" << endl ; 1801 1814 post() ; 1802 lastTsys->reset() ; 1803 lastTcalId.resize() ; 1804 theTsys->reset() ; 1805 theTcalId.resize() ; 1815 reset(true); 1806 1816 startTime = 0.0 ; 1807 1817 endTime = 0.0 ; … … 1817 1827 } 1818 1828 } 1819 virtual void leaveTime(const uInt recordNo, Double columnValue)1829 virtual void leaveTime(const uInt /*recordNo*/, Double columnValue) 1820 1830 { 1821 1831 //cout << "leaveTime" << endl ; … … 1824 1834 *lastTsys = *theTsys ; 1825 1835 lastTcalId = theTcalId ; 1826 theTsys->reset() ; 1827 theTcalId.resize() ; 1836 reset(false); 1828 1837 startTime = columnValue * 86400.0 - 0.5 * interval ; 1829 1838 endTime = columnValue * 86400.0 + 0.5 * interval ; … … 1838 1847 Vector<Float> tsys = tsysCol( recordNo ) ; 1839 1848 uInt tcalId = tcalIdCol.asuInt( recordNo ) ; 1840 // lastTsys.nrow() must be npol 1841 if ( lastTsys->nrow() == columnValue ) 1849 polno_.insert( columnValue ) ; 1850 uInt numPol = polno_.size() ; 1851 if ( lastTsys->nrow() < numPol ) 1842 1852 lastTsys->appendTsys( recordNo ) ; 1843 // lastTcalId.nelements() must be npol 1844 if ( lastTcalId.nelements() == columnValue ) 1845 appendTcalId( lastTcalId, tcalId, columnValue ) ; 1846 // theTsys.nrow() must be npol 1847 if ( theTsys->nrow() == columnValue ) 1853 if ( lastTcalId.nelements() <= numPol ) 1854 appendTcalId( lastTcalId, tcalId, numPol-1 ) ; 1855 if ( theTsys->nrow() < numPol ) 1848 1856 theTsys->appendTsys( recordNo ) ; 1849 1857 else { 1850 theTsys->setTsys( recordNo, columnValue) ;1851 } 1852 if ( theTcalId.nelements() == columnValue)1853 appendTcalId( theTcalId, tcalId, columnValue) ;1858 theTsys->setTsys( recordNo, numPol-1 ) ; 1859 } 1860 if ( theTcalId.nelements() < numPol ) 1861 appendTcalId( theTcalId, tcalId, numPol-1 ) ; 1854 1862 else 1855 setTcalId( theTcalId, tcalId, columnValue) ;1856 } 1857 virtual void leavePolNo( const uInt recordNo, uInt columnValue)1863 setTcalId( theTcalId, tcalId, numPol-1 ) ; 1864 } 1865 virtual void leavePolNo( const uInt /*recordNo*/, uInt /*columnValue*/ ) 1858 1866 { 1859 1867 } 1860 1868 1861 1869 private: 1862 void appendTcalId( Vector<uInt> &v, uInt &elem, uInt &polId ) 1870 void reset(bool completely) 1871 { 1872 if (completely) { 1873 lastTsys->reset() ; 1874 lastTcalId.resize() ; 1875 } 1876 theTsys->reset() ; 1877 theTcalId.resize() ; 1878 polno_.clear(); 1879 } 1880 void appendTcalId( Vector<uInt> &v, uInt &elem, uInt polId ) 1863 1881 { 1864 1882 v.resize( polId+1, True ) ; 1865 1883 v[polId] = elem ; 1866 1884 } 1867 void setTcalId( Vector<uInt> &v, uInt &elem, uInt &polId )1885 void setTcalId( Vector<uInt> &v, uInt &elem, uInt polId ) 1868 1886 { 1869 1887 v[polId] = elem ; … … 1891 1909 tcalProcessor->setTcalId( lastTcalId ) ; 1892 1910 Array<Float> tcal = tcalProcessor->getTcal() ; 1911 Array<Float> tsys = lastTsys->getTsys() ; 1893 1912 tcalRF.define( tcal ) ; 1894 tsysRF.define( lastTsys->getTsys()) ;1913 tsysRF.define( tsys ) ; 1895 1914 sctab.addRow( 1, True ) ; 1896 1915 scrow.put( rowidx ) ; … … 1900 1919 Bool isUpdated() 1901 1920 { 1902 Bool ret = False ; 1903 ret = anyNE( theTcalId, lastTcalId ) ; 1904 if ( !ret ) 1905 ret = anyNE( theTsys->getTsys(), lastTsys->getTsys() ) ; 1921 Bool ret = (anyNE( theTcalId, lastTcalId ) || anyNE( theTsys->getTsys(), lastTsys->getTsys() )) ; 1906 1922 return ret ; 1907 1923 } … … 1915 1931 CountedPtr<BaseTsysHolder> lastTsys,theTsys; 1916 1932 Vector<uInt> lastTcalId,theTcalId; 1933 set<uInt> polno_; 1917 1934 CountedPtr<BaseTcalProcessor> tcalProcessor ; 1918 1935 Vector<Bool> effectiveTcal; … … 1928 1945 MSWriter::MSWriter(CountedPtr<Scantable> stable) 1929 1946 : table_(stable), 1947 mstable_(NULL), 1930 1948 isWeather_(False), 1931 1949 tcalSpec_(False), 1932 1950 tsysSpec_(False), 1933 mstable_(NULL),1934 1951 ptTabName_("") 1935 1952 {
Note:
See TracChangeset
for help on using the changeset viewer.