Commits

Ville Suoranta authored c1ff075e49a Merge
Merge pull request #123 in CASA/casa from bugfix/CAS-10039 to master

* commit '24d9a0cfde99e4aca4b3055eb6b7a09a1dc72e41': Add unit test for single-polarization calibration Bug fix Fix single-polarization data problem Support single-polarization calibration.
No tags

code/synthesis/MeasurementComponents/SingleDishSkyCal.cc

Modified
708 708 }
709 709
710 710 currSpw() = ispw;
711 711 currField() = ifield;
712 712 timeCentroid /= (Double)numSpectra;
713 713 refTime() = timeCentroid;
714 714 interval_ = effectiveExposure;
715 715
716 716 debuglog << "spw " << ispw << ": solveAllRPar.shape=" << solveAllRPar().shape() << " nPar=" << nPar() << " nChanPar=" << nChanPar() << " nElem=" << nElem() << debugpost;
717 717
718 - solveAllRPar() = dataSum.addDegenerate(1);
719 - solveAllParOK() = resultMask.addDegenerate(1);
720 - solveAllParErr() = 0.1; // TODO: this is tentative
721 - solveAllParSNR() = 1.0; // TODO: this is tentative
718 + size_t const nCorr = dataSum.shape()[0];
719 + Cube<Float> const rpar = dataSum.addDegenerate(1);
720 + Cube<Bool> const parOK = resultMask.addDegenerate(1);
721 + for (size_t iCorr = 0; iCorr < nCorr; ++iCorr) {
722 + solveAllRPar().yzPlane(iCorr) = rpar.yzPlane(iCorr);
723 + solveAllParOK().yzPlane(iCorr) = parOK.yzPlane(iCorr);
724 + solveAllParErr().yzPlane(iCorr) = 0.1; // TODO: this is tentative
725 + solveAllParSNR().yzPlane(iCorr) = 1.0; // TODO: this is tentative
726 + }
722 727
723 728 keepNCT();
724 729
725 730 dataSum = 0.0f;
726 731 weightSum = 0.0f;
727 732 resultMask = true;
728 733 timeCentroid = 0.0;
729 734 numSpectra = 0;
730 735 effectiveExposure = 0.0;
731 736 }
768 773 default: {
769 774 throw(AipsError("Internal error(Calibrater Module): Unsupported parameter type "
770 775 "found in SingleDishSkyCal::initSolvePar()"));
771 776 break;
772 777 }
773 778 }//switch
774 779
775 780 solveAllParOK().resize(solveAllRPar().shape());
776 781 solveAllParErr().resize(solveAllRPar().shape());
777 782 solveAllParSNR().resize(solveAllRPar().shape());
778 - solveAllParOK()=true;
783 + solveAllParOK()=false;
779 784 solveAllParErr()=0.0;
780 785 solveAllParSNR()=0.0;
781 786 solveParOK().reference(solveAllParOK());
782 787 solveParErr().reference(solveAllParErr());
783 788 solveParSNR().reference(solveAllParSNR());
784 789 }
785 790 currSpw()=0;
786 791 currAnt_ = 0;
787 792
788 793 interval_.resize(nElem());
1085 1090 }
1086 1091 }
1087 1092
1088 1093 void SingleDishSkyCal::updateWt2(Matrix<Float> &weight, const Int &antenna1)
1089 1094 {
1090 1095 // apply weight scaling factor
1091 1096 Matrix<Float> const factor = currWtScale().xyPlane(antenna1);
1092 1097 debuglog << "factor.shape() = " << factor.shape() << debugpost;
1093 1098 debuglog << "weight.shape() = " << weight.shape() << debugpost;
1094 1099 debuglog << "weight = " << weight << debugpost;
1095 - if (weight.shape() == factor.shape()) {
1096 - weight *= factor;
1097 - }
1098 - else if (weight.shape() == IPosition(2,factor.shape()[0],1)) {
1099 - weight *= factor(Slice(0,factor.shape()[0]),Slice(0,1));
1100 - }
1101 - else {
1102 - throw AipsError("Shape mismatch between input weight and weight scaling factor");
1100 +
1101 + auto const wtShape = weight.shape();
1102 + size_t const nCorr = wtShape[0];
1103 + size_t const nChan = wtShape[1];
1104 + // for each correlation
1105 + for (size_t iCorr = 0; iCorr < nCorr; ++iCorr) {
1106 + auto wSlice = weight.row(iCorr);
1107 + auto const fSlice = factor.row(iCorr);
1108 + if (fSlice.nelements() == nChan) {
1109 + wSlice *= fSlice;
1110 + } else if (nChan == 1) {
1111 + // take mean of spectral weight factor to apply it to scalar weight
1112 + wSlice *= mean(fSlice);
1113 + } else {
1114 + throw AipsError("Shape mismatch between input weight and weight scaling factor");
1115 + }
1103 1116 }
1104 1117 }
1105 1118
1106 1119 //
1107 1120 // SingleDishPositionSwitchCal
1108 1121 //
1109 1122
1110 1123 // Constructor
1111 1124 SingleDishPositionSwitchCal::SingleDishPositionSwitchCal(VisSet& vs)
1112 1125 : VisCal(vs),

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut