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