Changeset 388
- Timestamp:
- 02/08/05 14:05:32 (20 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDContainer.cc
r349 r388 79 79 tsys_(IPosition(4,nBeam,nIF,nPol,nChan)), 80 80 freqidx_(nIF), 81 restfreqidx_(nIF), 81 82 direction_(IPosition(2,nBeam,2)) { 82 83 uChar x = 0; … … 93 94 flags_(shp), 94 95 tsys_(shp), 95 freqidx_(shp(1)) { 96 freqidx_(shp(1)), 97 restfreqidx_(shp(1)) { 96 98 IPosition ip(2,shp(0),2); 97 99 direction_.resize(ip); … … 113 115 tsys_.resize(shp); 114 116 freqidx_.resize(shp(1)); 117 restfreqidx_.resize(shp(1)); 115 118 IPosition ip(2,shp(0),2); 116 119 direction_.resize(ip); … … 342 345 343 346 344 Bool SDContainer::setFrequencyMap(uInt freq slot, uInt whichIF) {345 freqidx_[whichIF] = freq slot;347 Bool SDContainer::setFrequencyMap(uInt freqID, uInt whichIF) { 348 freqidx_[whichIF] = freqID; 346 349 return True; 347 350 } … … 350 353 freqidx_.resize(); 351 354 freqidx_ = freqs; 355 return True; 356 } 357 358 Bool SDContainer::setRestFrequencyMap(uInt freqID, uInt whichIF) { 359 restfreqidx_[whichIF] = freqID; 360 return True; 361 } 362 363 Bool SDContainer::putRestFreqMap(const Vector<uInt>& freqs) { 364 restfreqidx_.resize(); 365 restfreqidx_ = freqs; 352 366 return True; 353 367 } … … 415 429 416 430 417 418 // SDFrequenctTable 419 420 421 Int SDFrequencyTable::addFrequency(Double refPix, Double refVal, Double inc) { 422 Int idx = -1; 423 Bool addit = False; 431 uInt SDFrequencyTable::addFrequency(Double refPix, Double refVal, Double inc) 432 { 424 433 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; 430 439 } 431 440 } 432 if (idx >= 0) {433 return idx; 434 } 435 } 441 } 442 443 // Not found - add it 444 436 445 nFreq_ += 1; 437 446 refPix_.resize(nFreq_,True); … … 441 450 refVal_[nFreq_-1] = refVal; 442 451 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 455 uInt 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; 458 462 } 459 463 } 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 466 475 void SDFrequencyTable::restFrequencies(Vector<Double>& rfs, 467 476 String& rfunit ) const -
trunk/src/SDContainer.h
r349 r388 74 74 75 75 // 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, 77 77 casa::Double inc); 78 78 // … … 92 92 void setEquinox(casa::Float eq) { equinox_ = eq; } 93 93 void setRefFrame(const casa::String& reff) { refFrame_ = reff; } 94 voidaddRestFrequency(casa::Double);94 casa::uInt addRestFrequency(casa::Double); 95 95 void setRestFrequencyUnit(const casa::String& theunit) {restFreqUnit_ = theunit;} 96 96 97 97 private: 98 casa:: Int nFreq_;98 casa::uInt nFreq_; 99 99 casa::Vector<casa::Double> refPix_; 100 100 casa::Vector<casa::Double> refVal_; // Hz … … 136 136 casa::Bool setFrequencyMap(casa::uInt freqslot, casa::uInt whichIF); 137 137 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); 138 141 139 142 casa::Array<casa::Float> getSpectrum(casa::uInt whichBeam, … … 151 154 152 155 const casa::Vector<casa::uInt>& getFreqMap() const { return freqidx_; } 156 const casa::Vector<casa::uInt>& getRestFreqMap() const { return restfreqidx_; } 153 157 154 158 const casa::Vector<casa::String>& getHistory() const { return history_; } … … 183 187 //(nIF) indx into "global" frequency table 184 188 casa::Vector<casa::uInt> freqidx_; 189 // (nIF) indx into "global" rest frequency table 190 casa::Vector<casa::uInt> restfreqidx_; 185 191 //(nBeam,2) maybe use Measures here... 186 192 casa::Array<casa::Double> direction_;
Note:
See TracChangeset
for help on using the changeset viewer.