Changeset 380


Ignore:
Timestamp:
02/08/05 12:31:24 (19 years ago)
Author:
mar637
Message:
  • enabled getScan for lists of scanno
  • auto renumbering of scanids
  • added verbose flag to summary
  • slight 80 character width cosmetics on summary
Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/SDMemTable.cc

    r367 r380  
    111111  polSel_(0)
    112112{
     113  cout << exprs << endl;
    113114  Table t = tableCommand(exprs,tab);
    114115  if (t.nrow() == 0)
     
    116117  table_ = t.copyToMemoryTable("dummy");
    117118  attach();
     119  renumber();
    118120}
    119121
     
    181183}
    182184
    183 void SDMemTable::attach ()
     185void SDMemTable::attach()
    184186{
    185187  timeCol_.attach(table_, "TIME");
     
    262264}
    263265
    264 void SDMemTable::resetCursor ()
     266void SDMemTable::resetCursor()
    265267{
    266268   polSel_ = 0;
     
    639641  dirCol_.get(whichRow,posit);
    640642  Vector<Double> wpos(2);
     643  Int rb;
     644  rbeamCol_.get(whichRow,rb);
    641645  wpos[0] = posit(IPosition(2,beamSel_,0));
    642646  wpos[1] = posit(IPosition(2,beamSel_,1));
     647  if (refBeam && rb > -1) {  // use refBeam instead if it exists
     648    wpos[0] = posit(IPosition(2,rb,0));
     649    wpos[1] = posit(IPosition(2,rb,1));
     650  }
     651
    643652  Quantum<Double> lon(wpos[0],Unit(String("rad")));
    644653  Quantum<Double> lat(wpos[1],Unit(String("rad")));
     
    646655}
    647656
    648 MEpoch SDMemTable::getEpoch (Int whichRow) const
     657MEpoch SDMemTable::getEpoch(Int whichRow) const
    649658{
    650659  MEpoch::Types met = getTimeReference();
     
    697706
    698707
    699 SpectralCoordinate SDMemTable::getSpectralCoordinate(uInt freqID, uInt whichRow) const
     708SpectralCoordinate SDMemTable::getSpectralCoordinate(uInt freqID,
     709                                                     uInt whichRow) const
    700710{
    701711// Create basic SC
     
    10411051  MVAngle mvLat(t[1]);
    10421052  String sLat = mvLat.string(MVAngle::ANGLE+MVAngle::DIG2,prec);
    1043 
    1044    return sLon + String(" ") + sLat;
     1053  return sLon + String(" ") + sLat;
    10451054}
    10461055
     
    10741083}
    10751084
    1076 std::string SDMemTable::summary() const  {
     1085std::string SDMemTable::summary(bool verbose) const  {
    10771086
    10781087  ostringstream oss;
    10791088  oss << endl;
    1080   oss << "--------------------------------------------------" << endl;
     1089  oss << "--------------------------------------------------------------------------------" << endl;
    10811090  oss << " Scan Table Summary" << endl;
    1082   oss << "--------------------------------------------------" << endl;
     1091  oss << "--------------------------------------------------------------------------------" << endl;
    10831092  oss.flags(std::ios_base::left);
    10841093  oss << setw(15) << "Beams:" << setw(4) << nBeam() << endl
     
    11161125    MDirection::showType(getDirectionReference())+
    11171126    ")";
    1118   oss << setw(6) << "Scan"
     1127  oss << setw(5) << "Scan"
    11191128      << setw(15) << "Source"
    1120       << setw(26) << dirtype
     1129      << setw(24) << dirtype
    11211130      << setw(10) << "Time"
    11221131      << setw(18) << "Integration"
    1123       << setw(10) << "FreqIDs" << endl;
    1124   oss << "----------------------------------------------------------------------------------" << endl;
     1132      << setw(7) << "FreqIDs" << endl;
     1133  oss << "--------------------------------------------------------------------------------" << endl;
    11251134 
    11261135//
     
    11471156      if (i==nRow-1 &&scanID==lastScanID)  nInt++;   
    11481157      if (nInt==1 && i>1) {
    1149          for (uInt j=0; j<freqIDs.nelements(); j++) mathutil::addEntry(listFQ, freqIDs(j));
     1158         for (uInt j=0; j<freqIDs.nelements(); j++)
     1159           mathutil::addEntry(listFQ, freqIDs(j));
    11501160      }
    1151 //
    1152       oss << setw(6) << scanNo
     1161      oss << setw(3) << std::right << scanNo << std::left << setw(2) << "  "
    11531162          << setw(15) << name
    1154           << setw(26) << posit
     1163          << setw(24) << posit
    11551164          << setw(10) << getTime(firstRow,False)
    1156           << setw(3) << nInt  << setw(3) << " x " << setw(6) <<  t
     1165          << setw(3) << std::right << nInt  << setw(3) << " x " << std::left
     1166          << setw(6) <<  t
    11571167          << " " << listFQ << endl;
    11581168//
     
    11691179
    11701180// Frequency Table
    1171 
    1172   std::vector<string> info = getCoordInfo();
    1173   SDFrequencyTable sdft = getSDFreqTable();
    1174   oss << endl << endl;
    1175   oss << "FreqID  Frame   RefFreq(Hz)     RefPix   Increment(Hz)" << endl;
    1176   oss << "----------------------------------------------------------------------------------" << endl;
    1177   for (uInt i=0; i<sdft.length(); i++) {
    1178      oss << setw(8) << i << setw(8)
    1179                     << info[3] << setw(16) << setprecision (8)
    1180                     << sdft.referenceValue(i) << setw(10)
    1181                     << sdft.referencePixel(i) << setw(12)
    1182                     << sdft.increment(i) << endl;
    1183   }
    1184   oss << "----------------------------------------------------------------------------------" << endl;
     1181  if (verbose) {
     1182    std::vector<string> info = getCoordInfo();
     1183    SDFrequencyTable sdft = getSDFreqTable();
     1184    oss << endl << endl;
     1185    oss << "FreqID  Frame   RefFreq(Hz)     RefPix   Increment(Hz)" << endl;
     1186    oss << "--------------------------------------------------------------------------------" << endl;
     1187    for (uInt i=0; i<sdft.length(); i++) {
     1188      oss << setw(8) << i << setw(8)
     1189          << info[3] << setw(16) << setprecision(8)
     1190          << sdft.referenceValue(i) << setw(10)
     1191          << sdft.referencePixel(i) << setw(12)
     1192          << sdft.increment(i) << endl;
     1193    }
     1194    oss << "--------------------------------------------------------------------------------" << endl;
     1195  }
    11851196  return String(oss);
    11861197}
     
    12821293}
    12831294
    1284 MEpoch::Types SDMemTable::getTimeReference () const
     1295MEpoch::Types SDMemTable::getTimeReference() const
    12851296{
    12861297  MEpoch::Types met;
     
    12961307
    12971308
    1298 Instrument SDMemTable::convertInstrument (const String& instrument,
    1299                                           Bool throwIt)
     1309Instrument SDMemTable::convertInstrument(const String& instrument,
     1310                                        Bool throwIt)
    13001311{
    13011312   String t(instrument);
     
    13191330      inst = HOBART;
    13201331   } else {
    1321       if (throwIt) {
    1322          throw AipsError("Unrecognized instrument - use function scan.set_instrument to set");
    1323       }
     1332     if (throwIt) {
     1333       throw AipsError("Unrecognized instrument - use function scan.set_instrument to set");
     1334     }
    13241335   }
    13251336   return inst;
    13261337}
    13271338
     1339void SDMemTable::renumber()
     1340{
     1341  uInt nRow = scanCol_.nrow();
     1342  Int newscanid = 0;
     1343  Int cIdx;// the current scanid
     1344  // get the first scanid
     1345  scanCol_.getScalar(0,cIdx);
     1346  Int pIdx = cIdx;// the scanid of the previous row
     1347  for (uInt i=0; i<nRow;++i) {
     1348    scanCol_.getScalar(i,cIdx);
     1349    if (pIdx == cIdx) {
     1350      // renumber
     1351      scanCol_.put(i,newscanid);
     1352    } else {
     1353      ++newscanid;
     1354      pIdx = cIdx;   // store scanid
     1355      --i;           // don't increment next loop
     1356    }
     1357  }
     1358}
  • trunk/src/SDMemTable.h

    r322 r380  
    150150
    151151  // get a summary of the table
    152   virtual std::string summary() const;
     152  virtual std::string summary(bool verbose=false) const;
    153153
    154154  std::vector<std::string> history(int whichRow=0) const;
     
    217217  void setup();
    218218  void attach();
     219  void renumber();
    219220  // the current cursor into the array
    220221  casa::Int IFSel_,beamSel_,polSel_;
  • trunk/src/SDMemTableWrapper.h

    r260 r380  
    3434#include <vector>
    3535#include <string>
     36#include <casa/Arrays/Vector.h>
    3637
    3738#include "SDMemTable.h"
     
    6061  }
    6162
    62   SDMemTableWrapper getScan(int scan) {
    63     casa::String cond("SELECT * from $1 WHERE SCANID == ");
    64     cond += casa::String::toString(scan);
     63  //SDMemTableWrapper getScan(int scan) {
     64  SDMemTableWrapper getScan(std::vector<int> scan) {
     65    casa::String cond("SELECT FROM $1 WHERE SCANID IN ");
     66    casa::Vector<casa::Int> v(scan);
     67    casa::ostringstream oss;
     68    oss << v;
     69    cond += casa::String(oss);
    6570    return SDMemTableWrapper(*this, cond);
    6671  }
     
    157162  casa::CountedPtr<SDMemTable> getCP() const {return table_;}
    158163  SDMemTable* getPtr() {return &(*table_);}
    159   std::string summary() const { return table_->summary(); }
     164
     165  std::string summary(bool verbose=false) const {
     166    return table_->summary(verbose);
     167  }
    160168 
    161169  std::vector<std::string> history(int whichRow=0) {
Note: See TracChangeset for help on using the changeset viewer.