Changeset 185
- Timestamp:
- 01/10/05 17:00:45 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDMath.cc
r184 r185 71 71 {;} 72 72 73 SDMath::SDMath 73 SDMath::SDMath(const SDMath& other) 74 74 { 75 75 … … 90 90 91 91 92 CountedPtr<SDMemTable> SDMath::average 93 94 92 CountedPtr<SDMemTable> SDMath::average(const Block<CountedPtr<SDMemTable> >& in, 93 const Vector<Bool>& mask, Bool scanAv, 94 const std::string& weightStr) 95 95 // 96 96 // Weighted averaging of spectra from one or more Tables. … … 101 101 102 102 WeightType wtType = NONE; 103 convertWeightString 103 convertWeightString(wtType, weightStr); 104 104 105 105 // Create output Table by cloning from the first table … … 251 251 // Normalize data in 'sum' accumulation array according to weighting scheme 252 252 253 normalize 253 normalize(sum, sumSq, nPts, wtType, axis, nAxesSub); 254 254 255 255 // Fill scan container. The source and freqID come from the … … 258 258 259 259 Float nR(nAccum); 260 fillSDC 260 fillSDC(sc, sum.getMask(), sum.getArray(), tSysSum/nR, outScanID, 261 261 timeSum/nR, intSum, sourceNameStart, freqIDStart); 262 262 … … 290 290 // Accumulate 291 291 292 accumulate 292 accumulate(timeSum, intSum, nAccum, sum, sumSq, nPts, tSysSum, 293 293 tSys, nInc, mask, time, interval, in, iTab, iRow, axis, 294 294 nAxesSub, useMask, wtType); … … 305 305 // 306 306 // Normalize data in 'sum' accumulation array according to weighting scheme 307 normalize 307 normalize(sum, sumSq, nPts, wtType, axis, nAxesSub); 308 308 309 309 // Create and fill container. The container we clone will be from … … 313 313 Float nR(nAccum); 314 314 SDContainer sc = in[tableStart]->getSDContainer(rowStart); 315 fillSDC 315 fillSDC(sc, sum.getMask(), sum.getArray(), tSysSum/nR, outScanID, 316 316 timeSum/nR, intSum, sourceNameStart, freqIDStart); 317 317 // … … 335 335 CountedPtr<SDMemTable> 336 336 SDMath::quotient(const CountedPtr<SDMemTable>& on, 337 const CountedPtr<SDMemTable>& off) 337 const CountedPtr<SDMemTable>& off) 338 { 338 339 // 339 340 // Compute quotient spectrum 340 341 // 341 {342 342 const uInt nRows = on->nRow(); 343 343 if (off->nRow() != nRows) { … … 385 385 SDContainer sc = on->getSDContainer(i); 386 386 // 387 putDataInSDC 387 putDataInSDC(sc, out, outflagsb); 388 388 sc.putTsys(tsarr); 389 389 sc.scanid = i; … … 399 399 400 400 401 std::vector<float> SDMath::statistic 402 403 401 std::vector<float> SDMath::statistic(const CountedPtr<SDMemTable>& in, 402 const std::vector<bool>& mask, 403 const String& which) 404 404 // 405 405 // Perhaps iteration over pol/beam/if should be in here … … 414 414 415 415 IPosition start, end; 416 getCursorLocation 416 getCursorLocation(start, end, *in); 417 417 418 418 // Loop over rows … … 450 450 451 451 452 SDMemTable* SDMath::bin 452 SDMemTable* SDMath::bin(const SDMemTable& in, Int width) 453 453 { 454 454 SDHeader sh = in.getSDHeader(); … … 463 463 cSys.addCoordinate(in.getCoordinate(j)); 464 464 CoordinateSystem cSysBin = 465 CoordinateUtil::makeBinnedCoordinateSystem 465 CoordinateUtil::makeBinnedCoordinateSystem(factors, cSys, False); 466 466 // 467 467 SpectralCoordinate sCBin = cSysBin.spectralCoordinate(0); … … 472 472 473 473 IPosition shapeIn(1,sh.nchan); 474 IPosition shapeOut = RebinLattice<Float>::rebinShape 474 IPosition shapeOut = RebinLattice<Float>::rebinShape(shapeIn, factors); 475 475 sh.nchan = shapeOut(0); 476 476 pTabOut->putSDHeader(sh); … … 496 496 sc.resize(ip2); 497 497 // 498 putDataInSDC 498 putDataInSDC(sc, marrout.getArray(), marrout.getMask()); 499 499 500 500 // Bin up Tsys. … … 512 512 } 513 513 514 SDMemTable* SDMath::simpleOperate 515 514 SDMemTable* SDMath::simpleOperate(const SDMemTable& in, Float val, Bool doAll, 515 uInt what) 516 516 // 517 517 // what = 0 Multiply … … 546 546 547 547 IPosition start, end; 548 getCursorLocation 548 getCursorLocation(start, end, in); 549 549 // 550 550 for (uInt i=0; i < tOut.nrow(); i++) { … … 579 579 580 580 581 SDMemTable* SDMath::averagePol 581 SDMemTable* SDMath::averagePol(const SDMemTable& in, const Vector<Bool>& mask) 582 582 // 583 583 // Average all polarizations together, weighted by variance … … 585 585 { 586 586 // WeightType wtType = NONE; 587 // convertWeightString 587 // convertWeightString(wtType, weight); 588 588 589 589 const uInt nRows = in.nRow(); … … 704 704 sc.resize(shapeOut); 705 705 // 706 putDataInSDC 706 putDataInSDC(sc, outData, outMask); 707 707 pTabOut->putSDContainer(sc); 708 708 } … … 712 712 713 713 714 SDMemTable* SDMath::smooth (const SDMemTable& in, const casa::String& kernelType, 715 casa::Float width, Bool doAll) 714 SDMemTable* SDMath::smooth(const SDMemTable& in, 715 const casa::String& kernelType, 716 casa::Float width, Bool doAll) 716 717 { 717 718 … … 724 725 // Generate Kernel 725 726 726 VectorKernel::KernelTypes type = VectorKernel::toKernelType 727 VectorKernel::KernelTypes type = VectorKernel::toKernelType(kernelType); 727 728 Vector<Float> kernel = VectorKernel::make(type, width, nChan, True, False); 728 729 … … 739 740 740 741 IPosition start, end; 741 getCursorLocation 742 getCursorLocation(start, end, in); 742 743 // 743 744 IPosition shapeOut(4,1); … … 810 811 811 812 SDContainer sc = in.getSDContainer(ri); 812 putDataInSDC 813 putDataInSDC(sc, valuesIn, maskIn); 813 814 // 814 815 pTabOut->putSDContainer(sc); … … 824 825 // 'private' functions 825 826 826 void SDMath::fillSDC 827 828 829 830 831 832 827 void SDMath::fillSDC(SDContainer& sc, 828 const Array<Bool>& mask, 829 const Array<Float>& data, 830 const Array<Float>& tSys, 831 Int scanID, Double timeStamp, 832 Double interval, const String& sourceName, 833 const Vector<uInt>& freqID) 833 834 { 834 835 // Data and mask 835 836 836 putDataInSDC 837 putDataInSDC(sc, data, mask); 837 838 838 839 // TSys … … 850 851 } 851 852 852 void SDMath::normalize 853 void SDMath::normalize(MaskedArray<Float>& sum, 853 854 const Array<Float>& sumSq, 854 855 const Array<Float>& nPts, … … 883 884 884 885 885 void SDMath::accumulate 886 887 888 889 890 891 892 893 886 void SDMath::accumulate(Double& timeSum, Double& intSum, Int& nAccum, 887 MaskedArray<Float>& sum, Array<Float>& sumSq, 888 Array<Float>& nPts, Array<Float>& tSysSum, 889 const Array<Float>& tSys, const Array<Float>& nInc, 890 const Vector<Bool>& mask, Double time, Double interval, 891 const Block<CountedPtr<SDMemTable> >& in, 892 uInt iTab, uInt iRow, uInt axis, 893 uInt nAxesSub, Bool useMask, 894 WeightType wtType) 894 895 { 895 896 … … 958 959 959 960 960 void SDMath::getCursorLocation 961 961 void SDMath::getCursorLocation(IPosition& start, IPosition& end, 962 const SDMemTable& in) 962 963 { 963 964 const uInt nDim = 4; … … 981 982 982 983 983 void SDMath::convertWeightString 984 void SDMath::convertWeightString(WeightType& wtType, const std::string& weightStr) 984 985 { 985 986 String tStr(weightStr); … … 991 992 } else if (tStr.contains(String("TSYS"))) { 992 993 wtType = TSYS; 993 throw 994 throw(AipsError("T_sys weighting not yet implemented")); 994 995 } else { 995 throw 996 throw(AipsError("Unrecognized weighting type")); 996 997 } 997 998 } 998 999 999 void SDMath::putDataInSDC 1000 1000 void SDMath::putDataInSDC(SDContainer& sc, const Array<Float>& data, 1001 const Array<Bool>& mask) 1001 1002 { 1002 1003 sc.putSpectrum(data);
Note:
See TracChangeset
for help on using the changeset viewer.