- Timestamp:
- 08/26/10 19:46:26 (14 years ago)
- Location:
- trunk/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/STMath.cpp
r1819 r1907 1796 1796 out.push_back(outstat); 1797 1797 } 1798 return out; 1799 } 1800 1801 std::vector< float > STMath::statisticRow( const CountedPtr< Scantable > & in, 1802 const std::vector< bool > & mask, 1803 const std::string& which, 1804 int row ) 1805 { 1806 1807 Vector<Bool> m(mask); 1808 const Table& tab = in->table(); 1809 ROArrayColumn<Float> specCol(tab, "SPECTRA"); 1810 ROArrayColumn<uChar> flagCol(tab, "FLAGTRA"); 1811 std::vector<float> out; 1812 1813 Vector<Float> spec; specCol.get(row, spec); 1814 Vector<uChar> flag; flagCol.get(row, flag); 1815 MaskedArray<Float> ma = maskedArray(spec, flag); 1816 float outstat = 0.0; 1817 if ( spec.nelements() == m.nelements() ) { 1818 outstat = mathutil::statistics(which, ma(m)); 1819 } else { 1820 outstat = mathutil::statistics(which, ma); 1821 } 1822 out.push_back(outstat); 1823 1798 1824 return out; 1799 1825 } -
trunk/src/STMath.h
r1819 r1907 277 277 const std::vector<bool>& mask, 278 278 const std::string& which); 279 280 std::vector<float> statisticRow(const casa::CountedPtr<Scantable>& in, 281 const std::vector<bool>& mask, 282 const std::string& which, 283 int row); 279 284 280 285 std::vector< int > minMaxChan(const casa::CountedPtr<Scantable>& in, -
trunk/src/STMathWrapper.h
r1819 r1907 132 132 { return STMath::statistic(in.getCP(), mask, which); } 133 133 134 std::vector<float> statisticRow(const ScantableWrapper& in, 135 const std::vector<bool>& mask, 136 const std::string& which, 137 int row) 138 { return STMath::statisticRow(in.getCP(), mask, which, row); } 139 134 140 std::vector<int> minMaxChan(const ScantableWrapper& in, 135 141 const std::vector<bool>& mask, -
trunk/src/Scantable.cpp
r1881 r1907 1712 1712 } 1713 1713 1714 bool Scantable::getFlagtraFast(int whichrow) 1715 { 1716 uChar flag; 1717 Vector<uChar> flags; 1718 flagsCol_.get(uInt(whichrow), flags); 1719 for (int i = 0; i < flags.size(); i++) { 1720 if (i==0) { 1721 flag = flags[i]; 1722 } 1723 else { 1724 flag &= flags[i]; 1725 } 1726 return ((flag >> 7) == 1); 1727 } 1728 } 1729 1730 void Scantable::doPolyBaseline(const std::vector<bool>& mask, int order, int rowno, Fitter& fitter) 1731 { 1732 fitter.setExpression("poly", order); 1733 1734 std::vector<double> abcsd = getAbcissa(rowno); 1735 std::vector<float> abcs; 1736 for (int i = 0; i < abcsd.size(); i++) { 1737 abcs.push_back((float)abcsd[i]); 1738 } 1739 std::vector<float> spec = getSpectrum(rowno); 1740 std::vector<bool> fmask = getMask(rowno); 1741 for (int i = 0; i < fmask.size(); i++) { 1742 fmask[i] = fmask[i] && mask[i]; 1743 } 1744 fitter.setData(abcs, spec, fmask); 1745 1746 fitter.lfit(); 1747 } 1748 1749 void Scantable::polyBaseline(const std::vector<bool>& mask, int order, int rowno) 1750 { 1751 Fitter fitter = Fitter(); 1752 doPolyBaseline(mask, order, rowno, fitter); 1753 setSpectrum(fitter.getResidual(), rowno); 1754 } 1755 1756 void Scantable::polyBaseline(const std::vector<bool>& mask, int order, int rowno, int pars_ptr, int pars_size, int errs_ptr, int errs_size, int fmask_ptr, int fmask_size) 1757 { 1758 Fitter fitter = Fitter(); 1759 doPolyBaseline(mask, order, rowno, fitter); 1760 setSpectrum(fitter.getResidual(), rowno); 1761 1762 std::vector<float> pars = fitter.getParameters(); 1763 if (pars_size != pars.size()) { 1764 throw(AipsError("wrong pars size")); 1765 } 1766 float *ppars = reinterpret_cast<float*>(pars_ptr); 1767 for (int i = 0; i < pars_size; i++) { 1768 ppars[i] = pars[i]; 1769 } 1770 1771 std::vector<float> errs = fitter.getErrors(); 1772 if (errs_size != errs.size()) { 1773 throw(AipsError("wrong errors size")); 1774 } 1775 float *perrs = reinterpret_cast<float*>(errs_ptr); 1776 for (int i = 0; i < errs_size; i++) { 1777 perrs[i] = errs[i]; 1778 } 1779 1780 if (fmask_size != fmask.size()) { 1781 throw(AipsError("wrong fmask size")); 1782 } 1783 int *pfmask = reinterpret_cast<int*>(fmask_ptr); 1784 for (int i = 0; i < fmask_size; i++) { 1785 pfmask[i] = (fmask[i] ? 1 : 0); 1786 } 1787 } 1788 1714 1789 } 1715 1790 //namespace asap -
trunk/src/Scantable.h
r1819 r1907 47 47 #include "STFit.h" 48 48 #include "STFitEntry.h" 49 #include "STFitter.h" 49 50 50 51 namespace asap { … … 486 487 void regridChannel( int nchan, double dnu, int irow ) ; 487 488 489 bool getFlagtraFast(int whichrow); 490 491 void polyBaseline(const std::vector<bool>& mask, int order, int rowno); 492 void polyBaseline(const std::vector<bool>& mask, int order, int rowno, int pars_ptr, int pars_size, int errs_ptr, int errs_size, int fmask_ptr, int fmask_size); 493 488 494 489 495 private: … … 506 512 */ 507 513 std::string formatDirection(const casa::MDirection& md) const; 508 509 514 510 515 /** … … 598 603 const casa::String&, 599 604 const casa::Array<T2>&); 605 606 void doPolyBaseline(const std::vector<bool>& mask, int order, int rowno, Fitter& fitter); 600 607 }; 601 608 -
trunk/src/ScantableWrapper.h
r1819 r1907 250 250 { table_->reshapeSpectrum( nmin, nmax ); } 251 251 252 void polyBaseline(const std::vector<bool>& mask, int order, int rowno, int pars_ptr, int pars_size, int errs_ptr, int errs_size, int fmask_ptr, int fmask_size) 253 { table_->polyBaseline(mask, order, rowno, pars_ptr, pars_size, errs_ptr, errs_size, fmask_ptr, fmask_size); } 254 255 void polyBaseline(const std::vector<bool>& mask, int order, int rowno) 256 { table_->polyBaseline(mask, order, rowno); } 257 258 bool getFlagtraFast(int whichrow=0) const 259 { return table_->getFlagtraFast(whichrow); } 260 261 252 262 private: 253 263 casa::CountedPtr<Scantable> table_; -
trunk/src/python_STMath.cpp
r1819 r1907 59 59 .def("_dofs", &STMathWrapper::dofs) 60 60 .def("_stats", &STMathWrapper::statistic) 61 .def("_statsrow", &STMathWrapper::statisticRow) 61 62 .def("_minmaxchan", &STMathWrapper::minMaxChan) 62 63 .def("_freqswitch", &STMathWrapper::freqSwitch) -
trunk/src/python_Scantable.cpp
r1819 r1907 139 139 (boost::python::arg("nmin")=-1, 140 140 boost::python::arg("nmax")=-1) ) 141 .def("_poly_baseline", &ScantableWrapper::polyBaseline) 142 .def("_getflagtrafast", &ScantableWrapper::getFlagtraFast, 143 (boost::python::arg("whichrow")=0) ) 141 144 ; 142 145 };
Note:
See TracChangeset
for help on using the changeset viewer.