Changes in / [30:20]


Ignore:
Location:
/trunk/src
Files:
3 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • /trunk/src/SDContainer.cc

    r30 r20  
    173173  }
    174174}
    175 
    176 Array<Float> SDContainer::getSpectrum(uInt whichBeam, uInt whichIF) const
    177 {
    178   Matrix<Float> spectra(nChan_, nPol_);
    179 
    180   // Beam.
    181   ArrayAccessor<Float, Axis<0> > i0(spectrum_);
    182   i0.reset(i0.begin(whichBeam));
    183 
    184   // IF.
    185   ArrayAccessor<Float, Axis<1> > i1(i0);
    186   i1.reset(i1.begin(whichIF));
    187 
    188   // Polarization.
    189   ArrayAccessor<Float, Axis<2> > i2(i1);
    190   ArrayAccessor<Float, Axis<1> > o1(spectra);
    191 
    192   while (i2 != i2.end()) {
    193     // Channel.
    194     ArrayAccessor<Float, Axis<3> > i3(i2);
    195     ArrayAccessor<Float, Axis<0> > o0(o1);
    196 
    197     while (i3 != i3.end()) {
    198       *o0 = *i3;
    199 
    200       i3++;
    201       o0++;
    202     }
    203 
    204     i2++;
    205     o1++;
    206   }
    207 
    208   return spectra;
    209 }
    210 
    211 Array<uChar> SDContainer::getFlags(uInt whichBeam, uInt whichIF) const
    212 {
    213   Matrix<uChar> flagtra(nChan_, nPol_);
    214 
    215   // Beam.
    216   ArrayAccessor<uChar, Axis<0> > i0(flags_);
    217   i0.reset(i0.begin(whichBeam));
    218 
    219   // IF.
    220   ArrayAccessor<uChar, Axis<1> > i1(i0);
    221   i1.reset(i1.begin(whichIF));
    222 
    223   // Polarization.
    224   ArrayAccessor<uChar, Axis<2> > i2(i1);
    225   ArrayAccessor<uChar, Axis<1> > o1(flagtra);
    226 
    227   while (i2 != i2.end()) {
    228     // Channel.
    229     ArrayAccessor<uChar, Axis<3> > i3(i2);
    230     ArrayAccessor<uChar, Axis<0> > o0(o1);
    231 
    232     while (i3 != i3.end()) {
    233       *o0 = *i3;
    234 
    235       i3++;
    236       o0++;
    237     }
    238 
    239     i2++;
    240     o1++;
    241   }
    242 
    243   return flagtra;
    244 }
    245 
    246 Array<Float> SDContainer::getTsys(uInt whichBeam, uInt whichIF) const
    247 {
    248   Vector<Float> tsys(nPol_);
    249 
    250   // Beam.
    251   ArrayAccessor<Float, Axis<0> > i0(tsys_);
    252   i0.reset(i0.begin(whichBeam));
    253 
    254   // IF.
    255   ArrayAccessor<Float, Axis<1> > i1(i0);
    256   i1.reset(i1.begin(whichIF));
    257 
    258   // Channel.
    259   ArrayAccessor<Float, Axis<3> > i3(i1);
    260 
    261   // Polarization.
    262   ArrayAccessor<Float, Axis<2> > i2(i3);
    263   ArrayAccessor<Float, Axis<0> > o0(tsys);
    264 
    265   while (i2 != i2.end()) {
    266     *o0 = *i2;
    267 
    268     i2++;
    269     o0++;
    270   }
    271 
    272   return tsys;
    273 }
  • /trunk/src/SDContainer.h

    r30 r20  
    109109  const Array<uChar>& getFlags() const { return flags_; }
    110110  const Array<Float>& getTsys() const { return tsys_; }
    111  
    112   Array<Float> getSpectrum(uInt whichBeam, uInt whichIF) const;
    113   Array<uChar> getFlags(uInt whichBeam, uInt whichIF) const;
    114   Array<Float> getTsys(uInt whichBeam, uInt whichIF) const;
    115111
    116112  Double timestamp;
    117113  String sourcename;
    118114  Double interval;
    119   Int scanid;
     115  uInt scanid;
    120116 
    121117private:
  • /trunk/src/SDMemTable.cc

    r30 r20  
    6565  beamSel_(0),
    6666  polSel_(0) {
    67   Table tab("dummy");
    68   table_ = tab.copyToMemoryTable("dummy");
     67  name_ = String(name);
     68  Table tab(name_);
     69  table_ = tab.copyToMemoryTable(name_);
    6970}
    7071
     
    7475  this->polSel_= other.polSel_;
    7576  this->chanMask_ = other.chanMask_;
     77  this->name_ = String("dummy");
    7678  this->table_ = other.table_.copyToMemoryTable(String("dummy"));
    7779  // clear all rows()
     
    8991  beamSel_(0),
    9092  polSel_(0) {
     93  name_ = String("SDMemTable");
    9194  String exprs = String("select * from $1 where SCANID == ")
    9295    +String::toString(scanID);
    9396  cerr << exprs << endl;
    9497  Table t = tableCommand(exprs,tab);
    95   table_ = t.copyToMemoryTable("dummy");
     98  table_ = t.copyToMemoryTable(name_);
    9699}
    97100
     
    116119  // Now create a new table from the description.
    117120
    118   SetupNewTable aNewTab("dummy", td, Table::New);
     121  SetupNewTable aNewTab(name_, td, Table::New);
    119122  table_ = Table(aNewTab, Table::Memory, 0); 
     123}
     124
     125std::string SDMemTable::name() const {
     126  return name_;
    120127}
    121128
     
    199206  return mask;
    200207}
    201 std::vector<float> SDMemTable::getSpectrum(Int whichRow) {
     208std::vector<float> SDMemTable::getSpectrum(Int whichRow) const {
    202209
    203210  std::vector<float> spectrum;
     
    215222  }
    216223  return spectrum;
    217 }
    218 void SDMemTable::getSpectrum(Vector<Float>& spectrum, Int whichRow=0) {
    219   ROArrayColumn<Float> spec(table_, "SPECTRA");
    220   Array<Float> arr;
    221   spec.get(whichRow, arr);
    222   spectrum.resize(arr.shape()(3));
    223   ArrayAccessor<Float, Axis<0> > aa0(arr);
    224   aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam
    225   ArrayAccessor<Float, Axis<1> > aa1(aa0);
    226   aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF
    227   ArrayAccessor<Float, Axis<2> > aa2(aa1);
    228   aa2.reset(aa2.begin(uInt(polSel_)));// go to pol
    229 
    230   ArrayAccessor<Float, Axis<0> > va(spectrum);
    231   for (ArrayAccessor<Float, Axis<3> > i(aa2); i != i.end(); ++i) {
    232     (*va) = (*i);
    233     va++;
    234   }
    235 }
    236 
    237 void SDMemTable::getMask(Vector<Bool>& mask, Int whichRow=0) const {
    238   ROArrayColumn<uChar> spec(table_, "FLAGTRA");
    239   Array<uChar> arr;
    240   spec.get(whichRow, arr);
    241   mask.resize(arr.shape()(3));
    242 
    243   ArrayAccessor<uChar, Axis<0> > aa0(arr);
    244   aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam
    245   ArrayAccessor<uChar, Axis<1> > aa1(aa0);
    246   aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF
    247   ArrayAccessor<uChar, Axis<2> > aa2(aa1);
    248   aa2.reset(aa2.begin(uInt(polSel_)));// go to pol
    249 
    250   Bool useUserMask = ( chanMask_.size() == arr.shape()(3) );
    251  
    252   ArrayAccessor<Bool, Axis<0> > va(mask);
    253   std::vector<bool> tmp;
    254   tmp = chanMask_; // WHY the fxxx do I have to make a copy here. The
    255                    // iterator should work on chanMask_??
    256   std::vector<bool>::iterator miter;
    257   miter = tmp.begin();
    258 
    259   for (ArrayAccessor<uChar, Axis<3> > i(aa2); i != i.end(); ++i) {
    260     bool out =!static_cast<bool>(*i);
    261     if (useUserMask) {
    262       out = out && (*miter);
    263       miter++;
    264     }
    265     (*va) = out;
    266     va++;
    267   } 
    268224}
    269225
     
    347303}
    348304
    349 SDContainer SDMemTable::getSDContainer(uInt whichRow) const {
    350   ROScalarColumn<Double> mjd(table_, "TIME");
    351   ROScalarColumn<String> srcn(table_, "SRCNAME");
    352   ROArrayColumn<Float> spec(table_, "SPECTRA");
    353   ROArrayColumn<uChar> flags(table_, "FLAGTRA");
    354   ROArrayColumn<Float> ts(table_, "TSYS");
    355   ROScalarColumn<Int> scan(table_, "SCANID");
    356   ROScalarColumn<Double> integr(table_, "INTERVAL");
    357 
    358   SDContainer sdc(nBeam(),nIF(),nPol(),nChan());
    359   mjd.get(whichRow, sdc.timestamp);
    360   srcn.get(whichRow, sdc.sourcename);
    361   integr.get(whichRow, sdc.interval);
    362   scan.get(whichRow, sdc.scanid);
    363   Array<Float> spectrum;
    364   Array<Float> tsys;
    365   Array<uChar> flagtrum;
    366   spec.get(whichRow, spectrum);
    367   sdc.putSpectrum(spectrum);
    368   flags.get(whichRow, flagtrum);
    369   sdc.putFlags(flagtrum);
    370   ts.get(whichRow, tsys);
    371   sdc.putTsys(tsys);
    372   return sdc;
    373 }
    374305bool SDMemTable::putSDHeader(const SDHeader& sdh) {
    375306  table_.lock();
     
    391322  cerr << "Table Header set" << endl;
    392323  return true;
    393 }\
    394 
    395 SDHeader SDMemTable::getSDHeader() const {
    396   SDHeader sdh;
    397   table_.keywordSet().get("nBeam",sdh.nbeam);
    398   table_.keywordSet().get("nIF",sdh.nif);
    399   table_.keywordSet().get("nPol",sdh.npol);
    400   table_.keywordSet().get("nChan",sdh.nchan);
    401   table_.keywordSet().get("Observer", sdh.observer);
    402   table_.keywordSet().get("Project", sdh.project);
    403   table_.keywordSet().get("Obstype", sdh.obstype);
    404   table_.keywordSet().get("AntennaName", sdh.antennaname);
    405   table_.keywordSet().get("AntennaPosition", sdh.antennaposition);
    406   table_.keywordSet().get("Equinox", sdh.equinox);
    407   table_.keywordSet().get("FreqRefFrame", sdh.freqref);
    408   table_.keywordSet().get("FreqRefVal", sdh.reffreq);
    409   table_.keywordSet().get("Bandwidth", sdh.bandwidth);
    410   table_.keywordSet().get("UTC", sdh.utc);
    411   return sdh;
    412 }
     324}
     325
    413326void SDMemTable::makePersistent(const std::string& filename) {
    414327  table_.deepCopy(filename,Table::New);
     
    463376  return n;
    464377}
     378
    465379/*
    466380void SDMemTable::maskChannels(const std::vector<Int>& whichChans ) {
  • /trunk/src/SDMemTable.h

    r30 r20  
    6969  virtual bool putSDHeader(const SDHeader& sdh);
    7070  virtual bool putSDFreqTable(const SDFrequencyTable& sdft) {;}
    71 
    72   //get the dat wrapped up in a meta container
    73   virtual SDContainer getSDContainer(uInt whichRow=0) const;
    74   virtual SDHeader getSDHeader() const;
    7571 
    7672  // get spectrum,mask and tsys for the given row, at the selected
    77   // cursor - all as stl vectors
    78   virtual std::vector<float> getSpectrum(Int whichRow);
     73  // cursor
     74  virtual std::vector<float> getSpectrum(Int whichRow) const;
    7975  virtual std::vector<bool> getMask(Int whichRow) const;
     76  virtual Float getTsys(Int whichRow) const;
    8077
    81   virtual Float getTsys(Int whichRow) const;
    82   // get all as aips++ Vectors
    83   virtual void getSpectrum(Vector<Float>& spectrum, Int whichRow=0);
    84   virtual void getMask(Vector<Bool>& mask,Int whichRow=0) const;
    85 
    86   // get info for current row
     78  // get info fro current row
    8779  virtual Double getTime(Int whichRow) const ;
    8880  virtual std::string getSourceName(Int whichRow) const;
     
    10395  virtual void summary() const;
    10496 
     97  // the (irrelevant) name
     98  std::string name() const;
     99
    105100  // write to disk as aips++ table
    106101  void makePersistent(const std::string& filename);
     
    109104  SDMemTable getScan(Int scanID);
    110105
    111   const TableRecord& getHeader() const {return table_.keywordSet();}
     106  const TableRecord& getHeader() const {;}
    112107  // get a handle to the "raw" aips++ table
    113108  const Table& table() { return table_; }
     
    119114  Int nChan() const;
    120115
    121   // return the number of rows (integrations) in the table
    122   Int nRows() const { return table_.nrow(); }
    123 
    124116  // return a row as a Masked array, internally converting uChar flags
    125117  // to bool mask
     
    128120
    129121private:
    130   // set up table structure
     122  // set up tabel structure
    131123  void setup();
    132124  // the current cursor into the array
  • /trunk/src/SDMemTableWrapper.h

    r30 r20  
    9797  CountedPtr<SDMemTable> getCP() const {return table_;}
    9898  void summary() { table_->summary(); }
     99  std::string name() { return table_->name(); }
    99100 
    100101private:
     
    124125  SDMemTableWrapper multiply(const SDMemTableWrapper& in,
    125126                             Float factor) {
    126     return SDMemTableWrapper(SDMath::multiply(in.getCP(),factor));   
     127    return SDMemTableWrapper(SDMath::multiply(in.getCP(),factor));
    127128  }
    128   /*
    129   std::vector<float> baseline(const SDMemTableWrapper& in, const std::string& fitexpr) {
    130     return SDMath::baseline(in.getCP(), fitexpr);
    131   }
    132   */
    133129};
    134130
  • /trunk/src/SDReader.cc

    r30 r20  
    7777    return;
    7878  }
    79 
    8079  nBeam_ = beams.nelements();
     80  //cout << "Reading " + format + " format from " + inName << endl;
     81  //cout << "nChannels = " << nChan_ << ", " << "nPol = " << nPol_ << endl
     82  //     << "nIF = " << nIF_ << endl
     83  //     << "nBeams = " << nBeam_ << endl;
     84 
    8185  // Get basic parameters.
    8286  header_ = SDHeader();
     
    8589  header_.nbeam = nBeam_;
    8690
     91  //cerr << " getting header ..." << endl;
    8792  Int status = reader_->getHeader(header_.observer, header_.project,
    8893                                  header_.antennaname, header_.antennaposition,
     
    130135  Complex         xCalFctr;
    131136  Vector<Complex> xPol;
     137  mjd = 0;
    132138  uInt n = seq.size();
    133 
     139  //cerr <<  header_.nif << ", " << header_.nbeam << endl;
    134140  uInt stepsize = header_.nif*header_.nbeam;
    135141  cerr << "SDReader stepsize = " << stepsize << endl;
     142  uInt scanid = 0;
     143  String prevName = "_noname_";// temporary until scanid is present
    136144  uInt seqi = 0;
    137145  //SDFrequencyTable sdft();
  • /trunk/src/python_SD.cc

    r30 r20  
    2727//#                        AUSTRALIA
    2828//#
    29 //# $Id$
     29//# $Id:
    3030//#---------------------------------------------------------------------------
    3131#include <string>
     
    4141  atnf_sd::python::python_SDMemTable();
    4242  atnf_sd::python::python_SDReader();
    43   atnf_sd::python::python_SDWriter();
    4443  atnf_sd::python::python_SDMath();
    4544
  • /trunk/src/python_SD.h

    r30 r20  
    2727//#                        AUSTRALIA
    2828//#
    29 //# $Id$
     29//# $Id:
    3030//#---------------------------------------------------------------------------
    3131#ifndef _PYTHON_SD_H_
     
    3737void python_SDMemTable();
    3838void python_SDReader();
    39 void python_SDWriter();
    4039void python_SDMath();
    4140
  • /trunk/src/python_SDMemTable.cc

    r30 r20  
    4646    .def( init < SDMemTableWrapper, int > () )
    4747    .def("getscan", &SDMemTableWrapper::getScan)
    48     .def("getspectrum", &SDMemTableWrapper::getSpectrum,
    49          (boost::python::arg("whichRow")=0) )
    50     .def("getmask", &SDMemTableWrapper::getMask,
    51          (boost::python::arg("whichRow")=0) )
     48    .def("getspectrum", &SDMemTableWrapper::getSpectrum)
     49    .def("getmask", &SDMemTableWrapper::getMask)
    5250    .def("gettsys", &SDMemTableWrapper::getTsys)
    5351    .def("getsourcename", &SDMemTableWrapper::getSourceName)
     
    6866    .def("makepersistent",  &SDMemTableWrapper::makePersistent)
    6967    .def("summary",  &SDMemTableWrapper::summary)
     68    .def("name",  &SDMemTableWrapper::name)
    7069  ;
    7170};
Note: See TracChangeset for help on using the changeset viewer.