- Timestamp:
- 01/23/05 20:22:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDMath.cc
r267 r270 633 633 if (doAll) { 634 634 for (uInt i=0; i < tOut.nrow(); i++) { 635 636 // Get 637 638 MaskedArray<Float> marr(pOut->rowAsMaskedArray(i)); 639 640 // Operate 641 635 MaskedArray<Float> dataIn(pOut->rowAsMaskedArray(i)); 636 // 642 637 if (what==0) { 643 marr*= val;638 dataIn *= val; 644 639 } else if (what==1) { 645 marr+= val;640 dataIn += val; 646 641 } 647 648 // Put 649 650 spec.put(i, marr.getArray()); 642 // 643 spec.put(i, dataIn.getArray()); 651 644 } 652 645 } else { … … 658 651 // 659 652 for (uInt i=0; i < tOut.nrow(); i++) { 660 661 // Get662 663 653 MaskedArray<Float> dataIn(pOut->rowAsMaskedArray(i)); 664 665 // Modify. More work than we would like to deal with the mask 666 667 Array<Float>& values = dataIn.getRWArray(); 668 Array<Bool> mask(dataIn.getMask()); 669 // 670 Array<Float> values2 = values(start,end); 671 Array<Bool> mask2 = mask(start,end); 672 MaskedArray<Float> t(values2,mask2); 654 MaskedArray<Float> dataIn2 = dataIn(start,end); // Reference 655 // 673 656 if (what==0) { 674 t*= val;657 dataIn2 *= val; 675 658 } else if (what==1) { 676 t+= val;659 dataIn2 += val; 677 660 } 678 values(start, end) = t.getArray(); // Write back into 'dataIn' 679 680 // Put 661 // 681 662 spec.put(i, dataIn.getArray()); 682 663 } … … 982 963 cerr << "Applying conversion factor = " << factor << endl; 983 964 984 // For operations only on specified cursor location 985 986 IPosition start, end; 987 getCursorLocation(start, end, in); 988 989 // Loop over rows and apply factor to spectra 990 991 const uInt axis = asap::ChanAxis; 992 for (uInt i=0; i < in.nRow(); ++i) { 993 994 // Get data 995 996 MaskedArray<Float> dataIn(in.rowAsMaskedArray(i)); 997 Array<Float>& valuesIn = dataIn.getRWArray(); // writable reference 998 const Array<Bool>& maskIn = dataIn.getMask(); 999 1000 // Need to apply correct conversion factor (frequency and time dependent) 1001 // which should be sourced from a Table. For now we just apply the given 1002 // factor to everything 1003 1004 if (doAll) { 1005 VectorIterator<Float> itValues(valuesIn, asap::ChanAxis); 1006 while (!itValues.pastEnd()) { 1007 itValues.vector() *= factor; // Writes back into dataIn 1008 // 1009 itValues.next(); 1010 } 1011 } else { 1012 Array<Float> valuesIn2 = valuesIn(start,end); 1013 valuesIn2 *= factor; 1014 valuesIn(start,end) = valuesIn2; 1015 } 1016 1017 // Write out 1018 1019 SDContainer sc = in.getSDContainer(i); 1020 putDataInSDC(sc, valuesIn, maskIn); 1021 // 1022 pTabOut->putSDContainer(sc); 1023 } 965 // Generate correction vector. Apply same factor regardless 966 // of beam/pol/IF. This will need to change somewhen. 967 968 Vector<Float> factors(in.nRow(), factor); 969 970 // Correct 971 972 correctFromVector (pTabOut, in, doAll, factors); 973 // 1024 974 return pTabOut; 1025 975 } 1026 1027 976 1028 977 … … 1579 1528 Bool doAll, const Vector<Float>& factor) const 1580 1529 { 1530 1581 1531 // For operations only on specified cursor location 1582 1532 … … 1584 1534 getCursorLocation(start, end, in); 1585 1535 1586 // Loop over rows and interpolatecorrection factor1536 // Loop over rows and apply correction factor 1587 1537 1588 1538 const uInt axis = asap::ChanAxis; … … 1592 1542 1593 1543 MaskedArray<Float> dataIn(in.rowAsMaskedArray(i)); 1594 Array<Float>& valuesIn = dataIn.getRWArray();1595 const Array<Bool>& maskIn = dataIn.getMask();1596 1544 1597 1545 // Apply factor 1598 1546 1599 1547 if (doAll) { 1600 VectorIterator<Float> itValues(valuesIn, asap::ChanAxis); 1601 while (!itValues.pastEnd()) { 1602 itValues.vector() *= factor(i); 1603 itValues.next(); 1604 } 1548 dataIn *= factor[i]; 1605 1549 } else { 1606 Array<Float> valuesIn2 = valuesIn(start,end); 1607 valuesIn2 *= factor(i); 1608 valuesIn(start,end) = valuesIn2; 1550 MaskedArray<Float> dataIn2 = dataIn(start,end); // reference 1551 dataIn2 *= factor[i]; 1609 1552 } 1610 1553 … … 1612 1555 1613 1556 SDContainer sc = in.getSDContainer(i); 1614 putDataInSDC(sc, valuesIn, maskIn);1557 putDataInSDC(sc, dataIn.getArray(), dataIn.getMask()); 1615 1558 // 1616 1559 pTabOut->putSDContainer(sc);
Note:
See TracChangeset
for help on using the changeset viewer.