Changeset 496


Ignore:
Timestamp:
02/22/05 11:21:13 (19 years ago)
Author:
kil064
Message:

write header and data into seaprate files
write abcissa to data file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/SDAsciiWriter.cc

    r495 r496  
    3737#include <casa/Quanta/Quantum.h>
    3838#include <casa/Quanta/MVAngle.h>
    39 
     39#include <casa/Utilities/Assert.h>
    4040
    4141#include <casa/iostream.h>
     
    9494   const Unit RAD(String("rad"));
    9595
    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");
    100113   ofstream of(fName.chars(), ios::trunc);
    101114
     
    116129      const Array<Bool>& mask = dataIn.getMask();
    117130
     131// Get abcissa
     132
     133      std::vector<double> abcissa = sdTable.getAbcissa(Int(iRow));
     134      const uInt n = abcissa.size();
     135
    118136// Iterate through data in this row by spectra
    119137
     
    122140      while (!itData.pastEnd()) {
    123141         const IPosition& pos = itData.pos();
     142         AlwaysAssert(itData.vector().nelements()==n,AipsError);
    124143
    125144// FreqID
     
    144163               pos(asap::PolAxis) << " " <<
    145164               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
    147175// Write data
    148176
    149177         const Vector<Float>& data = itData.vector();
    150178         const Vector<Bool>& mask = itMask.vector();
    151          const uInt n = data.nelements();
    152179         for (uInt i=0; i<n; i++) {
    153180            of << data[i] << " ";
Note: See TracChangeset for help on using the changeset viewer.