Changeset 465 for trunk/src/SDMemTable.cc
- Timestamp:
- 02/17/05 14:46:17 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.