- Timestamp:
- 07/19/04 11:35:39 (20 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDMathWrapper.h
r49 r69 42 42 namespace atnf_sd { 43 43 44 class SDMathWrapper { 45 public: 44 namespace SDMathWrapper { 46 45 SDMemTableWrapper average(const SDMemTableWrapper& sdt) { 47 46 return SDMemTableWrapper(SDMath::average(sdt.getCP())); … … 83 82 84 83 float rms(const SDMemTableWrapper& in, 85 84 const std::vector<bool>& mask) { 86 85 return SDMath::rms(in.getCP(), mask); 87 86 } -
trunk/src/python_SDMath.cc
r55 r69 36 36 37 37 namespace atnf_sd { 38 namespace SDMathWrapper { 39 SDMemTableWrapper SDMathWrapper::averages(boost::python::tuple tp, 40 const std::vector<bool>& mask) { 41 int n; 42 n = extract<int>(tp.attr("__len__")()); 43 Block<CountedPtr<atnf_sd::SDMemTable> > b(n); 44 for (int i=0;i< n;++i) { 45 SDMemTableWrapper sdmw = 46 extract<SDMemTableWrapper>( tp.attr("__getitem__")(i) ); 47 b[i] = sdmw.getCP(); 48 } 49 Vector<Bool> msk(mask); 50 return SDMemTableWrapper(SDMath::averages(b,msk)); 51 }; 52 53 } // namespace SDMathWrapper 54 38 55 namespace python { 39 40 SDMemTableWrapper SDMathWrapper::averages(boost::python::tuple tp, 41 const std::vector<bool>& mask) { 42 int n; 43 n = extract<int>(tp.attr("__len__")()); 44 Block<CountedPtr<atnf_sd::SDMemTable> > b(n); 45 for (int i=0;i< n;++i) { 46 SDMemTableWrapper sdmw = 47 extract<SDMemTableWrapper>( tp.attr("__getitem__")(i) ); 48 b[i] = sdmw.getCP(); 49 } 50 Vector<Bool> msk(mask); 51 return SDMemTableWrapper(SDMath::averages(b,msk)); 52 }; 53 54 void python_SDMath() { 55 class_<SDMathWrapper>("sdmath") 56 .def("average", &SDMathWrapper::average) 57 .def("quotient", &SDMathWrapper::quotient) 58 .def("multiply", &SDMathWrapper::multiply) 59 .def("baseline", &SDMathWrapper::baseline) 60 .def("hanning", &SDMathWrapper::hanning) 61 .def("averages", &SDMathWrapper::averages) 62 .def("averagepol", &SDMathWrapper::averagePol) 63 .def("bin", &SDMathWrapper::bin) 64 .def("rms", &SDMathWrapper::rms) 65 ; 66 }; 67 56 void python_SDMath() { 57 def("average", &SDMathWrapper::average); 58 def("quotient", &SDMathWrapper::quotient); 59 def("multiply", &SDMathWrapper::multiply); 60 def("baseline", &SDMathWrapper::baseline); 61 def("hanning", &SDMathWrapper::hanning); 62 def("averages", &SDMathWrapper::averages); 63 def("averagepol", &SDMathWrapper::averagePol); 64 def("bin", &SDMathWrapper::bin); 65 def("rms", &SDMathWrapper::rms); 66 }; 67 68 68 } // python 69 69 } // atnf_sd
Note:
See TracChangeset
for help on using the changeset viewer.