Line data Source code
1 : // -*- C++ -*-
2 : //# BaselineType.cc: Implementation of the PhaseGrad class
3 : //# Copyright (C) 1997,1998,1999,2000,2001,2002,2003
4 : //# Associated Universities, Inc. Washington DC, USA.
5 : //#
6 : //# This library is free software; you can redistribute it and/or modify it
7 : //# under the terms of the GNU Library General Public License as published by
8 : //# the Free Software Foundation; either version 2 of the License, or (at your
9 : //# option) any later version.
10 : //#
11 : //# This library is distributed in the hope that it will be useful, but WITHOUT
12 : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 : //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14 : //# License for more details.
15 : //#
16 : //# You should have received a copy of the GNU Library General Public License
17 : //# along with this library; if not, write to the Free Software Foundation,
18 : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
19 : //#
20 : //# Correspondence concerning AIPS++ should be addressed as follows:
21 : //# Internet email: aips2-request@nrao.edu.
22 : //# Postal address: AIPS++ Project Office
23 : //# National Radio Astronomy Observatory
24 : //# 520 Edgemont Road
25 : //# Charlottesville, VA 22903-2475 USA
26 : //#
27 : //# $Id$
28 : //
29 :
30 :
31 : /*
32 :
33 : The intent of BaselineType Object is two fold
34 :
35 : 1. Based on the type of the telescope and antenna define an enumerated baseline Type
36 : 2. This is also the location where PhaseGrad for the Pointing Table for a given BlType
37 : calculated.
38 :
39 : The first point is still an action time to finish. This will allow for CF production
40 : for a truly heterogenous array, such as ALMA.
41 : The second however is what the rest of the code here is accomplishing. We compute
42 : the number of antenna groups that have a clustered pointing value based on nsigma
43 : binning criterion from the user. We then parse the pointing Table and determine the
44 : variance of the antennnas after subtracting the mean pointing direction. We then bin
45 : the antennas based on their deviation from the mean into one of the bins. This defines
46 : our antenna groups. We will then utilize nG + nG C 2 number of phase gradients during
47 : imaging with doPointing=True
48 :
49 :
50 : */
51 :
52 : #include <synthesis/TransformMachines2/BaselineType.h>
53 : #include <casacore/casa/Logging/LogIO.h>
54 : #include <casacore/casa/Logging/LogSink.h>
55 : #include <casacore/casa/Logging/LogOrigin.h>
56 : #include <casacore/scimath/Mathematics/Combinatorics.h>
57 : #include <casacore/casa/Arrays/Array.h>
58 : #include <casacore/casa/Arrays/ArrayMath.h>
59 : #include <casacore/casa/BasicSL/Constants.h>
60 : using namespace casacore;
61 : namespace casa{
62 : using namespace refim;
63 0 : BaselineType::~BaselineType()
64 : {
65 0 : vectorPhaseGradCalculator_p.resize(0);
66 0 : };
67 :
68 : // -----------------------------------------------------------------
69 :
70 0 : BaselineType::BaselineType(): vbRows_p(), doPointing_p(true), cachedGroups_p(false), vectorPhaseGradCalculator_p(), totalGroups_p(0), antennaGroups_p(), cachedAntennaGroups_p() , vbRow2BLMap_p(), cachedPointingOffsets_p(), cachedAntPointingOffsets_p(), antPair_p(), binsx_p(), binsy_p()
71 : {
72 0 : newPhaseGradComputed_p = false;
73 0 : vectorPhaseGradCalculator_p.resize(0);
74 0 : mapBLGroup_p.resize(0,0);
75 0 : binsx_p = 0;
76 0 : binsy_p = 0;
77 0 : };
78 :
79 0 : BaselineType& BaselineType::operator=(const BaselineType& other)
80 : {
81 0 : if(this!=&other)
82 : {
83 0 : vectorPhaseGradCalculator_p = other.vectorPhaseGradCalculator_p;
84 :
85 : }
86 0 : return *this;
87 :
88 : };
89 :
90 0 : vector< vector<double> > BaselineType::pairSort(const vector<int>& antArray, const vector<vector<double> >& poArray)
91 : {
92 0 : int n = antArray.size();
93 0 : pair<int, vector<double> > pairt[antArray.size()];
94 :
95 : // Storing the respective array
96 : // elements in pairs.
97 0 : for (int i = 0; i < n; i++)
98 : {
99 0 : pairt[i].first = antArray[i];
100 0 : pairt[i].second = {poArray[0][i],poArray[1][i]};
101 : }
102 :
103 : // Sorting the pair array.
104 0 : sort(pairt, pairt + n);
105 :
106 0 : vector <vector<double> > tempPOArray;
107 0 : tempPOArray.resize(poArray.size());
108 0 : tempPOArray[0].resize(poArray[0].size());
109 0 : tempPOArray[1].resize(poArray[1].size());
110 0 : vector<double> tempvec;
111 0 : for (int i = 0; i < n; i++)
112 : {
113 0 : tempvec = pairt[i].second;
114 0 : tempPOArray[0][i] = tempvec[0];
115 0 : tempPOArray[1][i] = tempvec[1];
116 : }
117 :
118 0 : return tempPOArray;
119 :
120 : }
121 :
122 0 : int BaselineType::returnIdx(const vector<int>& inpArray, const int& searchVal)
123 : {
124 :
125 : // cerr << "============================================" << endl;
126 : // for(unsigned int idx=0;idx < inpArray.size(); idx++)
127 : // cerr << "inpArray[idx] " << inpArray[idx] << " " << searchVal << endl;
128 : // cerr << "============================================" << endl;
129 :
130 0 : auto itrBLMap_p = find(inpArray.begin(),inpArray.end(), searchVal);
131 0 : int idx = distance(inpArray.begin(), itrBLMap_p);
132 0 : return idx;
133 :
134 :
135 : // for(unsigned int idx=0;idx < inpArray.size(); idx++)
136 : // {
137 : // if(inpArray[idx] == searchVal)
138 : // {
139 : // return idx;
140 : // }
141 : // else
142 : // {
143 : // return -1;
144 : // }
145 : // }
146 : }
147 :
148 0 : Vector<Vector<double> > BaselineType::stl2DVecToCasa2DVec (const vector<vector<double> >& stlVec)
149 : {
150 0 : int xrange = stlVec.size();
151 0 : int yrange = stlVec[0].size();
152 0 : Vector < Vector<double> > casVec;
153 0 : casVec.resize(xrange,0);
154 0 : for (int ii = 0; ii<xrange; ii++)
155 : {
156 0 : casVec(ii).resize(yrange,0);
157 0 : for (int jj=0; jj<yrange; jj++)
158 0 : casVec(ii)(jj) = stlVec[ii][jj];
159 : }
160 :
161 0 : return casVec;
162 : }
163 :
164 :
165 0 : Matrix<vector<int> > BaselineType::findAntennaGroups(const vi::VisBuffer2& vb,
166 : const CountedPtr<PointingOffsets>& pointingOffsets_p,
167 : const double& sigmaDev)
168 : {
169 0 : if (doPointing_p==false) return antennaGroups_p;
170 0 : else if(!cachedGroups_p)
171 : {
172 0 : totalGroups_p = 0;
173 : // const Int nRows = vb.nRows();
174 0 : cachedPointingOffsets_p.assign(pointingOffsets_p->pullPointingOffsets());
175 0 : vector< vector <double> > antDirPix_l = pointingOffsets_p->fetchAntOffsetToPix(vb, doPointing_p);
176 0 : cachedAntPointingOffsets_p.reference(stl2DVecToCasa2DVec(antDirPix_l));
177 0 : MVDirection vbdir=vb.direction1()(0).getValue();
178 0 : vector<double> phaseDirPix_l = (pointingOffsets_p->toPix(vb,vbdir,vbdir)).tovector();
179 :
180 : // Step 1 the problem scale is smaller than what we want to solve.
181 : // so we find the unique antennas per VB for the join of antenna1 and antenna2.
182 :
183 0 : vector<int> uniqueAnt1, uniqueAnt2;
184 0 : vector<int>::iterator ant1Itr, ant2Itr;
185 0 : uniqueAnt1 = (vb.antenna1()).tovector();
186 0 : uniqueAnt2 = (vb.antenna2()).tovector();
187 :
188 0 : uniqueAnt1.insert(uniqueAnt1.begin(),uniqueAnt2.begin(),uniqueAnt2.end());
189 0 : sort(uniqueAnt1.begin(),uniqueAnt1.end());
190 0 : ant1Itr = unique(uniqueAnt1.begin(),uniqueAnt1.end());
191 0 : uniqueAnt1.resize(distance(uniqueAnt1.begin(),ant1Itr));
192 :
193 :
194 :
195 0 : vector< vector <double> > poAnt1(2), poAnt2(2);
196 0 : for(unsigned int ii=0; ii<poAnt1.size();ii++)
197 : {
198 0 : poAnt1[ii].resize(poAnt1[ii].size(),0);
199 0 : poAnt2[ii].resize(poAnt2[ii].size(),0);
200 : }
201 :
202 0 : poAnt1[0] = antDirPix_l[0];
203 0 : poAnt1[1] = antDirPix_l[1];
204 : // poAnt2[0] = antDirPix_l[2];
205 : // poAnt2[1] = antDirPix_l[3];
206 :
207 :
208 :
209 0 : vector<double> pixSum(2,0), pixMean(2,0), pixVar(2,0), pixSigma(2,0), minPO(2,0), maxPO(2,0), minAntPO(2,0);
210 0 : vector<vector<double> > diffAntPointing_l(2), antGrdPointing_l(2), minDiffAntPointing_l(2);
211 0 : Vector<Vector<double> > casa_antGrdPointing_l(2);
212 :
213 0 : diffAntPointing_l[0].resize(poAnt1[0].size());
214 0 : diffAntPointing_l[1].resize(poAnt1[1].size());
215 0 : antGrdPointing_l[0].resize(poAnt1[0].size());
216 0 : antGrdPointing_l[1].resize(poAnt1[1].size());
217 0 : casa_antGrdPointing_l[0].resize(poAnt1[0].size());
218 0 : casa_antGrdPointing_l[1].resize(poAnt1[1].size());
219 :
220 0 : minAntPO[0] = *min_element(poAnt1[0].begin(), poAnt1[0].end());
221 0 : minAntPO[1] = *min_element(poAnt1[1].begin(), poAnt1[1].end());
222 :
223 :
224 : // cerr << "#################################"<<endl;
225 0 : for (unsigned int i=0; i<uniqueAnt1.size();i++)
226 : {
227 : // // diffAntPointing_l[0][i] = poAnt1[0][i] - phaseDirPix_l[0];
228 : // // diffAntPointing_l[1][i] = poAnt1[1][i] - phaseDirPix_l[1];
229 0 : diffAntPointing_l[0][i] = poAnt1[0][i] - minAntPO[0];
230 0 : diffAntPointing_l[1][i] = poAnt1[1][i] - minAntPO[1];
231 :
232 : // cerr << "Ant "<< uniqueAnt1[i] << " PO: "<< poAnt1[0][i] - phaseDirPix_l[0] << " " << poAnt1[1][i] - phaseDirPix_l[1] <<endl;
233 : }
234 : // cerr << "#################################"<<endl;
235 :
236 :
237 0 : for(unsigned int ii=0; ii < pixSum.size();ii++)
238 : {
239 :
240 0 : pixSum[ii] = accumulate(poAnt1[ii].begin(),poAnt1[ii].end(),0.0);
241 0 : pixMean[ii] = pixSum[ii]/poAnt1[ii].size();
242 :
243 0 : for(unsigned int jj=0; jj < poAnt1[ii].size(); jj++)
244 : {
245 0 : pixVar[ii] += (poAnt1[ii][jj] - pixMean[ii])*(poAnt1[ii][jj] - pixMean[ii]);
246 : }
247 : // for_each (poAnt1[ii].begin(), poAnt1[ii].end(), [&](const double d) {
248 : // pixVar[ii] += (d - phaseDirPix_l[0]) * (d - phaseDirPix_l[0]);
249 : // });
250 : //pixMean[ii] = (pixSum[ii] - poAnt1[ii].size()*phaseDirPix_l[ii])/poAnt1[ii].size();
251 0 : pixSigma[ii] = sqrt(pixVar[ii])/poAnt1[ii].size();
252 :
253 : // maxPO[ii] = *max_element(poAnt1[ii].begin(), poAnt1[ii].end());
254 : // minPO[ii] = *min_element(poAnt1[ii].begin(), poAnt1[ii].end());
255 0 : maxPO[ii] = *max_element(diffAntPointing_l[ii].begin(), diffAntPointing_l[ii].end());
256 0 : minPO[ii] = *min_element(diffAntPointing_l[ii].begin(), diffAntPointing_l[ii].end());
257 :
258 : }
259 : // cerr << "Maximum Pointing offset was : "<< maxPO[0] << " "<< maxPO[1]<< " " <<ceil ((maxPO[0] - minPO[0])/sigmaDev) << endl;
260 : // cerr << "Minimum Pointing offset was : "<< minPO[0] << " "<< minPO[1]<< " " <<ceil ((maxPO[1] - minPO[1])/sigmaDev)<< endl;
261 : // The single loop above computes all the statistics we need.
262 :
263 : // pixSum[1] = accumulate(poAnt1[1].begin(),poAnt1[1].end(),0.0);
264 : // pixMean[0] = pixSum[0]/poAnt1[0].size();
265 : // pixMean[1] = pixSum[1]/poAnt1[1].size();
266 :
267 :
268 :
269 :
270 : // double combinedSigma = sqrt(pixSigma[0]*pixSigma[0] + pixSigma[1]*pixSigma[1]);
271 : // // if(combinedSigma > sigmaDev)
272 :
273 : // cerr << "Bin Size in pixels : "<< sigmaDev << endl;
274 :
275 0 : binsx_p = ceil((fabs(maxPO[0] - minPO[0])/sigmaDev)+1);
276 0 : binsy_p = ceil((fabs(maxPO[1] - minPO[1])/sigmaDev)+1);
277 :
278 0 : deltaBinsX_p = sigmaDev;
279 0 : deltaBinsX_p = sigmaDev;
280 :
281 0 : if (binsx_p%2==0) binsx_p++;
282 0 : if (binsy_p%2==0) binsy_p++;
283 :
284 : // cerr <<"Binsx : "<<binsx_p <<" Binsy : "<<binsy_p<<endl;
285 0 : antennaGroups_p.resize(binsx_p,binsy_p);
286 0 : Matrix<vector<float> > meanAntGrdPO_l(binsx_p,binsy_p);
287 0 : meanAntGrdPO_l.resize(binsx_p,binsy_p);
288 : // cerr << "AntennaGroups_p shape : "<<antennaGroups_p.shape()<<endl;
289 0 : for(int ii=0; ii < binsx_p; ii++)
290 0 : for(int jj=0; jj < binsy_p; jj++)
291 : {
292 0 : antennaGroups_p(ii,jj).resize(0);
293 0 : meanAntGrdPO_l(ii,jj).resize(2,0);
294 : }
295 :
296 : int ii,jj;
297 : // int xOrigin=floor(binsx_p/2.0), yOrigin=floor(binsy_p/2.0);
298 : // // cerr <<"xOrigin : "<<xOrigin <<" yOrigin : "<<yOrigin<<endl;
299 : // int poGridOriginX = floor (maxPO[0] - minPO[0])/2.0 , poGridOriginY = floor (maxPO[1] - minPO[1])/2.0 ;
300 :
301 : // cerr <<"poGridOriginX : "<<poGridOriginX <<" poGridOriginY : "<<poGridOriginY<<endl;
302 0 : for(unsigned int kk=0; kk < poAnt1[0].size(); kk++)
303 : {
304 : // ii = max(0,min((int)(diffAntPointing_l[0][kk]/sigmaDev + xOrigin), binsx_p-1));
305 : // jj = max(0,min((int)(diffAntPointing_l[1][kk]/sigmaDev + yOrigin), binsy_p-1));
306 : // ii = (int)(diffAntPointing_l[0][kk]/sigmaDev + xOrigin);
307 : // jj = (int)(diffAntPointing_l[1][kk]/sigmaDev + yOrigin);
308 :
309 0 : ii = floor(diffAntPointing_l[0][kk]/sigmaDev);
310 0 : jj = floor(diffAntPointing_l[1][kk]/sigmaDev);
311 :
312 : // cerr << ii << " " << jj << " " << diffAntPointing_l[0][kk]/sigmaDev + minAntPO[0]<< " " <<diffAntPointing_l[1][kk]/sigmaDev + minAntPO[1]<< " " << antennaGroups_p(ii,jj).size() << " " <<endl;
313 :
314 : // cerr << ii << " " << jj << " " << poAnt1[0][kk]/pixSigma[0] << " " <<poAnt1[1][kk]/pixSigma[1] << " " << antennaGroups_p(ii,jj).size() << endl;
315 : // cerr << ii << " " << jj<< " " << poAnt1[0][kk] << " "<< poAnt1[0][kk] << endl;
316 0 : antennaGroups_p(ii,jj).push_back(uniqueAnt1[kk]);
317 0 : antGrdPointing_l[0][kk] = minAntPO[0] + (ii-1)*sigmaDev;
318 0 : antGrdPointing_l[1][kk] = minAntPO[1] + (jj-1)*sigmaDev;
319 :
320 0 : meanAntGrdPO_l(ii,jj)[0] += poAnt1[0][kk];
321 0 : meanAntGrdPO_l(ii,jj)[1] += poAnt1[1][kk];
322 : // casa_antGrdPointing_l(0)(kk) = minAntPO[0] + (ii-1)*sigmaDev;
323 : // casa_antGrdPointing_l(1)(kk) = minAntPO[1] + (jj-1)*sigmaDev;
324 :
325 : // antGrdPointing_l[0][kk] = poGridOriginX + (ii-1)*sigmaDev;
326 : // antGrdPointing_l[1][kk] = poGridOriginY + (jj-1)*sigmaDev;
327 :
328 : }
329 :
330 0 : for(int ii=0; ii<binsx_p; ii++)
331 0 : for(int jj=0; jj<binsy_p; jj++)
332 0 : if (antennaGroups_p(ii,jj).size() > 0)
333 : {
334 0 : meanAntGrdPO_l(ii,jj)[0] = meanAntGrdPO_l(ii,jj)[0]/antennaGroups_p(ii,jj).size();
335 0 : meanAntGrdPO_l(ii,jj)[1] = meanAntGrdPO_l(ii,jj)[1]/antennaGroups_p(ii,jj).size();
336 : }
337 0 : for(unsigned int kk=0; kk < uniqueAnt1.size(); kk++)
338 0 : for(int ii=0; ii<binsx_p; ii++)
339 0 : for(int jj=0; jj<binsy_p; jj++)
340 0 : if(!antennaGroups_p(ii,jj).empty())
341 0 : if(find(antennaGroups_p(ii,jj).begin(),antennaGroups_p(ii,jj).end(),uniqueAnt1[kk]) != antennaGroups_p(ii,jj).end())
342 : {
343 0 : casa_antGrdPointing_l(0)(kk) = meanAntGrdPO_l(ii,jj)[0];
344 0 : casa_antGrdPointing_l(1)(kk) = meanAntGrdPO_l(ii,jj)[1];
345 : // cerr << "AG: " << ii << " " << jj << " " << antennaGroups_p(ii,jj).size() << " with PO " << meanAntGrdPO_l(ii,jj)[0] << " "<< meanAntGrdPO_l(ii,jj)[1] << endl;
346 : }
347 :
348 : // cerr << "AG: " << ii << " " << jj << " " << antennaGroups_p(ii,jj).size() << " with PO " << poGridOriginX + (ii-1)*sigmaDev << " " << poGridOriginY + (jj-1)*sigmaDev << endl;
349 0 : pointingOffsets_p->setAntGridPointingOffsets(casa_antGrdPointing_l);
350 : {
351 0 : LogIO log_l(LogOrigin("BaselineType", "findAntennaGroups"));
352 0 : ostringstream ostr;
353 :
354 0 : for(int ii=0; ii<binsx_p; ii++)
355 0 : for(int jj=0; jj<binsy_p; jj++)
356 0 : if(antennaGroups_p(ii,jj).size() > 0)
357 : {
358 0 : totalGroups_p += 1;
359 0 : ostr <<"Antenna in bin " << totalGroups_p << " is : ";
360 0 : for (unsigned int kk=0;kk<antennaGroups_p(ii,jj).size();kk++)
361 0 : ostr <<antennaGroups_p(ii,jj).at(kk)<<" ";
362 0 : ostr << endl;
363 : }
364 0 : log_l << ostr.str() << LogIO::POST;
365 : }
366 : // cerr << "total groups " <<totalGroups_p<<endl;
367 0 : cacheAntGroups(antennaGroups_p);
368 0 : return antennaGroups_p;
369 : }
370 : else
371 : {
372 : // cerr<<"Utilizing cachedAntennaGroups_p"<<endl;
373 0 : return cachedAntennaGroups_p;
374 :
375 : }
376 :
377 : }
378 :
379 :
380 0 : void BaselineType::cacheAntGroups(const Matrix<vector<int> > antennaGroups_p)
381 : {
382 :
383 0 : const int nx = antennaGroups_p.nrow(), ny = antennaGroups_p.ncolumn();
384 0 : cachedAntennaGroups_p.resize(nx,ny);
385 0 : cachedAntennaPO_p.resize(nx,ny);
386 0 : for (int ii=0; ii < nx; ii++)
387 0 : for (int jj=0; jj < ny; jj++)
388 : {
389 0 : int vecLen = antennaGroups_p(ii,jj).size();
390 0 : cachedAntennaGroups_p(ii,jj).resize(vecLen);
391 :
392 0 : for (int kk=0; kk<vecLen; kk++)
393 : {
394 0 : cachedAntennaGroups_p(ii,jj)[kk] = antennaGroups_p(ii,jj)[kk];
395 : }
396 : }
397 0 : cachedGroups_p=true;
398 :
399 0 : }
400 :
401 :
402 0 : void BaselineType::makeVBRow2BLGMap(const vi::VisBuffer2& vb)
403 : // const Matrix<vector<int> >& antennaGroups_p)
404 : {
405 :
406 : /* The goal here is take the antenna groups given a vb and return a baseline group
407 : map for every VB row. This will then allow for the computation of the phase grad
408 : once per phase grad per vb. */
409 :
410 0 : const Int nRows=vb.nRows();
411 0 : const Int nx = cachedAntennaGroups_p.nrow(), ny = cachedAntennaGroups_p.ncolumn();
412 0 : Int numAntGroups=0;
413 0 : vector<int> mapAntType1, mapAntType2;
414 0 : const Vector<Int> antenna1 = vb.antenna1(), antenna2 = vb.antenna2();
415 :
416 0 : mapAntGrp_p.resize(nx,ny);
417 0 : mapAntType1.resize(nRows);
418 0 : mapAntType2.resize(nRows);
419 0 : vbRow2BLMap_p.resize(nRows);
420 :
421 0 : antPair_p.resize(nRows,make_pair(0,0));
422 : // for (int kk=0; kk<nRows;kk++)
423 : // {
424 : // antPair_p[kk].first = mapAntType1[kk];
425 : // antPair_p[kk].second = mapAntType2[kk];
426 : // }
427 :
428 0 : blNeedsNewPOPG_p.resize(nRows);
429 0 : vector<int> uniqueBLType_p(nRows,0);
430 0 : for(int ii=0; ii<nRows;ii++)
431 0 : blNeedsNewPOPG_p[ii]=false;
432 :
433 0 : for (int ii=0; ii < nx; ii++)
434 0 : for (int jj=0; jj < ny; jj++)
435 : {
436 0 : mapAntGrp_p(ii,jj)=0;
437 0 : if(cachedAntennaGroups_p(ii,jj).size() > 0)
438 : {
439 0 : numAntGroups++;
440 0 : mapAntGrp_p(ii,jj) = numAntGroups;
441 : }
442 : }
443 :
444 : // cout<<"mapAntGrp "<<mapAntGrp_p<<endl;
445 0 : if(numAntGroups > 0) // If any cell is populated...
446 : {
447 0 : mapBLGroup_p.resize(numAntGroups,numAntGroups);
448 0 : for (int ii=0; ii < numAntGroups; ii++)
449 0 : for (int jj=0; jj < numAntGroups; jj++)
450 0 : mapBLGroup_p(ii,jj) = ii*numAntGroups+jj+1;
451 : }
452 : else
453 : {
454 0 : mapBLGroup_p.resize(1,1);
455 0 : mapBLGroup_p(0,0) = 0;
456 : }
457 :
458 : // cerr<<"mapBLGrp "<<mapBLGroup_p<< endl <<" numAntGroups " << numAntGroups << " nx,ny " << nx <<" " << ny <<endl;
459 :
460 :
461 : // LogIO log_l(LogOrigin("VB2CFBMap", "makeVBRow2BLGMap[R&D]"));
462 : // log_l << "Number of Baseline Groups found " << (numAntGroups + (numAntGroups*(numAntGroups-1))/2) << LogIO::POST;
463 :
464 0 : for (int kk=0; kk<nRows;kk++)
465 : {
466 0 : for (int ii=0; ii < nx; ii++)
467 0 : for (int jj=0; jj < ny; jj++)
468 : {
469 0 : int n=cachedAntennaGroups_p(ii,jj).size();
470 0 : if( n> 0)
471 : {
472 0 : for(int tt=0; tt < n; tt++)
473 : {
474 0 : if(antenna1[kk] == (cachedAntennaGroups_p(ii,jj))[tt])
475 0 : mapAntType1[kk] = mapAntGrp_p(ii,jj);
476 : // else
477 : // mapAntType1[kk] = -1;
478 :
479 0 : if(antenna2[kk] == (cachedAntennaGroups_p(ii,jj))[tt])
480 0 : mapAntType2[kk] = mapAntGrp_p(ii,jj);
481 : // else
482 : // mapAntType2[kk] = -1;
483 : }
484 : }
485 : }
486 :
487 : }
488 :
489 : // cerr << "Baseline Groups for vb Row are as follows : ";
490 : // for(int ii = 0; ii < mapAntType1.size(); ii++)
491 : // cerr<<mapAntType1[ii]<<" "<<mapAntType2[ii]<<" " <<ii <<endl;
492 : // cerr<<endl<<"#############################################"<<endl;
493 :
494 :
495 :
496 0 : for (int kk=0; kk<nRows;kk++)
497 : {
498 : int ix,iy;
499 0 : ix=mapAntType1[kk]-1;
500 0 : iy=mapAntType2[kk]-1;
501 :
502 0 : if ((ix>=0) && (iy>=0))
503 : {
504 0 : vbRow2BLMap_p[kk] = mapBLGroup_p(ix,iy);
505 0 : antPair_p[kk].first = ix;
506 0 : antPair_p[kk].second = iy;
507 : }
508 : else
509 0 : vbRow2BLMap_p[kk] = -1;
510 : // cerr << "kk : " << kk << " " << ix << " " << iy << " " << vbRow2BLMap_p[kk] << " " << mapBLGroup_p(ix,iy) << endl;
511 : }
512 :
513 :
514 0 : }
515 :
516 :
517 :
518 0 : int BaselineType::numPhaseGrads(const int& nG)
519 : {
520 0 : if(nG<2)
521 0 : return nG;
522 : else
523 0 : return nG + Combinatorics::choose(nG,2);
524 :
525 :
526 : }
527 :
528 : };
|