Changeset 388 for trunk/src


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

add support for RestFreqID now beung a column in SDMemTable

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/SDContainer.cc

    r349 r388  
    7979    tsys_(IPosition(4,nBeam,nIF,nPol,nChan)),
    8080    freqidx_(nIF),
     81    restfreqidx_(nIF),
    8182    direction_(IPosition(2,nBeam,2)) {
    8283  uChar x = 0;
     
    9394    flags_(shp),
    9495    tsys_(shp),
    95     freqidx_(shp(1)) {
     96    freqidx_(shp(1)),
     97    restfreqidx_(shp(1)) {
    9698  IPosition ip(2,shp(0),2);
    9799  direction_.resize(ip);
     
    113115  tsys_.resize(shp);
    114116  freqidx_.resize(shp(1));
     117  restfreqidx_.resize(shp(1));
    115118  IPosition ip(2,shp(0),2);
    116119  direction_.resize(ip);
     
    342345
    343346
    344 Bool SDContainer::setFrequencyMap(uInt freqslot, uInt whichIF) {
    345   freqidx_[whichIF] = freqslot;
     347Bool SDContainer::setFrequencyMap(uInt freqID, uInt whichIF) {
     348  freqidx_[whichIF] = freqID;
    346349  return True;
    347350}
     
    350353  freqidx_.resize();
    351354  freqidx_ = freqs;
     355  return True;
     356}
     357
     358Bool SDContainer::setRestFrequencyMap(uInt freqID, uInt whichIF) {
     359  restfreqidx_[whichIF] = freqID;
     360  return True;
     361}
     362
     363Bool SDContainer::putRestFreqMap(const Vector<uInt>& freqs) {
     364  restfreqidx_.resize();
     365  restfreqidx_ = freqs;
    352366  return True;
    353367}
     
    415429
    416430
    417 
    418 // SDFrequenctTable
    419 
    420 
    421 Int SDFrequencyTable::addFrequency(Double refPix, Double refVal, Double inc) {
    422   Int idx = -1;
    423   Bool addit = False;
     431uInt SDFrequencyTable::addFrequency(Double refPix, Double refVal, Double inc)
     432{
    424433  if (length() > 0) {
    425     for (uInt i=0; i< length();++i) {
    426       if ( near(refVal,refVal_[i]) ) {
    427         if (near(refPix,refPix_[i]) )
    428           if ( near(inc,increment_[i]) )
    429             idx = Int(i);
     434    for (uInt i=0; i< length();i++) {
     435      if (near(refVal,refVal_[i]) &&
     436          near(refPix,refPix_[i]) &&
     437          near(inc,increment_[i])) {
     438         return i;
    430439      }
    431440    }
    432     if (idx >= 0) {
    433       return idx;
    434     }
    435   }
     441  }
     442
     443// Not found - add it
     444
    436445  nFreq_ += 1;
    437446  refPix_.resize(nFreq_,True);
     
    441450  refVal_[nFreq_-1] = refVal;
    442451  increment_[nFreq_-1] = inc;
    443   idx = nFreq_-1;
    444   return idx;
    445 }
    446 
    447 void SDFrequencyTable::addRestFrequency(Double val)
    448 {
    449   if (restFreqs_.nelements()  == 0) {
    450     restFreqs_.resize(1);
    451     restFreqs_[0] = val;
    452   } else {
    453     Bool found = False;
    454     for (uInt i=0;i<restFreqs_.nelements();++i) {
    455       if (restFreqs_[i] == val) {
    456         found = True;
    457         return;
     452  return nFreq_-1;
     453}
     454
     455uInt SDFrequencyTable::addRestFrequency(Double val)
     456{
     457  uInt nFreq = restFreqs_.nelements();
     458  if (nFreq>0) {
     459    for (uInt i=0; i<nFreq;i++) {
     460      if (near(restFreqs_[i],val)) {
     461         return i;
    458462      }
    459463    }
    460     if (!found) {
    461       restFreqs_.resize(restFreqs_.nelements()+1,True);
    462       restFreqs_[restFreqs_.nelements()-1] = val;
    463     }
    464   }
    465 }
     464  }
     465
     466// Not found - add it
     467
     468  nFreq += 1;
     469  restFreqs_.resize(nFreq,True);
     470  restFreqs_[nFreq-1] = val;
     471  return nFreq-1;
     472}
     473
     474
    466475void SDFrequencyTable::restFrequencies(Vector<Double>& rfs,
    467476                                       String& rfunit ) const
  • trunk/src/SDContainer.h

    r349 r388  
    7474
    7575// Add a new entry or match an existing one. Returns the index into the table
    76   casa::Int addFrequency(casa::Double refPix, casa::Double refVal,
     76  casa::uInt addFrequency(casa::Double refPix, casa::Double refVal,
    7777                         casa::Double inc);
    7878// 
     
    9292  void setEquinox(casa::Float eq) { equinox_ = eq; }
    9393  void setRefFrame(const casa::String& reff) { refFrame_ = reff; }
    94   void addRestFrequency(casa::Double);
     94  casa::uInt addRestFrequency(casa::Double);
    9595  void setRestFrequencyUnit(const casa::String& theunit) {restFreqUnit_ = theunit;}
    9696
    9797private:
    98   casa::Int nFreq_;
     98  casa::uInt nFreq_;
    9999  casa::Vector<casa::Double> refPix_;
    100100  casa::Vector<casa::Double> refVal_;           // Hz
     
    136136  casa::Bool setFrequencyMap(casa::uInt freqslot, casa::uInt whichIF);
    137137  casa::Bool putFreqMap(const casa::Vector<casa::uInt>& freqs);
     138
     139  casa::Bool setRestFrequencyMap(casa::uInt freqslot, casa::uInt whichIF);
     140  casa::Bool putRestFreqMap(const casa::Vector<casa::uInt>& freqs);
    138141 
    139142  casa::Array<casa::Float> getSpectrum(casa::uInt whichBeam,
     
    151154
    152155  const casa::Vector<casa::uInt>& getFreqMap() const { return freqidx_; }
     156  const casa::Vector<casa::uInt>& getRestFreqMap() const { return restfreqidx_; }
    153157 
    154158  const casa::Vector<casa::String>& getHistory() const { return history_; }
     
    183187  //(nIF) indx into "global" frequency table
    184188  casa::Vector<casa::uInt>    freqidx_;
     189 // (nIF) indx into "global" rest frequency table
     190  casa::Vector<casa::uInt>    restfreqidx_;
    185191  //(nBeam,2) maybe use Measures here...
    186192  casa::Array<casa::Double>   direction_;
Note: See TracChangeset for help on using the changeset viewer.