Changeset 16 for trunk/src/SDMemTable.cc


Ignore:
Timestamp:
06/30/04 11:00:23 (20 years ago)
Author:
mmarquar
Message:

Updated data container. Changed the axis order in the spectrum/flag arrays to [nBeam,nIF,nPol,nChan]

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/SDMemTable.cc

    r8 r16  
    3030//#---------------------------------------------------------------------------
    3131
     32
    3233#include <aips/iostream.h>
    3334#include <aips/Arrays/Array.h>
     
    6061}
    6162
    62 SDMemTable::SDMemTable(const SDMemTable& other) {
     63SDMemTable::SDMemTable(const SDMemTable& other, Bool clear) {
    6364  this->IFSel_= other.IFSel_;
    6465  this->beamSel_= other.beamSel_;
     
    6869  this->table_ = other.table_.copyToMemoryTable(String("dummy"));
    6970  // clear all rows()
    70   this->table_.removeRow(this->table_.rowNumbers());
     71  if (clear) {
     72    this->table_.removeRow(this->table_.rowNumbers());
     73  } else {
     74    this->IFSel_ = other.IFSel_;
     75    this->beamSel_ = other.beamSel_;
     76    this->polSel_ = other.polSel_;
     77  }
    7178}
    7279
     
    101108  td.addColumn(ArrayColumnDesc<Float>("TSYS")); 
    102109  td.addColumn(ScalarColumnDesc<Int>("SCANID")); 
     110  td.addColumn(ScalarColumnDesc<Double>("INTERVAL")); 
    103111  // Now create a new table from the description.
    104112  SetupNewTable aNewTab(name_, td, Table::New);
     
    147155}
    148156
    149 bool SDMemTable::setChannels(const std::vector<int>& whichChans) {
    150   //std::vector<bool>::iterator it;
    151   //std::fill(chanMask_.begin(), chanMask_.end(), false);
    152   //for (it = whichChans.begin(); it != whichChans.end(); it++) {
    153   //chanMask_[*it] = true;
    154   //}
    155   cout << "SDMemTable::setChannels() disabled" << endl;
     157bool SDMemTable::setMask(const std::vector<int>& whichChans) {
     158  ROArrayColumn<uChar> spec(table_, "FLAGTRA");
     159 
     160  std::vector<int>::iterator it;
     161  uInt n = spec.shape(0)(3);
     162  chanMask_.resize(n,true);
     163  for (it = whichChans.begin(); it != whichChans.end(); it++) {
     164    if (*it < n)
     165      chanMask_[*it] = false;
     166  }
    156167  return true;
    157168}
    158169
    159 std::vector<bool> SDMemTable::getMask() const {
    160   return chanMask_;
     170std::vector<bool> SDMemTable::getMask(Int whichRow) const {
     171  std::vector<bool> mask;
     172  ROArrayColumn<uChar> spec(table_, "FLAGTRA");
     173  Array<uChar> arr;
     174  spec.get(whichRow, arr);
     175  ArrayAccessor<uChar, Axis<0> > aa0(arr);
     176  aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam
     177  ArrayAccessor<uChar, Axis<1> > aa1(aa0);
     178  aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF
     179  ArrayAccessor<uChar, Axis<2> > aa2(aa1);
     180  aa2.reset(aa2.begin(uInt(polSel_)));// go to pol
     181
     182  Bool useUserMask = ( chanMask_.size() == arr.shape()(3) );
     183
     184  std::vector<bool> tmp;
     185  tmp = chanMask_; // WHY the fxxx do I have to make a copy here
     186  std::vector<bool>::iterator miter;
     187  miter = tmp.begin();
     188
     189  for (ArrayAccessor<uChar, Axis<3> > i(aa2); i != i.end(); ++i) {
     190    bool out =!static_cast<bool>(*i);
     191    if (useUserMask) {
     192      out = out && (*miter);
     193      miter++;
     194    }
     195    mask.push_back(out);
     196  } 
     197  return mask;
    161198}
    162199std::vector<float> SDMemTable::getSpectrum(Int whichRow) const {
     
    170207  ArrayAccessor<Float, Axis<1> > aa1(aa0);
    171208  aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF
    172   for (ArrayAccessor<Float, Axis<2> > i(aa1); i != i.end(); ++i) {
    173     ArrayAccessor<Float, Axis<3> > aa2(i);
    174     aa2.reset(aa2.begin(uInt(polSel_)));// go to pol
    175     spectrum.push_back(*aa2);
     209  ArrayAccessor<Float, Axis<2> > aa2(aa1);
     210  aa2.reset(aa2.begin(uInt(polSel_)));// go to pol
     211  for (ArrayAccessor<Float, Axis<3> > i(aa2); i != i.end(); ++i) {
     212    spectrum.push_back(*i);
    176213  }
    177214  return spectrum;
    178215}
    179216
    180 MaskedArray<Float> SDMemTable::rowAsMaskedArray(uInt whichRow) {
     217MaskedArray<Float> SDMemTable::rowAsMaskedArray(uInt whichRow,
     218                                                Bool useSelection) {
    181219  ROArrayColumn<Float> spec(table_, "SPECTRA");
    182220  Array<Float> arr;
     
    185223  spec.get(whichRow, arr);
    186224  flag.get(whichRow, farr);
    187   IPosition test(4,0,0,100,0);
    188225  Array<Bool> barr(farr.shape());convertArray(barr, farr);
    189226  MaskedArray<Float> marr;
    190   marr.setData(arr,!barr);
     227  if (useSelection) {
     228    ArrayAccessor<Float, Axis<0> > aa0(arr);
     229    aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam
     230    ArrayAccessor<Float, Axis<1> > aa1(aa0);
     231    aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF
     232    ArrayAccessor<Float, Axis<2> > aa2(aa1);
     233    aa2.reset(aa2.begin(uInt(polSel_)));// go to pol
     234   
     235    ArrayAccessor<Bool, Axis<0> > baa0(barr);
     236    baa0.reset(baa0.begin(uInt(beamSel_)));//go to beam
     237    ArrayAccessor<Bool, Axis<1> > baa1(baa0);
     238    baa1.reset(baa1.begin(uInt(IFSel_)));// go to IF
     239    ArrayAccessor<Bool, Axis<2> > baa2(baa1);
     240    baa2.reset(baa2.begin(uInt(polSel_)));// go to pol
     241
     242    Vector<Float> a(arr.shape()(3));
     243    Vector<Bool> b(barr.shape()(3));
     244    ArrayAccessor<Float, Axis<0> > a0(a);
     245    ArrayAccessor<Bool, Axis<0> > b0(b);
     246
     247    ArrayAccessor<Bool, Axis<3> > j(baa2);
     248    for (ArrayAccessor<Float, Axis<3> > i(aa2); i != i.end(); ++i) {
     249      (*a0) = (*i);
     250      (*b0) = !(*j);
     251      j++;
     252      a0++;
     253      b0++;
     254    }
     255    marr.setData(a,b);
     256  } else {
     257    marr.setData(arr,!barr);
     258  }
    191259  return marr;
    192260}
    193 
    194261
    195262Float SDMemTable::getTsys(Int whichRow) const {
     
    199266  Float out;
    200267  IPosition ip(arr.shape());
    201   ip(0) = beamSel_;ip(1) = IFSel_;ip(2)=0;ip(3) = polSel_;
     268  ip(0) = beamSel_;ip(1) = IFSel_;ip(2) = polSel_;ip(3)=0;
    202269  out = arr(ip);
    203270  return out;
     
    211278  ArrayColumn<Float> ts(table_, "TSYS");
    212279  ScalarColumn<Int> scan(table_, "SCANID");
     280  ScalarColumn<Double> integr(table_, "INTERVAL");
    213281
    214282  uInt rno = table_.nrow();
     
    221289  ts.put(rno, sdc.getTsys());
    222290  scan.put(rno, sdc.scanid);
     291  integr.put(rno, sdc.interval);
     292 
    223293  return true;
    224294}
     
    241311      previous = current;     
    242312      count++;
    243       cout << count << "\t" << name << endl;
     313      cout << count << "\t"
     314           << name
     315           << endl;
    244316    }
    245317  }
     
    247319  cout << "in " << count << "scans." << endl;
    248320}
    249 
     321/*
     322void maskChannels(const std::vector<Int>& whichChans ) {
     323 
     324  std::vector<int>::iterator it;
     325  ArrayAccessor<uChar, Axis<2> > j(flags_);
     326  for (it = whichChans.begin(); it != whichChans.end(); it++) {
     327    j.reset(j.begin(uInt(*it)));
     328    for (ArrayAccessor<uChar, Axis<0> > i(j); i != i.end(); ++i) {
     329      for (ArrayAccessor<uChar, Axis<1> > ii(i); ii != ii.end(); ++ii) {
     330        for (ArrayAccessor<uChar, Axis<3> > iii(ii);
     331             iii != iii.end(); ++iii) {   
     332          (*iii) =
     333        }
     334      }
     335    }
     336  }
     337 
     338}
     339*/
Note: See TracChangeset for help on using the changeset viewer.