Changeset 3063
- Timestamp:
- 11/20/15 19:26:02 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/MSWriter.cpp
r3059 r3063 912 912 // fill empty FIELD rows 913 913 infillField() ; 914 915 // sort POINTING rows 916 sortPointing(); 914 917 } 915 918 … … 1017 1020 porow.put( nrow ) ; 1018 1021 } 1022 1023 void sortPointing() 1024 { 1025 ScalarColumn<Double> timeCol(potab, "TIME"); 1026 Vector<Double> originalTime = timeCol.getColumn(); 1027 Sort sort; 1028 sort.sortKey(&originalTime[0], TpDouble, 0, Sort::Ascending); 1029 Vector<uInt> sortIndex; 1030 sort.sort(sortIndex, originalTime.nelements()); 1031 1032 sortPointingTime(sortIndex); 1033 sortPointingNumPoly(sortIndex); 1034 sortPointingInterval(sortIndex); 1035 sortPointingName(sortIndex); 1036 sortPointingDirection(sortIndex); 1037 } 1038 1039 void sortPointingTime(const Vector<uInt> &sortIndex) 1040 { 1041 sortScalarColumn<Double>("TIME", sortIndex, "TIME_ORIGIN"); 1042 } 1043 1044 void sortPointingNumPoly(const Vector<uInt> &sortIndex) 1045 { 1046 sortScalarColumn<Int>("NUM_POLY", sortIndex); 1047 } 1048 1049 void sortPointingInterval(const Vector<uInt> &sortIndex) 1050 { 1051 sortScalarColumn<Double>("INTERVAL", sortIndex); 1052 } 1053 1054 void sortPointingName(const Vector<uInt> &sortIndex) 1055 { 1056 sortScalarColumn<String>("NAME", sortIndex); 1057 } 1058 1059 void sortPointingDirection(const Vector<uInt> &sortIndex) 1060 { 1061 ArrayColumn<Double> col(potab, "DIRECTION"); 1062 Cube<Double> data = col.getColumn(); 1063 Cube<Double> sortedData(data.shape()); 1064 for (size_t i = 0; i < sortIndex.nelements(); ++i) { 1065 sortedData.xyPlane(i) = data.xyPlane(sortIndex[i]); 1066 } 1067 1068 col.putColumn(sortedData); 1069 col.attach(potab, "TARGET"); 1070 col.putColumn(sortedData); 1071 } 1072 1073 template<class T> 1074 void sortScalarColumn(const String &columnName, const Vector<uInt> &sortIndex, const String ©ColumnName="") 1075 { 1076 ScalarColumn<T> col(potab, columnName); 1077 Vector<T> data = col.getColumn(); 1078 Vector<T> sortedData(data.shape()); 1079 for (size_t i = 0; i < sortIndex.nelements(); ++i) { 1080 sortedData[i] = data[sortIndex[i]]; 1081 } 1082 col.putColumn(sortedData); 1083 if (copyColumnName.size() > 0) { 1084 col.attach(potab, copyColumnName); 1085 col.putColumn(sortedData); 1086 } 1087 } 1088 1019 1089 Int addPolarization() 1020 1090 {
Note:
See TracChangeset
for help on using the changeset viewer.