- Timestamp:
- 03/17/06 10:10:59 (19 years ago)
- Location:
- trunk/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/STMath.cpp
r896 r902 903 903 TableIterator iter(tout, cols); 904 904 STPol* stpol = NULL; 905 stpol =STPol::getPolClass( Scantable::getFactories(), out->getPolType() );905 stpol =STPol::getPolClass(out->factories_, out->getPolType() ); 906 906 while (!iter.pastEnd()) { 907 907 Table t = iter.table(); -
trunk/src/STSelector.cpp
r869 r902 16 16 #include <casa/iostream.h> 17 17 #include <casa/iomanip.h> 18 #include <casa/Exceptions/Error.h> 18 19 19 20 #include "MathUtils.h" 21 #include "STPol.h" 20 22 #include "STSelector.h" 21 23 … … 99 101 } 100 102 103 104 void asap::STSelector::setSortOrder( const std::vector< std::string > & order ) 105 { 106 order_.resize(order.size(), True); 107 for (int i=0;i<order.size();++i) { 108 order_[i] = order[i]; 109 } 110 } 111 101 112 Table STSelector::apply( const Table& tab ) 102 113 { 103 114 if ( empty() ) { 104 return tab;115 return sort(tab); 105 116 } 106 117 TableExprNode query; … … 132 143 tmpt = tableCommand(taql_, tab); 133 144 } 134 return tmpt;145 return sort(tmpt); 135 146 } else { 136 return tab(query); 147 if ( query.isNull() ) { 148 return sort(tab); 149 } else { 150 return sort(tab(query)); 151 } 137 152 } 138 153 } … … 207 222 return (intselections_.empty() && taql_.size() == 0 ); 208 223 } 224 225 casa::Table asap::STSelector::sort( const casa::Table & tab ) 226 { 227 if (order_.nelements() > 0) { 228 cout << "sorting" << endl; 229 Table t = tab.sort(order_); 230 return t; 231 } else { 232 return tab; 233 } 234 } 235 236 237 void asap::STSelector::setPolFromStrings( const std::vector< std::string >& pols ) 238 { 239 poltypes_.clear(); 240 std::vector<int> polints; 241 std::vector<std::string>::const_iterator strit = pols.begin(); 242 for (strit; strit != pols.end(); ++strit) { 243 std::pair<int, std::string> val; 244 try { 245 val = STPol::polFromString(*strit); 246 } catch (AipsError& e) { 247 poltypes_.clear(); 248 throw(e); 249 } 250 polints.push_back(val.first); 251 poltypes_.push_back(val.second); 252 } 253 setint("POLNO", polints); 254 } 255 256 std::vector< std::string > asap::STSelector::getPolTypes( ) 257 { 258 return poltypes_; 259 } -
trunk/src/STSelector.h
r850 r902 17 17 #include <map> 18 18 19 #include <casa/Containers/Block.h> 20 #include <casa/BasicSL/String.h> 19 21 #include <tables/Tables/Table.h> 20 22 … … 40 42 void setIFs(const std::vector<int>& ifs); 41 43 void setPolarizations(const std::vector<int>& pols); 44 void setPolFromStrings(const std::vector<std::string>& pols); 42 45 void setCycles(const std::vector<int>& cycs); 43 46 void setName(const std::string&); 44 47 virtual void setTaQL(const std::string& taql); 48 49 void setSortOrder(const std::vector<std::string>& order); 45 50 46 51 std::vector<int> getScans(); … … 49 54 std::vector<int> getPols(); 50 55 std::vector<int> getCycles(); 56 std::vector<std::string> getPolTypes(); 51 57 52 58 casa::Table apply(const casa::Table& tab); … … 67 73 68 74 private: 75 76 casa::Table sort(const casa::Table& tab); 77 69 78 typedef std::map<std::string, std::vector<int> > intidmap; 70 79 typedef std::map<std::string, std::vector<std::string> > stringidmap; … … 72 81 mutable intidmap intselections_; 73 82 mutable stringidmap stringselections_; 83 std::vector<std::string> poltypes_; 84 casa::Block<casa::String> order_; 74 85 std::string taql_; 75 86 }; -
trunk/src/Scantable.cpp
r901 r902 28 28 #include <casa/Quanta/MVAngle.h> 29 29 #include <casa/Containers/RecordField.h> 30 #include <casa/Utilities/GenSort.h> 30 31 31 32 #include <tables/Tables/TableParse.h> … … 56 57 #include "STPolLinear.h" 57 58 #include "STAttr.h" 59 #include "MathUtils.h" 58 60 59 61 using namespace casa; … … 126 128 Bool(clear)); 127 129 table_ = Table(newname, Table::Update); 128 copySubtables(other);130 if ( clear ) copySubtables(other); 129 131 table_.markForDelete(); 130 132 } … … 328 330 int Scantable::nscan() const { 329 331 int n = 0; 330 int previous = -1; int current = 0; 331 for (uInt i=0; i< scanCol_.nrow();i++) { 332 scanCol_.getScalar(i,current); 333 if (previous != current) { 334 previous = current; 335 n++; 336 } 337 } 338 return n; 332 Int previous = -1; Int current = 0; 333 Vector<uInt> scannos(scanCol_.getColumn()); 334 uInt nout = GenSort<uInt>::sort( scannos, Sort::Ascending, 335 Sort::QuickSort|Sort::NoDuplicates ); 336 return int(nout); 339 337 } 340 338 … … 482 480 while ( !it.pastEnd() ) { 483 481 ++n; 482 ++it; 484 483 } 485 484 return n; … … 595 594 596 595 std::vector<float> Scantable::getSpectrum( int whichrow, 597 const std::string& poltype) const 598 { 596 const std::string& poltype ) const 597 { 598 if ( whichrow < 0 || whichrow >= nrow() ) 599 throw(AipsError("Illegal row number.")); 599 600 std::vector<float> out; 600 601 Vector<Float> arr; … … 610 611 stpol->setSpectra(getPolMatrix(row)); 611 612 Float frot,fang,ftan; 612 focusTable_.getEntry(frot, fang, ftan, row);613 focusTable_.getEntry(frot, fang, ftan, mfocusidCol_(row)); 613 614 stpol->setPhaseCorrections(frot, fang, ftan); 614 615 arr = stpol->getSpectrum(requestedpol, poltype); … … 619 620 } 620 621 } 622 if ( arr.nelements() == 0 ) 623 pushLog("Not enough polarisations present to do the conversion."); 621 624 arr.tovector(out); 622 625 return out; … … 653 656 { 654 657 return table_.keywordSet().asString("POLTYPE"); 655 }656 657 658 std::string Scantable::getPolarizationLabel(bool linear, bool stokes,659 bool linpol, int polidx) const660 {661 uInt idx = 0;662 if (polidx >=0) idx = polidx;663 return "";664 //return SDPolUtil::polarizationLabel(idx, linear, stokes, linpol);665 658 } 666 659 … … 892 885 } 893 886 894 895 }//namespace asap 887 std::vector< std::string > asap::Scantable::columnNames( ) const 888 { 889 Vector<String> vec = table_.tableDesc().columnNames(); 890 return mathutil::tovectorstring(vec); 891 } 892 893 } //namespace asap -
trunk/src/Scantable.h
r901 r902 63 63 class Scantable : private Logger 64 64 { 65 66 friend class STMath; 67 65 68 public: 66 69 /** … … 177 180 /** 178 181 * Return a list of row numbers with respect to the original table. 179 * @return a l si of rownumbers with respect to the original table182 * @return a list of unsigned ints 180 183 */ 181 184 std::vector<unsigned int> rownumbers() const; … … 252 255 void setSpectrum(const std::vector<float>& spec, int whichrow); 253 256 254 std::string getPolarizationLabel(bool linear, bool stokes, 255 bool linpol, 256 int polidx=-1) const; 257 std::string getPolarizationLabel(int index, const std::string& ptype) const 258 { return STPol::getPolLabel(index, ptype ); } 257 259 258 260 /** … … 303 305 STHistory& history() { return historyTable_; } 304 306 305 static const std::map<std::string, STPol::STPolFactory *>& getFactories() 306 { return factories_; } 307 std::vector<std::string> columnNames() const; 307 308 308 309 private: -
trunk/src/ScantableWrapper.h
r901 r902 69 69 // std::string getPolarizationLabel(bool linear, bool stokes, bool linPol, int polIdx) const { 70 70 // Boost fails with 4 arguments. 71 std::string getPolarizationLabel(bool linear, bool stokes, 72 bool linPol) const { 73 int polIdx = -1; 74 return table_->getPolarizationLabel(linear, stokes, linPol, polIdx); 71 std::string getPolarizationLabel(int index, const std::string& ptype) const { 72 return table_->getPolarizationLabel(index, ptype); 75 73 } 76 74 … … 132 130 int nscan() const {return table_->nscan();} 133 131 int nrow() const {return table_->nrow();} 132 int ncycle(int scanno) const {return table_->ncycle(scanno);} 134 133 ///@todo int nstokes() {return table_->nStokes();} 135 134 -
trunk/src/python_STSelector.cpp
r853 r902 25 25 .def("_getifs", &STSelector::getIFs) 26 26 .def("_getpols", &STSelector::getPols) 27 .def("_getpoltypes", &STSelector::getPolTypes) 27 28 .def("_getscans", &STSelector::getScans) 28 29 .def("_getcycles", &STSelector::getCycles) … … 31 32 .def("_setifs", &STSelector::setIFs) 32 33 .def("_setpols", &STSelector::setPolarizations) 34 .def("_setpolstrings", &STSelector::setPolFromStrings) 33 35 .def("_setscans", &STSelector::setScans) 34 36 .def("_setcycles", &STSelector::setCycles) 35 37 .def("_setname", &STSelector::setName) 36 38 .def("_settaql", &STSelector::setTaQL) 39 .def("_setorder", &STSelector::setSortOrder) 37 40 ; 38 41 }; -
trunk/src/python_Scantable.cpp
r896 r902 53 53 .def("getscan", &ScantableWrapper::getScan) 54 54 .def("getcycle", &ScantableWrapper::getCycle) 55 .def("nif", &ScantableWrapper::nif) 56 .def("nbeam", &ScantableWrapper::nbeam) 57 .def("npol", &ScantableWrapper::npol) 58 .def("nchan", &ScantableWrapper::nchan) 55 .def("nif", &ScantableWrapper::nif, 56 (boost::python::arg("scanno")=-1) ) 57 .def("nbeam", &ScantableWrapper::nbeam, 58 (boost::python::arg("scanno")=-1) ) 59 .def("npol", &ScantableWrapper::npol, 60 (boost::python::arg("scanno")=-1) ) 61 .def("nchan", &ScantableWrapper::nchan, 62 (boost::python::arg("ifno")=-1) ) 63 .def("ncycle", &ScantableWrapper::ncycle, 64 (boost::python::arg("scanno")=-1) ) 59 65 .def("nscan", &ScantableWrapper::nscan) 60 66 .def("nrow", &ScantableWrapper::nrow) … … 65 71 (arg("whichrow")=0, arg("poltype")=std::string("linear")) ) 66 72 .def("poltype", &ScantableWrapper::getPolType ) 67 .def("_getpolarizationlabel", &ScantableWrapper::getPolarizationLabel, 68 ( arg("linear")=false, arg("stokes")=false, 69 arg("linpol")=false, arg("thepol")=0 ) ) 73 .def("_getpollabel", &ScantableWrapper::getPolarizationLabel) 70 74 .def("_setspectrum",&ScantableWrapper::setSpectrum, 71 75 (boost::python::arg("whichrow")=0) )
Note:
See TracChangeset
for help on using the changeset viewer.