Line data Source code
1 : //-*- C++ -*-
2 : //# VB2CFBMap.h: Definition of the VB2CFBMap 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: casa-feedback@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 : #include <synthesis/TransformMachines/SynthesisMath.h>
30 : #include <casacore/casa/Logging/LogIO.h>
31 : #include <casacore/casa/Logging/LogSink.h>
32 : #include <casacore/casa/Logging/LogOrigin.h>
33 : #include <casacore/casa/Arrays/Matrix.h>
34 : #include <casacore/casa/Arrays/Vector.h>
35 : #include <casacore/casa/Arrays/Array.h>
36 : #include <casacore/casa/Utilities/CountedPtr.h>
37 : #include <synthesis/TransformMachines2/CFStore2.h>
38 : #include <synthesis/TransformMachines2/ConvolutionFunction.h>
39 : #include <synthesis/TransformMachines2/CFBuffer.h>
40 : #include <msvis/MSVis/VisBuffer2.h>
41 : #include <synthesis/TransformMachines2/VB2CFBMap.h>
42 : #include <synthesis/TransformMachines2/Utils.h>
43 : namespace casa{
44 : using namespace vi;
45 : namespace refim{
46 0 : Int mapAntIDToAntType(const casacore::Int& /*ant*/) {return 0;};
47 :
48 0 : VB2CFBMap::VB2CFBMap(): vb2CFBMap_p(), cfPhaseGrad_p(), baselineType_p(), vectorPhaseGradCalculator_p(), doPointing_p(false), cachedFieldId_p(-1), vbRow2BLMap_p(), vbRows_p(0), sigmaDev(2), cachedCFBPtr_p(), maxCFShape_p(2), timer_p(),computePhaseScreen_p(true)
49 : {
50 0 : baselineType_p = new BaselineType();
51 0 : needsNewPOPG_p = false;
52 0 : needsNewFieldPG_p = false;
53 0 : totalCost_p=totalVB_p = 0.0;
54 0 : blNeedsNewPOPG_p.resize(0);
55 0 : blType_p=0;
56 0 : vectorPhaseGradCalculator_p.resize(0);
57 : // sigmaDev = SynthesisUtils::getenv("PO_SIGMADEV",3.0);
58 0 : };
59 0 : VB2CFBMap::VB2CFBMap(const VB2CFBMap& other){
60 0 : operator=(other);
61 0 : }
62 :
63 0 : VB2CFBMap& VB2CFBMap::operator=(const VB2CFBMap& other)
64 : {
65 0 : if(this!=&other)
66 : {
67 0 : baselineType_p = other.baselineType_p;
68 0 : cfPhaseGrad_p.assign(other.cfPhaseGrad_p);
69 0 : vb2CFBMap_p.assign(other.vb2CFBMap_p);
70 0 : vbRow2BLMap_p = other.vbRow2BLMap_p;
71 0 : vectorPhaseGradCalculator_p.assign(other.vectorPhaseGradCalculator_p);
72 0 : doPointing_p = other.doPointing_p;
73 0 : computePhaseScreen_p = other.computePhaseScreen_p;
74 : }
75 0 : return *this;
76 : };
77 :
78 :
79 : // void VB2CFBMap::setPhaseGradPerRow(const CountedPtr<PointingOffsets>& pointingOffset,
80 : // const casacore::CountedPtr<CFBuffer>& cfb,
81 : // const vi::VisBuffer2& vb,
82 : // const int& row)
83 : // {
84 : // // if (doPointing_p)
85 : // // {
86 : // // if (phaseGradCalculator_p->needsNewPhaseGrad(pointingOffset, vb, 0))
87 : // // {
88 : // // phaseGradCalculator_p->ComputeFieldPointingGrad(pointingOffset,cfb,vb, 0);
89 : // // newPhaseGradComputed_p=true;
90 : // // }
91 : // // }
92 : // // else
93 : // {
94 : // baselineType_p->phaseGradCalculator_p->ComputeFieldPointingGrad(pointingOffset,cfb,vb, 0);
95 : // }
96 : // {
97 : // //cfPhaseGrad_p(row).assign(phaseGradCalculator_p->getFieldPointingGrad());
98 : // cfPhaseGrad_p(row).reference(baselineType_p->phaseGradCalculator_p->field_phaseGrad_p);
99 : // }
100 : // }
101 :
102 0 : void VB2CFBMap::setBLNeedsNewPOPG(vector<int>& vbRow2BLMap_p)
103 : {
104 0 : blNeedsNewPOPG_p.resize(vbRow2BLMap_p.size(),false);
105 0 : vector<int> uniqueVbRow2BLMap_p = vbRow2BLMap_p;
106 0 : sort(uniqueVbRow2BLMap_p.begin(),uniqueVbRow2BLMap_p.end());
107 0 : auto itrBLMap = unique(uniqueVbRow2BLMap_p.begin(),uniqueVbRow2BLMap_p.end());
108 0 : uniqueVbRow2BLMap_p.erase(itrBLMap,uniqueVbRow2BLMap_p.end());
109 :
110 0 : for(unsigned int ii=0; ii < uniqueVbRow2BLMap_p.size(); ii++)
111 : {
112 0 : int idx = baselineType_p->returnIdx(vbRow2BLMap_p, uniqueVbRow2BLMap_p[ii]);
113 0 : blNeedsNewPOPG_p[idx] = true;
114 : // cerr << "unqVb2BL: "<< uniqueVbRow2BLMap_p[ii] << " ii " << ii << endl;
115 : }
116 :
117 :
118 0 : }
119 :
120 :
121 :
122 : //______________________________________________________
123 :
124 0 : Int VB2CFBMap::makeVBRow2CFBMap(CFStore2& cfs,
125 : const VisBuffer2& vb,
126 : const Quantity& dPA,
127 : const Vector<Int>& /*dataChan2ImChanMap*/,
128 : const Vector<Int>& /*dataPol2ImPolMap*/,
129 : const CountedPtr<PointingOffsets>& pointingOffsets_p)
130 : //const Bool& /*doPointing*/)
131 : {
132 : // VBRow2CFMapType& vbRow2CFMap_p,
133 0 : const Int nRow=vb.nRows();
134 : //UNUSED: nChan=dataChan2ImChanMap.nelements(),
135 : //UNUSED: nPol=dataPol2ImPolMap.nelements();
136 : // vbRow2CFMap_p.resize(nPol, nChan, nRow);
137 0 : vb2CFBMap_p.resize(nRow);
138 0 : cfPhaseGrad_p.resize(nRow);
139 0 : maxCFShape_p.resize(2,0);
140 0 : if(cachedFieldId_p != vb.fieldId()[0])
141 : {
142 0 : needsNewFieldPG_p = true;
143 0 : needsNewPOPG_p = true;
144 0 : baselineType_p->setCachedGroups(false);
145 0 : cachedFieldId_p = vb.fieldId()[0];
146 0 : vectorPhaseGradCalculator_p.resize(0);
147 0 : vbRows_p = vb.nRows();
148 : }
149 : // else if (vbRows_p == 0)
150 : // {
151 : // vbRows_p = vb.nRows();
152 : // baselineType_p->setCachedGroups(false);
153 : // needsNewPOPG_p = false;
154 : // }
155 0 : else if (vbRows_p != vb.nRows())
156 : {
157 0 : vbRows_p = vb.nRows();
158 0 : baselineType_p->setCachedGroups(false);
159 0 : needsNewPOPG_p = true;
160 : }
161 : else
162 : {
163 0 : baselineType_p->setCachedGroups(true);
164 0 : needsNewPOPG_p = false;
165 : }
166 :
167 :
168 0 : Quantity pa(getPA(vb),"rad");
169 : //PolOuterProduct outerProduct;
170 0 : Int statusCode=CFDefs::MEMCACHE;
171 :
172 : // baselineType_p->setCacheGroups(vbRows_p, vb);
173 : // baselineType_p->setCachedGroups(true);
174 0 : baselineType_p->setDoPointing(doPointing_p);
175 :
176 :
177 0 : if(doPointing_p)
178 : {
179 : // cerr<<"VB2CFBMap::makeVBRow2CFBMap DoP = T"<<endl;
180 0 : Float A2R = 4.848137E-06;
181 0 : Vector<Double> poIncrement = pointingOffsets_p->getIncrement();
182 : Double offsetDeviation;
183 0 : if(sigmaDev[0] > 0)
184 0 : offsetDeviation = sigmaDev[0] * A2R / sqrt(poIncrement[0]*poIncrement[0] + poIncrement[1]*poIncrement[1]);
185 : else
186 0 : offsetDeviation = 1e-3*A2R / sqrt(poIncrement[0]*poIncrement[0] + poIncrement[1]*poIncrement[1]);
187 0 : if(sigmaDev[1] == 0)
188 0 : sigmaDev[1] = sigmaDev[0];
189 :
190 0 : baselineType_p->findAntennaGroups(vb,pointingOffsets_p, offsetDeviation);
191 :
192 0 : baselineType_p->makeVBRow2BLGMap(vb);
193 0 : vbRow2BLMap_p = baselineType_p->getVBRow2BLMap();
194 : // if(cachedFieldId_p != vb.fieldId()[0])
195 0 : if(needsNewPOPG_p)
196 : {
197 0 : setBLNeedsNewPOPG(vbRow2BLMap_p);
198 : // cerr << "Setting blNeedsNewPOPG_p" <<endl;
199 : // for (unsigned int ii= 0; ii < blNeedsNewPOPG_p.size();ii++)
200 : // cerr << "row " << ii << " "<<blNeedsNewPOPG_p[ii] << endl;
201 : }
202 :
203 :
204 : // cerr << "vbRow2BLMap_p" ;
205 : // for(int i=0; i <= vbRow2BLMap_p.size(); i++)
206 : // cerr << vbRow2BLMap_p[i]<<" ";
207 : // cerr <<endl;
208 : // cerr << "baselineType->cachedGroups_p : "<< baselineType_p->cachedGroups_p <<endl;
209 0 : if(baselineType_p->getCachedGroups())
210 : {
211 0 : Vector < Vector <Double> > cachedAntPO_l = baselineType_p->getCachedAntennaPO();
212 0 : auto const po_l_v = pointingOffsets_p->fetchAntOffsetToPix(vb, doPointing_p) ;
213 0 : Vector < Vector <Double> > po_l(po_l_v.size());
214 0 : for (size_t i = 0; i < po_l_v.size(); ++i) {
215 0 : po_l[i] = Vector<Double>(po_l_v[i]);
216 : }
217 :
218 0 : unsigned int poShape_X = po_l.shape()[0];
219 0 : unsigned int poShape_Y = po_l(0).shape()[0];
220 0 : unsigned int cachedPOShape_X = cachedAntPO_l.shape()[0];
221 0 : unsigned int cachedPOShape_Y = cachedAntPO_l(0).shape()[0];
222 :
223 0 : Vector<Double> sumResPO_l(2,0), sumAntPO_l(2,0), sumPO_l(2,0);
224 0 : double avgResPO_l = 0.0;
225 : // sumResPO_l.resize(2,0);
226 : // sumAntPO_l.resize(2,0);
227 : // sumPO_l.resize(2,0);
228 :
229 : // cerr << "cachedAntPO_l : " << cachedAntPO_l << endl;
230 : // cerr << "po_l : " << po_l << endl;
231 :
232 : // cerr << " After initialization sumResPO_l "<< sumResPO_l[0] << " sumAntPO_l " << sumAntPO_l[0] <<" sumPO_l " << sumPO_l[0] << endl;
233 :
234 : // cerr << " After initialization sumResPO_l "<< sumResPO_l[1] << " sumAntPO_l " << sumAntPO_l[1] << " sumPO_l " << sumPO_l[1] << endl;
235 :
236 0 : if(poShape_X == cachedPOShape_X && poShape_Y == cachedPOShape_Y)
237 : {
238 0 : Vector < Vector <Double> > residualPointingOffsets_l = cachedAntPO_l - po_l;
239 : // cerr << "residualPointingOffsets_l : " << residualPointingOffsets_l << endl;
240 : // cerr <<"___________________________________________________________________"<<endl;
241 0 : for(unsigned int ii=0; ii < poShape_X; ii++)
242 : {
243 0 : for (unsigned int jj=0; jj < poShape_Y; jj++)
244 : {
245 0 : sumResPO_l[ii] = sumResPO_l[ii] + residualPointingOffsets_l[ii][jj];
246 0 : sumAntPO_l[ii] = sumAntPO_l[ii] + cachedAntPO_l[ii][jj];
247 0 : sumPO_l[ii] = sumPO_l[ii] + po_l[ii][jj];
248 : }
249 : // cerr << " ii " << ii << " sumResPO_l " << sumResPO_l[ii] << " sumAntPO_l " << sumAntPO_l[ii] << " sumPO_l " << sumPO_l[ii] << endl;
250 : }
251 : // cerr <<"___________________________________________________________________"<<endl;
252 :
253 0 : avgResPO_l = sqrt(sumResPO_l[0]*sumResPO_l[0] + sumResPO_l[1]*sumResPO_l[1])/poShape_Y; // The units are in pixels here
254 :
255 0 : if(avgResPO_l*sqrt(poIncrement[0]*poIncrement[0] + poIncrement[1]*poIncrement[1]) >= sigmaDev[1]*A2R)
256 : {
257 0 : baselineType_p->setCachedGroups(false);
258 0 : baselineType_p->findAntennaGroups(vb,pointingOffsets_p, sigmaDev[0]);
259 0 : baselineType_p->setCachedAntennaPO(pointingOffsets_p->pullPointingOffsets());
260 0 : baselineType_p->makeVBRow2BLGMap(vb);
261 0 : vbRow2BLMap_p = baselineType_p->getVBRow2BLMap();
262 0 : setBLNeedsNewPOPG(vbRow2BLMap_p);
263 0 : if (!needsNewFieldPG_p)
264 : {
265 0 : LogIO log_l(LogOrigin("VB2CFBMap", "makeVBRow2CFBMap[R&D]"));
266 :
267 0 : log_l << "The average antenna Offset : " << avgResPO_l*sqrt(poIncrement[0]*poIncrement[0] + poIncrement[1]*poIncrement[1])/A2R
268 0 : << " arcsec, exceeds the second parameter of sigmaDev : " << sigmaDev[1]
269 0 : << " arcsec for Field ID = " << vb.fieldId()(0) << LogIO::POST;
270 :
271 0 : }
272 : // cerr << "Avg of the Residual Pointing Offsets " << avgResPO_l*sqrt(poIncrement[0]*poIncrement[0] + poIncrement[1]*poIncrement[1])/A2R <<endl;
273 : }
274 0 : }
275 : else
276 : {
277 0 : baselineType_p->setCachedGroups(false);
278 0 : needsNewPOPG_p = true;
279 : }
280 :
281 0 : }
282 0 : baselineType_p->setCachedAntennaPO(pointingOffsets_p->pullPointingOffsets());
283 0 : }
284 :
285 : else
286 : {
287 0 : sigmaDev[0] = 0;
288 0 : sigmaDev[1] = 0;
289 : }
290 :
291 0 : for (Int irow=0;irow<nRow;irow++)
292 : {
293 : //
294 : // Translate antenna ID to antenna type
295 : //
296 0 : Int ant1Type = mapAntIDToAntType(vb.antenna1()(irow)),
297 0 : ant2Type = mapAntIDToAntType(vb.antenna2()(irow));
298 : //
299 : // Get the CFBuffer for the given PA and baseline catagorized
300 : // by the two antenna types. For homgeneous arrays, all
301 : // baselines will map to a single antenna-type pair.
302 : //
303 :
304 0 : CountedPtr<CFBuffer> cfb_l;
305 : try
306 : {
307 0 : cfb_l = cfs.getCFBuffer(pa, dPA, ant1Type, ant2Type);
308 :
309 0 : if (cfb_l != cachedCFBPtr_p)
310 : {
311 0 : maxCFShape_p[0] = maxCFShape_p[1] = cfb_l->getMaxCFSize();
312 0 : LogIO alog(LogOrigin("VB2CFBMap", "makeVBRow2CFBMap[R&D]"));
313 0 : alog << "CFBShape changed " << maxCFShape_p << LogIO::DEBUG2 << LogIO::POST;
314 :
315 0 : }
316 0 : cachedCFBPtr_p = cfb_l;
317 : }
318 0 : catch (CFNotCached& x)
319 : {
320 0 : LogIO log_l(LogOrigin("VB2CFBMap", "makeVBRow2CFBMap[R&D]"));
321 :
322 : log_l << "CFs not cached for " << pa.getValue("deg")
323 : << " deg, dPA = " << dPA.getValue("deg")
324 0 : << " Field ID = " << vb.fieldId()(0);
325 0 : log_l << " Ant1Type, Ant2Type = " << ant1Type << "," << ant2Type << LogIO::POST;
326 0 : statusCode=CFDefs::NOTCACHED;
327 0 : }
328 :
329 0 : if (statusCode==CFDefs::NOTCACHED)
330 : {
331 0 : break;
332 : }
333 : else
334 : {
335 : // Set the phase grad for the CF per VB row
336 : // setPhaseGradPerRow(pointingOffsets_p, cfb_l, vb, irow);
337 0 : timer_p.mark();
338 : // if (vbRows_p == 0)
339 : // {
340 : // vbRows_p = vb.nRows();
341 : // baselineType_p->setcachedGroups(false);
342 : // }
343 : // else if (vbRows_p != vb.nRows())
344 : // {
345 : // vbRows_p = vb.nRows();
346 : // baselineType_p->setcachedGroups(false);
347 : // }
348 : // else
349 : // baselineType_p->setcachedGroups_p(true);
350 : // baselineType_p->setCacheGroups(vbRows_p, vb);
351 : // baselineType_p->setDoPointing(doPointing_p);
352 : // if(computeAntennaGroups_p)
353 : // baselineType_p->findAntennaGroups(vb,pointingOffsets_p,sigmaDev);
354 0 : cfPhaseGrad_p(irow).reference(setBLPhaseGrad(pointingOffsets_p, vb, irow, sigmaDev[0]));
355 0 : totalCost_p += timer_p.real();
356 0 : totalVB_p++;
357 : // Set the CFB per VB row
358 0 : cfb_l->setPointingOffset(pointingOffsets_p->pullPointingOffsets());
359 0 : vb2CFBMap_p(irow) = cfb_l;
360 0 : vbRows_p = vb.nRows();
361 : // if( needsNewPOPG_p || needsNewFieldPG_p)
362 : // cerr << "NeedsNewPOPG_p " << needsNewPOPG_p << " NeedsNewFieldPG_p "<< needsNewFieldPG_p << " row " << myrow << endl;
363 :
364 : }
365 0 : }
366 : // {
367 : // double n=0;
368 : // for (int i=0;i<cfPhaseGrad_p.nelements();i++)
369 : // n+=cfPhaseGrad_p[i].shape().product()*sizeof(casacore::Complex);
370 : // log_l << "Size of VB2CFBMap::cfPhaseGrad_p = " << n << " bytes" << LogIO::POST;
371 : // }
372 0 : return statusCode;
373 0 : }
374 :
375 0 : Matrix<Complex> VB2CFBMap::setBLPhaseGrad(const CountedPtr<PointingOffsets>& pointingOffsets_p ,
376 : const vi::VisBuffer2& vb,
377 : const int& row,
378 : const double& /*sigmaDev*/)
379 : {
380 0 : int myrow=row;
381 0 : int idx = 0;
382 0 : if(doPointing_p)
383 : {
384 0 : vector<int> uniqueVbRow2BLMap_p = vbRow2BLMap_p;
385 0 : sort(uniqueVbRow2BLMap_p.begin(),uniqueVbRow2BLMap_p.end());
386 0 : auto itrBLMap = unique(uniqueVbRow2BLMap_p.begin(),uniqueVbRow2BLMap_p.end());
387 0 : uniqueVbRow2BLMap_p.erase(itrBLMap,uniqueVbRow2BLMap_p.end());
388 0 : int maxVB2BLMap = *max_element(uniqueVbRow2BLMap_p.begin(),uniqueVbRow2BLMap_p.end());
389 0 : pair<int,int> antGrp_l = (baselineType_p->getAntGrpPairs(myrow));
390 : // if (myrow==0 )
391 : // {
392 : // blType_p = vbRow2BLMap_p[myrow];
393 : // blNeedsNewPOPG_p[myrow] = true;
394 : // cerr <<"New POPG_p required for vb row : "<< myrow << " vbRow2BLMap_p[row] " << vbRow2BLMap_p[myrow] << endl;
395 : // }
396 : // else if (blType_p != vbRow2BLMap_p[myrow])
397 : // {
398 : // needsNewPOPG_p=true;
399 : // blType_p = vbRow2BLMap_p[myrow];
400 : // // cerr <<"New POPG_p required for vb row : "<< myrow << " vbRow2BLMap_p[row] " << vbRow2BLMap_p[myrow] << endl;
401 : // }
402 : // else
403 : // blNeedsNewPOPG_p[myrow]=false;
404 :
405 : // if (vectorPhaseGradCalculator_p.nelements() <= (unsigned int) vbRow2BLMap_p[row])
406 : // auto itrBLMap_p = find(uniqueVbRow2BLMap_p.begin(),uniqueVbRow2BLMap_p.end(), vbRow2BLMap_p[row]);
407 : // idx = distance(uniqueVbRow2BLMap_p.begin(), itrBLMap_p);
408 :
409 : // cerr<<"#######################" <<endl << "unqVBRow: ";
410 : // for(int ii=0; ii<uniqueVbRow2BLMap_p.size();idx++)
411 : // cerr << uniqueVbRow2BLMap_p[ii] << " " ;
412 : // cerr<<"#######################"<<endl;
413 : // if (vectorPhaseGradCalculator_p.nelements() <= maxVB2BLMap + 1)
414 : // vectorPhaseGradCalculator_p.resize(uniqueVbRow2BLMap_p.size()+1,true);
415 :
416 :
417 0 : vectorPhaseGradCalculator_p.resize(maxVB2BLMap+1,true); // not zero counted hence the plus 1 - PJ
418 : {
419 : // cerr<<"vbRow2BLMap_p [row] doP=T "<< vbRow2BLMap_p[row] << " " <<row << " " << maxVB2BLMap+1 << endl;
420 : // vectorPhaseGradCalculator_p.resize(vbRow2BLMap_p[myrow]+1,true); // Revisit this.
421 0 : for (unsigned int i=0;i<vectorPhaseGradCalculator_p.nelements(); i++)
422 0 : if (vectorPhaseGradCalculator_p[i].null())
423 : {
424 0 : vectorPhaseGradCalculator_p[i]=new PhaseGrad();
425 0 : vectorPhaseGradCalculator_p[i]->needCFPhaseGrad_p=computePhaseScreen_p;
426 : // blNeedsNewPOPG_p[i] = true;
427 : }
428 : }
429 :
430 :
431 : // if( baselineType_p->cachedGroups_p)
432 : // vectorPhaseGradCalculator_p[vbRow2BLMap_p[myrow]]->ComputeFieldPointingGrad(pointingOffsets_p,cfb,vb,0);
433 : // else
434 : // vectorPhaseGradCalculator_p[vbRow2BLMap_p[myrow]]->ComputeFieldPointingGrad(pointingOffsets_p,cfb,vb,row);
435 : // vectorPhaseGradCalculator_p[vbRow2BLMap_p[myrow]]->needsNewPOPG_p = blNeedsNewPOPG_p[myrow];
436 : // needsNewPOPG_p = true;
437 : // vectorPhaseGradCalculator_p[idx]->needsNewPOPG_p = needsNewPOPG_p;
438 : // vectorPhaseGradCalculator_p[idx]->needsNewFieldPG_p = needsNewFieldPG_p;
439 : // vectorPhaseGradCalculator_p[idx]->ComputeFieldPointingGrad(pointingOffsets_p,cfb,vb,myrow);
440 : // cerr << "maxVB2BLMap "<< maxVB2BLMap << " vbRow2BLMap_p[myrow]" << vbRow2BLMap_p[myrow] << " " << myrow << " " << needsNewPOPG_p << endl;
441 0 : vectorPhaseGradCalculator_p[vbRow2BLMap_p[myrow]]->maxCFShape_p = maxCFShape_p;
442 0 : vectorPhaseGradCalculator_p[vbRow2BLMap_p[myrow]]->needsNewPOPG_p = blNeedsNewPOPG_p[myrow];
443 0 : vectorPhaseGradCalculator_p[vbRow2BLMap_p[myrow]]->needsNewFieldPG_p = needsNewFieldPG_p;
444 0 : vectorPhaseGradCalculator_p[vbRow2BLMap_p[myrow]]->ComputeFieldPointingGrad(pointingOffsets_p,vb,row,antGrp_l);
445 :
446 0 : blNeedsNewPOPG_p[myrow] = false;
447 :
448 0 : }
449 : else
450 : {
451 0 : needsNewPOPG_p = false;
452 0 : myrow=0;
453 0 : vbRow2BLMap_p.resize(vb.nRows(),0);
454 0 : blNeedsNewPOPG_p.resize(vb.nRows(),false);
455 : // vbRow2BLMap_p[0]=0;
456 0 : if (vectorPhaseGradCalculator_p.nelements() <= (unsigned int) vbRow2BLMap_p[myrow])
457 : {
458 : // cerr<<"vbRow2BLMap_p [row] doP=F "<< vbRow2BLMap_p[myrow] << " " <<myrow <<endl;
459 0 : vectorPhaseGradCalculator_p.resize(1);
460 0 : if (vectorPhaseGradCalculator_p[myrow].null())
461 0 : vectorPhaseGradCalculator_p[myrow]=new PhaseGrad();
462 0 : vectorPhaseGradCalculator_p[myrow]->needCFPhaseGrad_p=computePhaseScreen_p;
463 : }
464 : // vectorPhaseGradCalculator_p[vbRow2BLMap_p[myrow]]->ComputeFieldPointingGrad(pointingOffsets_p,cfb,vb,0);
465 0 : vectorPhaseGradCalculator_p[vbRow2BLMap_p[myrow]]->maxCFShape_p = maxCFShape_p;
466 0 : vectorPhaseGradCalculator_p[vbRow2BLMap_p[myrow]]->needsNewPOPG_p = needsNewPOPG_p;
467 0 : vectorPhaseGradCalculator_p[vbRow2BLMap_p[myrow]]->needsNewFieldPG_p = needsNewFieldPG_p;
468 0 : vectorPhaseGradCalculator_p[vbRow2BLMap_p[myrow]]->ComputeFieldPointingGrad(pointingOffsets_p,vb,myrow,make_pair(0,0));
469 0 : idx =0;
470 : }
471 : // if (needsNewPOPG_p)
472 : {
473 :
474 : // vectorPhaseGradCalculator_p[vbRow2BLMap_p[myrow]]->needsNewFieldPG_p = needsNewFieldPG_p;
475 : // vectorPhaseGradCalculator_p[vbRow2BLMap_p[myrow]]->ComputeFieldPointingGrad(pointingOffsets_p,cfb,vb,myrow);
476 0 : needsNewPOPG_p = false;
477 0 : needsNewFieldPG_p = false;
478 : }
479 :
480 0 : return vectorPhaseGradCalculator_p[idx]->field_phaseGrad_p;
481 :
482 : };
483 :
484 :
485 : }
486 : }
|