Changeset 206


Ignore:
Timestamp:
01/18/05 17:29:02 (20 years ago)
Author:
mar637
Message:
  • now using asap::AxisNo enum instead of fixed axis indeces
  • using fluxunit, epoch, equinox
  • added restfrequencies
  • added history
  • now using asap::AxisNo enum instead of fixed axis indeces
  • added getDirection method
Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/SDMemTable.cc

    r164 r206  
    3030//#---------------------------------------------------------------------------
    3131
     32#include <map>
     33
    3234#include <casa/aips.h>
    3335#include <casa/iostream.h>
     
    3840#include <casa/Arrays/ArrayLogical.h>
    3941#include <casa/Arrays/ArrayAccessor.h>
     42#include <casa/Arrays/Vector.h>
    4043
    4144#include <tables/Tables/TableParse.h>
     
    5457#include <casa/Quanta/MVTime.h>
    5558
     59#include "Definitions.h"
    5660#include "SDMemTable.h"
    5761#include "SDContainer.h"
     62
    5863
    5964using namespace casa;
     
    6368  IFSel_(0),
    6469  beamSel_(0),
    65   polSel_(0) {
     70  polSel_(0)
     71{
    6672  setup();
    6773}
     74
    6875SDMemTable::SDMemTable(const std::string& name) :
    6976  IFSel_(0),
    7077  beamSel_(0),
    71   polSel_(0) {
     78  polSel_(0)
     79{
    7280  Table tab(name);
    7381  table_ = tab.copyToMemoryTable("dummy");
    74 }
    75 
    76 SDMemTable::SDMemTable(const SDMemTable& other, Bool clear) {
     82  //cerr << "hello from C SDMemTable @ " << this << endl;
     83}
     84
     85SDMemTable::SDMemTable(const SDMemTable& other, Bool clear)
     86{
    7787  IFSel_= other.IFSel_;
    7888  beamSel_= other.beamSel_;
     
    8898    polSel_ = other.polSel_;
    8999  }
     100  //cerr << "hello from CC SDMemTable @ " << this << endl;
    90101}
    91102
     
    93104  IFSel_(0),
    94105  beamSel_(0),
    95   polSel_(0) {
     106  polSel_(0)
     107{
    96108  Table t = tableCommand(exprs,tab);
    97109  if (t.nrow() == 0)
     
    100112}
    101113
    102 SDMemTable::~SDMemTable(){
     114SDMemTable::~SDMemTable()
     115{
    103116  //cerr << "goodbye from SDMemTable @ " << this << endl;
    104117}
    105118
    106 SDMemTable SDMemTable::getScan(Int scanID) const {
     119SDMemTable SDMemTable::getScan(Int scanID) const
     120{
    107121  String cond("SELECT * from $1 WHERE SCANID == ");
    108122  cond += String::toString(scanID);
     
    110124}
    111125
    112 SDMemTable &SDMemTable::operator=(const SDMemTable& other) {
     126SDMemTable &SDMemTable::operator=(const SDMemTable& other)
     127{
    113128  if (this != &other) {
    114129     IFSel_= other.IFSel_;
     
    118133     chanMask_ = other.chanMask_;
    119134     table_ = other.table_.copyToMemoryTable(String("dummy"));
    120    }
     135  }
     136  //cerr << "hello from ASS SDMemTable @ " << this << endl;
    121137  return *this;
    122138}
    123139
    124 SDMemTable SDMemTable::getSource(const std::string& source) const {
     140SDMemTable SDMemTable::getSource(const std::string& source) const
     141{
    125142  String cond("SELECT * from $1 WHERE SRCNAME == ");
    126143  cond += source;
     
    128145}
    129146
    130 void SDMemTable::setup() {
     147void SDMemTable::setup()
     148{
    131149  TableDesc td("", "1", TableDesc::Scratch);
    132150  td.comment() = "A SDMemTable";
     
    147165  td.addColumn(ScalarColumnDesc<Float>("PARANGLE"));
    148166  td.addColumn(ScalarColumnDesc<Int>("REFBEAM"));
     167  td.addColumn(ArrayColumnDesc<String>("HISTORY"));
    149168
    150169  // Now create a new table from the description.
     
    154173}
    155174
    156 std::string SDMemTable::getSourceName(Int whichRow) const {
     175std::string SDMemTable::getSourceName(Int whichRow) const
     176{
    157177  ROScalarColumn<String> src(table_, "SRCNAME");
    158178  String name;
     
    161181}
    162182
    163 std::string SDMemTable::getTime(Int whichRow) const {
     183std::string SDMemTable::getTime(Int whichRow) const
     184{
    164185  ROScalarColumn<Double> src(table_, "TIME");
    165186  Double tm;
     
    172193  return str;
    173194}
    174 double SDMemTable::getInterval(Int whichRow) const {
     195double SDMemTable::getInterval(Int whichRow) const
     196{
    175197  ROScalarColumn<Double> src(table_, "INTERVAL");
    176198  Double intval;
     
    179201}
    180202
    181 bool SDMemTable::setIF(Int whichIF) {
     203bool SDMemTable::setIF(Int whichIF)
     204{
    182205  if ( whichIF >= 0 && whichIF < nIF()) {
    183206    IFSel_ = whichIF;
     
    187210}
    188211
    189 bool SDMemTable::setBeam(Int whichBeam) {
     212bool SDMemTable::setBeam(Int whichBeam)
     213{
    190214  if ( whichBeam >= 0 && whichBeam < nBeam()) {
    191215    beamSel_ = whichBeam;
     
    195219}
    196220
    197 bool SDMemTable::setPol(Int whichPol) {
     221bool SDMemTable::setPol(Int whichPol)
     222{
    198223  if ( whichPol >= 0 && whichPol < nPol()) {
    199224    polSel_ = whichPol;
     
    203228}
    204229
    205 bool SDMemTable::setMask(std::vector<int> whichChans) {
     230bool SDMemTable::setMask(std::vector<int> whichChans)
     231{
    206232  ROArrayColumn<uChar> spec(table_, "FLAGTRA");
    207233  std::vector<int>::iterator it;
     
    225251  Array<uChar> arr;
    226252  spec.get(whichRow, arr);
    227   ArrayAccessor<uChar, Axis<0> > aa0(arr);
     253  ArrayAccessor<uChar, Axis<asap::BeamAxis> > aa0(arr);
    228254  aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam
    229   ArrayAccessor<uChar, Axis<1> > aa1(aa0);
     255  ArrayAccessor<uChar, Axis<asap::IFAxis> > aa1(aa0);
    230256  aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF
    231   ArrayAccessor<uChar, Axis<2> > aa2(aa1);
     257  ArrayAccessor<uChar, Axis<asap::PolAxis> > aa2(aa1);
    232258  aa2.reset(aa2.begin(uInt(polSel_)));// go to pol
    233259
     
    239265  miter = tmp.begin();
    240266
    241   for (ArrayAccessor<uChar, Axis<3> > i(aa2); i != i.end(); ++i) {
     267  for (ArrayAccessor<uChar, Axis<asap::ChanAxis> > i(aa2); i != i.end(); ++i) {
    242268    bool out =!static_cast<bool>(*i);
    243269    if (useUserMask) {
     
    249275  return mask;
    250276}
    251 std::vector<float> SDMemTable::getSpectrum(Int whichRow) const {
    252 
     277std::vector<float> SDMemTable::getSpectrum(Int whichRow) const
     278{
    253279  std::vector<float> spectrum;
    254280  ROArrayColumn<Float> spec(table_, "SPECTRA");
    255281  Array<Float> arr;
    256282  spec.get(whichRow, arr);
    257   ArrayAccessor<Float, Axis<0> > aa0(arr);
     283  ArrayAccessor<Float, Axis<asap::BeamAxis> > aa0(arr);
    258284  aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam
    259   ArrayAccessor<Float, Axis<1> > aa1(aa0);
     285  ArrayAccessor<Float, Axis<asap::IFAxis> > aa1(aa0);
    260286  aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF
    261   ArrayAccessor<Float, Axis<2> > aa2(aa1);
     287  ArrayAccessor<Float, Axis<asap::PolAxis> > aa2(aa1);
    262288  aa2.reset(aa2.begin(uInt(polSel_)));// go to pol
    263   for (ArrayAccessor<Float, Axis<3> > i(aa2); i != i.end(); ++i) {
     289  for (ArrayAccessor<Float, Axis<asap::ChanAxis> > i(aa2); i != i.end(); ++i) {
    264290    spectrum.push_back(*i);
    265291  }
    266292  return spectrum;
    267293}
    268 std::vector<string> SDMemTable::getCoordInfo() const {
     294std::vector<string> SDMemTable::getCoordInfo() const
     295{
    269296  String un;
    270297  Table t = table_.keywordSet().asTable("FREQUENCIES");
     
    283310}
    284311
    285 void SDMemTable::setCoordInfo(std::vector<string> theinfo) {
    286 
     312void SDMemTable::setCoordInfo(std::vector<string> theinfo)
     313{
    287314  std::vector<string>::iterator it;
    288315  String un,rfrm,dpl;
     
    291318  dpl = theinfo[2];
    292319
    293   //String un(theunit);
    294320  Table t = table_.rwKeywordSet().asTable("FREQUENCIES");
    295321  Vector<Double> rstf;
     
    321347}
    322348
    323 std::vector<double> SDMemTable::getAbcissa(Int whichRow) const {
     349std::vector<double> SDMemTable::getAbcissa(Int whichRow) const
     350{
    324351  std::vector<double> absc(nChan());
    325352  Vector<Double> absc1(nChan());
     
    331358  SpectralCoordinate spc = getCoordinate(specidx);
    332359  Table t = table_.keywordSet().asTable("FREQUENCIES");
    333   String rf;
    334   //t.keywordSet().get("EQUINOX",rf);
    335   MDirection::Types mdr;
    336   //if (!MDirection::getType(mdr, rf)) {
    337   mdr = MDirection::J2000;
    338   //cout << "Unknown equinox using J2000" << endl;
    339   //}
    340   ROArrayColumn<Double> dir(table_, "DIRECTION");
    341   Array<Double> posit;
    342   dir.get(whichRow,posit);
    343   Vector<Double> wpos(2);
    344   wpos[0] = posit(IPosition(2,beamSel_,0));
    345   wpos[1] = posit(IPosition(2,beamSel_,1));
    346   Quantum<Double> lon(wpos[0],Unit(String("rad")));
    347   Quantum<Double> lat(wpos[1],Unit(String("rad")));
    348   MDirection direct(lon, lat, mdr);
     360
     361  MDirection direct = getDirection(whichRow);
     362
    349363  ROScalarColumn<Double> tme(table_, "TIME");
    350364  Double obstime;
    351365  tme.get(whichRow,obstime);
    352366  MVEpoch tm2(Quantum<Double>(obstime, Unit(String("d"))));
    353   MEpoch epoch(tm2);
     367  MEpoch::Types met;
     368  String ep;
     369  table_.keywordSet().get("Epoch",ep);
     370  if (!MEpoch::getType(met, ep)) {
     371    cerr << "Epoch type uknown - using UTC" << endl;
     372    met = MEpoch::UTC;
     373  }
     374
     375  MEpoch epoch(tm2, met);
    354376
    355377  Vector<Double> antpos;
     
    448470}
    449471
    450 void SDMemTable::setSpectrum(std::vector<float> spectrum, int whichRow) {
     472void SDMemTable::setSpectrum(std::vector<float> spectrum, int whichRow)
     473{
    451474  ArrayColumn<Float> spec(table_, "SPECTRA");
    452475  Array<Float> arr;
     
    456479  }
    457480
    458   ArrayAccessor<Float, Axis<0> > aa0(arr);
     481  ArrayAccessor<Float, Axis<asap::BeamAxis> > aa0(arr);
    459482  aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam
    460   ArrayAccessor<Float, Axis<1> > aa1(aa0);
     483  ArrayAccessor<Float, Axis<asap::IFAxis> > aa1(aa0);
    461484  aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF
    462   ArrayAccessor<Float, Axis<2> > aa2(aa1);
     485  ArrayAccessor<Float, Axis<asap::PolAxis> > aa2(aa1);
    463486  aa2.reset(aa2.begin(uInt(polSel_)));// go to pol
    464487
    465488  std::vector<float>::iterator it = spectrum.begin();
    466   for (ArrayAccessor<Float, Axis<3> > i(aa2); i != i.end(); ++i) {
     489  for (ArrayAccessor<Float, Axis<asap::ChanAxis> > i(aa2); i != i.end(); ++i) {
    467490    (*i) = Float(*it);
    468491    it++;
     
    471494}
    472495
    473 void SDMemTable::getSpectrum(Vector<Float>& spectrum, Int whichRow) const {
     496void SDMemTable::getSpectrum(Vector<Float>& spectrum, Int whichRow) const
     497{
    474498  ROArrayColumn<Float> spec(table_, "SPECTRA");
    475499  Array<Float> arr;
    476500  spec.get(whichRow, arr);
    477501  spectrum.resize(arr.shape()(3));
    478   ArrayAccessor<Float, Axis<0> > aa0(arr);
     502  ArrayAccessor<Float, Axis<asap::BeamAxis> > aa0(arr);
    479503  aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam
    480   ArrayAccessor<Float, Axis<1> > aa1(aa0);
     504  ArrayAccessor<Float, Axis<asap::IFAxis> > aa1(aa0);
    481505  aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF
    482   ArrayAccessor<Float, Axis<2> > aa2(aa1);
     506  ArrayAccessor<Float, Axis<asap::PolAxis> > aa2(aa1);
    483507  aa2.reset(aa2.begin(uInt(polSel_)));// go to pol
    484508
    485   ArrayAccessor<Float, Axis<0> > va(spectrum);
    486   for (ArrayAccessor<Float, Axis<3> > i(aa2); i != i.end(); ++i) {
     509  ArrayAccessor<Float, Axis<asap::BeamAxis> > va(spectrum);
     510  for (ArrayAccessor<Float, Axis<asap::ChanAxis> > i(aa2); i != i.end(); ++i) {
    487511    (*va) = (*i);
    488512    va++;
     
    496520  mask.resize(arr.shape()(3));
    497521
    498   ArrayAccessor<uChar, Axis<0> > aa0(arr);
     522  ArrayAccessor<uChar, Axis<asap::BeamAxis> > aa0(arr);
    499523  aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam
    500   ArrayAccessor<uChar, Axis<1> > aa1(aa0);
     524  ArrayAccessor<uChar, Axis<asap::IFAxis> > aa1(aa0);
    501525  aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF
    502   ArrayAccessor<uChar, Axis<2> > aa2(aa1);
     526  ArrayAccessor<uChar, Axis<asap::PolAxis> > aa2(aa1);
    503527  aa2.reset(aa2.begin(uInt(polSel_)));// go to pol
    504528
    505529  Bool useUserMask = ( chanMask_.size() == arr.shape()(3) );
    506530
    507   ArrayAccessor<Bool, Axis<0> > va(mask);
     531  ArrayAccessor<Bool, Axis<asap::BeamAxis> > va(mask);
    508532  std::vector<bool> tmp;
    509533  tmp = chanMask_; // WHY the fxxx do I have to make a copy here. The
     
    512536  miter = tmp.begin();
    513537
    514   for (ArrayAccessor<uChar, Axis<3> > i(aa2); i != i.end(); ++i) {
     538  for (ArrayAccessor<uChar, Axis<asap::ChanAxis> > i(aa2); i != i.end(); ++i) {
    515539    bool out =!static_cast<bool>(*i);
    516540    if (useUserMask) {
     
    535559  MaskedArray<Float> marr;
    536560  if (useSelection) {
    537     ArrayAccessor<Float, Axis<0> > aa0(arr);
     561    ArrayAccessor<Float, Axis<asap::BeamAxis> > aa0(arr);
    538562    aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam
    539     ArrayAccessor<Float, Axis<1> > aa1(aa0);
     563    ArrayAccessor<Float, Axis<asap::IFAxis> > aa1(aa0);
    540564    aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF
    541     ArrayAccessor<Float, Axis<2> > aa2(aa1);
     565    ArrayAccessor<Float, Axis<asap::PolAxis> > aa2(aa1);
    542566    aa2.reset(aa2.begin(uInt(polSel_)));// go to pol
    543567
    544     ArrayAccessor<Bool, Axis<0> > baa0(barr);
     568    ArrayAccessor<Bool, Axis<asap::BeamAxis> > baa0(barr);
    545569    baa0.reset(baa0.begin(uInt(beamSel_)));//go to beam
    546     ArrayAccessor<Bool, Axis<1> > baa1(baa0);
     570    ArrayAccessor<Bool, Axis<asap::IFAxis> > baa1(baa0);
    547571    baa1.reset(baa1.begin(uInt(IFSel_)));// go to IF
    548     ArrayAccessor<Bool, Axis<2> > baa2(baa1);
     572    ArrayAccessor<Bool, Axis<asap::PolAxis> > baa2(baa1);
    549573    baa2.reset(baa2.begin(uInt(polSel_)));// go to pol
    550574
    551575    Vector<Float> a(arr.shape()(3));
    552576    Vector<Bool> b(barr.shape()(3));
    553     ArrayAccessor<Float, Axis<0> > a0(a);
    554     ArrayAccessor<Bool, Axis<0> > b0(b);
    555 
    556     ArrayAccessor<Bool, Axis<3> > j(baa2);
    557     for (ArrayAccessor<Float, Axis<3> > i(aa2); i != i.end(); ++i) {
     577    ArrayAccessor<Float, Axis<asap::BeamAxis> > a0(a);
     578    ArrayAccessor<Bool, Axis<asap::BeamAxis> > b0(b);
     579
     580    ArrayAccessor<Bool, Axis<asap::ChanAxis> > j(baa2);
     581    for (ArrayAccessor<Float, Axis<asap::ChanAxis> > i(aa2);
     582         i != i.end(); ++i) {
    558583      (*a0) = (*i);
    559584      (*b0) = !(*j);
     
    569594}
    570595
    571 Float SDMemTable::getTsys(Int whichRow) const {
     596Float SDMemTable::getTsys(Int whichRow) const
     597{
    572598  ROArrayColumn<Float> ts(table_, "TSYS");
    573599  Array<Float> arr;
     
    580606}
    581607
    582 SpectralCoordinate SDMemTable::getCoordinate(uInt whichIdx)  const {
    583 
     608MDirection SDMemTable::getDirection(Int whichRow) const
     609{
     610  Float eq;
     611  table_.keywordSet().get("Equinox",eq);
     612  std::map<float,string> mp;
     613  mp[2000.0] = "J2000";
     614  mp[1950.0] = "B1950";
     615  MDirection::Types mdr;
     616  if (!MDirection::getType(mdr, mp[eq])) {
     617    mdr = MDirection::J2000;
     618    cerr  << "Unknown equinox using J2000" << endl;
     619  }
     620  ROArrayColumn<Double> dir(table_, "DIRECTION");
     621  Array<Double> posit;
     622  dir.get(whichRow,posit);
     623  Vector<Double> wpos(2);
     624  wpos[0] = posit(IPosition(2,beamSel_,0));
     625  wpos[1] = posit(IPosition(2,beamSel_,1));
     626  Quantum<Double> lon(wpos[0],Unit(String("rad")));
     627  Quantum<Double> lat(wpos[1],Unit(String("rad")));
     628  MDirection direct(lon, lat, mdr);
     629  return direct;
     630}
     631
     632SpectralCoordinate SDMemTable::getCoordinate(uInt whichIdx) const
     633{
     634 
    584635  Table t = table_.keywordSet().asTable("FREQUENCIES");
    585636  if (whichIdx > t.nrow() ) {
    586     cerr << "SDMemTable::getCoordinate - whichIdx out of range" << endl;
    587     return SpectralCoordinate();
     637    throw(AipsError("SDMemTable::getCoordinate - whichIdx out of range"));
    588638  }
    589639
     
    633683}
    634684
    635 void SDMemTable::setRestFreqs(std::vector<double> freqs, const std::string& theunit)
     685void SDMemTable::setRestFreqs(std::vector<double> freqs,
     686                              const std::string& theunit)
    636687{
    637688  Vector<Double> tvec(freqs);
     
    643694}
    644695
    645 bool SDMemTable::putSDFreqTable(const SDFrequencyTable& sdft) {
     696bool SDMemTable::putSDFreqTable(const SDFrequencyTable& sdft)
     697{
    646698  TableDesc td("", "1", TableDesc::Scratch);
    647699  td.addColumn(ScalarColumnDesc<Double>("REFPIX"));
     
    667719  aTable.rwKeywordSet().define("DOPPLER", String("RADIO"));
    668720  Vector<Double> rfvec;
     721  String rfunit;
     722  sdft.restFrequencies(rfvec,rfunit);
     723  Quantum<Vector<Double> > q(rfvec, rfunit);
     724  rfvec.resize();
     725  rfvec = q.getValue("Hz");
    669726  aTable.rwKeywordSet().define("RESTFREQS", rfvec);
    670727  table_.rwKeywordSet().defineTable ("FREQUENCIES", aTable);
     
    672729}
    673730
    674 SDFrequencyTable SDMemTable::getSDFreqTable() const  {
     731SDFrequencyTable SDMemTable::getSDFreqTable() const
     732{
    675733  SDFrequencyTable sdft;
    676734
     
    678736}
    679737
    680 bool SDMemTable::putSDContainer(const SDContainer& sdc) {
     738bool SDMemTable::putSDContainer(const SDContainer& sdc)
     739{
    681740  ScalarColumn<Double> mjd(table_, "TIME");
    682741  ScalarColumn<String> srcn(table_, "SRCNAME");
     
    695754  ScalarColumn<Float> el(table_, "ELEVATION");
    696755  ScalarColumn<Float> para(table_, "PARANGLE");
     756  ArrayColumn<String> hist(table_, "HISTORY");
    697757
    698758  uInt rno = table_.nrow();
     
    715775  el.put(rno, sdc.elevation);
    716776  para.put(rno, sdc.parangle);
     777  hist.put(rno, sdc.getHistory());
    717778
    718779  return true;
    719780}
    720781
    721 SDContainer SDMemTable::getSDContainer(uInt whichRow) const {
     782SDContainer SDMemTable::getSDContainer(uInt whichRow) const
     783{
    722784  ROScalarColumn<Double> mjd(table_, "TIME");
    723785  ROScalarColumn<String> srcn(table_, "SRCNAME");
     
    736798  ROScalarColumn<Float> el(table_, "ELEVATION");
    737799  ROScalarColumn<Float> para(table_, "PARANGLE");
     800  ROArrayColumn<String> hist(table_, "HISTORY");
    738801
    739802  SDContainer sdc(nBeam(),nIF(),nPol(),nChan());
     
    756819  Vector<uInt> fmap;
    757820  Array<Double> direction;
     821  Vector<String> histo;
    758822  spec.get(whichRow, spectrum);
    759823  sdc.putSpectrum(spectrum);
     
    766830  dir.get(whichRow, direction);
    767831  sdc.putDirection(direction);
     832  hist.get(whichRow, histo);
     833  sdc.putHistory(histo);
    768834  return sdc;
    769835}
    770836
    771 bool SDMemTable::putSDHeader(const SDHeader& sdh) {
    772   table_.lock();
     837bool SDMemTable::putSDHeader(const SDHeader& sdh)
     838{
    773839  table_.rwKeywordSet().define("nIF", sdh.nif);
    774840  table_.rwKeywordSet().define("nBeam", sdh.nbeam);
     
    785851  table_.rwKeywordSet().define("Bandwidth", sdh.bandwidth);
    786852  table_.rwKeywordSet().define("UTC", sdh.utc);
    787   table_.unlock();
     853  table_.rwKeywordSet().define("FluxUnit", sdh.fluxunit);
     854  table_.rwKeywordSet().define("Epoch", sdh.epoch);
    788855  return true;
    789856}
    790857
    791 SDHeader SDMemTable::getSDHeader() const {
     858SDHeader SDMemTable::getSDHeader() const
     859{
    792860  SDHeader sdh;
    793861  table_.keywordSet().get("nBeam",sdh.nbeam);
     
    805873  table_.keywordSet().get("Bandwidth", sdh.bandwidth);
    806874  table_.keywordSet().get("UTC", sdh.utc);
     875  table_.keywordSet().get("FluxUnit", sdh.fluxunit);
     876  table_.keywordSet().get("Epoch", sdh.epoch);
    807877  return sdh;
    808878}
    809 void SDMemTable::makePersistent(const std::string& filename) {
     879void SDMemTable::makePersistent(const std::string& filename)
     880{
    810881  table_.deepCopy(filename,Table::New);
    811882}
     
    825896}
    826897
    827 String SDMemTable::formatSec(Double x) {
     898String SDMemTable::formatSec(Double x)
     899{
    828900  Double xcop = x;
    829901  MVTime mvt(xcop/24./3600.);  // make days
     
    832904  return mvt.string(MVTime::TIME_CLEAN_NO_H, 7)+" ";
    833905};
     906
     907std::string SDMemTable::getFluxUnit() const
     908{
     909  String tmp;
     910  table_.keywordSet().get("FluxUnit", tmp);
     911  return tmp;
     912}
    834913
    835914std::string SDMemTable::summary()   {
     
    856935  table_.keywordSet().get("AntennaName", tmp);
    857936  oss << setw(15) << "Antenna Name:" << tmp << endl;
     937  table_.keywordSet().get("FluxUnit", tmp);
     938  oss << setw(15) << "Flux Unit:" << tmp << endl;
    858939  Table t = table_.rwKeywordSet().asTable("FREQUENCIES");
    859940  Vector<Double> vec;
     
    899980}
    900981
    901 Int SDMemTable::nBeam() const {
     982Int SDMemTable::nBeam() const
     983{
    902984  Int n;
    903985  table_.keywordSet().get("nBeam",n);
     
    9191001  return n;
    9201002}
     1003bool SDMemTable::appendHistory(const std::string& hist, int whichRow)
     1004{
     1005  ArrayColumn<String> histo(table_, "HISTORY");
     1006  Vector<String> history;
     1007  histo.get(whichRow, history);
     1008  history.resize(history.nelements()+1,True);
     1009  history[history.nelements()-1] = hist;
     1010  histo.put(whichRow, history);
     1011}
     1012
     1013std::vector<std::string> SDMemTable::history(int whichRow) const
     1014{
     1015  ROArrayColumn<String> hist(table_, "HISTORY");
     1016  Vector<String> history;
     1017  hist.get(whichRow, history);
     1018  std::vector<std::string> stlout;
     1019  // there is no Array<String>.tovector(std::vector<std::string>), so
     1020  // do it by hand
     1021  for (uInt i=0; i<history.nelements(); ++i) {
     1022    stlout.push_back(history[i]);
     1023  }
     1024  return stlout;
     1025}
    9211026/*
    9221027void SDMemTable::maskChannels(const std::vector<Int>& whichChans ) {
    9231028
    9241029  std::vector<int>::iterator it;
    925   ArrayAccessor<uChar, Axis<2> > j(flags_);
     1030  ArrayAccessor<uChar, Axis<asap::PolAxis> > j(flags_);
    9261031  for (it = whichChans.begin(); it != whichChans.end(); it++) {
    9271032    j.reset(j.begin(uInt(*it)));
    928     for (ArrayAccessor<uChar, Axis<0> > i(j); i != i.end(); ++i) {
    929       for (ArrayAccessor<uChar, Axis<1> > ii(i); ii != ii.end(); ++ii) {
    930         for (ArrayAccessor<uChar, Axis<3> > iii(ii);
     1033    for (ArrayAccessor<uChar, Axis<asap::BeamAxis> > i(j); i != i.end(); ++i) {
     1034      for (ArrayAccessor<uChar, Axis<asap::IFAxis> > ii(i); ii != ii.end(); ++ii) {
     1035        for (ArrayAccessor<uChar, Axis<asap::ChanAxis> > iii(ii);
    9311036             iii != iii.end(); ++iii) {
    9321037          (*iii) =
     
    9381043}
    9391044*/
    940 void SDMemTable::flag(int whichRow) {
     1045void SDMemTable::flag(int whichRow)
     1046{
    9411047  ArrayColumn<uChar> spec(table_, "FLAGTRA");
    9421048  Array<uChar> arr;
    9431049  spec.get(whichRow, arr);
    9441050
    945   ArrayAccessor<uChar, Axis<0> > aa0(arr);
     1051  ArrayAccessor<uChar, Axis<asap::BeamAxis> > aa0(arr);
    9461052  aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam
    947   ArrayAccessor<uChar, Axis<1> > aa1(aa0);
     1053  ArrayAccessor<uChar, Axis<asap::IFAxis> > aa1(aa0);
    9481054  aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF
    949   ArrayAccessor<uChar, Axis<2> > aa2(aa1);
     1055  ArrayAccessor<uChar, Axis<asap::PolAxis> > aa2(aa1);
    9501056  aa2.reset(aa2.begin(uInt(polSel_)));// go to pol
    9511057
    952   for (ArrayAccessor<uChar, Axis<3> > i(aa2); i != i.end(); ++i) {
     1058  for (ArrayAccessor<uChar, Axis<asap::ChanAxis> > i(aa2); i != i.end(); ++i) {
    9531059    (*i) = uChar(True);
    9541060  }
  • trunk/src/SDMemTable.h

    r164 r206  
    100100                            const std::string& theunit);
    101101  virtual void setCoordInfo(std::vector<string> theinfo);
     102
     103  std::string getFluxUnit() const;
     104
    102105  // set the current value
    103106  virtual bool setIF(casa::Int whichIF=0);
     
    114117  virtual casa::Int getBeam() const { return beamSel_; }
    115118  virtual casa::Int getPol() const { return polSel_; }
    116   virtual std::vector<string> getCoordInfo() const;
     119  virtual std::vector<std::string> getCoordInfo() const;
    117120
    118121  // number of scans in table
    119122  virtual casa::Int nScan() const;
    120123
    121   // print a summary to stdout
     124  // get a summary of the table
    122125  virtual std::string summary();
    123126
     127  std::vector<std::string> history(int whichRow=0) const;
     128  bool appendHistory(const std::string& hist, int whichRow=0);
    124129  // write to disk as aips++ table
    125130  void makePersistent(const std::string& filename);
     
    145150  // to bool mask
    146151  casa::MaskedArray<casa::Float> rowAsMaskedArray(casa::uInt whichRow,
    147                                                   casa::Bool useSelection = casa::False) const;
     152                                                  casa::Bool useSelection =
     153                                                  casa::False) const;
    148154
    149155  casa::SpectralCoordinate getCoordinate(casa::uInt whichIdx) const;
     
    153159  casa::Int nCoordinates() const;
    154160
     161
    155162  std::vector<double> getAbcissa(int whichRow=0) const;
    156163  std::string getAbcissaString(casa::Int whichRow=0) const;
     164 
     165  casa::MDirection getDirection(casa::Int whichRow=0) const;
    157166
    158167private:
Note: See TracChangeset for help on using the changeset viewer.