Changeset 18 for trunk/src


Ignore:
Timestamp:
06/30/04 16:34:24 (20 years ago)
Author:
mmarquar
Message:

Moved SDHeader from SDReader to SDConatiner. Added header to SDMemTable. Added access funtions to nif,nbema,npol,nchan

Location:
trunk/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/SDContainer.cc

    r16 r18  
    3333#include <aips/Arrays/ArrayAccessor.h>
    3434#include <aips/Arrays/Matrix.h>
     35#include <aips/Quanta/MVTime.h>
    3536
    3637#include "SDContainer.h"
    3738
    3839using namespace atnf_sd;
     40
     41void SDHeader::print() const {
     42  MVTime mvt(this->utc);
     43
     44  cout << "Observer: " << this->observer << endl
     45       << "Project: " << this->project << endl
     46       << "Obstype: " << this->obstype << endl
     47       << "Antenna: " << this->antennaname << endl
     48       << "Ant. Position: " << this->antennaposition << endl
     49       << "Equinox: " << this->equinox << endl
     50       << "Freq. ref.: " << this->freqref << endl
     51       << "Ref. frequency: " << this->reffreq << endl
     52       << "Bandwidth: "  << this->bandwidth << endl
     53       << "Time (utc): "
     54       << mvt.string()
     55       << endl;
     56  //setprecision(10) << this->utc << endl;
     57}
     58
    3959
    4060SDContainer::SDContainer(uInt nBeam, uInt nIF, uInt nPol, uInt nChan)
  • trunk/src/SDContainer.h

    r16 r18  
    3232#define _SDCONTAINER_H_
    3333
     34#include <vector>
     35
    3436#include <aips/aips.h>
    3537#include <aips/Utilities/String.h>
     
    4143namespace atnf_sd {
    4244
     45
     46struct SDHeader {
     47  Int nchan;
     48  Int npol;
     49  Int nif;
     50  Int nbeam;
     51  String observer;
     52  String project;
     53  String obstype;
     54  String antennaname;
     55  Vector<Double> antennaposition;
     56  Float equinox;
     57  String freqref;
     58  Double reffreq;
     59  Double bandwidth;
     60  Double utc;
     61  void print() const ;
     62};
     63
    4364class SDFrequencyTable {
    4465
    4566public:
    4667
    47   SDFrequencyTable(Double refPix, Double refVal, Double inc) {;}
     68  SDFrequencyTable() {;}
    4869  // returns the index into the table
    4970  // this creates a new one or returns an existing one
     
    5273  Int length() const { return nFreq_;};// # of stored Frequencies
    5374  // returns a Table with nRows == nFreq, and three cols
    54 
     75 
    5576private:
    5677  Int nFreq_;
    57   Vector<Double> refPix_;
    58   Vector<Double> revVal_;
    59   Vector<Double> increment_;
     78  std::vector<double> refPix_;
     79  std::vector<double> revVal_;
     80  std::vector<double> increment_;
    6081};
    6182
  • trunk/src/SDMemTable.cc

    r16 r18  
    4747#include <aips/Tables/ScalarColumn.h>
    4848#include <aips/Tables/ArrayColumn.h>
     49#include <aips/Tables/TableRecord.h>
     50
    4951
    5052#include "SDMemTable.h"
     
    5355using namespace atnf_sd;
    5456
     57SDMemTable::SDMemTable() :
     58  IFSel_(0),
     59  beamSel_(0),
     60  polSel_(0) {
     61  setup();
     62}
    5563SDMemTable::SDMemTable(const std::string& name) :
    5664  IFSel_(0),
     
    5866  polSel_(0) {
    5967  name_ = String(name);
    60   setup();
     68  Table tab(name_);
     69  table_ = tab.copyToMemoryTable(name_);
    6170}
    6271
     
    101110  TableDesc td("", "1", TableDesc::Scratch);
    102111  td.comment() = "A SDMemTable";
    103   //td.rwKeywordSet().define("VERSION",Float(0.1));
    104112  td.addColumn(ScalarColumnDesc<Double>("TIME"));
    105113  td.addColumn(ScalarColumnDesc<String>("SRCNAME"));
     
    110118  td.addColumn(ScalarColumnDesc<Double>("INTERVAL")); 
    111119  // Now create a new table from the description.
     120
    112121  SetupNewTable aNewTab(name_, td, Table::New);
    113122  table_ = Table(aNewTab, Table::Memory, 0); 
     
    293302  return true;
    294303}
     304
     305bool SDMemTable::putSDHeader(const SDHeader& sdh) {
     306  table_.lock();
     307  table_.rwKeywordSet().define("nIF", sdh.nif);
     308  table_.rwKeywordSet().define("nBeam", sdh.nbeam);
     309  table_.rwKeywordSet().define("nPol", sdh.npol);
     310  table_.rwKeywordSet().define("nChan", sdh.nchan);
     311  table_.rwKeywordSet().define("Observer", sdh.observer);
     312  table_.rwKeywordSet().define("Project", sdh.project);
     313  table_.rwKeywordSet().define("Obstype", sdh.obstype);
     314  table_.rwKeywordSet().define("AntennaName", sdh.antennaname);
     315  table_.rwKeywordSet().define("AntennaPosition", sdh.antennaposition);
     316  table_.rwKeywordSet().define("Equinox", sdh.equinox);
     317  table_.rwKeywordSet().define("FreqRefFrame", sdh.freqref);
     318  table_.rwKeywordSet().define("FreqRefVal", sdh.reffreq);
     319  table_.rwKeywordSet().define("Bandwidth", sdh.bandwidth);
     320  table_.rwKeywordSet().define("UTC", sdh.utc);
     321  table_.unlock();
     322  cerr << "Table Header set" << endl;
     323  return true;
     324}
     325
    295326void SDMemTable::makePersistent(const std::string& filename) {
    296327  table_.deepCopy(filename,Table::New);
     
    298329
    299330void SDMemTable::summary() const {
    300   cerr << "SDMemTable::summary()" << endl;
    301331  ROScalarColumn<Int> scans(table_, "SCANID");
    302332  ROScalarColumn<String> srcs(table_, "SRCNAME");
     333  cout << "*************** Header ***************" << endl;
     334  cout << "nBeam = " << nBeam() << "\t"
     335       << "nIF   = " << nIF() << endl
     336       << "nPol  = " << nPol() << "\t"
     337       << "nChan = " << nChan() << "\t" << endl;
     338  cout << "*************** Header ***************" << endl;
    303339  uInt count = 0;
    304340  String name;
     
    316352    }
    317353  }
    318   cout << "Table contains " << table_.nrow() << "integrations." << endl;
    319   cout << "in " << count << "scans." << endl;
    320 }
     354  cout << "Table contains " << table_.nrow() << " integration(s)." << endl;
     355  cout << "in " << count << " scan(s)." << endl;
     356}
     357
     358Int SDMemTable::nBeam() const {
     359  Int n;
     360  table_.keywordSet().get("nBeam",n);
     361  return n;
     362}
     363Int SDMemTable::nIF() const {
     364  Int n;
     365  table_.keywordSet().get("nIF",n);
     366  return n;
     367}
     368Int SDMemTable::nPol() const {
     369  Int n;
     370  table_.keywordSet().get("nPol",n);
     371  return n;
     372}
     373Int SDMemTable::nChan() const {
     374  Int n;
     375  table_.keywordSet().get("nChan",n);
     376  return n;
     377}
     378
    321379/*
    322 void maskChannels(const std::vector<Int>& whichChans ) {
     380void SDMemTable::maskChannels(const std::vector<Int>& whichChans ) {
    323381 
    324382  std::vector<int>::iterator it;
  • trunk/src/SDMemTable.h

    r16 r18  
    5050class SDMemTable {
    5151public:
    52   SDMemTable(const std::string& name= "SDInputTable.tbl");
     52  SDMemTable();
     53  SDMemTable(const std::string& name);
    5354  SDMemTable(const SDMemTable& other, Bool clear=False);
    5455
     
    5657  virtual ~SDMemTable();
    5758  virtual bool putSDContainer(const SDContainer& sdc);
    58   virtual bool putSDHeader(const SDHeader& sdh) {;}
     59  virtual bool putSDHeader(const SDHeader& sdh);
    5960  virtual bool putSDFreqTable(const SDFrequencyTable& sdft) {;}
    6061 
     
    7273  virtual bool setBeam(Int whichBeam=0);
    7374  virtual bool setPol(Int whichPol=0);   
     75  //sets the user mask
     76  virtual bool setMask(const std::vector<int>& whichChans);
     77 
    7478
    7579  virtual Int getIF() { return IFSel_; }
    7680  virtual Int getBeam() { return beamSel_; }
    7781  virtual Int getPol() { return polSel_; }   
    78 
    79   //sets the mask
    80   virtual bool setMask(const std::vector<int>& whichChans);
    81  
     82 
    8283  virtual void summary() const;
    8384 
     
    8586  void makePersistent(const std::string& filename);
    8687  SDMemTable getScan(Int scanID);
     88
     89  const TableRecord& getHeader() const {;}
    8790  const Table& table() { return table_; }
     91
     92  Int nBeam() const;
     93  Int nIF() const;
     94  Int nPol() const;
     95  Int nChan() const;
    8896
    8997private:
    9098  void setup();
    91   //Int nBeam_,nIF_,nChan_,nPol_;
     99
    92100  Int IFSel_,beamSel_,polSel_;
    93101  std::vector<bool> chanMask_;
  • trunk/src/SDMemTableWrapper.h

    r16 r18  
    4444
    4545public:
    46   SDMemTableWrapper(const std::string& name = "SDinput.tbl") :
     46  SDMemTableWrapper(const std::string& name) :
    4747    table_(new SDMemTable(name)) {;}
     48  SDMemTableWrapper() :
     49    table_(new SDMemTable()) {;}
     50 
    4851  SDMemTableWrapper(CountedPtr<SDMemTable> cp) : table_(cp) {;}
    4952  SDMemTableWrapper(SDMemTable* sdmt) : table_(sdmt) {;}
     
    8083  int getPol() {return table_->getPol();}
    8184
     85  int nIF() {return table_->nIF();}
     86  int nBeam() {return table_->nBeam();}
     87  int nPol() {return table_->nPol();}
     88  int nChan() {return table_->nChan();}
    8289
    8390  //sets the mask
  • trunk/src/SDReader.cc

    r17 r18  
    3030//#---------------------------------------------------------------------------
    3131#include <atnf/PKSIO/PKSreader.h>
    32 #include <aips/Quanta/MVTime.h>
    33 #include "SDContainer.h"
     32
    3433#include "SDReader.h"
    3534
    3635using namespace atnf_sd;
    37 
    38 void SDHeader::print() const {
    39   MVTime mvt(this->utc);
    40 
    41   cout << "Observer: " << this->observer << endl
    42        << "Project: " << this->project << endl
    43        << "Obstype: " << this->obstype << endl
    44        << "Antenna: " << this->antennaname << endl
    45        << "Ant. Position: " << this->antennaposition << endl
    46        << "Equinox: " << this->equinox << endl
    47        << "Freq. ref.: " << this->freqref << endl
    48        << "Ref. frequency: " << this->reffreq << endl
    49        << "Bandwidth: "  << this->bandwidth << endl
    50        << "Time (utc): "
    51        << mvt.string()
    52        << endl;
    53   //setprecision(10) << this->utc << endl;
    54 }
    55 
    5636
    5737SDReader::SDReader() :
     
    9878  }
    9979  nBeam_ = beams.nelements();
    100   cout << "Reading " + format + " format from " + inName << endl;
    101   cout << "nChannels = " << nChan_ << ", " << "nPol = " << nPol_ << endl
    102        << "nIF = " << nIF_ << endl
    103        << "nBeams = " << nBeam_ << endl;
     80  //cout << "Reading " + format + " format from " + inName << endl;
     81  //cout << "nChannels = " << nChan_ << ", " << "nPol = " << nPol_ << endl
     82  //     << "nIF = " << nIF_ << endl
     83  //     << "nBeams = " << nBeam_ << endl;
    10484 
    10585  // Get basic parameters.
     
    131111  header_.nif = nIF_;
    132112  // Apply selection criteria.
    133   cerr << "applying selection criteria..." << endl;
    134113  Vector<Int> start(nIF_, 1);
    135114  Vector<Int> end(nIF_, 0);
     
    138117  Vector<Bool> IFsel(nIF_,True);
    139118  reader_->select(beamSel, IFsel, start, end, ref, True, haveXPol);
    140   cerr << "open finished" << endl;
     119  table_->putSDHeader(header_);
    141120}
    142121
    143122int SDReader::read(const std::vector<int>& seq) {
    144   cerr << "SDReader::read" << endl;
    145123  int status = 0; 
    146124 
     
    159137  mjd = 0;
    160138  uInt n = seq.size();
    161   cerr <<  header_.nif << ", " << header_.nbeam << endl;
     139  //cerr <<  header_.nif << ", " << header_.nbeam << endl;
    162140  uInt stepsize = header_.nif*header_.nbeam;
    163141  cerr << "SDReader stepsize = " << stepsize << endl;
     
    174152    // iterate over one correlator integration cycle = nBeam*nIF
    175153    for (uInt row=0; row < stepsize; row++) {
    176       // add scanid from GROUP field -- this will remove the need for
    177154      // stepsize as well
    178155      // spectra(nChan,nPol)!!!
     
    213190        //uInt frqslot = sdft.addFrequency(refPix, refFreq, freqInc);
    214191
    215         //if ( srcName != prevName ) {//temp
    216         //scanid++;//temp
    217         // prevName = srcName;//temp
    218         //}//temp
    219192        sc.scanid = scanNo;
    220193        //sc.setFrequencyMap(frqslot,IFno-1);
  • trunk/src/SDReader.h

    r16 r18  
    4343
    4444#include "SDMemTable.h"
     45#include "SDContainer.h"
    4546
    4647class PKSreader;
    4748
    4849namespace atnf_sd {
    49 
    50 struct SDHeader {
    51   Int nchan;
    52   Int npol;
    53   Int nif;
    54   Int nbeam;
    55   String observer;
    56   String project;
    57   String obstype;
    58   String antennaname;
    59   Vector<Double> antennaposition;
    60   Float equinox;
    61   String freqref;
    62   Double reffreq;
    63   Double bandwidth;
    64   Double utc;
    65   void print() const ;
    66 };
    6750
    6851class SDReader {
     
    9073private:
    9174  Int nBeam_,nIF_,nPol_,nChan_;
    92   Bool getHeader();
    9375  PKSreader* reader_; 
    9476  SDHeader header_;
     
    10183}// namespace
    10284#endif
    103 
  • trunk/src/python_SDMemTable.cc

    r16 r18  
    4242void python_SDMemTable() {
    4343  class_<SDMemTableWrapper>("sdtable")
     44    .def( init <> () )
    4445    .def( init < std::string > () )
    4546    .def( init < SDMemTableWrapper, int > () )
     
    5354    .def("getbeam", &SDMemTableWrapper::getBeam)
    5455    .def("getpol", &SDMemTableWrapper::getPol)
     56    .def("nif", &SDMemTableWrapper::nIF)
     57    .def("nbeam", &SDMemTableWrapper::nBeam)
     58    .def("npol", &SDMemTableWrapper::nPol)
     59    .def("nchan", &SDMemTableWrapper::nChan)
     60
    5561    .def("setif", &SDMemTableWrapper::setIF,
    5662         (boost::python::arg("whichIF")=0) )
Note: See TracChangeset for help on using the changeset viewer.