Changeset 279 for trunk/src


Ignore:
Timestamp:
01/24/05 14:12:39 (20 years ago)
Author:
kil064
Message:

write output files into a directory

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/SDFITSImageWriter.cc

    r215 r279  
    3737#include <casa/Arrays/VectorIter.h>
    3838#include <casa/Utilities/CountedPtr.h>
     39#include <casa/OS/Directory.h>
    3940
    4041#include <coordinates/Coordinates/CoordinateUtil.h>
     
    7273
    7374Bool SDFITSImageWriter::write(const SDMemTable& sdTable,
    74                               const String& rootName, Bool verbose)
     75                              const String& dirName, Bool verbose)
    7576{
    7677
     
    9091
    9192   Table tab = sdTable.table();
    92    ROArrayColumn<Double> dir(tab, String("DIRECTION"));
    93    ROScalarColumn<Double> time(tab, "TIME");
    94    ROArrayColumn<uInt> freqid(tab, "FREQID");
    95    ROScalarColumn<String> src(tab, "SRCNAME");
     93   ROArrayColumn<Double> dirCol(tab, String("DIRECTION"));
     94   ROScalarColumn<Double> timeCol(tab, "TIME");
     95   ROArrayColumn<uInt> freqidCol(tab, "FREQID");
     96   ROScalarColumn<String> srcCol(tab, "SRCNAME");
    9697
    9798// Output Image Shape; spectral axis to be updated
     
    106107   const uInt chanAxis = asap::ChanAxis;
    107108   const Unit RAD(String("rad"));
     109
     110// Output Directory
     111
     112   String dirName2(dirName);
     113   if (dirName.length()==0) {
     114      dirName2 = String("asap_FITS");
     115   }
     116   Directory dir(dirName2);
     117   dir.create(True);
     118   cerr << "Created directory '" << dirName2 << "' for output files" << endl;
    108119
    109120// Temps
     
    147158
    148159      Double dTmp;
    149       time.get(iRow, dTmp);
     160      timeCol.get(iRow, dTmp);
    150161      MVEpoch tmp2(Quantum<Double>(dTmp, Unit(String("d"))));
    151162      MEpoch epoch(tmp2, timeRef);
     
    162173
    163174         Vector<uInt> iTmp;
    164          freqid.get(iRow, iTmp);
     175         freqidCol.get(iRow, iTmp);
    165176         SpectralCoordinate sC = sdTable.getCoordinate(iTmp(pos(ifAxis)));
    166177
    167178// Form DirectionCoordinate
    168179 
    169          dir.get(iRow, whichDir);
     180         dirCol.get(iRow, whichDir);
    170181         posDir(0) = pos(beamAxis);
    171182         posDir(1) = 0;
     
    210221         ostringstream oss;
    211222         oss << "row" << iRow << "_beam" << pos(0) << "_if"
    212              << pos(1) << "_pol" << pos(2) << "_" << src(iRow) << ".fits";
    213          String fileName;
    214          if (rootName.length()>0) {
    215             fileName = rootName + "_" + String(oss);
    216          } else {
    217             fileName = String(oss);
    218          }
     223             << pos(1) << "_pol" << pos(2) << "_" << srcCol(iRow) << ".fits";
     224         String tS(oss);
     225         String fileName = dirName2 + String("/") + tS;
    219226         if (verbose) cerr << "Writing row " << iRow
    220                            << " into file " << fileName << endl;
     227                           << " into file '" << tS << "'" << endl;
    221228//
    222229         Bool ok = ImageFITSConverter::ImageToFITS(errMsg, tIm, fileName,
Note: See TracChangeset for help on using the changeset viewer.