MSUVWGenerator.h

Go to the documentation of this file.
00001 //# MSUVWGenerator.h: Generate and insert the (u, v, w)s of a MS.
00002 //# Copyright (C) 2008
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id$
00027 //#
00028 #ifndef MS_MSUVWGENERATOR_H
00029 #define MS_MSUVWGENERATOR_H
00030 
00031 #include <casa/aips.h>
00032 #include <casa/BasicSL/String.h>
00033 #include <ms/MeasurementSets/MeasurementSet.h>
00034 #include <ms/MeasurementSets/MSColumns.h>
00035 #include <measures/Measures/MBaseline.h>
00036 
00037 // FTMachine::rotateUVW(Matrix<Double>& uvw, Vector<Double>& dphase,
00038 //                      const VisBuffer& vb)
00039 
00040 namespace casa { //# NAMESPACE CASA - BEGIN
00041 
00042 class MeasurementSet;
00043 class LogIO;
00044 
00045 // <summary>Generates and inserts the (u, v, w)s of a MS that may or may not
00046 // already have them.  Includes antenna offsets when known.</summary>
00047 // <use visibility=export>
00048 // 
00049 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00050 // </reviewed>
00051 // 
00052 // <prerequisite>
00053 //   <li> <linkto class=MeasurementSet>MeasurementSet</linkto>
00054 //   <li> <linkto class=Measure>Measure</linkto>
00055 // </prerequisite>
00056 //
00057 // <etymology>
00058 // It generates a UVW column for the MS, whether or not it already has one.
00059 // It is an adaptation of alma/apps/asdm2MS/UvwCoords to work with MSes instead
00060 // of ASDMs.
00061 // </etymology>
00062 //
00063 // <synopsis>
00064 // (u, v, w)s are needed for imaging, but some data sets may not come with them
00065 // included, or the (u, v, w)s may need correction.
00066 // </synopsis>
00067 //
00068 // <motivation>
00069 // Currently (10/30/2008), ASDMs from either the ALMA Test Facility or the
00070 // EVLA do not come with (u, v, w)s, and need to be processed with the UVFIX
00071 // task in AIPS.  It would be preferable to process them entirely inside CASA.
00072 // </motivation>
00073 //
00074 // <todo asof="11/20/2008">
00075 // It requires as input the MS timeCentroids item which is an output in the
00076 // ASDM DAMs.
00077 //     - the use-case when the timeCentroid is baseline-based and or spectral
00078 //       window based.
00079 //     - correlationMode filter (hopefully handled by SDM -> MS import routines).
00080 //       direction item in the field table.
00081 // @note The current limitations are set by the status of the ASDM
00082 //     - OTF not supported due to a limitation in the model of the phase
00083 // </todo>
00084 class MSUVWGenerator
00085 {
00086 public:
00087   // Constructor 
00088   //      @param ms_ref Reference to the MS's columns.
00089   //      @post - The relative positions for all the antennas in the Antenna
00090   //              table are in bl_an_p.
00091   //            - timeRes_p has been conservatively calculated using rough
00092   //              estimates of the maximum baseline length and field of view.
00093   MSUVWGenerator(MSColumns& ms_ref, const MBaseline::Types bltype,
00094                  const Muvw::Types uvwtype);
00095 
00096   // Destructor
00097   ~MSUVWGenerator();
00098 
00099   // Determine the uvw for a single phaseDir and timeCentroid, and pair of
00100   // feeds (which may be the same).
00101   //
00102   //       @param ant1   Row number in the ANTENNA table of the 1st antenna.
00103   //       @param feed1  Row number in the FEED    table of the 1st feed.
00104   //       @param ant1   Row number in the ANTENNA table of the 2nd antenna.
00105   //       @param feed2  Row number in the FEED    table of the 2nd feed.
00106   //       @param uvw    The returned UVW coordinates.
00107   void uvw_bl(const uInt ant1, const uInt feed1,
00108               const uInt ant2, const uInt feed2, Array<Double>& uvw);
00109 
00110   // Calculate the uvws for the field IDs in flds that are not -1, and set
00111   // those phase directions according to phaseDirs.
00112   //       @param flds       A map from row numbers in the FIELD table to
00113   //                         indices in phaseDirs.  For example, if the MS has
00114   //                         5 fields, and the user wants to (re)calculate the
00115   //                         UVWs of only 0, 2, and 4, phaseDirs will have 3
00116   //                         entries and flds will be [0, -1, 1, -1, 2].  
00117   Bool make_uvws(const Vector<Int> flds);
00118 private:
00119   // Sets up the antenna positions as baselines (bl_an_p), the number of
00120   // antennas (nant_p), and timeRes_p.
00121   void fill_bl_an(Vector<MVBaseline>& bl_an_p);
00122   
00123   // Determine antUVW_p for every member of the sequence of antennas
00124   // defining a (sub)array.
00125   //     @param  timeCentroid    An epoch, the 'when' characterization.
00126   //     @param  fldID           The row number in the FIELD table which gives
00127   //                             the phase tracking center.
00128   //     @param  WSRTConvention  If true (WSRT only?), the l in the ul + vm
00129   //                             phase calculation decreases toward increasing
00130   //                             RA.  If false (VLA), it increases with
00131   //                             increasing RA.  See the code for more info.
00132   //     @note This function only calculates UVWs for a single time and a
00133   //     single phase center.  Fields can potentially have multiple phase
00134   //     directions, so be prepared to call this function from within a loop
00135   //     that also takes care of setting timeCentroid and phaseDir.
00136   //     @warning timeCentroid can be initialized like
00137   //       MEpoch timeCentroid(Quantity(<double>, "s"), MEpoch::TAI);
00138   //      but the accuracy is limited since there is no extra precision
00139   //      attribute (see Main table of MS v2).
00140   void uvw_an(const MEpoch& timeCentroid, const Int fldID,
00141               const Bool WSRTConvention=false);
00142 
00143   // (Sub-)array parameters constraining order and size of the output vector 
00144   // of UVW coords triplets.
00145   // struct ArrayParam{
00146 //   public:
00147 //     Int                   subarrayId;        // (sub)array identifier
00148 //     vector<Tag>           v_ant;             //<! sequence of antennas
00149 //     unsigned int          nrepeat;           //<! number of MS main table rows
00150 //                                           //   per antenna baseline
00151 //     Enum<CorrelationMode> e_correlationMode; //<! correlation mode (original
00152 //                                           //   mode passed through the user
00153 //                                           //   filter) (FOLLOWUP: is this needed?)
00154 //     string show(){
00155 //       ostringstream os;
00156 //       os << " nrepeat " << nrepeat;
00157 //       return os.str();
00158 //     }
00159   //};
00160 
00161   //****************** Member variables ********************************
00162 
00163   //**************** Initialized by ctor, ******************************
00164   //**************** so they should appear ******************************
00165   //**************** here in the same order ******************************
00166   //**************** as they do in the ctor. ******************************
00167 
00168   MSColumns& msc_p;  // the columns of the measurement set.
00169 
00170   // Coordinate system selectors.
00171   MBaseline::Ref bl_csys_p;
00172   Muvw::Types    uvw_csys_p;
00173   
00174   const ROMSAntennaColumns& antColumns_p;
00175 
00176   // The antenna positions of ms_p in ITRF.  It cannot be const because of the
00177   // need to update satellite positions.
00178   // antPositions_p and antOffset_p are references and must therefore be
00179   // initialized in the initialization list.
00180   const ROScalarMeasColumn<MPosition>& antPositions_p;
00181 
00182   // The offsets between the phase reference point (see feed_offsets below for
00183   // clarification) of each antenna and the closest point which is fixed
00184   // relative to the antenna position (i.e. an axis).  Since no one else has
00185   // defined it yet, I am defining it as the offset when the antenna is
00186   // pointing at zenith, oriented so that if it slewed down, it would move
00187   // toward the north.  (x, y, z) = (east, north, up).
00188   //
00189   // This appears to be a required column of the ANTENNA table in version 2.0
00190   // of the MeasurementSet definition
00191   // (http://aips2.nrao.edu/docs/notes/229/229.html), so it is assumed to be
00192   // present.  However, it is usually a set of zeroes, based on the common
00193   // belief that it is only needed for heterogeneous arrays, since the
00194   // receivers of homogeneous arrays move in concert.  That is not true when
00195   // there are independent pointing errors.
00196   const ROScalarMeasColumn<MPosition>& antOffset_p;
00197 
00198   // The position of the first antenna.
00199   MPosition refpos_p;
00200   
00201   // Ditto for feed.
00202   //const ROMSFeedColumns *feedColumns_;
00203 
00204   // The offset between the feed and the phase reference point of each antenna
00205   // in the same frame as ant_offsets.  Therefore the feed position is
00206   //  ant_positions_p(ant) + [rotation matrix](pointing) (ant_offsets_p[ant] +
00207   //                                                    feed_offsets_p[ant])
00208   const ROScalarMeasColumn<MPosition>& feedOffset_p;
00209 
00210   MBaseline::Types refposref_p;  
00211 
00212   // The antenna positions - refpos_p.getValue().
00213   Vector<MVBaseline> bl_an_p;
00214 
00215   uInt nant_p;  // # of antennas
00216 
00217   // The minimum time difference for forcing an update of the UVWs.  We're not
00218   // trying to do time averaging here, so it should be small, but not so small
00219   // that uvw_an() is called for every baseline, even when the times are
00220   // practically the same.
00221   Double timeRes_p;
00222 
00223   //************* Initialized later, if at all. ********************
00224   
00225   // Log functions and variables
00226   LogIO sink_p;
00227   LogIO& logSink() {return sink_p;}
00228 
00229   //map<Tag, ArrayParam>      m_array_p;     // FIX: Tag
00230 
00231   // The UVW "positions" of each antenna being used during a time bin,
00232   // i.e. the (u, v, w) of the baseline between antennas m and n is
00233   //  antUVW_p[n] - antUVW_p[m].
00234   // <todo asof="02/18/2009">
00235   // Generalize to multifeed systems.
00236   // </todo>
00237   Vector<Vector<Double> > antUVW_p;
00238 
00239   // the 3 fundamental attributes of the state machine
00240   Double                timeCentroid_p;
00241   ROArrayColumn<Double> phaseDir_p; 
00242   //Int                   subarrayId_p;
00243 
00244   // The number of wavelengths by which a feed may move relative to the
00245   // corresponding feed in another antenna of the array without requiring the
00246   // offset to be included in uvw calculations.  If < 0 the offset will always
00247   // be included.
00248   //
00249   // Offsets include:
00250   //    ant_offset:  OFFSET in the ANTENNA table of an MS.
00251   //                 The separation between an antenna's "phase reference
00252   //                 point" and its closest point (usu. an axis) fixed rel
00253   //                 to its position.
00254   //
00255   //    feed_offset: POSITION in the FEED table of an MS.
00256   //                 The separation between a feed and ant_pos + ant_offset.
00257   //                 Just another offset to add to ant_offset, but unlike
00258   //                 ant_offset it is likely to change when the band is
00259   //                 changed.
00260   //
00261   //    rec_offset: Not found in MSes, acc. to vers. 2 of of the MeasurementSet
00262   //                definition (http://aips2.nrao.edu/docs/notes/229/229.html).
00263   //                The separation between a receptor and its feed.
00264   //                Only needed for feed arrays.  The above URL defines a feed
00265   //                (incl. feed arrays) as a set of receptors that should be
00266   //                calibrated as a single entity.  Predicting how observers
00267   //                will decide to calibrate feed arrays is difficult,
00268   //                especially since there are no interferometers with feed
00269   //                arrays yet, but it can be argued that rec_offset can be
00270   //                ignored in many cases.  If a feed array's output is
00271   //                combined before leaving the feed (i.e. a beamforming
00272   //                array), it may as well be treated as a single feed.  If the
00273   //                receptor outputs are kept separate longer, they likely need
00274   //                to be calibrated separately and get their own FEED tables.
00275   //
00276   // They affect how the baselines of heterogeneous arrays vary with phase
00277   // tracking direction, and make the baselines of any array depend on pointing
00278   // errors.  The latter effect is often neglected, and the offsets are written
00279   // as sets of zeroes, even though they really are not.
00280   //
00281   Double offset_tolerance;
00282   
00283   // 
00284   Bool   adj_uvw_for_ptg_err;
00285 };
00286   
00287 } //# NAMESPACE CASA - END
00288 
00289 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1