Commits
292 292 | Cube<Float> soldiff=amplitude(soln-x); |
293 293 | //cout << "Diff = " << soldiff << endl; |
294 294 | |
295 295 | ASSERT_TRUE(allNearAbs(soldiff,0.0f,1e-7)); |
296 296 | |
297 297 | } |
298 298 | |
299 299 | |
300 300 | |
301 301 | |
302 - | class XparangJonesTest : public VisCalTestBase { |
302 + | class XparangJonesLINTest : public VisCalTestBase { |
303 303 | |
304 304 | public: |
305 305 | |
306 306 | Cube<Complex> x; |
307 307 | |
308 - | XparangJonesTest() : |
308 + | XparangJonesLINTest() : |
309 309 | VisCalTestBase(1,10,1,4,4,64,1,true,"lin"), |
310 + | //VisCalTestBase(1,3,1,4,4,64,1,true,"lin"), |
310 311 | x(1,nChan,nAnt,Complex(0.0)) |
311 312 | { |
312 313 | for (Int ich=0;ich<nChan;++ich) { |
313 - | Float a((C::pi/4)*cos(ich*C::pi/90.0)); |
314 + | //Float a((C::pi/4)*cos(ich*C::pi/90.0)); // nominal ambiguity |
315 + | Float a((C::pi/4)*cos(5*ich*C::pi/90.0)+C::pi/2); // wrong ambiguity |
314 316 | x(Slice(),Slice(ich,1,1),Slice())=Complex(cos(a),sin(a)); |
315 317 | } |
316 318 | |
317 - | //summary("XparangJonesTest"); |
318 - | //cout << "x = " << phase(x)*180/C::pi << endl; |
319 + | //summary("XparangJonesLINTest"); |
320 + | // cout << "x = " << phase(x)*180/C::pi << endl; |
319 321 | } |
320 322 | |
321 323 | |
322 324 | }; |
323 - | |
324 325 | |
325 - | TEST_F(XparangJonesTest, XfparangJonesTest){ |
326 + | |
327 + | TEST_F(XparangJonesLINTest, XfparangJonesTest){ |
326 328 | |
327 329 | // Apply-able parang |
328 330 | PJones Papp(msmc); |
329 331 | Papp.setApply(); |
330 332 | |
331 333 | // Apply-able Xf |
332 334 | XfJones Xapp(msmc); |
333 335 | Xapp.setApply(); |
334 336 | |
335 337 | for (Int ispw=0;ispw<nSpw;++ispw) { |
336 338 | Xapp.setMeta(0,1,0.0, |
337 339 | ispw,ssvp.freqs(ispw), |
338 340 | nChan); |
339 341 | Xapp.sizeApplyParCurrSpw(nChan); |
340 342 | |
341 343 | Xapp.setApplyParCurrSpw(x,true,false); // correct below will corrupt |
342 344 | } |
343 345 | |
344 346 | XfparangJones XYsol(msmc); |
345 347 | Record solvePar; |
346 - | solvePar.define("table",String("test.Xf")); |
348 + | solvePar.define("table",String("test.Xfparang")); |
347 349 | solvePar.define("solint",String("inf")); |
348 350 | solvePar.define("combine",String("")); |
349 351 | Vector<Int> refant(1,0); solvePar.define("refant",refant); |
350 352 | XYsol.setSolve(solvePar); |
351 353 | |
352 354 | SDBList sdbs; |
353 355 | for (vi2.originChunks();vi2.moreChunks();vi2.nextChunk()) { |
354 356 | for (vi2.origin();vi2.more();vi2.next()) { |
355 357 | |
356 358 | Int ispw=vb2->spectralWindows()(0); |
367 369 | Cube<Complex> vC(vb2->visCube()); |
368 370 | vb2->setVisCubeCorrected(vC); |
369 371 | vb2->setFlagCube(vb2->flagCube()); |
370 372 | |
371 373 | Xapp.setMeta(obsid,scan,timestamp, |
372 374 | ispw,freqs, |
373 375 | fldid); |
374 376 | Xapp.correct2(*vb2,false,false,false); // (trial?,doWtSp?,dosync?) |
375 377 | |
376 378 | |
379 + | Papp.setMeta(obsid,scan,timestamp, |
380 + | ispw,freqs, |
381 + | fldid); |
382 + | Papp.corrupt2(*vb2); |
383 + | |
384 + | |
385 + | //cout << "time=" << timestamp-86400.0*floor(timestamp/86400.0) << endl; |
377 386 | //cout << "vCC=" << Vector<Complex>(vb2->visCubeCorrected()(Slice(),Slice(nChan/2),Slice(0))) << endl; |
378 387 | //cout << "vCM=" << Vector<Complex>(vb2->visCubeModel()(Slice(),Slice(nChan/2),Slice(0))) << endl; |
379 388 | |
380 389 | |
381 390 | sdbs.add(*vb2); |
382 391 | //cout << "sdb.feedPa() = " << sdbs(sdbs.nSDB()-1).feedPa() << endl; |
383 392 | } |
384 393 | } |
385 394 | |
395 + | XYsol.createMemCalTable2(); |
396 + | |
397 + | |
386 398 | // Setup meta & sizes for the solve |
387 399 | XYsol.setMeta(sdbs.aggregateObsId(), |
388 400 | sdbs.aggregateScan(), |
389 401 | sdbs.aggregateTime(), |
390 402 | sdbs.aggregateSpw(), |
391 403 | sdbs.freqs(), |
392 404 | sdbs.aggregateFld()); |
405 + | |
406 + | XYsol.setOrVerifyCTFrequencies(sdbs.aggregateSpw()); |
407 + | |
408 + | |
393 409 | XYsol.sizeSolveParCurrSpw(sdbs.nChannels()); |
394 410 | |
395 411 | // Call the specialized solver |
396 412 | XYsol.selfSolveOne(sdbs); |
397 413 | |
398 414 | //cout << "srcPolPar() = " << real(XYsol.srcPolPar()) << endl; |
399 415 | ASSERT_NEAR(0.04,real(XYsol.srcPolPar()(0)),1e-3); |
400 416 | ASSERT_NEAR(0.03,real(XYsol.srcPolPar()(1)),1e-3); |
401 417 | |
402 418 | Cube<Complex> soln(XYsol.solveAllCPar()(Slice(0),Slice(),Slice())); |
403 419 | //cout << "soln = " << phase(soln.xyPlane(0))*180/C::pi << endl; |
420 + | //cout << "x = " << phase(x)*180/C::pi << endl; |
404 421 | |
405 422 | Cube<Float> soldiff=amplitude(soln-x); |
406 423 | //cout << "Diff = " << soldiff << endl; |
407 424 | |
408 425 | ASSERT_TRUE(allNearAbs(soldiff,0.0f,1e-7)); |
409 426 | |
427 + | XYsol.keepNCT(); |
428 + | XYsol.storeNCT(); |
429 + | |
430 + | } |
431 + | |
432 + | |
433 + | |
434 + | class XparangJonesCIRCTest : public VisCalTestBase { |
435 + | |
436 + | public: |
437 + | |
438 + | Cube<Complex> x; |
439 + | |
440 + | XparangJonesCIRCTest() : |
441 + | VisCalTestBase(1,10,1,4,4,64,1,true,"circ"), |
442 + | //VisCalTestBase(1,3,1,4,4,64,1,true,"lin"), |
443 + | x(1,nChan,nAnt,Complex(0.0)) |
444 + | { |
445 + | for (Int ich=0;ich<nChan;++ich) { |
446 + | //Float a((C::pi/4)*cos(ich*C::pi/90.0)); // nominal ambiguity |
447 + | Float a((C::pi/4)*cos(5*ich*C::pi/90.0)+C::pi/2); // wrong ambiguity |
448 + | x(Slice(),Slice(ich,1,1),Slice())=Complex(cos(a),sin(a)); |
449 + | } |
450 + | |
451 + | //summary("XparangJonesCIRCTest"); |
452 + | // cout << "x = " << phase(x)*180/C::pi << endl; |
453 + | } |
454 + | |
455 + | |
456 + | }; |
457 + | |
458 + | |
459 + | TEST_F(XparangJonesCIRCTest, XfparangJonesTest){ |
460 + | |
461 + | // Apply-able parang |
462 + | PJones Papp(msmc); |
463 + | Papp.setApply(); |
464 + | |
465 + | // Apply-able Xf |
466 + | XfJones Xapp(msmc); |
467 + | Xapp.setApply(); |
468 + | |
469 + | for (Int ispw=0;ispw<nSpw;++ispw) { |
470 + | Xapp.setMeta(0,1,0.0, |
471 + | ispw,ssvp.freqs(ispw), |
472 + | nChan); |
473 + | Xapp.sizeApplyParCurrSpw(nChan); |
474 + | |
475 + | Xapp.setApplyParCurrSpw(x,true,false); // correct below will corrupt |
476 + | } |
477 + | |
478 + | XfparangJones XYsol(msmc); |
479 + | Record solvePar; |
480 + | solvePar.define("table",String("test.Xfparang")); |
481 + | solvePar.define("solint",String("inf")); |
482 + | solvePar.define("combine",String("")); |
483 + | Vector<Int> refant(1,0); solvePar.define("refant",refant); |
484 + | XYsol.setSolve(solvePar); |
485 + | |
486 + | SDBList sdbs; |
487 + | for (vi2.originChunks();vi2.moreChunks();vi2.nextChunk()) { |
488 + | for (vi2.origin();vi2.more();vi2.next()) { |
489 + | |
490 + | Int ispw=vb2->spectralWindows()(0); |
491 + | Int obsid(vb2->observationId()(0)); |
492 + | Int scan(vb2->scan()(0)); |
493 + | Double timestamp(vb2->time()(0)); |
494 + | Int fldid(vb2->fieldId()(0)); |
495 + | Vector<Double> freqs(vb2->getFrequencies(0)); |
496 + | Vector<Int> a1(vb2->antenna1()); |
497 + | Vector<Int> a2(vb2->antenna2()); |
498 + | |
499 + | vb2->resetWeightsUsingSigma(); |
500 + | |
501 + | Cube<Complex> vC(vb2->visCube()); |
502 + | vb2->setVisCubeCorrected(vC); |
503 + | vb2->setFlagCube(vb2->flagCube()); |
504 + | |
505 + | Xapp.setMeta(obsid,scan,timestamp, |
506 + | ispw,freqs, |
507 + | fldid); |
508 + | Xapp.correct2(*vb2,false,false,false); // (trial?,doWtSp?,dosync?) |
509 + | |
510 + | |
511 + | Papp.setMeta(obsid,scan,timestamp, |
512 + | ispw,freqs, |
513 + | fldid); |
514 + | Papp.corrupt2(*vb2); |
515 + | |
516 + | |
517 + | //cout << "time=" << timestamp-86400.0*floor(timestamp/86400.0) << endl; |
518 + | //cout << "vCC=" << Vector<Complex>(vb2->visCubeCorrected()(Slice(),Slice(nChan/2),Slice(0))) << endl; |
519 + | //cout << "vCM=" << Vector<Complex>(vb2->visCubeModel()(Slice(),Slice(nChan/2),Slice(0))) << endl; |
520 + | |
521 + | |
522 + | sdbs.add(*vb2); |
523 + | //cout << "sdb.feedPa() = " << sdbs(sdbs.nSDB()-1).feedPa() << endl; |
524 + | } |
525 + | } |
526 + | |
527 + | XYsol.createMemCalTable2(); |
528 + | |
529 + | |
530 + | // Setup meta & sizes for the solve |
531 + | XYsol.setMeta(sdbs.aggregateObsId(), |
532 + | sdbs.aggregateScan(), |
533 + | sdbs.aggregateTime(), |
534 + | sdbs.aggregateSpw(), |
535 + | sdbs.freqs(), |
536 + | sdbs.aggregateFld()); |
537 + | |
538 + | XYsol.setOrVerifyCTFrequencies(sdbs.aggregateSpw()); |
539 + | |
540 + | |
541 + | XYsol.sizeSolveParCurrSpw(sdbs.nChannels()); |
542 + | |
543 + | // Call the specialized solver |
544 + | XYsol.selfSolveOne(sdbs); |
545 + | |
546 + | cout << "srcPolPar() = " << real(XYsol.srcPolPar()) << endl; |
547 + | //ASSERT_NEAR(0.04,real(XYsol.srcPolPar()(0)),1e-3); |
548 + | //ASSERT_NEAR(0.03,real(XYsol.srcPolPar()(1)),1e-3); |
549 + | |
550 + | Cube<Complex> soln(XYsol.solveAllCPar()(Slice(0),Slice(),Slice())); |
551 + | //cout << "soln = " << phase(soln.xyPlane(0))*180/C::pi << endl; |
552 + | //cout << "x = " << phase(x)*180/C::pi << endl; |
553 + | |
554 + | Cube<Float> soldiff=amplitude(soln-x); |
555 + | //cout << "Diff = " << soldiff << endl; |
556 + | |
557 + | //ASSERT_TRUE(allNearAbs(soldiff,0.0f,1e-7)); |
558 + | |
559 + | //XYsol.keepNCT(); |
560 + | //XYsol.storeNCT(); |
561 + | |
410 562 | } |