Changeset 281 for trunk


Ignore:
Timestamp:
01/24/05 17:13:36 (20 years ago)
Author:
mar637
Message:
  • revamped summary Function, added postion and number of integr. per scan
  • added formatDirection
  • modified getTime to return Header time on whichRow=-1
Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/SDMemTable.cc

    r275 r281  
    5656#include <coordinates/Coordinates/CoordinateUtil.h>
    5757#include <casa/Quanta/MVTime.h>
     58#include <casa/Quanta/MVAngle.h>
    5859
    5960#include "SDDefs.h"
     
    181182}
    182183
    183 std::string SDMemTable::getTime(Int whichRow) const
    184 {
    185   ROScalarColumn<Double> src(table_, "TIME");
     184std::string SDMemTable::getTime(Int whichRow, Bool showDate) const
     185{
    186186  Double tm;
    187   src.get(whichRow, tm);
     187  if (whichRow > -1) {
     188    ROScalarColumn<Double> src(table_, "TIME");
     189    src.get(whichRow, tm);
     190  } else {
     191    table_.keywordSet().get("UTC",tm);
     192  }
    188193  MVTime mvt(tm);
    189   mvt.setFormat(MVTime::TIME);
     194  if (showDate)
     195    mvt.setFormat(MVTime::YMD);
     196  else
     197    mvt.setFormat(MVTime::TIME);
    190198  ostringstream oss;
    191199  oss << mvt;
    192   String str(oss);
    193   return str;
    194 }
     200  return String(oss);
     201}
     202
    195203double SDMemTable::getInterval(Int whichRow) const
    196204{
     
    620628}
    621629
    622 MDirection SDMemTable::getDirection(Int whichRow) const
     630MDirection SDMemTable::getDirection(Int whichRow, Bool refBeam) const
    623631{
    624632  MDirection::Types mdr = getDirectionReference();
     
    917925  Double xcop = x;
    918926  MVTime mvt(xcop/24./3600.);  // make days
     927 
    919928  if (x < 59.95)
    920     return  String("   ") + mvt.string(MVTime::TIME_CLEAN_NO_HM, 7)+"s";
    921   return mvt.string(MVTime::TIME_CLEAN_NO_H, 7)+" ";
     929    return  String("      ") + mvt.string(MVTime::TIME_CLEAN_NO_HM, 7)+"s";
     930  else if (x < 3599.95)
     931    return String("   ") + mvt.string(MVTime::TIME_CLEAN_NO_H,7)+" ";
     932  else {
     933    ostringstream oss;
     934    oss << setw(2) << std::right << setprecision(1) << mvt.hour();
     935    oss << ":" << mvt.string(MVTime::TIME_CLEAN_NO_H,7) << " ";
     936    return String(oss);
     937  }   
    922938};
     939
     940String SDMemTable::formatDirection(const MDirection& md) const
     941{
     942  Vector<Double> t = md.getAngle(Unit(String("rad"))).getValue();
     943  Int prec = 7;
     944
     945  MVAngle mvLon(t[0]);
     946  String sLon = mvLon.string(MVAngle::TIME,prec);
     947  MVAngle mvLat(t[1]);
     948  String sLat = mvLat.string(MVAngle::ANGLE+MVAngle::DIG2,prec);
     949
     950   return sLon + String(" ") + sLat;
     951}
     952
    923953
    924954std::string SDMemTable::getFluxUnit() const
     
    953983  ROScalarColumn<Int> scans(table_, "SCANID");
    954984  ROScalarColumn<String> srcs(table_, "SRCNAME");
     985
     986  // get number of integrations per scan
     987  int cIdx = 0;
     988  int idx = 0;
     989  int scount = 0;
     990  std::vector<int> cycles;
     991  for (uInt i=0; i<scans.nrow();++i) {
     992    while (idx == cIdx && i<scans.nrow()) {
     993      scans.getScalar(++i,cIdx);
     994      ++scount;
     995    }
     996    idx = cIdx;
     997    cycles.push_back(scount);
     998    scount=0;
     999    --i;
     1000  } 
     1001
     1002
    9551003  ostringstream oss;
    9561004  oss << endl;
     
    9671015  table_.keywordSet().get("Observer", tmp);
    9681016  oss << setw(15) << "Observer:" << tmp << endl;
     1017  oss << setw(15) << "Obs Date:" << getTime(-1,True) << endl;
    9691018  table_.keywordSet().get("Project", tmp);
    9701019  oss << setw(15) << "Project:" << tmp << endl;
     
    9921041  Int previous = -1;Int current=0;
    9931042  Int integ = 0;
     1043  String dirtype ="Position ("+
     1044    MDirection::showType(getDirectionReference())+
     1045    ")";
    9941046  oss << setw(6) << "Scan"
    995       << setw(12) << "Source"
    996       << setw(21) << "Time"
    997       << setw(11) << "Integration" << endl;
    998   oss << "--------------------------------------------------" << endl;
     1047      << setw(15) << "Source"
     1048      << setw(26) << dirtype
     1049      << setw(10) << "Time"
     1050      << setw(13) << "Integration" << endl;
     1051  oss << "-------------------------------------------------------------------------------" << endl;
     1052 
     1053  std::vector<int>::iterator it = cycles.begin();
    9991054  for (uInt i=0; i< scans.nrow();i++) {
    10001055    scans.getScalar(i,current);
     
    10031058      previous = current;
    10041059      String t = formatSec(Double(getInterval(i)));
    1005       oss << setw(6) << count << setw(12) << name << setw(21) << getTime(i)
    1006           << setw(2) << setprecision(1)
    1007           << t << endl;
     1060      String posit = formatDirection(getDirection(i,True));
     1061      oss << setw(6) << count
     1062          << setw(15) << name
     1063          << setw(26) << posit
     1064          << setw(10) << getTime(i,False)
     1065          << setw(3) << std::right << *it << " x "
     1066          << setw(10)
     1067          << t << std::left << endl;
    10081068      count++;
     1069      it++;
    10091070    } else {
    10101071      integ++;
     
    10141075  oss << "Table contains " << table_.nrow() << " integration(s)." << endl;
    10151076  oss << "in " << count << " scan(s)." << endl;
    1016   oss << "--------------------------------------------------";
     1077  oss << "-------------------------------------------------------------------------------";
    10171078  return String(oss);
    10181079}
     
    11011162}
    11021163
    1103 MDirection::Types SDMemTable::getDirectionReference () const
     1164MDirection::Types SDMemTable::getDirectionReference() const
    11041165
    11051166  Float eq;
  • trunk/src/SDMemTable.h

    r263 r281  
    9393  std::vector<double> getRestFreqs() const;
    9494 
    95   // get info for current row
    96   std::string getTime(casa::Int whichRow=0) const ;
     95  // get info for current row 
     96  // if whichRow == -1 the Header time is given
     97  std::string getTime(casa::Int whichRow=0,
     98                      casa::Bool showDate=casa::False) const ;
    9799  std::string getSourceName(casa::Int whichRow=0) const;
    98100  double getInterval(casa::Int whichRow=0) const;
     
    173175
    174176// Get MDirection for this row
    175   casa::MDirection getDirection(casa::Int whichRow=0) const;
     177  casa::MDirection getDirection(casa::Int whichRow=0,
     178                                casa::Bool refBeam=casa::False) const;
    176179
    177180// Get gloabl Direction reference
    178   casa::MDirection::Types getDirectionReference () const;
     181  casa::MDirection::Types getDirectionReference() const;
    179182
    180183// Get global Time reference
    181   casa::MEpoch::Types getTimeReference () const;
     184  casa::MEpoch::Types getTimeReference() const;
    182185
    183186// Helper function to check instrument (antenna) name and give enum
    184   static Instrument convertInstrument (const casa::String& instrument,
    185                                        casa::Bool throwIt);
     187  static Instrument convertInstrument(const casa::String& instrument,
     188                                      casa::Bool throwIt);
    186189
    187190private:
    188191  // utility func for nice printout
    189192  casa::String formatSec(casa::Double x) const;
     193  casa::String formatDirection(const casa::MDirection& md) const;
    190194  void setup();
    191195  // the current cursor into the array
Note: See TracChangeset for help on using the changeset viewer.