Changeset 496
- Timestamp:
- 02/22/05 11:21:13 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDAsciiWriter.cc
r495 r496 37 37 #include <casa/Quanta/Quantum.h> 38 38 #include <casa/Quanta/MVAngle.h> 39 39 #include <casa/Utilities/Assert.h> 40 40 41 41 #include <casa/iostream.h> … … 94 94 const Unit RAD(String("rad")); 95 95 96 // Open file 97 98 String fName(fileName); 99 if (fileName.length()==0) fName = String("ascii.txt"); 96 // Open and write header file 97 98 99 String rootName(fileName); 100 if (rootName.length()==0) rootName = String("ascii"); 101 { 102 String fName = String(rootName) + String("_header.txt"); 103 cout << "Writing header to " << fName << endl; 104 ofstream of(fName.chars(), ios::trunc); 105 std::string summary = sdTable.summary(true); 106 of << summary; 107 of.close(); 108 } 109 110 // Open data file 111 112 String fName = rootName + String(".txt"); 100 113 ofstream of(fName.chars(), ios::trunc); 101 114 … … 116 129 const Array<Bool>& mask = dataIn.getMask(); 117 130 131 // Get abcissa 132 133 std::vector<double> abcissa = sdTable.getAbcissa(Int(iRow)); 134 const uInt n = abcissa.size(); 135 118 136 // Iterate through data in this row by spectra 119 137 … … 122 140 while (!itData.pastEnd()) { 123 141 const IPosition& pos = itData.pos(); 142 AlwaysAssert(itData.vector().nelements()==n,AipsError); 124 143 125 144 // FreqID … … 144 163 pos(asap::PolAxis) << " " << 145 164 src(iRow) << " " << formatDirection(lonLat) << " " << 146 sdTable.getTime(iRow,True) << " " << itData.vector().nelements() << " "; 165 sdTable.getTime(iRow,True) << " " << n << " "; 166 167 // Write abcissa 168 169 of.setf(ios::fixed, ios::floatfield); 170 of.precision(4); 171 for (uInt i=0; i<n; i++) { 172 of << abcissa[i] << " "; 173 } 174 147 175 // Write data 148 176 149 177 const Vector<Float>& data = itData.vector(); 150 178 const Vector<Bool>& mask = itMask.vector(); 151 const uInt n = data.nelements();152 179 for (uInt i=0; i<n; i++) { 153 180 of << data[i] << " ";
Note:
See TracChangeset
for help on using the changeset viewer.