Commits

George Moellenbrock authored 9a641f28e7e
For CAS-12735, in Calibrater::genericGatherAndSolve, handle simdata_p=True case properly in Freq meta-data section so that c++ unit tests using SimpleSimVi2 will work properly (e.g., tCalibraterSolveSimData_GT); also added tests of FreqMetaData class to tVisCal_GT.cc

casa5/code/synthesis/MeasurementComponents/test/tVisCal_GT.cc

Modified
60 60 msmc(ss)
61 61 {}
62 62
63 63 Int nFld,nScan,nSpw,nAnt,nCorr;
64 64 Vector<Int> nChan;
65 65 SimpleSimVi2Parameters ss;
66 66 MSMetaInfoForCal msmc;
67 67
68 68 };
69 69
70 +
71 +
72 +class FreqMetaDataTest : public ::testing::Test {
73 +
74 +public:
75 +
76 + FreqMetaDataTest() :
77 + nSpw(12),
78 + msfreq(12),
79 + mswidth(12),
80 + nofanin(12,-1),
81 + faninSC(12,-1),
82 + faninCONT(12,-1),
83 + faninSPEC(12,-1),
84 + faninHETSPW(12,-1)
85 + {
86 +
87 + // Four single-channel spws
88 + msfreq(0).resize(1); msfreq(0)(0)=80.0e9; //msfreq(0)(0)+=1.000001;
89 + msfreq(1).resize(1); msfreq(1)(0)=81.0e9; //msfreq(1)(0)+=1.001;
90 + msfreq(2).resize(1); msfreq(2)(0)=83.0e9; //msfreq(2)(0)+=1.001;
91 + msfreq(3).resize(1); msfreq(3)(0)=84.0e9; //msfreq(3)(0)+=1.001;
92 + mswidth(0).resize(1); mswidth(0)(0)=1.024e9;
93 + mswidth(1).resize(1); mswidth(1)(0)=1.024e9;
94 + mswidth(2).resize(1); mswidth(2)(0)=1.024e9;
95 + mswidth(3).resize(1); mswidth(3)(0)=1.024e9;
96 +
97 + // Four eight-channel "continuum" spws
98 + msfreq(4).resize(8); indgen(msfreq(4)); msfreq(4)-=3.5; msfreq(4)*=128e6; msfreq(4)+=90.0e9;
99 + msfreq(5).resize(8); indgen(msfreq(5)); msfreq(5)-=3.5; msfreq(5)*=128e6; msfreq(5)+=91.0e9;
100 + msfreq(6).resize(8); indgen(msfreq(6)); msfreq(6)-=3.5; msfreq(6)*=128e6; msfreq(6)+=93.0e9;
101 + msfreq(7).resize(8); indgen(msfreq(7)); msfreq(7)-=3.5; msfreq(7)*=128e6; msfreq(7)+=94.0e9;
102 + mswidth(4).resize(8); mswidth(4)=128e6;
103 + mswidth(5).resize(8); mswidth(5)=128e6;
104 + mswidth(6).resize(8); mswidth(6)=128e6;
105 + mswidth(7).resize(8); mswidth(7)=128e6;
106 +
107 + // Four 32-channel "specline" spws
108 + msfreq(8).resize(32); indgen(msfreq(8)); msfreq(8)-=15.5; msfreq(8)*=2e6; msfreq(8)+=100.0e9;
109 + msfreq(9).resize(32); indgen(msfreq(9)); msfreq(9)-=15.5; msfreq(9)*=2e6; msfreq(9)+=101.0e9;
110 + msfreq(10).resize(32); indgen(msfreq(10)); msfreq(10)-=15.5; msfreq(10)*=2e6; msfreq(10)+=103.0e9;
111 + msfreq(11).resize(32); indgen(msfreq(11)); msfreq(11)-=15.5; msfreq(11)*=2e6; msfreq(11)+=104.0e9;
112 + mswidth(8).resize(32); mswidth(8)=2e6;
113 + mswidth(9).resize(32); mswidth(9)=2e6;
114 + mswidth(10).resize(32); mswidth(10)=2e6;
115 + mswidth(11).resize(32); mswidth(11)=2e6;
116 +
117 + faninSC(Slice(0,4,1))=0;
118 + faninCONT(Slice(4,4,1))=4;
119 + faninSPEC(Slice(8,4,1))=8;
120 +
121 + faninHETSPW(0)=0;
122 + faninHETSPW(4)=0;
123 + faninHETSPW(8)=0;
124 + faninHETSPW(11)=0;
125 +
126 + }
127 +
128 + Int nSpw;
129 + Vector< Vector<Double> > msfreq, mswidth;
130 + Vector<Int> nofanin,faninSC,faninCONT,faninSPEC,faninHETSPW;
131 +
132 +};
133 +
134 +
135 +
70 136 int main(int argc, char **argv) {
71 137 ::testing::InitGoogleTest(&argc, argv);
72 138 return RUN_ALL_TESTS();
73 139 }
74 140
75 141
76 142
143 +TEST_F(FreqMetaDataTest, SingleChannelTests) {
144 +
145 + // cout << endl << endl << "Doing SingleChannelTests..." << endl;
146 + cout.precision(18);
147 +
148 + Vector<uInt> selspw(4); indgen(selspw);
149 + // cout << "selspw = " << selspw << endl;
150 + // cout << "faninSC = " << faninSC << endl;
151 +
152 + FreqMetaData fmd;
153 +
154 +
155 + fmd.calcFreqMeta(msfreq,mswidth,selspw,false,true,faninSC);
156 + ASSERT_TRUE(fmd.ok());
157 +
158 +
159 + for (uInt i=0;i<selspw.nelements();++i) {
160 + Int ispw=selspw(i);
161 + ASSERT_EQ(82.0e9,fmd.freq(ispw)[0]);
162 + ASSERT_EQ(1.024e9,fmd.width(ispw)[0]);
163 + ASSERT_EQ(4.096e9,fmd.effBW(ispw)[0]);
164 + /*
165 + cout << "spw=" << ispw
166 + << " freq=" << fmd.freq(ispw)
167 + << " width=" << fmd.width(ispw)
168 + << " effBW=" << fmd.effBW(ispw)
169 + << endl;
170 + */
171 + }
172 +}
173 +
174 +
175 +TEST_F(FreqMetaDataTest, ContinuumTests) {
176 +
177 + // cout << endl << endl << "Doing ContinuumTests..." << endl;
178 +
179 + Vector<Int> selspwI(4); indgen(selspwI); selspwI+=4;
180 + Vector<uInt> selspw(4);
181 + convertArray(selspw,selspwI);
182 + // cout << "selspw = " << selspw << endl;
183 + // cout << "faninCONT = " << faninCONT << endl;
184 +
185 +
186 + FreqMetaData fmd;
187 +
188 + fmd.calcFreqMeta(msfreq,mswidth,selspw,false,true,faninCONT);
189 + ASSERT_TRUE(fmd.ok());
190 +
191 +
192 + for (uInt i=0;i<selspw.nelements();++i) {
193 + Int ispw=selspw(i);
194 + ASSERT_EQ(92.0e9,fmd.freq(ispw)[0]);
195 + ASSERT_EQ(1.024e9,fmd.width(ispw)[0]);
196 + ASSERT_EQ(4.096e9,fmd.effBW(ispw)[0]);
197 + /*
198 + cout << "spw=" << ispw
199 + << " freq=" << fmd.freq(ispw)
200 + << " width=" << fmd.width(ispw)
201 + << " effBW=" << fmd.effBW(ispw)
202 + << endl;
203 + */
204 + }
205 +
206 +}
207 +
208 +
209 +TEST_F(FreqMetaDataTest, SpecLineTests) {
210 +
211 + // cout << endl << endl << "Doing SpecLineTests..." << endl;
212 +
213 +
214 + Vector<Int> selspwI(4); indgen(selspwI); selspwI+=8;
215 + Vector<uInt> selspw(4);
216 + convertArray(selspw,selspwI);
217 + // cout << "selspw = " << selspw << endl;
218 + // cout << "faninSPEC = " << faninSPEC << endl;
219 +
220 + FreqMetaData fmd;
221 +
222 + fmd.calcFreqMeta(msfreq,mswidth,selspw,true,true,faninSPEC);
223 + ASSERT_TRUE(fmd.ok());
224 +
225 +
226 + for (uInt i=0;i<selspw.nelements();++i) {
227 + Int ispw=selspw(i);
228 + ASSERT_EQ(101.993e9,fmd.freq(ispw)[12]);
229 + ASSERT_EQ(2.0e6,fmd.width(ispw)[12]);
230 + ASSERT_EQ(8.0e6,fmd.effBW(ispw)[12]);
231 + /*
232 + cout << "spw=" << ispw
233 + << " freq=" << fmd.freq(ispw)[12]
234 + << " width=" << fmd.width(ispw)[12]
235 + << " effBW=" << fmd.effBW(ispw)[12]
236 + << endl;
237 + */
238 + }
239 +
240 +}
241 +
242 +
243 +TEST_F(FreqMetaDataTest, HeteroSpwTests) {
244 +
245 + // cout << endl << endl << "Doing HeteroSpwTests..." << endl;
246 +
247 + Vector<uInt> selspw(4);
248 + selspw(0)=0;
249 + selspw(1)=4;
250 + selspw(2)=8;
251 + selspw(3)=11;
252 + //cout << "selspw = " << selspw << endl;
253 + //cout << "faninHET = " << faninHETSPW << endl;
254 +
255 + FreqMetaData fmd;
256 +
257 + fmd.calcFreqMeta(msfreq,mswidth,selspw,false,true,faninHETSPW);
258 + ASSERT_TRUE(fmd.ok());
259 +
260 +
261 + for (uInt i=0;i<selspw.nelements();++i) {
262 + Int ispw=selspw(i);
263 + ASSERT_EQ(86.0e9,fmd.freq(ispw)[0]);
264 + ASSERT_NEAR(967529411.764705896,fmd.width(ispw)[0],1e-6); // 1uHz
265 + ASSERT_EQ(2.1760e9,fmd.effBW(ispw)[0]);
266 + /*
267 + cout << "spw=" << ispw
268 + << " freq=" << fmd.freq(ispw)
269 + << " width=" << fmd.width(ispw)
270 + << " effBW=" << fmd.effBW(ispw)
271 + << endl;
272 + */
273 + }
274 +
275 +}
276 +
277 +
278 +
77 279
78 280 TEST_F(VisCalTest, GJonesApplyState) {
79 281
80 282 VisCal *G = new GJones(msmc);
81 283 G->setApply();
82 284
83 285 G->setMeta(0,0,0.0,
84 286 0,ss.freqs(0),
85 287 0);
86 288 G->sizeApplyParCurrSpw(ss.nChan_(0));

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut