Changeset 386
- Timestamp:
- 02/08/05 14:00:43 (20 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDMemTable.cc
r385 r386 167 167 td.addColumn(ScalarColumnDesc<Double>("INTERVAL")); 168 168 td.addColumn(ArrayColumnDesc<uInt>("FREQID")); 169 td.addColumn(ArrayColumnDesc<uInt>("RESTFREQID")); 169 170 td.addColumn(ArrayColumnDesc<Double>("DIRECTION")); 170 171 td.addColumn(ScalarColumnDesc<String>("FIELDNAME")); … … 193 194 integrCol_.attach(table_, "INTERVAL"); 194 195 freqidCol_.attach(table_, "FREQID"); 196 restfreqidCol_.attach(table_, "RESTFREQID"); 195 197 dirCol_.attach(table_, "DIRECTION"); 196 198 fldnCol_.attach(table_, "FIELDNAME"); … … 434 436 } 435 437 436 // Continue with km/s or Hz. Get FreqID 438 // Continue with km/s or Hz. Get FreqIDs 437 439 438 440 Vector<uInt> freqIDs; 439 441 freqidCol_.get(whichRow, freqIDs); 440 442 uInt freqID = freqIDs(IFSel_); 443 restfreqidCol_.get(whichRow, freqIDs); 444 uInt restFreqID = freqIDs(IFSel_); 441 445 442 446 // Get SpectralCoordinate, set reference frame conversion, 443 447 // velocity conversion, and rest freq state 444 448 445 SpectralCoordinate spc = getSpectralCoordinate(freqID, whichRow);449 SpectralCoordinate spc = getSpectralCoordinate(freqID, restFreqID, whichRow); 446 450 Vector<Double> pixel(nChan()); 447 451 indgen(pixel); … … 486 490 Vector<uInt> freqIDs; 487 491 freqidCol_.get(whichRow, freqIDs); 488 uInt freqID = freqIDs(IFSel_); 492 uInt freqID = freqIDs(IFSel_); 493 restfreqidCol_.get(whichRow, freqIDs); 494 uInt restFreqID = freqIDs(IFSel_); 489 495 490 496 // Get SpectralCoordinate, with frame, velocity, rest freq state set 491 497 492 SpectralCoordinate spc = getSpectralCoordinate(freqID, whichRow);498 SpectralCoordinate spc = getSpectralCoordinate(freqID, restFreqID, whichRow); 493 499 // 494 500 String s = "Channel"; … … 705 711 706 712 707 SpectralCoordinate SDMemTable::getSpectralCoordinate(uInt freqID, 708 713 SpectralCoordinate SDMemTable::getSpectralCoordinate(uInt freqID, uInt restFreqID, 714 uInt whichRow) const 709 715 { 710 716 … … 715 721 Table t = table_.keywordSet().asTable("FREQUENCIES"); 716 722 717 // Get rest frequencies from table, one per IF ??? 718 719 Vector<Double> vec; 720 t.keywordSet().get("RESTFREQS",vec); 721 if (vec.nelements() > 0) { 722 spec.setRestFrequencies(vec); 723 724 // Select rest freq 725 726 if (IFSel_ < vec.nelements()) { 727 spec.selectRestFrequency(uInt(IFSel_)); 728 } else { 729 cerr << "There is no rest frequency for this IF; selecting rest freq for IF=0" << endl; 730 spec.selectRestFrequency(0u); 731 } 723 // Set rest frequency 724 725 Vector<Double> restFreqIDs; 726 t.keywordSet().get("RESTFREQS",restFreqIDs); 727 if (restFreqID < restFreqIDs.nelements()) { // SHould always be true 728 spec.setRestFrequency(restFreqIDs(restFreqID),True); 732 729 } 733 730 … … 856 853 SDFrequencyTable SDMemTable::getSDFreqTable() const 857 854 { 855 cerr << "ENter SDMemTbale::getSDFreqTable" << endl; 856 858 857 const Table& t = table_.keywordSet().asTable("FREQUENCIES"); 859 858 SDFrequencyTable sdft; … … 893 892 Vector<Double> restFreqs; 894 893 t.keywordSet().get("RESTFREQS", restFreqs); 894 cerr << "old restfreqs from Table = " << restFreqs << endl; 895 cerr << "add them to SDFreqTable" << endl; 895 896 for (uInt i=0; i<restFreqs.nelements(); i++) { 896 897 sdft.addRestFrequency(restFreqs[i]); 897 898 } 898 899 sdft.setRestFrequencyUnit(String("Hz")); 900 cerr << "Exit getSDFreqTable" << endl; 899 901 // 900 902 return sdft; … … 905 907 uInt rno = table_.nrow(); 906 908 table_.addRow(); 907 908 // mjd.put(rno, sdc.timestamp); 909 // 909 910 timeCol_.put(rno, sdc.timestamp); 910 911 srcnCol_.put(rno, sdc.sourcename); … … 916 917 integrCol_.put(rno, sdc.interval); 917 918 freqidCol_.put(rno, sdc.getFreqMap()); 919 restfreqidCol_.put(rno, sdc.getRestFreqMap()); 918 920 dirCol_.put(rno, sdc.getDirection()); 919 921 rbeamCol_.put(rno, sdc.refbeam); … … 924 926 paraCol_.put(rno, sdc.parangle); 925 927 histCol_.put(rno, sdc.getHistory()); 926 928 // 927 929 return true; 928 930 } … … 944 946 sdc.tcal[0] = tc[0];sdc.tcal[1] = tc[1]; 945 947 tcaltCol_.get(whichRow, sdc.tcaltime); 948 // 946 949 Array<Float> spectrum; 947 950 Array<Float> tsys; … … 950 953 Array<Double> direction; 951 954 Vector<String> histo; 955 // 952 956 specCol_.get(whichRow, spectrum); 953 957 sdc.putSpectrum(spectrum); … … 958 962 freqidCol_.get(whichRow, fmap); 959 963 sdc.putFreqMap(fmap); 964 restfreqidCol_.get(whichRow, fmap); 965 sdc.putRestFreqMap(fmap); 960 966 dirCol_.get(whichRow, direction); 961 967 sdc.putDirection(direction); … … 1335 1341 } 1336 1342 1343 casa::Bool SDMemTable::selectRestFreq (casa::Double restFreq, const String& unit, 1344 const casa::String& source, 1345 casa::Int whichIF) 1346 { 1347 const Int nIFs = nIF(); 1348 if (whichIF>=nIFs) { 1349 throw(AipsError("Illegal IF index")); 1350 } 1351 1352 // Find rest frequency. Add it if necessary 1353 1354 SDFrequencyTable sdft = getSDFreqTable(); 1355 Quantum<Double> rf(restFreq, Unit(unit)); 1356 uInt idx = sdft.addRestFrequency(rf.getValue("Hz")); 1357 1358 // Replace 1359 1360 Bool empty = source.empty(); 1361 Bool ok = False; 1362 if (putSDFreqTable(sdft)) { 1363 const uInt nRow = table_.nrow(); 1364 String srcName; 1365 Vector<uInt> restFreqIDs; 1366 for (uInt i=0; i<nRow; i++) { 1367 srcnCol_.get(i, srcName); 1368 restfreqidCol_.get(i,restFreqIDs); 1369 // 1370 if (empty || source==srcName) { 1371 if (whichIF<0) { 1372 restFreqIDs = idx; 1373 } else { 1374 restFreqIDs(whichIF) = idx; 1375 } 1376 } 1377 // 1378 restfreqidCol_.put(i,restFreqIDs); 1379 } 1380 ok = True; 1381 } else { 1382 ok = False; 1383 } 1384 // 1385 return ok; 1386 } 1387 1388 1337 1389 void SDMemTable::renumber() 1338 1390 { … … 1355 1407 } 1356 1408 } 1409 -
trunk/src/SDMemTable.h
r380 r386 83 83 84 84 //get the data wrapped up in a meta container 85 85 86 SDContainer getSDContainer(casa::uInt whichRow=0) const; 86 87 SDHeader getSDHeader() const; … … 118 119 virtual void setCoordInfo(std::vector<string> theinfo); 119 120 121 // Select RestFreqID. FInds the restFreq ID for specified restFreq, 122 // and updates RESTFREQID column of table for specified IF index 123 // (-1 means all IFs) and source combination 124 virtual casa::Bool selectRestFreq (casa::Double restFreq, const casa::String& unit, 125 const casa::String& source, 126 casa::Int whichIF=-1); 127 120 128 // Get/Set flux unit 121 129 std::string getFluxUnit() const; … … 185 193 casa::SpectralCoordinate getSpectralCoordinate(casa::uInt whichIdx) const; 186 194 187 // Return SC. Set velocity conversion state (unit,doppler), 188 // set rest frequencies. If row number given (>-0), also set195 // Return SC. Set velocity conversion state (unit,doppler), and 196 // rest frequency. If row number given (>=0), also set 189 197 // frame conversion layer (needs direction & time which require row) 190 casa::SpectralCoordinate getSpectralCoordinate(casa::uInt whichIdx, casa::uInt row) const; 198 casa::SpectralCoordinate getSpectralCoordinate(casa::uInt freqID, 199 casa::uInt restFreqID, 200 casa::uInt row) const; 191 201 192 202 // Set just the reference value, pixel and increment into the table … … 232 242 casa::ArrayColumn<casa::Double> dirCol_; 233 243 casa::ArrayColumn<casa::uChar> flagsCol_; 234 casa::ArrayColumn<casa::uInt> freqidCol_ ;244 casa::ArrayColumn<casa::uInt> freqidCol_, restfreqidCol_; 235 245 casa::ArrayColumn<casa::String> histCol_; 236 246 }; -
trunk/src/SDMemTableWrapper.h
r380 r386 149 149 } 150 150 151 bool selectRestFreq(double freq, const std::string& unit, 152 const std::string& source, int whichIF) { 153 return table_->selectRestFreq(casa::Double(freq), casa::String(unit), 154 casa::String(source), 155 casa::Int(whichIF)); 156 } 157 151 158 std::vector<double> getRestFreqs() { 152 159 return table_->getRestFreqs(); -
trunk/src/python_SDMemTable.cc
r357 r386 89 89 .def("_setrestfreqs", &SDMemTableWrapper::setRestFreqs) 90 90 .def("_getrestfreqs", &SDMemTableWrapper::getRestFreqs) 91 .def("_selectrestfreq", &SDMemTableWrapper::selectRestFreq) 91 92 .def("_setcoordinfo", &SDMemTableWrapper::setCoordInfo) 92 93 .def("_getcoordinfo", &SDMemTableWrapper::getCoordInfo)
Note:
See TracChangeset
for help on using the changeset viewer.