- Timestamp:
- 03/10/06 12:09:29 (19 years ago)
- Location:
- trunk/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/STFocus.cpp
r856 r896 45 45 } 46 46 47 STFocus 47 STFocus& asap::STFocus::operator =( const STFocus & other ) 48 48 { 49 49 if (this != &other) { … … 94 94 95 95 void asap::STFocus::getEntry( Float& rotation, Float& angle, Float& ftan, 96 uInt id) 96 uInt id) const 97 97 { 98 98 Table t = table_(table_.col("ID") == Int(id) ); -
trunk/src/STFocus.h
r856 r896 41 41 42 42 void getEntry( casa::Float& rotation, casa::Float& angle, 43 casa::Float& ftan, casa::uInt id) ;43 casa::Float& ftan, casa::uInt id) const; 44 44 45 45 const casa::String& name() const { return name_; } -
trunk/src/STMath.cpp
r878 r896 871 871 return out; 872 872 } 873 874 CountedPtr< Scantable > 875 STMath::invertPhase( const CountedPtr < Scantable >& in ) 876 { 877 applyToPol(in, &STPol::invertPhase, Float(0.0)); 878 } 879 880 CountedPtr< Scantable > 881 STMath::rotateXYPhase( const CountedPtr < Scantable >& in, float phase ) 882 { 883 return applyToPol(in, &STPol::rotatePhase, Float(phase)); 884 } 885 886 CountedPtr< Scantable > 887 STMath::rotateLinPolPhase( const CountedPtr < Scantable >& in, float phase ) 888 { 889 return applyToPol(in, &STPol::rotateLinPolPhase, Float(phase)); 890 } 891 892 CountedPtr< Scantable > STMath::applyToPol( const CountedPtr<Scantable>& in, 893 STPol::polOperation fptr, 894 Float phase ) 895 { 896 CountedPtr< Scantable > out = getScantable(in, false); 897 Table& tout = out->table(); 898 Block<String> cols(4); 899 cols[0] = String("SCANNO"); 900 cols[1] = String("BEAMNO"); 901 cols[2] = String("IFNO"); 902 cols[3] = String("CYCLENO"); 903 TableIterator iter(tout, cols); 904 STPol* stpol = NULL; 905 stpol =STPol::getPolClass(Scantable::getFactories(), out->getPolType() ); 906 while (!iter.pastEnd()) { 907 Table t = iter.table(); 908 ArrayColumn<Float> speccol(t, "SPECTRA"); 909 Matrix<Float> pols = speccol.getColumn(); 910 Matrix<Float> out; 911 try { 912 stpol->setSpectra(pols); 913 (stpol->*fptr)(phase); 914 speccol.putColumn(stpol->getSpectra()); 915 delete stpol;stpol=0; 916 } catch (AipsError& e) { 917 delete stpol;stpol=0; 918 throw(e); 919 } 920 ++iter; 921 } 922 return out; 923 } 924 925 CountedPtr< Scantable > 926 STMath::swapPolarisations( const CountedPtr< Scantable > & in ) 927 { 928 CountedPtr< Scantable > out = getScantable(in, false); 929 Table& tout = out->table(); 930 Table t0 = tout(tout.col("POLNO") == 0); 931 Table t1 = tout(tout.col("POLNO") == 1); 932 if ( t0.nrow() != t1.nrow() ) 933 throw(AipsError("Inconsistent number of polarisations")); 934 ArrayColumn<Float> speccol0(t0, "SPECTRA"); 935 ArrayColumn<uChar> flagcol0(t0, "FLAGTRA"); 936 ArrayColumn<Float> speccol1(t1, "SPECTRA"); 937 ArrayColumn<uChar> flagcol1(t1, "FLAGTRA"); 938 Matrix<Float> s0 = speccol0.getColumn(); 939 Matrix<uChar> f0 = flagcol0.getColumn(); 940 speccol0.putColumn(speccol1.getColumn()); 941 flagcol0.putColumn(flagcol1.getColumn()); 942 speccol1.putColumn(s0); 943 flagcol1.putColumn(f0); 944 return out; 945 } -
trunk/src/STMath.h
r894 r896 24 24 #include "Scantable.h" 25 25 #include "STDefs.h" 26 #include "STPol.h" 26 27 #include "Logger.h" 27 28 … … 99 100 merge(const std::vector<casa::CountedPtr<Scantable> >& in); 100 101 102 casa::CountedPtr<Scantable> 103 invertPhase( const casa::CountedPtr<Scantable>& in); 104 casa::CountedPtr<Scantable> 105 rotateXYPhase( const casa::CountedPtr<Scantable>& in, float phase); 106 casa::CountedPtr<Scantable> 107 rotateLinPolPhase( const casa::CountedPtr<Scantable>& in, float phase); 108 101 109 /// @todo frequency alignment 102 110 111 casa::CountedPtr<Scantable> 112 swapPolarisations(const casa::CountedPtr<Scantable>& in); 113 103 114 private: 115 casa::CountedPtr<Scantable> applyToPol( const casa::CountedPtr<Scantable>& in, 116 STPol::polOperation fptr, 117 casa::Float phase); 118 104 119 static imethod stringToIMethod(const std::string& in); 105 120 static WeightType stringToWeight(const std::string& in); -
trunk/src/Scantable.cpp
r888 r896 54 54 55 55 #include "Scantable.h" 56 #include "STPolLinear.h" 56 57 #include "STAttr.h" 57 58 … … 59 60 60 61 namespace asap { 62 63 std::map<std::string, STPol::STPolFactory *> Scantable::factories_; 64 65 void Scantable::initFactories() { 66 if ( factories_.empty() ) { 67 Scantable::factories_["linear"] = &STPolLinear::myFactory; 68 } 69 } 61 70 62 71 Scantable::Scantable(Table::TableType ttype) : 63 72 type_(ttype) 64 73 { 74 initFactories(); 65 75 setupMainTable(); 66 76 freqTable_ = STFrequencies(*this); … … 85 95 type_(ttype) 86 96 { 97 initFactories(); 87 98 Table tab(name, Table::Update); 88 99 Int version; … … 566 577 if ( selector_.empty() ) 567 578 throw(AipsError("Trying to flag whole scantable. Aborted.")); 579 TableVector<uChar> tvec(table_, "FLAGTRA"); 580 uChar userflag = 1 << 7; 581 tvec = userflag; 568 582 } 569 583 … … 580 594 } 581 595 582 std::vector<float> Scantable::getSpectrum(int whichrow) const 583 { 596 std::vector<float> Scantable::getSpectrum( int whichrow, 597 const std::string& poltype) const 598 { 599 std::vector<float> out; 584 600 Vector<Float> arr; 585 specCol_.get(whichrow, arr); 586 std::vector<float> out; 601 uInt requestedpol = polCol_(whichrow); 602 String basetype = getPolType(); 603 if ( String(poltype) == basetype) { 604 specCol_.get(whichrow, arr); 605 } else { 606 STPol* stpol = 0; 607 stpol =STPol::getPolClass(Scantable::factories_, basetype); 608 try { 609 uInt row = uInt(whichrow); 610 stpol->setSpectra(getPolMatrix(row)); 611 Float frot,fang,ftan; 612 focusTable_.getEntry(frot, fang, ftan, row); 613 stpol->setPhaseCorrections(frot, fang, ftan); 614 arr = stpol->getSpectrum(requestedpol, poltype); 615 delete stpol; 616 } catch (AipsError& e) { 617 delete stpol; 618 throw(e); 619 } 620 } 587 621 arr.tovector(out); 588 622 return out; 589 623 } 590 591 624 592 625 void asap::Scantable::setSpectrum( const std::vector<float>& spec, … … 597 630 specCol_.get(whichrow, arr); 598 631 if ( spectrum.nelements() != arr.nelements() ) 599 throw AipsError("The spect urm has incorrect number of channels.");632 throw AipsError("The spectrum has incorrect number of channels."); 600 633 specCol_.put(whichrow, spectrum); 601 634 } … … 616 649 return table_; 617 650 } 651 652 std::string Scantable::getPolType() const 653 { 654 return table_.keywordSet().asString("POLTYPE"); 655 } 656 618 657 619 658 std::string Scantable::getPolarizationLabel(bool linear, bool stokes, … … 655 694 oss << setw(15) << "Beams:" << setw(4) << nbeam() << endl 656 695 << setw(15) << "IFs:" << setw(4) << nif() << endl 657 << setw(15) << "Polarisations:" << setw(4) << npol() << endl 696 << setw(15) << "Polarisations:" << setw(4) << npol() 697 << "(" << getPolType() << ")" << endl 658 698 << setw(15) << "Channels:" << setw(4) << nchan() << endl; 659 699 oss << endl; … … 839 879 840 880 881 Matrix<Float> asap::Scantable::getPolMatrix( uInt whichrow ) const 882 { 883 ROTableRow row(table_); 884 const TableRecord& rec = row.get(whichrow); 885 Table t = 886 originalTable_( originalTable_.col("SCANNO") == Int(rec.asuInt("SCANNO")) 887 && originalTable_.col("BEAMNO") == Int(rec.asuInt("BEAMNO")) 888 && originalTable_.col("IFNO") == Int(rec.asuInt("IFNO")) 889 && originalTable_.col("CYCLENO") == Int(rec.asuInt("CYCLENO")) ); 890 ROArrayColumn<Float> speccol(t, "SPECTRA"); 891 return speccol.getColumn(); 892 } 893 841 894 842 895 }//namespace asap -
trunk/src/Scantable.h
r894 r896 39 39 #include "STSelector.h" 40 40 #include "STHistory.h" 41 42 41 #include "STPol.h" 43 42 44 43 namespace asap { … … 205 204 int npol(int scanno=-1) const; 206 205 206 std::string getPolType() const; 207 207 208 /** 208 209 * Get the number of channels in the data or a specific IF. This currently … … 246 247 247 248 std::vector<bool> getMask(int whichrow) const; 248 std::vector<float> getSpectrum(int whichrow) const; 249 std::vector<float> getSpectrum(int whichrow, 250 const std::string& poltype ="linear") const; 249 251 250 252 void setSpectrum(const std::vector<float>& spec, int whichrow); 251 253 252 std::vector<float> getStokesSpectrum( int whichrow=0,253 bool dopol=false) const;254 254 std::string getPolarizationLabel(bool linear, bool stokes, 255 255 bool linpol, … … 303 303 STHistory& history() { return historyTable_; } 304 304 305 static const std::map<std::string, STPol::STPolFactory *>& getFactories() 306 { return factories_; } 307 305 308 private: 309 310 casa::Matrix<casa::Float> getPolMatrix( casa::uInt whichrow ) const; 311 306 312 /** 307 313 * Turns a time vale into a formatted string … … 395 401 casa::ScalarColumn<casa::uInt> mmolidCol_; 396 402 403 static std::map<std::string, STPol::STPolFactory *> factories_; 404 void initFactories(); 405 397 406 }; 398 407 -
trunk/src/ScantableWrapper.h
r884 r896 63 63 } 64 64 65 std::vector<float> getSpectrum(int whichRow=0) const { 66 return table_->getSpectrum(whichRow); 65 std::vector<float> getSpectrum( int whichrow=0, 66 const std::string& poltype="linear" ) const { 67 return table_->getSpectrum(whichrow, poltype); 67 68 } 68 /*69 std::vector<float> getStokesSpectrum(int whichRow=0,70 bool linPol=false) const {71 return table_->getStokesSpectrum(whichRow, linPol);72 }73 74 std::vector<float> stokesToPolSpectrum(int whichRow=0, bool linear=false,75 int polIdx=-1) const {76 return table_->stokesToPolSpectrum(whichRow, linear, polIdx);77 }78 */79 69 // std::string getPolarizationLabel(bool linear, bool stokes, bool linPol, int polIdx) const { 80 70 // Boost fails with 4 arguments. … … 85 75 } 86 76 87 std::vector<double> getAbcissa(int which Row=0) const88 { return table_->getAbcissa(which Row); }77 std::vector<double> getAbcissa(int whichrow=0) const 78 { return table_->getAbcissa(whichrow); } 89 79 90 std::string getAbcissaLabel(int which Row=0) const91 { return table_->getAbcissaLabel(which Row); }80 std::string getAbcissaLabel(int whichrow=0) const 81 { return table_->getAbcissaLabel(whichrow); } 92 82 93 float getTsys(int which Row=0) const94 { return table_->getTsys(which Row); }83 float getTsys(int whichrow=0) const 84 { return table_->getTsys(whichrow); } 95 85 96 std::string getTime(int which Row=0) const97 { return table_->getTime(which Row); }86 std::string getTime(int whichrow=0) const 87 { return table_->getTime(whichrow); } 98 88 99 89 std::string getFluxUnit() const { return table_->getFluxUnit(); } … … 103 93 void setInstrument(const std::string& name) {table_->setInstrument(name);} 104 94 105 std::vector<bool> getMask(int which Row=0) const106 { return table_->getMask(which Row); }95 std::vector<bool> getMask(int whichrow=0) const 96 { return table_->getMask(whichrow); } 107 97 108 98 void flag() { table_->flag(); } 109 99 110 std::string getSourceName(int which Row=0) const111 { return table_->getSourceName(which Row); }100 std::string getSourceName(int whichrow=0) const 101 { return table_->getSourceName(whichrow); } 112 102 113 float getElevation(int which Row=0) const114 { return table_->getElevation(which Row); }103 float getElevation(int whichrow=0) const 104 { return table_->getElevation(whichrow); } 115 105 116 float getAzimuth(int which Row=0) const117 { return table_->getAzimuth(which Row); }106 float getAzimuth(int whichrow=0) const 107 { return table_->getAzimuth(whichrow); } 118 108 119 float getParAngle(int which Row=0) const120 { return table_->getParAngle(which Row); }109 float getParAngle(int whichrow=0) const 110 { return table_->getParAngle(whichrow); } 121 111 122 112 … … 133 123 void setSelection(const STSelector& sts) 134 124 { return table_->setSelection(sts);} 125 126 std::string getPolType() const { return table_->getPolType(); } 135 127 136 128 int nif(int scanno=-1) const {return table_->nif(scanno);} … … 175 167 { table_->addHistory(hist); } 176 168 /* 177 void addFit(int which Row, const std::vector<double>& p,169 void addFit(int whichrow, const std::vector<double>& p, 178 170 const std::vector<bool>& m, const std::vector<string>& f, 179 171 const std::vector<int>& c) { … … 183 175 casa::Vector<casa::String> f2 = mathutil::toVectorString(f); 184 176 casa::Vector<casa::Int> c2(c); 185 table_->addFit(casa::uInt(which Row), p2,m2,f2,c2);177 table_->addFit(casa::uInt(whichrow), p2,m2,f2,c2); 186 178 } 187 SDFitTable getSDFitTable(int which Row) {188 return table_->getSDFitTable(casa::uInt(which Row));179 SDFitTable getSDFitTable(int whichrow) { 180 return table_->getSDFitTable(casa::uInt(whichrow)); 189 181 } 190 182 */ -
trunk/src/Templates.cpp
r894 r896 74 74 template class TabVecRep<Float>; 75 75 76 template class ROTableVector<uChar>; 77 template class TableVector<uChar>; 78 template class TabVecScaCol<uChar>; 79 template class TabVecTemp<uChar>; 80 template class TabVecRep<uChar>; 81 76 82 template void convertArray<Bool, uChar>(Array<Bool> &, Array<uChar> const &); 77 83 template void convertArray<uChar, Bool>(Array<uChar> &, Array<Bool> const &); … … 110 116 Bool, Bool); 111 117 } 112 //template Array<Bool> SDPolUtil::stokesData (Array<Bool>& dataIn, Bool);113 //template Array<Float> SDPolUtil::computeStokesDataForWriter(Array<Float>& dataIn, Bool);114 //template Array<uChar> SDPolUtil::computeStokesDataForWriter(Array<uChar>& dataIn, Bool);115 118 -
trunk/src/python_Scantable.cpp
r884 r896 63 63 .def("_setInstrument", &ScantableWrapper::setInstrument) 64 64 .def("_getspectrum", &ScantableWrapper::getSpectrum, 65 (boost::python::arg("whichrow")=0)) 66 /* 67 .def("nstokes", &ScantableWrapper::nStokes) 68 .def("_getstokesspectrum", &ScantableWrapper::getStokesSpectrum, 69 (boost::python::arg("whichrow")=0), 70 (boost::python::arg("linpol")=false) ) 71 .def("_stokestopolspectrum", &ScantableWrapper::stokesToPolSpectrum, 72 (boost::python::arg("whichrow")=0), 73 (boost::python::arg("linear")=false), 74 (boost::python::arg("thepol")=-1) ) 75 */ 65 (arg("whichrow")=0, arg("poltype")=std::string("linear")) ) 66 .def("poltype", &ScantableWrapper::getPolType ) 76 67 .def("_getpolarizationlabel", &ScantableWrapper::getPolarizationLabel, 77 (boost::python::arg("linear")=false), 78 (boost::python::arg("stokes")=false), 79 (boost::python::arg("linpol")=false) ) 80 // (boost::python::arg("thepol")=0) ) // Boost fails with 4 arguments 81 .def("_setspectrum",&ScantableWrapper::setSpectrum, 68 ( arg("linear")=false, arg("stokes")=false, 69 arg("linpol")=false, arg("thepol")=0 ) ) 70 .def("_setspectrum",&ScantableWrapper::setSpectrum, 82 71 (boost::python::arg("whichrow")=0) ) 83 72 .def("_getabcissa", &ScantableWrapper::getAbcissa,
Note:
See TracChangeset
for help on using the changeset viewer.