Line data Source code
1 : // -*- C++ -*-
2 : //# VisibilityResamplerBase.cc: Implementation of the VisibilityResamplerBase 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/TransformMachines2/VisibilityResamplerBase.h>
30 : #include <synthesis/TransformMachines2/PolOuterProduct.h>
31 : #include <synthesis/TransformMachines/SynthesisError.h>
32 : #include <synthesis/TransformMachines2/Utils.h>
33 : #include <stdcasa/thread/AsynchronousTools.h>
34 : #include <casacore/casa/Quanta/MVTime.h>
35 : #include <fstream>
36 :
37 : using namespace casacore;
38 : namespace casa{
39 : using namespace refim;
40 : //
41 : //-----------------------------------------------------------------------------------
42 : //
43 0 : void VisibilityResamplerBase::copy(const VisibilityResamplerBase& other)
44 : {
45 0 : SynthesisUtils::SETVEC(uvwScale_p, other.uvwScale_p);
46 0 : SynthesisUtils::SETVEC(offset_p, other.offset_p);
47 0 : SynthesisUtils::SETVEC(dphase_p, other.dphase_p);
48 0 : SynthesisUtils::SETVEC(chanMap_p, other.chanMap_p);
49 0 : SynthesisUtils::SETVEC(polMap_p, other.polMap_p);
50 0 : SynthesisUtils::SETVEC(spwChanFreq_p, other.spwChanFreq_p);
51 0 : SynthesisUtils::SETVEC(spwChanConjFreq_p, other.spwChanConjFreq_p);
52 0 : SynthesisUtils::SETVEC(cfMap_p, other.cfMap_p);
53 0 : SynthesisUtils::SETVEC(conjCFMap_p, other.conjCFMap_p);
54 : // vbRow2CFMap_p.assign(other.vbRow2CFMap_p);
55 0 : convFuncStore_p = other.convFuncStore_p;
56 0 : paTolerance_p = other.paTolerance_p;
57 0 : vb2CFBMap_p = other.vb2CFBMap_p;
58 :
59 0 : }
60 :
61 0 : void VisibilityResamplerBase::setVB2CFMap(const casacore::CountedPtr<refim::VB2CFBMap>& thisMap)
62 : {
63 0 : vb2CFBMap_p = thisMap;
64 : //cerr << "setvb2CF address " << vb2CFBMap_p.get() << endl;
65 : // uInt n=vb2CFBMap_p->vbRow2BLMap_p.size();
66 : // for(uInt i=0;i<n;i++)
67 : // cerr << i << " " << vb2CFBMap_p->vbRow2BLMap_p[i]<< " " << thisMap->vbRow2BLMap_p[i] << endl;
68 : // return;
69 0 : }
70 : //
71 : //-----------------------------------------------------------------------------------
72 : //
73 0 : VisibilityResamplerBase& VisibilityResamplerBase::operator=(const VisibilityResamplerBase& other)
74 : {
75 0 : copy(other);
76 0 : return *this;
77 : }
78 : //
79 : //-----------------------------------------------------------------------------------
80 : //
81 : // template void VisibilityResamplerBase::addTo4DArray(DComplex* store,const Int* iPos, Complex& val, Double& wt) __restrict__;
82 : // template void VisibilityResamplerBase::addTo4DArray(Complex* store,const Int* iPos, Complex& val, Double& wt) __restrict__;
83 : //
84 : //-----------------------------------------------------------------------------------
85 : //
86 0 : void VisibilityResamplerBase::sgrid(Int& uvwDim,
87 : Double* __restrict__ pos,
88 : Int* __restrict__ loc,
89 : Int* __restrict__ off,
90 : Complex& phasor, const Int& irow,
91 : // const Matrix<Double>& __restrict__ uvw,
92 : const Double* __restrict__ uvw,
93 : const Double& dphase,
94 : const Double& freq,
95 : const Double* __restrict__ scale,
96 : const Double* __restrict__ offset,
97 : const Float* __restrict__ sampling) // __restrict__
98 : // const Vector<Double>& __restrict__ scale,
99 : // const Vector<Double>& __restrict__ offset,
100 : // const Vector<Float>& __restrict__ sampling) __restrict__
101 : {
102 : Double phase;
103 0 : Int ndim=2;
104 :
105 0 : for(Int idim=0;idim<ndim;idim++)
106 : {
107 0 : pos[idim]=scale[idim]*uvw[idim+irow*uvwDim]*freq/C::c+offset[idim];
108 0 : loc[idim]=(Int)std::floor(pos[idim]+0.5);
109 0 : off[idim]=(Int)std::floor(((loc[idim]-pos[idim])*sampling[idim])+0.5);
110 : }
111 :
112 0 : if (dphase != 0.0)
113 : {
114 0 : phase=-2.0*M_PI*dphase*freq/C::c;
115 0 : phasor=Complex(cos(phase), sin(phase));
116 : }
117 : else
118 0 : phasor=Complex(1.0);
119 : //cerr << "### " << pos[0] << " " << offset[0] << " " << off[0] << endl;
120 0 : }
121 :
122 : //
123 : //-----------------------------------------------------------------------------------
124 : //
125 : // Int VisibilityResamplerBase::makeVBRow2CFBMap(CFStore2& cfs,
126 : // ConvolutionFunction& cf,
127 : // const VisBuffer2& vbs,
128 : // const Quantity& dPA,
129 : // const Vector<Int>& /*dataChan2ImChanMap*/,
130 : // const Vector<Int>& /*dataPol2ImPolMap*/,
131 : // const Vector<Double>& pointingOffset)
132 : // {
133 : // // VBRow2CFMapType& vbRow2CFMap_p,
134 : // const Int nRow=vbs.nRows();
135 : // //UNUSED: nChan=dataChan2ImChanMap.nelements(),
136 : // //UNUSED: nPol=dataPol2ImPolMap.nelements();
137 : // // vbRow2CFMap_p.resize(nPol, nChan, nRow);
138 : // vbRow2CFBMap_p.resize(nRow);
139 : // Quantity pa(getPA(vbs),"rad");
140 : // PolOuterProduct outerProduct;
141 : // Int statusCode=CFDefs::MEMCACHE;
142 : // for (Int irow=0;irow<nRow;irow++)
143 : // {
144 : // //
145 : // // Translate antenna ID to antenna type
146 : // //
147 : // Int ant1Type = cf.mapAntIDToAntType(vbs.antenna1()(irow)),
148 : // ant2Type = cf.mapAntIDToAntType(vbs.antenna2()(irow));
149 : // //
150 : // // Get the CFBuffer for the given PA and baseline catagorized
151 : // // by the two antenna types. For homgeneous arrays, all
152 : // // baselines will map to a single antenna-type pair.
153 : // //
154 :
155 : // CountedPtr<CFBuffer> cfb_l;
156 : // try
157 : // {
158 : // cfb_l = cfs.getCFBuffer(pa, dPA, ant1Type, ant2Type);
159 : // //cfb_l->show("From VRB: ");
160 : // }
161 : // catch (CFNotCached& x)
162 : // {
163 : // LogIO log_l(LogOrigin("VisibilityResamplerBase2", "makeVBRow2CFMap"));
164 : // log_l << "CFs not cached for " << pa.getValue("deg")
165 : // << " deg, dPA = " << dPA.getValue("deg")
166 : // << " Field ID = " << vbs.fieldId()(0);
167 : // // << " TimeStamps(0-10) = " << vbs.feedPa1(getCurrentTimeStamp(vbs)).nelements() << " ";
168 : // // << " TimeStamps(0-10) = " << vbs.feedPa1().nelements() << " ";
169 : // // for (Int i=0;i<10;i++)
170 : // // {
171 : // // // log_l << MVTime(vbs.time()(i)).string(MVTime::TIME) << " ";
172 : // // log_l << vbs.time()(i)/1.0e8 << " ";
173 : // // log_l << "(" << (vbs.feed_pa(getCurrentTimeStamp(vbs))(i))*57.2956 << ") ";
174 : // // }
175 : // log_l << " Ant1Type, Ant2Type = " << ant1Type << "," << ant2Type << LogIO::POST;
176 : // statusCode=CFDefs::NOTCACHED;
177 : // }
178 :
179 : // if (statusCode==CFDefs::NOTCACHED)
180 : // {
181 : // break;
182 : // }
183 : // else
184 : // {
185 : // cfb_l->setPointingOffset(pointingOffset);
186 : // vbRow2CFBMap_p(irow) = cfb_l;
187 : // }
188 :
189 : // /*
190 : // //
191 : // // Now do the in-row mappings.
192 : // //
193 : // // Convert the VB polarizations to MuelllerElements.
194 : // for (Int ichan=0;ichan<nChan;ichan++)
195 : // {
196 : // // Double freq = vb.freq_p(ichan), wVal=vbs.uvw_p(irow,2);
197 : // Double freq = vbs.frequency()(ichan), wVal=abs(vbs.uvw()(irow)(2));
198 : // wVal *= freq/C::c;
199 : // for (Int ipol=0;ipol<nPol;ipol++)
200 : // {
201 : // Vector<Int> vbPol = vbs.corrType();
202 : // if (dataPol2ImPolMap(ipol) >= 0)
203 : // {
204 : // // The translate global functions comes from
205 : // // PolOuterProduct.{cc,h}.
206 : // //
207 : // // The code below translates, e.g.,
208 : // // Stokes::RR-->PolCrossProduct::RR-->MuellerElement.
209 : // MuellerElementType muellerElement;// = outerProduct.getMuellerElement(translateStokesToCrossPol(vbPol(ipol)));
210 : // Bool found=false;
211 : // Double f,w;
212 : // f=cfb_l->nearestFreq(found,freq);
213 : // w=cfb_l->nearestWVal(found,wVal);
214 : // if (!found) log_l << "Nearest freq. or w value not found "
215 : // << freq << " " << wVal << LogIO::EXCEPTION;
216 :
217 : // vbRow2CFMap_p(ipol,ichan,irow) = cfb_l->getCFCellPtr(f, w, muellerElement);
218 :
219 : // // Bool Dummy;
220 : // // if (irow == 1)
221 : // // {
222 : // // cerr << "#### " << ipol << ", " << ichan << ", " << irow << " "
223 : // // << vbRow2CFMap_p(ipol,ichan,irow)->getStorage()->getStorage(Dummy) << endl;
224 : // // }
225 : // }
226 : // }
227 : // }
228 : // */
229 : // }
230 : // return statusCode;
231 : // }
232 :
233 0 : std::shared_ptr<std::complex<double>> VisibilityResamplerBase::getGridPtr(size_t& size) const
234 : {
235 0 : size = 0;
236 0 : return std::shared_ptr<std::complex<double>>();
237 : }
238 :
239 0 : std::shared_ptr<double> VisibilityResamplerBase::getSumWeightsPtr(size_t& size) const
240 : {
241 0 : size = 0;
242 0 : return std::shared_ptr<double>();
243 : }
244 :
245 : using namespace casacore;
246 : };// end namespace casa
|