Changeset 465
- Timestamp:
- 02/17/05 14:46:17 (20 years ago)
- Location:
- trunk/src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/Makefile
r460 r465 45 45 SDAttr.o \ 46 46 SDContainer.o \ 47 SDFitTable.o \ 47 48 SDPol.o \ 48 49 SDPol2.o \ … … 62 63 python_SDMath.o \ 63 64 python_SDFitter.o \ 65 python_SDFitTable.o \ 64 66 python_SDLineFinder.o \ 65 67 python_SD.o … … 69 71 SDAttr.h \ 70 72 SDContainer.h \ 73 SDFitTable.h \ 71 74 SDMemTable.h \ 72 75 SDPol.h \ -
trunk/src/MathUtils.cc
r452 r465 34 34 #include <casa/Arrays/MaskedArray.h> 35 35 #include <casa/Arrays/MaskArrMath.h> 36 #include <casa/Arrays/VectorSTLIterator.h> 36 37 #include <casa/BasicSL/String.h> 37 38 … … 107 108 endInt.resize(j+1,True); 108 109 } 110 111 std::vector<std::string> mathutil::tovectorstring(const Vector<String>& in) 112 { 113 std::vector<std::string> out; 114 VectorSTLIterator<String> it(in); 115 for (uInt i=0; it != in.end(); ++it,++i) { 116 out.push_back(*it); 117 } 118 return out; 119 } 120 121 Vector<String> mathutil::toVectorString(const std::vector<std::string>& in) 122 { 123 Vector<String> out(in.size()); 124 uInt i=0; 125 std::vector<std::string>::const_iterator it; 126 for (it=in.begin();it != in.end();++it,++i) { 127 out[i] = casa::String(*it); 128 } 129 return out; 130 } -
trunk/src/MathUtils.h
r452 r465 32 32 #define MATHUTILS_H 33 33 34 #include <string> 35 #include <vector> 34 36 #include <casa/aips.h> 35 37 #include <casa/Arrays/Vector.h> 38 #include <casa/BasicSL/String.h> 36 39 37 40 namespace mathutil { … … 42 45 43 46 // Find the scan boundaries from a list of ScanIDs 44 void scanBoundaries 45 46 47 void scanBoundaries(casa::Vector<casa::uInt>& startInt, 48 casa::Vector<casa::uInt>& endInt, 49 const casa::Vector<casa::Int>& scanIDs); 47 50 48 51 // Hanning smoothing … … 50 53 void hanning(casa::Vector<T>& out, casa::Vector<casa::Bool>& outmask, 51 54 const casa::Vector<T>& in, const casa::Vector<casa::Bool>& mask, 52 casa::Bool relaxed=False, casa::Bool ignoreOther=False); 55 casa::Bool relaxed=casa::False, 56 casa::Bool ignoreOther=casa::False); 53 57 54 58 // Generate specified statistic … … 58 62 // Replace masked value by zero 59 63 void replaceMaskByZero(casa::Vector<casa::Float>& data, 60 64 const casa::Vector<casa::Bool>& mask); 61 65 62 66 // Extend the … … 64 68 void extendLastArrayAxis(casa::Array<T>& out, const casa::Array<T>& in, 65 69 const T& initVal); 70 71 std::vector<std::string> tovectorstring(const casa::Vector<casa::String>& in); 72 73 casa::Vector<casa::String> toVectorString(const std::vector<std::string>& in); 66 74 67 75 }; -
trunk/src/SDContainer.cc
r453 r465 582 582 } 583 583 584 // SDFitTable585 586 587 const Vector<Double>& SDFitTable::getFitParameters(uInt whichRow) const588 {589 if (whichRow <= n_)590 return fitParms_[whichRow];591 }592 593 const Vector<Bool>& SDFitTable::getFitParameterMask(uInt whichRow) const594 {595 if (whichRow <= n_)596 return parMask_[whichRow];597 }598 599 const Vector<Int>& SDFitTable::getFitComponents(uInt whichRow) const600 {601 if (whichRow <= n_)602 return fitComps_[whichRow];603 }604 605 const Vector<String>& SDFitTable::getFitFunctions(uInt whichRow) const606 {607 if (whichRow <= n_)608 return fitFuncs_[whichRow];609 }610 611 void SDFitTable::putFitParameters(uInt whichRow, const Vector<Double>& arr)612 {613 if (whichRow <= n_)614 fitParms_[whichRow] = arr;615 }616 617 void SDFitTable::putFitParameterMask(uInt whichRow, const Vector<Bool>& arr)618 {619 if (whichRow <= n_)620 parMask_[whichRow] = arr;621 }622 623 void SDFitTable::putFitComponents(uInt whichRow, const Vector<Int>& arr)624 {625 if (whichRow <= n_)626 fitComps_[whichRow] = arr;627 }628 void SDFitTable::putFitFunctions(uInt whichRow, const Vector<String>& arr)629 {630 if (whichRow <= n_)631 fitFuncs_[whichRow] = arr;632 }633 634 635 584 // SDDataDesc 636 585 -
trunk/src/SDContainer.h
r453 r465 261 261 }; 262 262 263 class SDFitTable {264 public:265 // Create a FitTable with "n" rows266 SDFitTable(casa::uInt n=0) : n_(n) {;};267 268 casa::uInt length() const { return n_; };269 const casa::Vector<casa::Double>& getFitParameters(casa::uInt which) const;270 const casa::Vector<casa::Bool>& getFitParameterMask(casa::uInt which) const;271 const casa::Vector<casa::String>& getFitFunctions(casa::uInt which) const;272 const casa::Vector<casa::Int>& getFitComponents(casa::uInt which) const;273 274 void putFitParameters(casa::uInt whichRow,275 const casa::Vector<casa::Double>& arr);276 void putFitParameterMask(casa::uInt whichRow,277 const casa::Vector<casa::Bool>& arr);278 void putFitFunctions(casa::uInt whichRow,279 const casa::Vector<casa::String>& arr);280 void putFitComponents(casa::uInt whichRow,281 const casa::Vector<casa::Int>& arr);282 283 private:284 285 casa::uInt n_;286 casa::Vector<casa::Vector<casa::Double> > fitParms_;287 // (npars,nrows)288 casa::Vector<casa::Vector<casa::Bool> > parMask_;289 // the fit function names (nnames,nrows)290 casa::Vector<casa::Vector<casa::String> > fitFuncs_;291 // the number of components of the function (ncomps, nrows)292 casa::Vector<casa::Vector<casa::Int> > fitComps_;293 294 };295 263 296 264 } // namespace -
trunk/src/SDMemTable.cc
r464 r465 60 60 61 61 #include "SDDefs.h" 62 #include "SDMemTable.h"63 62 #include "SDContainer.h" 64 63 #include "MathUtils.h" 65 64 #include "SDPol.h" 66 65 67 66 #include "SDMemTable.h" 68 67 69 68 using namespace casa; … … 206 205 tdf.addColumn(ArrayColumnDesc<Double>("PARAMETERS")); 207 206 tdf.addColumn(ArrayColumnDesc<Bool>("PARMASK")); 207 tdf.addColumn(ArrayColumnDesc<String>("FRAMEINFO")); 208 208 SetupNewTable fittab("fits", tdf, Table::New); 209 209 Table fitTable(fittab, Table::Memory); … … 948 948 td.addColumn(ArrayColumnDesc<Double>("PARAMETERS")); 949 949 td.addColumn(ArrayColumnDesc<Bool>("PARMASK")); 950 td.addColumn(ArrayColumnDesc<String>("FRAMEINFO")); 950 951 SetupNewTable aNewTab("fits", td, Table::New); 951 952 Table aTable(aNewTab, Table::Memory); … … 954 955 ArrayColumn<Double> sc2(aTable, "PARAMETERS"); 955 956 ArrayColumn<Bool> sc3(aTable, "PARMASK"); 957 ArrayColumn<String> sc4(aTable, "FRAMEINFO"); 956 958 for (uInt i; i<sdft.length(); ++i) { 957 const Vector<Double>& parms = sdft.getFitParameters(i); 958 const Vector<Bool>& parmask = sdft.getFitParameterMask(i); 959 const Vector<String>& funcs = sdft.getFitFunctions(i); 960 const Vector<Int>& comps = sdft.getFitComponents(i); 959 const Vector<Double>& parms = sdft.getParameters(i); 960 const Vector<Bool>& parmask = sdft.getParameterMask(i); 961 const Vector<String>& funcs = sdft.getFunctions(i); 962 const Vector<Int>& comps = sdft.getComponents(i); 963 const Vector<String>& finfo = sdft.getFrameInfo(i); 961 964 sc0.put(i,funcs); 962 965 sc1.put(i,comps); 963 966 sc3.put(i,parmask); 964 967 sc2.put(i,parms); 968 sc4.put(i,finfo); 965 969 } 966 970 table_.rwKeywordSet().defineTable("FITS", aTable); … … 974 978 Vector<Bool> parmask; 975 979 Vector<String> funcs; 980 Vector<String> finfo; 976 981 Vector<Int> comps; 977 982 ROArrayColumn<Double> parmsCol(t, "PARAMETERS"); … … 979 984 ROArrayColumn<Int> compsCol(t, "COMPONENTS"); 980 985 ROArrayColumn<String> funcsCol(t, "FUNCTIONS"); 986 ROArrayColumn<String> finfoCol(t, "FRAMEINFO"); 981 987 uInt n = t.nrow(); 982 SDFitTable sdft (n);988 SDFitTable sdft; 983 989 for (uInt i=0; i<n; ++i) { 984 990 parmaskCol.get(i, parmask); 985 sdft.putFitParameterMask(i, parmask);986 991 parmsCol.get(i, parms); 987 sdft.putFitParameters(i, parms);988 992 funcsCol.get(i, funcs); 989 sdft.putFitFunctions(i, funcs);990 993 compsCol.get(i, comps); 991 sdft.putFitComponents(i, comps); 994 finfoCol.get(i, finfo); 995 sdft.addFit(parms, parmask, funcs, comps, finfo); 992 996 } 993 997 return sdft; 994 998 } 995 999 1000 SDFitTable SDMemTable::getSDFitTable(uInt whichRow) const { 1001 Array<Int> fitid; 1002 fitCol_.get(whichRow, fitid); 1003 if (fitid.nelements() == 0) return SDFitTable(); 1004 1005 IPosition shp = fitid.shape(); 1006 IPosition start(4, beamSel_, IFSel_, polSel_,0); 1007 IPosition end(4, beamSel_, IFSel_, polSel_, shp[3]-1); 1008 1009 // reform the output array slice to be of dim=1 1010 Vector<Int> tmp = (fitid(start, end)).reform(IPosition(1,shp[3])); 1011 1012 const Table& t = table_.keywordSet().asTable("FITS"); 1013 Vector<Double> parms; 1014 Vector<Bool> parmask; 1015 Vector<String> funcs; 1016 Vector<String> finfo; 1017 Vector<Int> comps; 1018 ROArrayColumn<Double> parmsCol(t, "PARAMETERS"); 1019 ROArrayColumn<Bool> parmaskCol(t, "PARMASK"); 1020 ROArrayColumn<Int> compsCol(t, "COMPONENTS"); 1021 ROArrayColumn<String> funcsCol(t, "FUNCTIONS"); 1022 ROArrayColumn<String> finfoCol(t, "FRAMEINFO"); 1023 if (t.nrow() == 0) return SDFitTable(); 1024 SDFitTable sdft; 1025 Int k=-1; 1026 for (uInt i=0; i< tmp.nelements(); ++i) { 1027 k = tmp[i]; 1028 if ( k > -1 && k < t.nrow() ) { 1029 parms.resize(); 1030 parmsCol.get(k, parms); 1031 parmask.resize(); 1032 parmaskCol.get(k, parmask); 1033 funcs.resize(); 1034 funcsCol.get(k, funcs); 1035 comps.resize(); 1036 compsCol.get(k, comps); 1037 finfo.resize(); 1038 finfoCol.get(k, finfo); 1039 sdft.addFit(parms, parmask, funcs, comps, finfo); 1040 } 1041 } 1042 return sdft; 1043 } 996 1044 997 1045 void SDMemTable::addFit(uInt whichRow, … … 1009 1057 ArrayColumn<Int> compsCol(t, "COMPONENTS"); 1010 1058 ArrayColumn<String> funcsCol(t, "FUNCTIONS"); 1059 ArrayColumn<String> finfoCol(t, "FRAMEINFO"); 1011 1060 parmsCol.put(nrow, p); 1012 1061 parmaskCol.put(nrow, m); 1013 1062 compsCol.put(nrow, c); 1014 1063 funcsCol.put(nrow, f); 1064 Vector<String> fi = mathutil::toVectorString(getCoordInfo()); 1065 finfoCol.put(nrow, fi); 1015 1066 1016 1067 Array<Int> fitarr; … … 1432 1483 Vector<String> history; 1433 1484 histCol_.get(whichRow, history); 1434 std::vector<std::string> stlout; 1435 // there is no Array<String>.tovector(std::vector<std::string>), so 1436 // do it by hand 1437 for (uInt i=0; i<history.nelements(); ++i) { 1438 stlout.push_back(history[i]); 1439 } 1485 std::vector<std::string> stlout = mathutil::tovectorstring(history); 1440 1486 return stlout; 1441 1487 } -
trunk/src/SDMemTable.h
r457 r465 45 45 46 46 #include "SDDefs.h" 47 48 47 #include "SDFitTable.h" 49 48 50 49 namespace asap { … … 243 242 bool putSDFitTable(const SDFitTable& sdft); 244 243 SDFitTable getSDFitTable() const; 244 SDFitTable getSDFitTable(casa::uInt whichRow) const; 245 245 246 246 void addFit(casa::uInt whichRow, … … 249 249 const casa::Vector<casa::String>& f, 250 250 const casa::Vector<casa::Int>& c); 251 251 252 252 253 private: -
trunk/src/SDMemTableWrapper.h
r457 r465 36 36 #include <casa/Arrays/Vector.h> 37 37 38 #include "MathUtils.h" 39 #include "SDFitTable.h" 38 40 #include "SDMemTable.h" 39 41 … … 195 197 casa::Vector<casa::Double> p2(p); 196 198 casa::Vector<casa::Bool> m2(m); 197 casa::Vector<casa::String> f2(f.size()); 198 casa::uInt i=0; 199 std::vector<std::string>::const_iterator it; 200 for (it=f.begin();it != f.end();++it) { 201 f2[i] = casa::String(*it); 202 } 199 casa::Vector<casa::String> f2 = mathutil::toVectorString(f); 203 200 casa::Vector<casa::Int> c2(c); 204 201 table_->addFit(casa::uInt(whichRow), p2,m2,f2,c2); 205 202 } 203 SDFitTable getSDFitTable(int whichRow) { 204 return table_->getSDFitTable(casa::uInt(whichRow)); 205 } 206 206 207 207 208 private: -
trunk/src/python_SD.cc
r297 r465 59 59 asap::python::python_SDMath(); 60 60 asap::python::python_SDFitter(); 61 asap::python::python_SDFitTable(); 61 62 asap::python::python_SDLineFinder(); 62 63 -
trunk/src/python_SD.h
r297 r465 42 42 void python_SDMath(); 43 43 void python_SDFitter(); 44 void python_SDFitTable(); 44 45 void python_SDLineFinder(); 45 46 -
trunk/src/python_SDMemTable.cc
r457 r465 102 102 (boost::python::arg("whichRow")=0) ) 103 103 .def("_addfit", &SDMemTableWrapper::addFit) 104 .def("_getfit", &SDMemTableWrapper::getSDFitTable) 104 105 ; 105 106 };
Note:
See TracChangeset
for help on using the changeset viewer.