Changeset 405


Ignore:
Timestamp:
02/10/05 15:25:10 (20 years ago)
Author:
mar637
Message:

fixed reder rest behaviour. renamed all pyhton_SDReader functions to "_"

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/SDReader.cc

    r404 r405  
    4646SDReader::SDReader() :
    4747  reader_(0),
     48  header_(0),
     49  frequencies_(0),
    4850  table_(new SDMemTable()) {
    4951  cursor_ = 0;
     
    5254                   int whichIF, int whichBeam) :
    5355  reader_(0),
     56  header_(0),
     57  frequencies_(0),
    5458  table_(new SDMemTable()) {
    5559  cursor_ = 0;
     
    5963SDReader::SDReader(CountedPtr<SDMemTable> tbl) :
    6064  reader_(0),
     65  header_(0),
    6166  table_(tbl) {
    6267  cursor_ = 0;
     
    6469
    6570SDReader::~SDReader() {
    66   if (reader_) delete reader_; reader_ = 0;
     71  if (reader_) delete reader_;
     72  if (header_) delete header_;
     73  if (frequencies_) delete frequencies_;
    6774}
    6875
     
    7077  cursor_ = 0;
    7178  table_ = new SDMemTable();
    72   if (reader_) delete reader_; reader_ = 0;
    73   // re-create the reader
    74   Bool   haveBase, haveSpectra, haveXPol;
    75   String format;
    76   Vector<Bool> beams;
    77   if ((reader_ = getPKSreader(filename_, 0, False, format, beams, nIF_,
    78                               nChan_, nPol_, haveBase, haveSpectra,
    79                               haveXPol)) == 0)  {
    80     throw(AipsError("PKSreader failed"));
    81   }
    82   // re-enter the header
    83   table_->putSDHeader(header_);
     79  open(filename_,ifOffset_, beamOffset_);
    8480}
    8581
     
    8884  cerr << "disabled" << endl;
    8985}
    90 
    91 
    9286
    9387void SDReader::open(const std::string& filename,
     
    9589  if (reader_) delete reader_; reader_ = 0;
    9690  Bool   haveBase, haveSpectra, haveXPol;
    97 //
     91
    9892  String inName(filename);
    9993  Path path(inName);
    10094  inName = path.expandedName();
    101 //
     95
    10296  File file(inName);
    10397  if (!file.exists()) {
     
    106100  filename_ = inName;
    107101
    108 // Create reader and fill in values for arguments
    109 
     102  // Create reader and fill in values for arguments
    110103  String format;
    111104  Vector<Bool> beams;
     
    113106                              nChan_, nPol_, haveBase, haveSpectra,
    114107                              haveXPol)) == 0)  {
    115     throw(AipsError("PKSreader failed"));
     108    throw(AipsError("Creation of PKSreader failed"));
    116109  }
    117110  if (!haveSpectra) {
     
    121114    return;
    122115  }
     116
    123117  nBeam_ = beams.nelements();
    124118  // Get basic parameters.
     
    127121    nPol_--;   
    128122  }
    129   header_ = SDHeader();
    130   header_.nchan = nChan_;
    131   header_.npol = nPol_;
    132   header_.nbeam = nBeam_;
    133   Int status = reader_->getHeader(header_.observer, header_.project,
    134                                   header_.antennaname, header_.antennaposition,
    135                                   header_.obstype,header_.equinox,
    136                                   header_.freqref,
    137                                   header_.utc, header_.reffreq,
    138                                   header_.bandwidth);
     123  if (header_) delete header_;
     124  header_ = new SDHeader();
     125  header_->nchan = nChan_;
     126  header_->npol = nPol_;
     127  header_->nbeam = nBeam_;
     128
     129  Int status = reader_->getHeader(header_->observer, header_->project,
     130                                  header_->antennaname, header_->antennaposition,
     131                                  header_->obstype,header_->equinox,
     132                                  header_->freqref,
     133                                  header_->utc, header_->reffreq,
     134                                  header_->bandwidth);
     135
    139136  if (status) {
    140137    delete reader_;
     
    143140    return;
    144141  }
    145   if ((header_.obstype).matches("*SW*")) {
     142  if ((header_->obstype).matches("*SW*")) {
    146143    // need robust way here - probably read ahead of next timestamp
    147144    cout << "Header indicates frequency switched observation.\n"
     
    150147  }
    151148
    152 // Determine Telescope and set brightness unit
     149  // Determine Telescope and set brightness unit
    153150
    154151  Bool throwIt = False;
    155   Instrument inst = SDMemTable::convertInstrument (header_.antennaname, throwIt);
    156   header_.fluxunit = "Jy";
     152  Instrument inst = SDMemTable::convertInstrument(header_->antennaname,
     153                                                  throwIt);
     154  header_->fluxunit = "Jy";
    157155  if (inst==ATMOPRA || inst==TIDBINBILLA) {
    158      header_.fluxunit = "K";
    159   }
    160 //
    161   header_.nif = nIF_;
    162   header_.epoch = "UTC";
     156     header_->fluxunit = "K";
     157  }
     158
     159  header_->nif = nIF_;
     160  header_->epoch = "UTC";
    163161
    164162  // Apply selection criteria.
     
    167165  Vector<Bool> beamSel(nBeam_,True);
    168166  Vector<Bool> IFsel(nIF_,True);
    169 //
     167
    170168  ifOffset_ = 0;
    171169  if (whichIF>=0) {
     
    173171       IFsel = False;
    174172       IFsel(whichIF) = True;
    175        header_.nif = 1;
     173       header_->nif = 1;
    176174       nIF_ = 1;
    177175       ifOffset_ = whichIF;
     
    180178    }
    181179  }
    182 //
     180
    183181  beamOffset_ = 0;
    184182  if (whichBeam>=0) {
     
    186184        beamSel = False;
    187185        beamSel(whichBeam) = True;
    188         header_.nbeam = 1;
     186        header_->nbeam = 1;
    189187        nBeam_ = 1;
    190188        beamOffset_ = whichBeam;
     
    193191     }
    194192  }
    195 //
    196193  Vector<Int> start(nIF_, 1);
    197194  Vector<Int> end(nIF_, 0);
    198195  reader_->select(beamSel, IFsel, start, end, ref, True, haveXPol);
    199   table_->putSDHeader(header_);
    200   frequencies_.setRefFrame(header_.freqref);
    201   frequencies_.setRestFrequencyUnit("Hz");
    202   frequencies_.setEquinox(header_.equinox);
     196  table_->putSDHeader(*header_);
     197
     198  if (frequencies_) delete frequencies_;
     199  frequencies_ = new SDFrequencyTable();
     200  frequencies_->setRefFrame(header_->freqref);
     201  frequencies_->setRestFrequencyUnit("Hz");
     202  frequencies_->setEquinox(header_->equinox);
    203203}
    204204
     
    220220  uInt n = seq.size();
    221221
    222   uInt stepsize = header_.nif*header_.nbeam;
     222  uInt stepsize = header_->nif*header_->nbeam;
    223223  uInt seqi = 0;
    224224  Bool getAll = False;
     225
    225226  if (seq[n-1] == -1) getAll = True;
    226227  while ( (cursor_ <= seq[n-1]) || getAll) {
    227228    // only needs to be create if in seq
    228     SDContainer sc(header_.nbeam,header_.nif,header_.npol,header_.nchan);
     229    SDContainer sc(header_->nbeam,header_->nif,header_->npol,header_->nchan);
    229230    // iterate over one correlator integration cycle = nBeam*nIF
    230231    for (uInt row=0; row < stepsize; row++) {
     
    241242                             spectra, flagtra, xCalFctr, xPol);
    242243
    243 // Make sure beam/IF numbers are 0-relative - dealing with possible IF or Beam selection
    244 
     244      // Make sure beam/IF numbers are 0-relative - dealing with
     245      // possible IF or Beam selection
    245246      beamNo = beamNo - beamOffset_ - 1;     
    246247      IFno = IFno - ifOffset_ - 1;
    247 //
     248
    248249      if (status) {
    249250        if (status == -1) {
     
    251252          if (row > 0 && row < stepsize-1)
    252253            cerr << "incomplete scan data.\n Probably means not all Beams/IFs/Pols within a scan are present." << endl;
    253           //cerr << "EOF" << endl;
    254           table_->putSDFreqTable(frequencies_);
     254
     255          // flush frequency table
     256          table_->putSDFreqTable(*frequencies_);
    255257          return status;
    256258        }
     
    273275        // add specific info
    274276        // refPix = nChan/2+1 in  1-rel Integer arith.!
    275         Int refPix = header_.nchan/2;                                         // 0-rel
    276         uInt freqID = frequencies_.addFrequency(refPix, refFreq, freqInc);
    277         uInt restFreqID = frequencies_.addRestFrequency(restFreq);
    278 //   
     277        Int refPix = header_->nchan/2;       // 0-rel
     278        uInt freqID = frequencies_->addFrequency(refPix, refFreq, freqInc);
     279        uInt restFreqID = frequencies_->addRestFrequency(restFreq);
     280
    279281        sc.setFrequencyMap(freqID, IFno);
    280282        sc.setRestFrequencyMap(restFreqID, IFno);
     283
    281284        sc.tcal[0] = tcal[0];sc.tcal[1] = tcal[1];
    282285        sc.tcaltime = tcalTime;
     
    299302
    300303  }
    301   table_->putSDFreqTable(frequencies_);
     304  table_->putSDFreqTable(*frequencies_);
    302305  return status;
    303306}
  • trunk/src/SDReader.h

    r342 r405  
    7878  casa::Int nBeam_,nIF_,nPol_,nChan_;
    7979  PKSreader* reader_; 
    80   SDHeader header_;
    81   SDFrequencyTable frequencies_;
     80  SDHeader* header_;
     81  SDFrequencyTable* frequencies_;
    8282  casa::CountedPtr<SDMemTable> table_;
    8383  casa::String filename_;
  • trunk/src/python_SDReader.cc

    r342 r405  
    4141      class_<SDReaderWrapper>("sdreader")
    4242        .def( init < std::string, int, int > () )
    43         .def("open", &SDReaderWrapper::open)
    44         .def("read", &SDReaderWrapper::read)
    45         .def("reset", &SDReaderWrapper::reset)
    46         .def("getdata", &SDReaderWrapper::getSDMemTable)
    47         .def("header",  &SDReaderWrapper::pseudoHeader);
     43        .def("_open", &SDReaderWrapper::open)
     44        .def("_read", &SDReaderWrapper::read)
     45        .def("_reset", &SDReaderWrapper::reset)
     46        .def("_getdata", &SDReaderWrapper::getSDMemTable)
     47        .def("_header",  &SDReaderWrapper::pseudoHeader);
    4848      ;
    4949    };
Note: See TracChangeset for help on using the changeset viewer.