Source
696
696
697
697
// The indexer is now ready for plotting
698
698
indexerReady_ = true;
699
699
}
700
700
701
701
void PlotMSIndexer::reindexForConnect() {
702
702
// Need points reordered for connecting points.
703
703
// get set of times, spws, corrs, ant1s
704
704
std::set<casacore::Double> times;
705
705
std::set<casacore::Int> spws, corrs, ant1s;
706
-
std::map<casacore::Double, casacore::Int> spwPerTime;
707
706
std::map<casacore::Int, casacore::Int> chansPerSpw;
708
-
getConnectSetsMaps(times, spws, corrs, ant1s, spwPerTime, chansPerSpw);
707
+
getConnectSetsMaps(times, spws, corrs, ant1s, chansPerSpw);
709
708
710
709
// If iteraxis, only use points for current iteration
711
710
Int npoints(nCumulPoints_(nSegment_-1));
712
711
Vector<bool> itermask(npoints, true);
713
712
if (iterAxis_ != PMS::NONE) {
714
713
if (iterAxis_ == PMS::ANTENNA) {
715
714
for (Int ipt=0; ipt<npoints; ++ipt) {
716
715
setChunk(ipt, true);
717
716
if (plotmscache_->getAnt1(currChunk_, getIndex0010(currChunk_, irel_)) != iterValue_)
718
717
itermask(ipt) = false;
763
762
if (isGSpline)
764
763
nSegment_ = (spws.size() * corrs.size() * ant1s.size());
765
764
else
766
765
nSegment_ = (totalSpwChans * corrs.size() * ant1s.size());
767
766
break;
768
767
case PMS::SPW:
769
768
nSegment_ = (times.size() * maxChans * corrs.size() * ant1s.size());
770
769
break;
771
770
case PMS::CHANNEL:
772
771
case PMS::FREQUENCY:
773
-
if (spwPerTime.empty()) // spw or time iter
774
-
nSegment_ = (times.size() * spws.size() * corrs.size() * ant1s.size());
775
-
else
776
-
nSegment_ = (spwPerTime.size() * corrs.size() * ant1s.size());
772
+
nSegment_ = (times.size() * spws.size() * corrs.size() * ant1s.size());
777
773
break;
778
774
case PMS::CORR:
779
775
nSegment_ = (times.size() * totalSpwChans * ant1s.size());
780
776
break;
781
777
case PMS::ANTENNA1:
782
778
nSegment_ = (times.size() * totalSpwChans * corrs.size());
783
779
break;
784
780
default:
785
781
nSegment_ = (times.size() * totalSpwChans * corrs.size() * ant1s.size());
786
782
break;
798
794
} else switch (currentX_) {
799
795
case PMS::TIME:
800
796
if (isGSpline) reindexForTimeConnectNoChans(spws, corrs, ant1s, itermask);
801
797
else reindexForTimeConnect(spws, chansPerSpw, corrs, ant1s, itermask);
802
798
break;
803
799
case PMS::SPW:
804
800
reindexForSpwConnect(times, maxChans, corrs, ant1s, itermask);
805
801
break;
806
802
case PMS::CHANNEL:
807
803
case PMS::FREQUENCY:
808
-
if (spwPerTime.empty()) // spw or time iter
809
-
reindexForChannelConnect(times, spws, corrs, ant1s, itermask);
810
-
else
811
-
reindexForChannelConnect(spwPerTime, corrs, ant1s, itermask);
804
+
reindexForChannelConnect(times, spws, corrs, ant1s, itermask);
812
805
break;
813
806
case PMS::CORR:
814
807
reindexForCorrConnect(times, spws, chansPerSpw, ant1s, itermask);
815
808
break;
816
809
case PMS::ANTENNA1:
817
810
reindexForAnt1Connect(times, spws, chansPerSpw, corrs, itermask);
818
811
break;
819
812
default:
820
813
reindexForAllConnect(times, spws, chansPerSpw, corrs, ant1s, itermask);
821
814
break;
826
819
nCumulPoints_.resize(nSegment_);
827
820
nCumulPoints_(0) = nSegPoints_(0);
828
821
for (Int iseg=1; iseg<nSegment_; ++iseg)
829
822
nCumulPoints_(iseg) = nCumulPoints_(iseg-1) + nSegPoints_(iseg);
830
823
nPoints_.reference(nSegPoints_);
831
824
nCumulative_.reference(nCumulPoints_);
832
825
connectReady_ = true;
833
826
}
834
827
835
828
void PlotMSIndexer::getConnectSetsMaps(std::set<Double>& times, std::set<Int>& spws,
836
-
std::set<Int>& corrs, std::set<Int>& ant1s, std::map<casacore::Double, casacore::Int>& spwPerTime,
829
+
std::set<Int>& corrs, std::set<Int>& ant1s,
837
830
std::map<casacore::Int, casacore::Int>& chansPerSpw) {
838
831
// We need these values if the axis is not the x-axis, unless it is the iteraxis
839
832
bool timeconnect(itsXConnect_ != "none" && itsTimeConnect_);
840
833
bool needTime(true), needSpw(true), needChan(true), needCorr(true), needAnt1(true);
841
834
PMS::Axis connectAxes[] = { PMS::TIME, PMS::SPW, PMS::CHANNEL, PMS::CORR, PMS::ANTENNA1 };
842
835
for (PMS::Axis axis : connectAxes) {
843
836
bool connectX(axis == currentX_), axisIsIter(axis == iterAxis_);
844
837
if (axis==PMS::CHANNEL)
845
838
connectX = ((currentX_==PMS::CHANNEL) || (currentX_==PMS::FREQUENCY));
846
839
if (timeconnect) connectX = false; // do not connect along X axis
885
878
if (plotmscache_->calType() == "GSPLINE")
886
879
needChan = false; // axis not loaded
887
880
888
881
for (uInt chunk : cacheChunk_) {
889
882
Double time = plotmscache_->time(chunk);
890
883
casacore::Int spw = plotmscache_->spw(chunk);
891
884
if (needTime)
892
885
times.insert(time);
893
886
if (needSpw)
894
887
spws.insert(spw);
895
-
if (needTime && needSpw)
896
-
spwPerTime[time] = spw;
897
888
if (needChan)
898
889
chansPerSpw[spw] = plotmscache_->chan(chunk).size();
899
890
if (needCorr) {
900
891
Vector<Int> corr(plotmscache_->corr(chunk));
901
892
for (Int thiscorr : corr) corrs.insert(thiscorr);
902
893
}
903
894
if (needAnt1) {
904
895
Vector<Int> ant1(plotmscache_->ant1(chunk));
905
896
for (Int thisant : ant1) ant1s.insert(thisant);
906
897
}
1124
1115
}
1125
1116
}
1126
1117
}
1127
1118
}
1128
1119
}
1129
1120
}
1130
1121
}
1131
1122
reindexBins(npoints, &newCacheChunk[0], &newCacheOffset[0]);
1132
1123
}
1133
1124
1134
-
void PlotMSIndexer::reindexForChannelConnect(std::map<Double, Int>& spwPerTime, std::set<Int>& corrs,
1135
-
std::set<Int>& ant1s, Vector<bool>& itermask) {
1136
-
// Sort into bins with same times, spws, corrs, ant1s then reindex
1137
-
uInt npoints(itermask.size());
1138
-
std::vector<casacore::uInt> newCacheChunk[nSegment_], newCacheOffset[nSegment_];
1139
-
Int iseg;
1140
-
bool foundbin(false); // each point goes into one particular bin
1141
-
for (uInt ipt=0; ipt<npoints; ++ipt) {
1142
-
if (itermask(ipt)) { // only use point if correct iteration
1143
-
setChunk(ipt, true);
1144
-
iseg = -1;
1145
-
foundbin = false;
1146
-
for (auto& spwtime : spwPerTime) {
1147
-
if (foundbin) break;
1148
-
Double time = spwtime.first;
1149
-
Int spw = spwtime.second;
1150
-
for (Int corr : corrs) {
1151
-
if (foundbin) break;
1152
-
for (Int ant1 : ant1s) {
1153
-
++iseg;
1154
-
if ((plotmscache_->getTime(currChunk_, getIndex0000(currChunk_, irel_)) == time) &&
1155
-
(plotmscache_->getSpw(currChunk_, getIndex0000(currChunk_, irel_)) == spw) &&
1156
-
(plotmscache_->getCorr(currChunk_, getIndex1000(currChunk_, irel_)) == corr) &&
1157
-
(plotmscache_->getAnt1(currChunk_, getIndex0010(currChunk_, irel_)) == ant1)) {
1158
-
newCacheChunk[iseg].push_back(currChunk_);
1159
-
newCacheOffset[iseg].push_back(irel_);
1160
-
++nSegPoints_(iseg);
1161
-
foundbin = true;
1162
-
break;
1163
-
}
1164
-
}
1165
-
}
1166
-
}
1167
-
}
1168
-
}
1169
-
reindexBins(npoints, &newCacheChunk[0], &newCacheOffset[0]);
1170
-
}
1171
-
1172
1125
void PlotMSIndexer::reindexForCorrConnect(std::set<Double>& times, std::set<Int>& spws, std::map<Int,Int>& chans,
1173
1126
std::set<Int>& ant1s, Vector<bool>& itermask) {
1174
1127
// Sort into bins with same times, spws, chans, ant1s then reindex
1175
1128
uInt npoints(itermask.size());
1176
1129
std::vector<casacore::uInt> newCacheChunk[nSegment_], newCacheOffset[nSegment_];
1177
1130
Int iseg(-1);
1178
1131
bool foundbin(false); // each point goes into one particular bin
1179
1132
for (uInt ipt=0; ipt<npoints; ++ipt) {
1180
1133
if (itermask(ipt)) { // only use point if correct iteration
1181
1134
setChunk(ipt, true);