LCOV - code coverage report
Current view: top level - msvis/MSVis - PhaseShiftTvi.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 47 0.0 %
Date: 2024-12-11 20:54:31 Functions: 0 5 0.0 %

          Line data    Source code
       1             : /*
       2             :  * PhaseShiftTvi.cc
       3             :  *
       4             :  *  Created on: Mar 12, 2015
       5             :  *      Author: jjacobs
       6             :  */
       7             : 
       8             : #include <msvis/MSVis/PhaseShiftTvi.h>
       9             : #include <casacore/casa/Arrays/Cube.h>
      10             : #include <casacore/casa/Arrays/Matrix.h>
      11             : 
      12             : using namespace casacore;
      13             : namespace casa {
      14             : 
      15             : namespace vi {
      16             : 
      17           0 : PhaseShiftTvi::PhaseShiftTvi (ViImplementation2 * inputVi, double dXArcseconds,
      18           0 :                               double dYArcseconds)
      19             : : TransformingVi2 (inputVi),
      20           0 :   dXArcseconds_p (dXArcseconds),
      21           0 :   dYArcseconds_p (dYArcseconds)
      22           0 : {}
      23             : 
      24             : void
      25           0 : PhaseShiftTvi::phaseCenterShift (Cube<Complex> & cube) const
      26             : {
      27             :     // Notes:
      28             :     //
      29             :     // 1) This is an operation that is likely performed elsewhere in CASA so that we ought to
      30             :     //    factor out any commonality.
      31             :     //
      32             :     // 2) This operation will put the uvw and phaseCenter values out alignment with the shifted
      33             :     //    data.  If the data is going to be consumed by a more exacting application than plotMS
      34             :     //    these values ought to be adjusted as well by this TVI.
      35             : 
      36             :     // Get cube shape as scalars
      37             : 
      38           0 :     IPosition shape = cube.shape();
      39           0 :     Int nCorrelations = shape (0);
      40           0 :     Int nChannels = shape (1);
      41           0 :     rownr_t nRows = shape (2);
      42             : 
      43           0 :     const Int uIndex = 0; // uvw matrix is [3,nRows]
      44           0 :     const Int vIndex = 1;
      45             : 
      46             :     // Convert the offsets from arcseconds to radians
      47             : 
      48           0 :     double radiansPerArcsecond = C::pi / (180 * 3600);
      49           0 :     double dXRadians = dXArcseconds_p * radiansPerArcsecond;
      50           0 :     double dYRadians = dYArcseconds_p * radiansPerArcsecond;
      51             : 
      52             :     // Capture the uvw and the time for the VB window.
      53             : 
      54           0 :     Matrix<Double> theUvw;
      55           0 :     getVii()->uvw (theUvw);
      56             : 
      57           0 :     Vector<Double> timeForRows;
      58           0 :     getVii()->time (timeForRows);
      59             : 
      60             :     // Allow for the case where the iterator window has many timestamps by making the
      61             :     // frequencies a function of row number but not doing it when not needed.
      62             : 
      63           0 :     double frequencyTime = timeForRows (0);
      64           0 :     Vector<Double> frequency = getVii()->getFrequencies (frequencyTime, getObservatoryFrequencyType ());
      65             : 
      66           0 :     for (rownr_t row = 0; row < nRows; row ++){
      67             : 
      68           0 :         double t = timeForRows (row);
      69             : 
      70           0 :         if (t != frequencyTime){
      71             : 
      72             :             // This row has a different timestamp, so get the new frequencies
      73             : 
      74           0 :             frequencyTime = t;
      75           0 :             frequency = getVii()->getFrequencies (frequencyTime, getObservatoryFrequencyType ());
      76             :         }
      77             : 
      78             :         // Compute the phase change per Hz for this row
      79             : 
      80           0 :         double u = theUvw (uIndex, row);
      81           0 :         double v = theUvw (vIndex, row);
      82           0 :         double rowPhasePerHz = (u * dXRadians + v * dYRadians) * -2 * C::pi / C::c;
      83             : 
      84           0 :         for (Int channel = 0; channel < nChannels; channel ++){
      85             : 
      86             :             // Compute the phase change given this channel's frequency
      87             : 
      88           0 :             double channelPhase = rowPhasePerHz * frequency (channel);
      89           0 :             Complex phasor (cos(channelPhase), sin(channelPhase));
      90             : 
      91           0 :             for (Int correlation = 0; correlation < nCorrelations; correlation ++){
      92             : 
      93             :                 // Apply the phase change
      94             : 
      95           0 :                 cube (correlation, channel, row) *= phasor;
      96             :             }
      97             :         }
      98             :     }
      99           0 : }
     100             : 
     101             : 
     102             : void
     103           0 : PhaseShiftTvi::visibilityCorrected (Cube<Complex> & vis) const
     104             : {
     105             :     // Have the upstream VII fill the cube with the appropriate data and
     106             :     // then phase shift the entire cube.
     107             : 
     108           0 :     getVii()->visibilityCorrected (vis);
     109             : 
     110           0 :     phaseCenterShift (vis);
     111           0 : }
     112             : 
     113             : void
     114           0 : PhaseShiftTvi::visibilityModel (Cube<Complex> & vis) const
     115             : {
     116             :     // Have the upstream VII fill the cube with the appropriate data and
     117             :     // then phase shift the entire cube.
     118             : 
     119           0 :     getVii()->visibilityModel (vis);
     120             : 
     121           0 :     phaseCenterShift (vis);
     122           0 : }
     123             : 
     124             : void
     125           0 : PhaseShiftTvi::visibilityObserved (Cube<Complex> & vis) const
     126             : {
     127             :     // Have the upstream VII fill the cube with the appropriate data and
     128             :     // then phase shift the entire cube.
     129             : 
     130           0 :     getVii()->visibilityObserved (vis);
     131             : 
     132           0 :     phaseCenterShift (vis);
     133           0 : }
     134             : 
     135             : } // end namespace vi
     136             : 
     137             : using namespace casacore;
     138             : } // end namespace casa
     139             : 
     140             : 
     141             : 

Generated by: LCOV version 1.16