LCOV - code coverage report
Current view: top level - msvis/MSVis - MSUVWGenerator.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 1 0.0 %
Date: 2024-10-10 19:51:30 Functions: 0 1 0.0 %

          Line data    Source code
       1             : //# MSUVWGenerator.h: Generate and insert the (u, v, w)s of a MS.
       2             : //# Copyright (C) 2008
       3             : //# Associated Universities, Inc. Washington DC, USA.
       4             : //#
       5             : //# This library is free software; you can redistribute it and/or modify it
       6             : //# under the terms of the GNU Library General Public License as published by
       7             : //# the Free Software Foundation; either version 2 of the License, or (at your
       8             : //# option) any later version.
       9             : //#
      10             : //# This library is distributed in the hope that it will be useful, but WITHOUT
      11             : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      12             : //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
      13             : //# License for more details.
      14             : //#
      15             : //# You should have received a copy of the GNU Library General Public License
      16             : //# along with this library; if not, write to the Free Software Foundation,
      17             : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
      18             : //#
      19             : //# Correspondence concerning AIPS++ should be addressed as follows:
      20             : //#        Internet email: casa-feedback@nrao.edu.
      21             : //#        Postal address: AIPS++ Project Office
      22             : //#                        National Radio Astronomy Observatory
      23             : //#                        520 Edgemont Road
      24             : //#                        Charlottesville, VA 22903-2475 USA
      25             : //#
      26             : //# $Id$
      27             : //#
      28             : #ifndef MS_MSUVWGENERATOR_H
      29             : #define MS_MSUVWGENERATOR_H
      30             : 
      31             : #include <casacore/casa/aips.h>
      32             : #include <casacore/casa/BasicSL/String.h>
      33             : #include <casacore/ms/MeasurementSets/MeasurementSet.h>
      34             : #include <casacore/ms/MeasurementSets/MSColumns.h>
      35             : #include <casacore/measures/Measures/MBaseline.h>
      36             : 
      37             : // FTMachine::rotateUVW(casacore::Matrix<casacore::Double>& uvw, casacore::Vector<casacore::Double>& dphase,
      38             : //                      const VisBuffer& vb)
      39             : 
      40             : namespace casacore{
      41             : 
      42             : class MeasurementSet;
      43             : class LogIO;
      44             : }
      45             : 
      46             : namespace casa { //# NAMESPACE CASA - BEGIN
      47             : 
      48             : 
      49             : // <summary>Generates and inserts the (u, v, w)s of a casacore::MS that may or may not
      50             : // already have them.  Includes antenna offsets when known.</summary>
      51             : // <use visibility=export>
      52             : // 
      53             : // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
      54             : // </reviewed>
      55             : // 
      56             : // <prerequisite>
      57             : //   <li> <linkto class=casacore::MeasurementSet>MeasurementSet</linkto>
      58             : //   <li> <linkto class=casacore::Measure>Measure</linkto>
      59             : // </prerequisite>
      60             : //
      61             : // <etymology>
      62             : // It generates a UVW column for the casacore::MS, whether or not it already has one.
      63             : // It is an adaptation of alma/apps/asdm2MS/UvwCoords to work with MSes instead
      64             : // of ASDMs.
      65             : // </etymology>
      66             : //
      67             : // <synopsis>
      68             : // (u, v, w)s are needed for imaging, but some data sets may not come with them
      69             : // included, or the (u, v, w)s may need correction.
      70             : // </synopsis>
      71             : //
      72             : // <motivation>
      73             : // Currently (10/30/2008), ASDMs from either the ALMA Test Facility or the
      74             : // EVLA do not come with (u, v, w)s, and need to be processed with the UVFIX
      75             : // task in AIPS.  It would be preferable to process them entirely inside CASA.
      76             : // </motivation>
      77             : //
      78             : // <todo asof="11/20/2008">
      79             : // It requires as input the casacore::MS timeCentroids item which is an output in the
      80             : // ASDM DAMs.
      81             : //     - the use-case when the timeCentroid is baseline-based and or spectral
      82             : //       window based.
      83             : //     - correlationMode filter (hopefully handled by SDM -> casacore::MS import routines).
      84             : //       direction item in the field table.
      85             : // @note The current limitations are set by the status of the ASDM
      86             : //     - OTF not supported due to a limitation in the model of the phase
      87             : // </todo>
      88             : class MSUVWGenerator
      89             : {
      90             : public:
      91             :   // Constructor 
      92             :   //      @param ms_ref Reference to the casacore::MS's columns.
      93             :   //      @post - The relative positions for all the antennas in the Antenna
      94             :   //              table are in bl_an_p.
      95             :   //            - timeRes_p has been conservatively calculated using rough
      96             :   //              estimates of the maximum baseline length and field of view.
      97             :   MSUVWGenerator(casacore::MSColumns& ms_ref, const casacore::MBaseline::Types bltype,
      98             :                  const casacore::Muvw::Types uvwtype);
      99             : 
     100             :   // Destructor
     101             :   ~MSUVWGenerator();
     102             : 
     103             :   // Determine the uvw for a single phaseDir and timeCentroid, and pair of
     104             :   // feeds (which may be the same).
     105             :   //
     106             :   //       @param ant1   Row number in the ANTENNA table of the 1st antenna.
     107             :   //       @param feed1  Row number in the FEED    table of the 1st feed.
     108             :   //       @param ant1   Row number in the ANTENNA table of the 2nd antenna.
     109             :   //       @param feed2  Row number in the FEED    table of the 2nd feed.
     110             :   //       @param uvw    The returned UVW coordinates.
     111             :   void uvw_bl(const casacore::uInt ant1, const casacore::uInt feed1,
     112             :               const casacore::uInt ant2, const casacore::uInt feed2, casacore::Array<casacore::Double>& uvw);
     113             : 
     114             :   // Calculate the uvws for the field IDs in flds that are not -1, and set
     115             :   // those phase directions according to phaseDirs.
     116             :   //       @param flds       A map from row numbers in the FIELD table to
     117             :   //                         indices in phaseDirs.  For example, if the casacore::MS has
     118             :   //                         5 fields, and the user wants to (re)calculate the
     119             :   //                         UVWs of only 0, 2, and 4, phaseDirs will have 3
     120             :   //                         entries and flds will be [0, -1, 1, -1, 2].  
     121             :   casacore::Bool make_uvws(const casacore::Vector<casacore::Int> flds);
     122             : private:
     123             :   // Sets up the antenna positions as baselines (bl_an_p), the number of
     124             :   // antennas (nant_p), and timeRes_p.
     125             :   void fill_bl_an(casacore::Vector<casacore::MVBaseline>& bl_an_p);
     126             :   
     127             :   // Determine antUVW_p for every member of the sequence of antennas
     128             :   // defining a (sub)array.
     129             :   //     @param  timeCentroid    An epoch, the 'when' characterization.
     130             :   //     @param  fldID           The row number in the FIELD table which gives
     131             :   //                             the phase tracking center.
     132             :   //     @param  WSRTConvention  If true (WSRT only?), the l in the ul + vm
     133             :   //                             phase calculation decreases toward increasing
     134             :   //                             RA.  If false (VLA), it increases with
     135             :   //                             increasing RA.  See the code for more info.
     136             :   //     @note This function only calculates UVWs for a single time and a
     137             :   //     single phase center.  Fields can potentially have multiple phase
     138             :   //     directions, so be prepared to call this function from within a loop
     139             :   //     that also takes care of setting timeCentroid and phaseDir.
     140             :   //     @warning timeCentroid can be initialized like
     141             :   //       casacore::MEpoch timeCentroid(casacore::Quantity(<double>, "s"), casacore::MEpoch::TAI);
     142             :   //      but the accuracy is limited since there is no extra precision
     143             :   //      attribute (see Main table of casacore::MS v2).
     144             :   void uvw_an(const casacore::MEpoch& timeCentroid, const casacore::Int fldID,
     145             :               const casacore::Bool WSRTConvention=false);
     146             : 
     147             :   // (Sub-)array parameters constraining order and size of the output vector 
     148             :   // of UVW coords triplets.
     149             :   // struct ArrayParam{
     150             : //   public:
     151             : //     casacore::Int                   subarrayId;        // (sub)array identifier
     152             : //     vector<Tag>           v_ant;             //<! sequence of antennas
     153             : //     unsigned int          nrepeat;           //<! number of casacore::MS main table rows
     154             : //                                           //   per antenna baseline
     155             : //     Enum<CorrelationMode> e_correlationMode; //<! correlation mode (original
     156             : //                                           //   mode passed through the user
     157             : //                                           //   filter) (FOLLOWUP: is this needed?)
     158             : //     string show(){
     159             : //       ostringstream os;
     160             : //       os << " nrepeat " << nrepeat;
     161             : //       return os.str();
     162             : //     }
     163             :   //};
     164             : 
     165             :   //****************** Member variables ********************************
     166             : 
     167             :   //**************** Initialized by ctor, ******************************
     168             :   //**************** so they should appear ******************************
     169             :   //**************** here in the same order ******************************
     170             :   //**************** as they do in the ctor. ******************************
     171             : 
     172             :   casacore::MSColumns& msc_p;  // the columns of the measurement set.
     173             : 
     174             :   // casacore::Coordinate system selectors.
     175             :   casacore::MBaseline::Ref bl_csys_p;
     176             :   
     177             :   const casacore::MSAntennaColumns& antColumns_p;
     178             : 
     179             :   // The antenna positions of ms_p in ITRF.  It cannot be const because of the
     180             :   // need to update satellite positions.
     181             :   // antPositions_p and antOffset_p are references and must therefore be
     182             :   // initialized in the initialization list.
     183             :   const casacore::ROScalarMeasColumn<casacore::MPosition>& antPositions_p;
     184             : 
     185             :   // The offsets between the phase reference point (see feed_offsets below for
     186             :   // clarification) of each antenna and the closest point which is fixed
     187             :   // relative to the antenna position (i.e. an axis).  Since no one else has
     188             :   // defined it yet, I am defining it as the offset when the antenna is
     189             :   // pointing at zenith, oriented so that if it slewed down, it would move
     190             :   // toward the north.  (x, y, z) = (east, north, up).
     191             :   //
     192             :   // This appears to be a required column of the ANTENNA table in version 2.0
     193             :   // of the casacore::MeasurementSet definition
     194             :   // (http://aips2.nrao.edu/docs/notes/229/229.html), so it is assumed to be
     195             :   // present.  However, it is usually a set of zeroes, based on the common
     196             :   // belief that it is only needed for heterogeneous arrays, since the
     197             :   // receivers of homogeneous arrays move in concert.  That is not true when
     198             :   // there are independent pointing errors.
     199             :   const casacore::ROScalarMeasColumn<casacore::MPosition>& antOffset_p;
     200             : 
     201             :   // The position of the first antenna.
     202             :   casacore::MPosition refpos_p;
     203             :   
     204             :   // Ditto for feed.
     205             :   //const casacore::MSFeedColumns *feedColumns_;
     206             : 
     207             :   // The offset between the feed and the phase reference point of each antenna
     208             :   // in the same frame as ant_offsets.  Therefore the feed position is
     209             :   //  ant_positions_p(ant) + [rotation matrix](pointing) (ant_offsets_p[ant] +
     210             :   //                                                    feed_offsets_p[ant])
     211             :   const casacore::ROScalarMeasColumn<casacore::MPosition>& feedOffset_p;
     212             : 
     213             :   casacore::MBaseline::Types refposref_p;  
     214             : 
     215             :   // The antenna positions - refpos_p.getValue().
     216             :   casacore::Vector<casacore::MVBaseline> bl_an_p;
     217             : 
     218             :   casacore::uInt nant_p;  // # of antennas
     219             : 
     220             :   // The minimum time difference for forcing an update of the UVWs.  We're not
     221             :   // trying to do time averaging here, so it should be small, but not so small
     222             :   // that uvw_an() is called for every baseline, even when the times are
     223             :   // practically the same.
     224             :   casacore::Double timeRes_p;
     225             : 
     226             :   //************* Initialized later, if at all. ********************
     227             :   
     228             :   // Log functions and variables
     229             :   casacore::LogIO sink_p;
     230           0 :   casacore::LogIO& logSink() {return sink_p;}
     231             : 
     232             :   //map<Tag, ArrayParam>      m_array_p;     // FIX: Tag
     233             : 
     234             :   // The UVW "positions" of each antenna being used during a time bin,
     235             :   // i.e. the (u, v, w) of the baseline between antennas m and n is
     236             :   //  antUVW_p[n] - antUVW_p[m].
     237             :   // <todo asof="02/18/2009">
     238             :   // Generalize to multifeed systems.
     239             :   // </todo>
     240             :   casacore::Vector<casacore::Vector<casacore::Double> > antUVW_p;
     241             : 
     242             :   // the 3 fundamental attributes of the state machine
     243             :   casacore::ArrayColumn<casacore::Double> phaseDir_p; 
     244             :   //casacore::Int                   subarrayId_p;
     245             : 
     246             :   // The number of wavelengths by which a feed may move relative to the
     247             :   // corresponding feed in another antenna of the array without requiring the
     248             :   // offset to be included in uvw calculations.  If < 0 the offset will always
     249             :   // be included.
     250             :   //
     251             :   // Offsets include:
     252             :   //    ant_offset:  OFFSET in the ANTENNA table of an MS.
     253             :   //                 The separation between an antenna's "phase reference
     254             :   //                 point" and its closest point (usu. an axis) fixed rel
     255             :   //                 to its position.
     256             :   //
     257             :   //    feed_offset: POSITION in the FEED table of an MS.
     258             :   //                 The separation between a feed and ant_pos + ant_offset.
     259             :   //                 Just another offset to add to ant_offset, but unlike
     260             :   //                 ant_offset it is likely to change when the band is
     261             :   //                 changed.
     262             :   //
     263             :   //    rec_offset: Not found in MSes, acc. to vers. 2 of of the MeasurementSet
     264             :   //                definition (http://aips2.nrao.edu/docs/notes/229/229.html).
     265             :   //                The separation between a receptor and its feed.
     266             :   //                Only needed for feed arrays.  The above URL defines a feed
     267             :   //                (incl. feed arrays) as a set of receptors that should be
     268             :   //                calibrated as a single entity.  Predicting how observers
     269             :   //                will decide to calibrate feed arrays is difficult,
     270             :   //                especially since there are no interferometers with feed
     271             :   //                arrays yet, but it can be argued that rec_offset can be
     272             :   //                ignored in many cases.  If a feed array's output is
     273             :   //                combined before leaving the feed (i.e. a beamforming
     274             :   //                array), it may as well be treated as a single feed.  If the
     275             :   //                receptor outputs are kept separate longer, they likely need
     276             :   //                to be calibrated separately and get their own FEED tables.
     277             :   //
     278             :   // They affect how the baselines of heterogeneous arrays vary with phase
     279             :   // tracking direction, and make the baselines of any array depend on pointing
     280             :   // errors.  The latter effect is often neglected, and the offsets are written
     281             :   // as sets of zeroes, even though they really are not.
     282             :   //
     283             :   
     284             :   // 
     285             : };
     286             :   
     287             : } //# NAMESPACE CASA - END
     288             : 
     289             : #endif

Generated by: LCOV version 1.16