Changeset 332


Ignore:
Timestamp:
01/31/05 18:17:22 (20 years ago)
Author:
kil064
Message:

add IF and beam selection

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/SDReader.cc

    r290 r332  
    4444  cursor_ = 0;
    4545}
    46 SDReader::SDReader(const std::string& filename) :
     46SDReader::SDReader(const std::string& filename, int whichIF, int whichBeam) :
    4747  reader_(0),
    4848  table_(new SDMemTable()) {
    4949  cursor_ = 0;
    50   open(filename);
     50  open(filename, whichIF, whichBeam);
    5151}
    5252
     
    7878}
    7979
     80
    8081void SDReader::close() {
    8182  cerr << "disabled" << endl;
    8283}
    8384
    84 void SDReader::open(const std::string& filename) {
     85
     86
     87void SDReader::open(const std::string& filename, int whichIF, int whichBeam) {
    8588  if (reader_) delete reader_; reader_ = 0;
    8689  Bool   haveBase, haveSpectra, haveXPol;
     
    9598  }
    9699  filename_ = inName;
    97 //
     100
     101// Create reader and fill in values for arguments
     102
    98103  String format;
    99104  Vector<Bool> beams;
     
    137142    nIF_ = 1;
    138143  }
     144//
    139145  header_.nif = nIF_;
    140146  header_.fluxunit = "K";
    141147  header_.epoch = "UTC";
     148
    142149  // Apply selection criteria.
    143   Vector<Int> start(nIF_, 1);
    144   Vector<Int> end(nIF_, 0);
     150
    145151  Vector<Int> ref;
    146152  Vector<Bool> beamSel(nBeam_,True);
    147153  Vector<Bool> IFsel(nIF_,True);
     154//
     155  ifOffset_ = 0;
     156  if (whichIF>=0) {
     157    if (whichIF>=0 && whichIF<nIF_) {
     158       IFsel = False;
     159       IFsel(whichIF) = True;
     160       header_.nif = 1;
     161       nIF_ = 1;
     162       ifOffset_ = whichIF;
     163    } else {
     164       throw(AipsError("Illegal IF selection"));
     165    }
     166  }
     167//
     168  beamOffset_ = 0;
     169  if (whichBeam>=0) {
     170     if (whichBeam>=0 && whichBeam<nBeam_) {
     171        beamSel = False;
     172        beamSel(whichBeam) = True;
     173        header_.nbeam = 1;
     174        nBeam_ = 1;
     175        beamOffset_ = whichBeam;
     176     } else {
     177       throw(AipsError("Illegal Beam selection"));
     178     }
     179  }
     180//
     181  Vector<Int> start(nIF_, 1);
     182  Vector<Int> end(nIF_, 0);
    148183  reader_->select(beamSel, IFsel, start, end, ref, True, haveXPol);
    149184  table_->putSDHeader(header_);
     
    190225                             tsys, sigma, calFctr, baseLin, baseSub,
    191226                             spectra, flagtra, xCalFctr, xPol);
     227
     228// Make sure beam/IF numbers are 0-relative
     229
     230      beamNo = beamNo - beamOffset_ - 1;     
     231      IFno = IFno - ifOffset_ - 1;
     232//
    192233      if (status) {
    193234        if (status == -1) {
     
    216257        }
    217258        // add specific info
    218         // IFno beamNo are 1-relative
    219259        // refPix = nChan/2+1 in  Integer arith.!
    220260        Int refPix = header_.nchan/2+1;
    221         Int frqslot = frequencies_.addFrequency(refPix, refFreq, freqInc);
    222         frequencies_.addRestFrequency(restFreq);
    223         sc.setFrequencyMap(frqslot,IFno-1);
     261        uInt frqslot = frequencies_.addFrequency(refPix, refFreq, freqInc);
     262        uInt restFrqSlot = frequencies_.addRestFrequency(restFreq);
     263//   
     264        sc.setFrequencyMap(frqslot,IFno);
     265        sc.setRestFrequencyMap(restFrqSlot,IFno);
    224266        sc.tcal[0] = tcal[0];sc.tcal[1] = tcal[1];
    225267        sc.tcaltime = tcalTime;
     
    227269        sc.refbeam = refBeam;
    228270        sc.scanid = scanNo-1;//make it 0-based
    229         sc.setSpectrum(spectra, beamNo-1, IFno-1);
    230         sc.setFlags(flagtra,  beamNo-1, IFno-1);
    231         sc.setTsys(tsys, beamNo-1, IFno-1);
    232         sc.setDirection(direction, beamNo-1);
     271        sc.setSpectrum(spectra, beamNo, IFno);
     272        sc.setFlags(flagtra,  beamNo, IFno);
     273        sc.setTsys(tsys, beamNo, IFno);
     274        sc.setDirection(direction, beamNo);
    233275      }
    234276    }
  • trunk/src/SDReader.h

    r125 r332  
    5151public:
    5252  SDReader();
    53   SDReader(const std::string& filename);
     53  SDReader(const std::string& filename, int whichIF=-1,
     54          int whichBeam=-1);
    5455  SDReader(casa::CountedPtr<SDMemTable> tbl);
    5556  virtual ~SDReader();
    5657
    57   void open(const std::string& filename);
     58  void open(const std::string& filename,
     59            int whichIF=-1,
     60            int whichBeam=-1);
    5861  void close();
    5962  int read(const std::vector<int>& seq);
     
    8184  casa::uInt cursor_;
    8285  casa::Double timestamp_;
     86  casa::uInt beamOffset_, ifOffset_;
    8387};
    8488
  • trunk/src/SDReaderWrapper.h

    r125 r332  
    4343public:
    4444  SDReaderWrapper() {;}
    45   SDReaderWrapper(const std::string& filename) : SDReader(filename) {;}
     45  SDReaderWrapper(const std::string& filename, int ifSel=-1, int beamSel=-1) : SDReader(filename,ifSel,beamSel) {;}
    4646  SDReaderWrapper(SDMemTableWrapper tbl) :
    4747    SDReader(tbl.getCP()){;}
  • trunk/src/python_SDReader.cc

    r125 r332  
    4040    void python_SDReader() {
    4141      class_<SDReaderWrapper>("sdreader")
    42         .def( init < std::string > () )
     42        .def( init < std::string, int, int > () )
    4343        .def("open", &SDReaderWrapper::open)
    4444        .def("read", &SDReaderWrapper::read)
Note: See TracChangeset for help on using the changeset viewer.