Changeset 386 for trunk/src


Ignore:
Timestamp:
02/08/05 14:00:43 (20 years ago)
Author:
kil064
Message:

support RESTFREQID column in SDMemTable object

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/SDMemTable.cc

    r385 r386  
    167167  td.addColumn(ScalarColumnDesc<Double>("INTERVAL"));
    168168  td.addColumn(ArrayColumnDesc<uInt>("FREQID"));
     169  td.addColumn(ArrayColumnDesc<uInt>("RESTFREQID"));
    169170  td.addColumn(ArrayColumnDesc<Double>("DIRECTION"));
    170171  td.addColumn(ScalarColumnDesc<String>("FIELDNAME"));
     
    193194  integrCol_.attach(table_, "INTERVAL");
    194195  freqidCol_.attach(table_, "FREQID");
     196  restfreqidCol_.attach(table_, "RESTFREQID");
    195197  dirCol_.attach(table_, "DIRECTION");
    196198  fldnCol_.attach(table_, "FIELDNAME");
     
    434436  }
    435437
    436 // Continue with km/s or Hz.  Get FreqID
     438// Continue with km/s or Hz.  Get FreqIDs
    437439
    438440  Vector<uInt> freqIDs;
    439441  freqidCol_.get(whichRow, freqIDs);
    440442  uInt freqID = freqIDs(IFSel_);
     443  restfreqidCol_.get(whichRow, freqIDs);
     444  uInt restFreqID = freqIDs(IFSel_);
    441445
    442446// Get SpectralCoordinate, set reference frame conversion,
    443447// velocity conversion, and rest freq state
    444448
    445   SpectralCoordinate spc = getSpectralCoordinate(freqID, whichRow);
     449  SpectralCoordinate spc = getSpectralCoordinate(freqID, restFreqID, whichRow);
    446450  Vector<Double> pixel(nChan());
    447451  indgen(pixel);
     
    486490  Vector<uInt> freqIDs;
    487491  freqidCol_.get(whichRow, freqIDs);
    488   uInt freqID = freqIDs(IFSel_);
     492  uInt freqID = freqIDs(IFSel_); 
     493  restfreqidCol_.get(whichRow, freqIDs);
     494  uInt restFreqID = freqIDs(IFSel_);
    489495
    490496// Get SpectralCoordinate, with frame, velocity, rest freq state set
    491497
    492   SpectralCoordinate spc = getSpectralCoordinate(freqID, whichRow);
     498  SpectralCoordinate spc = getSpectralCoordinate(freqID, restFreqID, whichRow);
    493499//
    494500  String s = "Channel";
     
    705711
    706712
    707 SpectralCoordinate SDMemTable::getSpectralCoordinate(uInt freqID,
    708                                                      uInt whichRow) const
     713SpectralCoordinate SDMemTable::getSpectralCoordinate(uInt freqID, uInt restFreqID,
     714                                                     uInt whichRow) const
    709715{
    710716
     
    715721  Table t = table_.keywordSet().asTable("FREQUENCIES");
    716722
    717 // Get rest frequencies from table, one per IF ???
    718 
    719   Vector<Double> vec;
    720   t.keywordSet().get("RESTFREQS",vec);
    721   if (vec.nelements() > 0) {
    722     spec.setRestFrequencies(vec);
    723 
    724 // Select rest freq
    725 
    726     if (IFSel_ < vec.nelements()) {
    727        spec.selectRestFrequency(uInt(IFSel_));
    728     } else {
    729        cerr << "There is no rest frequency for this IF; selecting rest freq for IF=0" << endl;
    730        spec.selectRestFrequency(0u);
    731     }
     723// Set rest frequency
     724
     725  Vector<Double> restFreqIDs;
     726  t.keywordSet().get("RESTFREQS",restFreqIDs);
     727  if (restFreqID < restFreqIDs.nelements()) {                  // SHould always be true
     728    spec.setRestFrequency(restFreqIDs(restFreqID),True);
    732729  }
    733730
     
    856853SDFrequencyTable SDMemTable::getSDFreqTable() const
    857854{
     855cerr << "ENter SDMemTbale::getSDFreqTable" << endl;
     856
    858857  const Table& t = table_.keywordSet().asTable("FREQUENCIES");
    859858  SDFrequencyTable sdft;
     
    893892  Vector<Double> restFreqs;
    894893  t.keywordSet().get("RESTFREQS", restFreqs);
     894cerr << "old restfreqs from Table = " << restFreqs << endl;
     895cerr << "add them to SDFreqTable" << endl;
    895896  for (uInt i=0; i<restFreqs.nelements(); i++) {
    896897     sdft.addRestFrequency(restFreqs[i]);
    897898  }
    898899  sdft.setRestFrequencyUnit(String("Hz"));
     900cerr << "Exit getSDFreqTable" << endl;
    899901//
    900902  return sdft;
     
    905907  uInt rno = table_.nrow();
    906908  table_.addRow();
    907 
    908 //  mjd.put(rno, sdc.timestamp);
     909//
    909910  timeCol_.put(rno, sdc.timestamp);
    910911  srcnCol_.put(rno, sdc.sourcename);
     
    916917  integrCol_.put(rno, sdc.interval);
    917918  freqidCol_.put(rno, sdc.getFreqMap());
     919  restfreqidCol_.put(rno, sdc.getRestFreqMap());
    918920  dirCol_.put(rno, sdc.getDirection());
    919921  rbeamCol_.put(rno, sdc.refbeam);
     
    924926  paraCol_.put(rno, sdc.parangle);
    925927  histCol_.put(rno, sdc.getHistory());
    926 
     928//
    927929  return true;
    928930}
     
    944946  sdc.tcal[0] = tc[0];sdc.tcal[1] = tc[1];
    945947  tcaltCol_.get(whichRow, sdc.tcaltime);
     948//
    946949  Array<Float> spectrum;
    947950  Array<Float> tsys;
     
    950953  Array<Double> direction;
    951954  Vector<String> histo;
     955//
    952956  specCol_.get(whichRow, spectrum);
    953957  sdc.putSpectrum(spectrum);
     
    958962  freqidCol_.get(whichRow, fmap);
    959963  sdc.putFreqMap(fmap);
     964  restfreqidCol_.get(whichRow, fmap);
     965  sdc.putRestFreqMap(fmap);
    960966  dirCol_.get(whichRow, direction);
    961967  sdc.putDirection(direction);
     
    13351341}
    13361342
     1343casa::Bool SDMemTable::selectRestFreq (casa::Double restFreq, const String& unit,
     1344                                       const casa::String& source,
     1345                                       casa::Int whichIF)
     1346{
     1347   const Int nIFs = nIF();
     1348   if (whichIF>=nIFs) {
     1349      throw(AipsError("Illegal IF index"));
     1350   }
     1351
     1352// Find rest frequency.  Add it if necessary
     1353
     1354   SDFrequencyTable sdft = getSDFreqTable();
     1355   Quantum<Double> rf(restFreq, Unit(unit));
     1356   uInt idx = sdft.addRestFrequency(rf.getValue("Hz"));
     1357
     1358// Replace
     1359
     1360   Bool empty = source.empty();
     1361   Bool ok = False;
     1362   if (putSDFreqTable(sdft)) {
     1363      const uInt nRow = table_.nrow();
     1364      String srcName;
     1365      Vector<uInt> restFreqIDs;
     1366      for (uInt i=0; i<nRow; i++) {
     1367         srcnCol_.get(i, srcName);
     1368         restfreqidCol_.get(i,restFreqIDs);       
     1369//
     1370         if (empty || source==srcName) {
     1371            if (whichIF<0) {
     1372               restFreqIDs = idx;
     1373            } else {             
     1374               restFreqIDs(whichIF) = idx;
     1375            }
     1376         }
     1377//
     1378         restfreqidCol_.put(i,restFreqIDs);       
     1379      }
     1380      ok = True;
     1381   } else {
     1382      ok = False;
     1383   }
     1384//
     1385   return ok;
     1386}
     1387
     1388
    13371389void SDMemTable::renumber()
    13381390{
     
    13551407  }
    13561408}
     1409
  • trunk/src/SDMemTable.h

    r380 r386  
    8383
    8484  //get the data wrapped up in a meta container
     85
    8586  SDContainer getSDContainer(casa::uInt whichRow=0) const;
    8687  SDHeader getSDHeader() const;
     
    118119  virtual void setCoordInfo(std::vector<string> theinfo);
    119120
     121// Select RestFreqID.  FInds the restFreq ID for specified restFreq,
     122// and updates RESTFREQID column of table for specified IF index
     123// (-1 means all IFs) and source combination
     124  virtual casa::Bool selectRestFreq (casa::Double restFreq, const casa::String& unit,
     125                                     const casa::String& source,
     126                                     casa::Int whichIF=-1);
     127
    120128// Get/Set flux unit
    121129  std::string getFluxUnit() const;
     
    185193  casa::SpectralCoordinate getSpectralCoordinate(casa::uInt whichIdx) const;
    186194
    187   // Return SC. Set velocity conversion state (unit,doppler),
    188   // set rest frequencies.  If row number given (>-0), also set
     195  // Return SC. Set velocity conversion state (unit,doppler), and
     196  // rest frequency.  If row number given (>=0), also set
    189197  // frame conversion layer (needs direction & time which require row)
    190   casa::SpectralCoordinate getSpectralCoordinate(casa::uInt whichIdx, casa::uInt row) const;
     198  casa::SpectralCoordinate getSpectralCoordinate(casa::uInt freqID,
     199                                                 casa::uInt restFreqID,
     200                                                 casa::uInt row) const;
    191201
    192202  // Set just the reference value, pixel and increment into the table
     
    232242  casa::ArrayColumn<casa::Double> dirCol_;
    233243  casa::ArrayColumn<casa::uChar> flagsCol_;
    234   casa::ArrayColumn<casa::uInt> freqidCol_;
     244  casa::ArrayColumn<casa::uInt> freqidCol_, restfreqidCol_;
    235245  casa::ArrayColumn<casa::String> histCol_;
    236246};
  • trunk/src/SDMemTableWrapper.h

    r380 r386  
    149149  }
    150150
     151  bool selectRestFreq(double freq, const std::string& unit,
     152                      const std::string& source, int whichIF) {
     153    return table_->selectRestFreq(casa::Double(freq), casa::String(unit),
     154                                  casa::String(source),
     155                                  casa::Int(whichIF));
     156  }
     157
    151158  std::vector<double> getRestFreqs() {
    152159    return table_->getRestFreqs();
  • trunk/src/python_SDMemTable.cc

    r357 r386  
    8989    .def("_setrestfreqs",  &SDMemTableWrapper::setRestFreqs)
    9090    .def("_getrestfreqs",  &SDMemTableWrapper::getRestFreqs)
     91    .def("_selectrestfreq",  &SDMemTableWrapper::selectRestFreq)
    9192    .def("_setcoordinfo", &SDMemTableWrapper::setCoordInfo)
    9293    .def("_getcoordinfo", &SDMemTableWrapper::getCoordInfo)
Note: See TracChangeset for help on using the changeset viewer.