Changeset 1453 for branches/alma/external/atnf/PKSIO/PKSMS2reader.cc
- Timestamp:
- 11/27/08 12:47:15 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/alma/external/atnf/PKSIO/PKSMS2reader.cc
r1393 r1453 92 92 cPKSMS = MeasurementSet(msName); 93 93 // taql access to the syscal table 94 String tmpcalName = msName; 95 tmpcalName.append("/SYSCAL"); 96 cSysCalTab = Table(tmpcalName); 94 cHaveSysCal = False; 95 if (cHaveSysCal=Table::isReadable(cPKSMS.sysCalTableName())) { 96 cSysCalTab = Table(cPKSMS.sysCalTableName()); 97 } 97 98 98 99 cIdx = 0; … … 116 117 ROMSSysCalColumns sysCalCols(cPKSMS.sysCal()); 117 118 ROMSWeatherColumns weatherCols(cPKSMS.weather()); 119 ROMSAntennaColumns antennaCols(cPKSMS.antenna()); 118 120 119 121 // Column accessors for required columns. … … 153 155 154 156 // Optional columns. 157 cHaveTsys = False; 158 cHaveTcal = False; 155 159 if ((cHaveSrcVel = cPKSMS.source().tableDesc().isColumn("SYSVEL"))) { 156 160 cSrcVelCol.attach(cPKSMS.source(), "SYSVEL"); 157 161 } 158 162 159 if ( (cHaveTsys = cPKSMS.sysCal().tableDesc().isColumn("TSYS"))) {163 if (cHaveSysCal && (cHaveTsys = cPKSMS.sysCal().tableDesc().isColumn("TSYS"))) { 160 164 cTsysCol.attach(cPKSMS.sysCal(), "TSYS"); 161 165 } 162 166 163 if ( (cHaveTcal = cPKSMS.sysCal().tableDesc().isColumn("TCAL"))) {167 if (cHaveSysCal && (cHaveTcal = cPKSMS.sysCal().tableDesc().isColumn("TCAL"))) { 164 168 cTcalCol.attach(cPKSMS.sysCal(), "TCAL"); 165 169 } … … 176 180 // Spectral data should always be present. 177 181 haveSpectra = True; 178 cFloatDataCol.reference(msCols.floatData()); 182 cHaveDataCol = False; 183 cHaveCorrectedDataCol = False; 184 //String telName = antennaCols.name()(0); 185 ROMSObservationColumns observationCols(cPKSMS.observation()); 186 String telName = observationCols.telescopeName()(0); 187 //cATF = (telName.contains("DA41") || telName.contains("DV01")); 188 cATF = telName.contains("ATF"); 189 190 if (cHaveDataCol = cPKSMS.isColumn(MSMainEnums::DATA)) { 191 if (cATF) { 192 //try to read a single baseline interferometeric data 193 //and treat it as single dish data 194 //maybe extended for ALMA commissioning later 195 cDataCol.reference(msCols.data()); 196 if (cHaveCorrectedDataCol = cPKSMS.isColumn(MSMainEnums::CORRECTED_DATA)) { 197 //cerr<<"Do have CORRECTED_DATA column"<<endl; 198 cCorrectedDataCol.reference(msCols.correctedData()); 199 } 200 } 201 } 202 else { 203 cFloatDataCol.reference(msCols.floatData()); 204 } 179 205 cFlagCol.reference(msCols.flag()); 180 206 181 207 182 if ( (cGetXPol = cPKSMS.isColumn(MSMainEnums::DATA))) {208 if (cGetXPol = (cPKSMS.isColumn(MSMainEnums::DATA) && (!cATF))) { 183 209 if ((cHaveXCalFctr = cPKSMS.tableDesc().isColumn("XCALFCTR"))) { 184 210 cXCalFctrCol.attach(cPKSMS, "XCALFCTR"); … … 223 249 haveXPol = False; 224 250 225 if (cGetXPol ) {251 if (cGetXPol && !(cATF)) { 226 252 for (Int irow = 0; irow < cNRow; irow++) { 227 253 if (cDataCol.isDefined(irow)) { … … 303 329 304 330 fluxunit = ""; 305 const TableRecord& keywordSet 306 = cFloatDataCol.columnDesc().keywordSet(); 331 if (cHaveDataCol) { 332 const TableRecord& keywordSet2 333 = cDataCol.columnDesc().keywordSet(); 334 if(keywordSet2.isDefined("UNIT")) { 335 fluxunit = keywordSet2.asString("UNIT"); 336 } 337 } else { 338 const TableRecord& keywordSet 339 = cFloatDataCol.columnDesc().keywordSet(); 340 if(keywordSet.isDefined("UNIT")) { 341 fluxunit = keywordSet.asString("UNIT"); 342 } 343 } 344 345 /*** 346 const TableRecord& keywordSet 347 = cFloatDataCol.columnDesc().keywordSet(); 307 348 if(keywordSet.isDefined("UNIT")) { 308 349 fluxunit = keywordSet.asString("UNIT"); 309 350 } 310 351 ***/ 311 352 // Coordinate equinox. 312 353 ROMSPointingColumns pointingCols(cPKSMS.pointing()); … … 529 570 Double &bandwidth, 530 571 Double &freqInc, 531 Double&restFreq,572 Vector<Double> &restFreq, 532 573 Vector<Float> &tcal, 533 574 String &tcalTime, … … 584 625 } 585 626 } 586 587 627 // Renumerate scan no. Here still is 1-based 588 628 //scanNo = cScanNoCol(cIdx) - cScanNoCol(0) + 1; … … 624 664 625 665 // Systemic velocity. 626 if (!cHaveSrcVel ) {666 if (!cHaveSrcVel || cATF) { 627 667 srcVel = 0.0f; 628 668 } else { … … 634 674 Bool cGBT = telescope.contains("GBT"); 635 675 // Observation type. 636 Int stateId = cStateIdCol(cIdx); 637 if (stateId == -1) { 638 //obsMode = " "; 639 } else { 640 obsMode = cObsModeCol(stateId); 641 Bool sigState =cSigStateCol(stateId); 642 Bool refState =cRefStateCol(stateId); 643 //DEBUG 644 //cerr <<"stateid="<<stateId<<" obsmode="<<obsMode<<endl; 645 if (cGBT) { 646 // split the obsMode string and append a proper label 647 // (these are GBT specific) 648 int epos = obsMode.find_first_of(':'); 649 int nextpos = obsMode.find_first_of(':',epos+1); 650 string obsMode1 = obsMode.substr(0,epos); 651 string obsMode2 = obsMode.substr(epos+1,nextpos-epos-1); 676 // check if State Table exist 677 //Bool cHaveStateTab=Table::isReadable(cPKSMS.stateTableName()); 678 Int stateId = 0; 679 Int StateNRow = 0; 680 StateNRow=cObsModeCol.nrow(); 681 if (Table::isReadable(cPKSMS.stateTableName())) { 682 obsMode = " "; 683 if (StateNRow > 0) { 684 stateId = cStateIdCol(cIdx); 685 if (stateId == -1) { 686 //obsMode = " "; 687 } else { 688 obsMode = cObsModeCol(stateId); 689 Bool sigState =cSigStateCol(stateId); 690 Bool refState =cRefStateCol(stateId); 691 //DEBUG 692 //cerr <<"stateid="<<stateId<<" obsmode="<<obsMode<<endl; 693 if (cGBT) { 694 // split the obsMode string and append a proper label 695 // (these are GBT specific) 696 int epos = obsMode.find_first_of(':'); 697 int nextpos = obsMode.find_first_of(':',epos+1); 698 string obsMode1 = obsMode.substr(0,epos); 699 string obsMode2 = obsMode.substr(epos+1,nextpos-epos-1); 652 700 653 //cerr <<"obsMode2= "<<obsMode2<<endl; 654 if (!srcName.contains("_ps") 655 &&!srcName.contains("_psr") 656 &&!srcName.contains("_nod") 657 &&!srcName.contains("_fs") 658 &&!srcName.contains("_fsr")) { 659 // if Nod mode observation , append '_nod' 660 if (obsMode1 == "Nod") { 661 srcName.append("_nod"); 662 } else if (obsMode1 == "OffOn") { 663 // for GBT position switch observations (OffOn or OnOff) 664 if (obsMode2 == "PSWITCHON") srcName.append("_ps"); 665 if (obsMode2 == "PSWITCHOFF") srcName.append("_psr"); 666 } else { 667 if (obsMode2 == "FSWITCH") { 668 // for GBT frequency switch mode 669 if (sigState) srcName.append("_fs"); 670 if (refState) srcName.append("_fsr"); 701 //cerr <<"obsMode2= "<<obsMode2<<endl; 702 if (!srcName.contains("_ps") 703 &&!srcName.contains("_psr") 704 &&!srcName.contains("_nod") 705 &&!srcName.contains("_fs") 706 &&!srcName.contains("_fsr")) { 707 // if Nod mode observation , append '_nod' 708 if (obsMode1 == "Nod") { 709 srcName.append("_nod"); 710 } else if (obsMode1 == "OffOn") { 711 // for GBT position switch observations (OffOn or OnOff) 712 if (obsMode2 == "PSWITCHON") srcName.append("_ps"); 713 if (obsMode2 == "PSWITCHOFF") srcName.append("_psr"); 714 } else { 715 if (obsMode2 == "FSWITCH") { 716 // for GBT frequency switch mode 717 if (sigState) srcName.append("_fs"); 718 if (refState) srcName.append("_fsr"); 719 } 720 } 671 721 } 672 } 673 } 674 } 675 } 722 } 723 } 724 } 725 } 676 726 // CAL state 677 727 // this should be apply just for GBT data? 678 728 Double Cal; 679 if (stateId==-1 ) {729 if (stateId==-1 || StateNRow==0) { 680 730 Cal = 0; 681 731 } else { … … 694 744 Vector<Double> chanFreq = cChanFreqCol(iIF); 695 745 if (nChan == 1) { 696 cout << "The input is continuum data. "<< endl;697 746 freqInc = chanFreq(0); 698 747 refFreq = chanFreq(0); 699 748 restFreq = 0.0f; 700 749 } else { 750 701 751 if (cStartChan(iIF) <= cEndChan(iIF)) { 702 752 freqInc = chanFreq(1) - chanFreq(0); … … 705 755 } 706 756 refFreq = chanFreq(cRefChan(iIF)-1); 707 restFreq = cSrcRestFrqCol(srcId)(IPosition(1,0)); 757 Bool HaveSrcRestFreq= cSrcRestFrqCol.isDefined(srcId); 758 if (HaveSrcRestFreq) { 759 //restFreq = cSrcRestFrqCol(srcId)(IPosition(1,0)); 760 restFreq = cSrcRestFrqCol(srcId); 761 } else { 762 restFreq = 0.0f; 763 } 708 764 } 709 765 bandwidth = abs(freqInc * nChan); … … 720 776 721 777 // Find the appropriate entry in the WEATHER subtable. 722 Vector<Double> wTimes = cWeatherTimeCol.getColumn(); 723 Int weatherIdx; 724 for (weatherIdx = wTimes.nelements()-1; weatherIdx >= 0; weatherIdx--) { 725 if (cWeatherTimeCol(weatherIdx) <= time) { 726 break; 727 } 728 } 729 730 if (weatherIdx < 0) { 778 //Bool cHaveStateTab=Table::isReadable(cPKSMS.stateTableName()); 779 Bool cHaveWeatherTab = Table::isReadable(cPKSMS.weatherTableName()); 780 Int weatherIdx=-1; 781 if (cHaveWeatherTab) { 782 Vector<Double> wTimes = cWeatherTimeCol.getColumn(); 783 for (weatherIdx = wTimes.nelements()-1; weatherIdx >= 0; weatherIdx--) { 784 if (cWeatherTimeCol(weatherIdx) <= time) { 785 break; 786 } 787 } 788 } 789 if (weatherIdx < 0 || !cHaveWeatherTab) { 731 790 // No appropriate WEATHER entry. 732 791 pressure = 0.0f; … … 874 933 baseSub.resize(0,0); 875 934 } 876 877 935 // Get spectral data. 878 936 if (cGetSpectra) { 879 937 Matrix<Float> tmpData; 880 938 Matrix<Bool> tmpFlag; 881 cFloatDataCol.getSlice(cIdx, cDataSel(iIF), tmpData, True); 939 if (cHaveDataCol) { 940 Matrix<Complex> tmpCmplxData; 941 Matrix<Float> tmpReData; 942 Matrix<Float> tmpImData; 943 //cerr<<"reading spectra..."<<endl; 944 //# TODO - should have a flag to user to select DATA or CORRECTED_DATA 945 //# currently just automatically determined, --- read CORRECTED one 946 //# if the column exist. 947 if (cHaveCorrectedDataCol) { 948 cCorrectedDataCol.getSlice(cIdx, cDataSel(iIF), tmpCmplxData, True); 949 } else { 950 cDataCol.getSlice(cIdx, cDataSel(iIF), tmpCmplxData, True); 951 } 952 tmpReData = real(tmpCmplxData); 953 tmpImData = imag(tmpCmplxData); 954 tmpData = sqrt(tmpReData*tmpReData + tmpImData*tmpImData); 955 } else { 956 cFloatDataCol.getSlice(cIdx, cDataSel(iIF), tmpData, True); 957 } 882 958 cFlagCol.getSlice(cIdx, cDataSel(iIF), tmpFlag, True); 883 959 … … 909 985 // Get cross-polarization data. 910 986 if (cGetXPol) { 987 //cerr<<"cGetXPol="<<cGetXPol<<endl; 988 //cerr<<"cHaveXCalFctr="<<cHaveXCalFctr<<endl; 989 911 990 if (cHaveXCalFctr) { 912 991 cXCalFctrCol.get(cIdx, xCalFctr); … … 915 994 } 916 995 917 cDataCol.get(cIdx, xPol, True); 918 919 if (cEndChan(iIF) < cStartChan(iIF)) { 920 Complex ctmp; 921 Int jchan = nChan - 1; 922 for (Int ichan = 0; ichan < nChan/2; ichan++, jchan--) { 923 ctmp = xPol(ichan); 924 xPol(ichan) = xPol(jchan); 925 xPol(jchan) = ctmp; 926 } 927 } 928 } 929 996 if(!cATF) { 997 cDataCol.get(cIdx, xPol, True); 998 999 if (cEndChan(iIF) < cStartChan(iIF)) { 1000 Complex ctmp; 1001 Int jchan = nChan - 1; 1002 for (Int ichan = 0; ichan < nChan/2; ichan++, jchan--) { 1003 ctmp = xPol(ichan); 1004 xPol(ichan) = xPol(jchan); 1005 xPol(jchan) = ctmp; 1006 } 1007 } 1008 } 1009 } 1010 /** 1011 cerr<<"scanNo="<<scanNo<<endl; 1012 cerr<<"cycleNo="<<cycleNo<<endl; 1013 cerr<<"mjd="<<mjd<<endl; 1014 cerr<<"interval="<<interval<<endl; 1015 cerr<<"fieldName="<<fieldName<<endl; 1016 cerr<<"srcNmae="<<srcName<<endl; 1017 cerr<<"srcDir="<<srcDir<<endl; 1018 cerr<<"srcPM="<<srcPM<<endl; 1019 cerr<<"srcVel="<<srcVel<<endl; 1020 cerr<<"obsMode="<<obsMode<<endl; 1021 cerr<<"IFno="<<IFno<<endl; 1022 cerr<<"refFreq="<<refFreq<<endl; 1023 cerr<<"tcal="<<tcal<<endl; 1024 cerr<<"direction="<<direction<<endl; 1025 cerr<<"scanRate="<<scanRate<<endl; 1026 cerr<<"tsys="<<tsys<<endl; 1027 cerr<<"sigma="<<sigma<<endl; 1028 cerr<<"calFctr="<<calFctr<<endl; 1029 cerr<<"baseLin="<<baseLin<<endl; 1030 cerr<<"baseSub="<<baseSub<<endl; 1031 cerr<<"spectra="<<spectra.shape()<<endl; 1032 cerr<<"flagged="<<flagged.shape()<<endl; 1033 cerr<<"xCalFctr="<<xCalFctr<<endl; 1034 cerr<<"xPol="<<xPol<<endl; 1035 **/ 930 1036 cIdx++; 931 1037 … … 1003 1109 Matrix<Float> tmpData; 1004 1110 Matrix<Bool> tmpFlag; 1005 cFloatDataCol.getSlice(cIdx, cDataSel(iIF), tmpData, True); 1111 if (cHaveDataCol) { 1112 Matrix<Complex> tmpCmplxData; 1113 cDataCol.getSlice(cIdx, cDataSel(iIF), tmpCmplxData, True); 1114 tmpData = real(tmpCmplxData); 1115 } else { 1116 cFloatDataCol.getSlice(cIdx, cDataSel(iIF), tmpData, True); 1117 } 1006 1118 cFlagCol.getSlice(cIdx, cDataSel(iIF), tmpFlag, True); 1007 1119
Note: See TracChangeset
for help on using the changeset viewer.