Commits

Pam Harris authored 2a261ae1458
Move flag cube access outside VB averager loop

casa5/code/plotms/Data/PlotMSVBAverager.cc

Modified
404 404 throw(AipsError("PlotMSVBAverager: data shape does not conform"));
405 405
406 406 Double vbWt(0.0); // will accumulate this VBs total data weight
407 407 const Float* wt;
408 408
409 409 // Mutable vis cubes for accumulation
410 410 Cube<Complex> accumVisCube;
411 411 Cube<Complex> accumVisCubeModel;
412 412 Cube<Complex> accumVisCubeCorrected;
413 413 Cube<Float> accumVisCubeFloat;
414 + Cube<Bool> accumFlagCube;
414 415 if (doVC_p) {
415 416 accumVisCube.reference(vb.visCube());
416 417 if (inCoh_p) convertToAP(accumVisCube);
417 418 }
418 419 if (doMVC_p) {
419 420 accumVisCubeModel.reference(vb.visCubeModel());
420 421 if (inCoh_p) convertToAP(accumVisCubeModel);
421 422 }
422 423 if (doCVC_p) {
423 424 accumVisCubeCorrected.reference(vb.visCubeCorrected());
424 425 if (inCoh_p) convertToAP(accumVisCubeCorrected);
425 426 }
426 427 if (doFC_p) {
427 428 accumVisCubeFloat.reference(vb.visCubeFloat());
428 429 }
430 + accumFlagCube.reference(vb.flagCube());
429 431
430 432 for (rownr_t ibln=0; ibln<vb.nRows(); ++ibln) {
431 433 // Calculate row from antenna numbers with the hash function.
432 434 Int ant1 = vb.antenna1()(ibln);
433 435 Int ant2 = vb.antenna2()(ibln);
434 436 Int obln = baseline(ant1, ant2);
435 437
436 438 // This baseline occurs in input, so preserve in output
437 439 blnOK_p(obln) = true;
438 440
444 446 Double blnWt(0.0);
445 447
446 448 for (Int chn=0; chn<vb.nChannels(); chn++) {
447 449 for (Int cor=0; cor<nCorr_p; ++cor,++wt) {
448 450
449 451 // Assume we won't accumulate anything in this cell
450 452 // (output is unflagged, input is flagged)
451 453 Bool acc(false);
452 454
453 455 IPosition flagPos(3, cor, chn, ibln);
454 - if (!vb.flagCube()(flagPos)) { // input UNflagged
456 + if (!accumFlagCube(flagPos)) { // input UNflagged
455 457 // we will accumulate
456 458 acc=true;
457 459 if (avgFlagCube_(cor,chn,obln)) { // output flagged
458 460 // This cell now NEWLY unflagged in output
459 461 avgFlagCube_(cor,chn,obln)=false;
460 462 // ...so zero the accumulators
461 463 if (doVC_p)
462 464 avgVisCube_(cor,chn,obln) = 0.0;
463 465 if (doMVC_p)
464 466 avgModelCube_(cor,chn,obln) = 0.0;
562 564 Cube<Float> wtsp;
563 565 wtsp.resize();
564 566 wtsp = vb.weightSpectrum();
565 567 Float wt;
566 568
567 569 // Mutable vis cubes for accumulation
568 570 Cube<Complex> accumVisCube;
569 571 Cube<Complex> accumVisCubeModel;
570 572 Cube<Complex> accumVisCubeCorrected;
571 573 Cube<Float> accumVisCubeFloat;
574 + Cube<Bool> accumFlagCube;
572 575 if (doVC_p) {
573 576 accumVisCube.reference(vb.visCube());
574 577 if (inCoh_p) convertToAP(accumVisCube);
575 578 }
576 579 if (doMVC_p) {
577 580 accumVisCubeModel.reference(vb.visCubeModel());
578 581 if (inCoh_p) convertToAP(accumVisCubeModel);
579 582 }
580 583 if (doCVC_p) {
581 584 accumVisCubeCorrected.reference(vb.visCubeCorrected());
582 585 if (inCoh_p) convertToAP(accumVisCubeCorrected);
583 586 }
584 587 if (doFC_p) {
585 588 accumVisCubeFloat.reference(vb.visCubeFloat());
586 589 }
590 + accumFlagCube.reference(vb.flagCube());
587 591
588 592 for (rownr_t ibln=0; ibln<vb.nRows(); ++ibln) {
589 593
590 594 // The antennas in the baseline
591 595 Vector<Int> oblnij(2);
592 596 oblnij(0) = vb.antenna1()(ibln);
593 597 oblnij(1) = vb.antenna2()(ibln);
594 598 Int& obln_i(oblnij(0));
595 599 Int& obln_j(oblnij(1));
596 600
602 606 for (Int chn=0; chn<vb.nChannels(); chn++) {
603 607 for (Int cor=0; cor<nCorr_p; ++cor) {
604 608 wt = wtsp(cor, chn, ibln);
605 609 if (wt < FLT_MIN) wt = FLT_MIN;
606 610 // Assume we won't accumulate anything in this cell
607 611 // (output is unflagged, input is flagged)
608 612 Bool acc_i(false),acc_j(false);
609 613
610 614 // Consider accumulation according to state of flags
611 615 IPosition flagPos(3, cor, chn, ibln);
612 - if (!vb.flagCube()(flagPos)) { // input UNflagged
616 + if (!accumFlagCube(flagPos)) { // input UNflagged
613 617 // we will accumulate both ants
614 618 acc_i = acc_j = true;
615 619
616 620 // Zero accumulators if output cell currently flagged
617 621 for (Int ij=0; ij<2; ++ij) {
618 622 Int ia = oblnij(ij);
619 623 if (avgFlagCube_(cor,chn,ia)) { // output flagged
620 624 // This cell now NEWLY unflagged in output
621 625 avgFlagCube_(cor,chn,ia) = false;
622 626 // ...so zero the accumulators

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

Add shortcut