Changeset 175
- Timestamp:
- 01/06/05 16:40:42 (20 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDMath.cc
r171 r175 391 391 392 392 393 SDMemTable* SDMath::hanning(const SDMemTable& in )393 SDMemTable* SDMath::hanning(const SDMemTable& in, Bool doAll) 394 394 // 395 395 // Hanning smooth each row … … 397 397 // 398 398 { 399 400 // New Table 401 399 402 SDMemTable* pTabOut = new SDMemTable(in,True); 400 403 404 // Get cursor location 405 406 IPosition start, end; 407 getCursorLocation (start, end, in); 408 // 409 const uInt chanAxis = 3; // Spectrum axis 410 IPosition shapeOut(4,1); 411 401 412 // Loop over rows in Table 402 413 403 414 for (uInt ri=0; ri < in.nRow(); ++ri) { 404 415 405 // Get data416 // Get copy of data 406 417 407 const MaskedArray<Float>& marr(in.rowAsMaskedArray(ri));408 Array<Float> arr = marr.getArray();409 Array<Bool> barr = marr.getMask();418 const MaskedArray<Float>& dataIn(in.rowAsMaskedArray(ri)); 419 Array<Float> valuesIn = dataIn.getArray(); 420 Array<Bool> maskIn = dataIn.getMask(); 410 421 411 422 // Smooth along the channels axis 412 423 413 uInt axis = 3; 414 VectorIterator<Float> itData(arr, axis); 415 VectorIterator<Bool> itMask(barr, axis); 416 Vector<Float> outv; 417 Vector<Bool> outm; 418 while (!itData.pastEnd()) { 419 mathutil::hanning(outv, outm, itData.vector(), itMask.vector()); 420 itData.vector() = outv; 421 itMask.vector() = outm; 422 // 423 itData.next(); 424 itMask.next(); 424 Vector<Float> outValues; 425 Vector<Bool> outMask; 426 if (doAll) { 427 uInt axis = 3; 428 VectorIterator<Float> itValues(valuesIn, axis); 429 VectorIterator<Bool> itMask(maskIn, axis); 430 while (!itValues.pastEnd()) { 431 mathutil::hanning(outValues, outMask, itValues.vector(), itMask.vector()); 432 itValues.vector() = outValues; 433 itMask.vector() = outMask; 434 // 435 itValues.next(); 436 itMask.next(); 437 } 438 } else { 439 440 // Set multi-dim Vector shape 441 442 shapeOut(chanAxis) = valuesIn.shape()(chanAxis); 443 444 // Stuff about with shapes so that we don't have conformance run-time errors 445 446 Vector<Float> valuesIn2 = valuesIn(start,end).nonDegenerate(); 447 Vector<Bool> maskIn2 = maskIn(start,end).nonDegenerate(); 448 mathutil::hanning(outValues, outMask, valuesIn2, maskIn2); 449 450 // Write back 451 452 valuesIn(start,end) = outValues.reform(shapeOut); 453 maskIn(start,end) = outMask.reform(shapeOut); 425 454 } 426 455 … … 428 457 429 458 SDContainer sc = in.getSDContainer(ri); 430 putDataInSDC (sc, arr, barr);459 putDataInSDC (sc, valuesIn, maskIn); 431 460 // 432 461 pTabOut->putSDContainer(sc); -
trunk/src/SDMath.h
r171 r175 59 59 60 60 // Average in time 61 casa::CountedPtr<SDMemTable> average 62 63 61 casa::CountedPtr<SDMemTable> average(const casa::Block<casa::CountedPtr<SDMemTable> >& in, 62 const casa::Vector<casa::Bool>& mask, 63 bool scanAverage, const std::string& weightStr); 64 64 65 65 // Statistics … … 67 67 const std::vector<bool>& mask, const std::string& which); 68 68 69 // Hanning 70 SDMemTable* hanning(const SDMemTable& in); 71 69 // Hanning 70 SDMemTable* hanning(const SDMemTable& in, casa::Bool doAll); 72 71 73 72 // Bin up spectra 74 SDMemTable* bin 73 SDMemTable* bin(const SDMemTable& in, casa::Int width); 75 74 76 75 // Simple mathematical operations. what=0 (mul) or 1 (add) 77 SDMemTable* simpleOperate 78 76 SDMemTable* simpleOperate(const SDMemTable& in, casa::Float offset, 77 casa::Bool doAll, casa::uInt what); 79 78 80 79 // Average polarizations 81 SDMemTable* averagePol 80 SDMemTable* averagePol(const SDMemTable& in, const casa::Vector<casa::Bool>& mask); 82 81 83 82 private: -
trunk/src/SDMathWrapper.cc
r171 r175 88 88 } 89 89 90 void SDMathWrapper::hanningInSitu(SDMemTableWrapper& in )90 void SDMathWrapper::hanningInSitu(SDMemTableWrapper& in, bool doAll) 91 91 { 92 92 SDMemTable* pIn = in.getPtr(); 93 93 SDMath sdm; 94 SDMemTable* pOut = sdm.hanning (*pIn );94 SDMemTable* pOut = sdm.hanning (*pIn, Bool(doAll)); 95 95 *pIn = *pOut; 96 96 delete pOut; 97 97 } 98 98 99 SDMemTableWrapper SDMathWrapper::hanning (const SDMemTableWrapper& in )99 SDMemTableWrapper SDMathWrapper::hanning (const SDMemTableWrapper& in, bool doAll) 100 100 { 101 101 const CountedPtr<SDMemTable>& pIn = in.getCP(); 102 102 SDMath sdm; 103 return CountedPtr<SDMemTable>(sdm.hanning(*pIn ));103 return CountedPtr<SDMemTable>(sdm.hanning(*pIn, Bool(doAll))); 104 104 } 105 105 -
trunk/src/SDMathWrapper.h
r171 r175 53 53 54 54 // Add 55 void addInSitu(SDMemTableWrapper& in, float offset, bool all);55 void addInSitu(SDMemTableWrapper& in, float offset, bool doAall); 56 56 SDMemTableWrapper add(const SDMemTableWrapper& in, float offset, bool all); 57 57 58 58 // Hanning 59 void hanningInSitu (SDMemTableWrapper& in );60 SDMemTableWrapper hanning(const SDMemTableWrapper& in );59 void hanningInSitu (SDMemTableWrapper& in, bool doAll); 60 SDMemTableWrapper hanning(const SDMemTableWrapper& in, bool doAll); 61 61 62 62 // Bin up
Note:
See TracChangeset
for help on using the changeset viewer.