MSSimulator.h

Go to the documentation of this file.
00001 //# MSSimulator.h: this defines the MeasurementSet Simulator
00002 //# Copyright (C) 1995,1996,1998,1999,2000,2002
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: MSSimulator.h 20299 2008-04-03 05:56:44Z gervandiepen $
00027 
00028 #ifndef MS_MSSIMULATOR_H
00029 #define MS_MSSIMULATOR_H
00030 
00031 
00032 //# Includes
00033 #include <casa/BasicSL/String.h>
00034 #include <casa/Arrays/Vector.h>
00035 #include <casa/Arrays/Matrix.h>
00036 #include <casa/Arrays/Cube.h>
00037 #include <casa/BasicSL/Complex.h>
00038 #include <casa/Quanta/Quantum.h>
00039 #include <measures/Measures/MPosition.h>
00040 #include <measures/Measures/MEpoch.h>
00041 namespace casa { //# NAMESPACE CASA - BEGIN
00042 
00043 //# Forward Declarations
00044 class MeasurementSet;
00045 class MDirection;
00046 
00047 // <category lib=aips module="ModuleName">
00048 // <summary> Create an empty MeasurementSet from observation and telescope descriptions. </summary>
00049 // <reviewed reviewer="" date="" tests="">
00050 //
00051 // <prerequisite>
00052 //# Classes you should understand before using this one.
00053 //   <li> MeasurementSet
00054 // </prerequisite>
00055 //
00056 // <etymology>
00057 // MS is from MeasurementSet, Simulator refers to the generation of
00058 // 'fake' data from a set of parameters for instrument and sources.
00059 // </etymology>
00060 //
00061 // <synopsis> 
00062 // This class creates a MeasurementSet from a set of parameters for instrument
00063 // and sources. It does not simulate the data, only the coordinates of a 
00064 // measurement. The application "simulator" uses this class to create a true
00065 // simulated MS with perfect or corrupted data.
00066 // </synopsis> 
00067 //
00068 // <motivation>
00069 // To test calibration and imaging programs it is necessary to have flawless
00070 // data and data with errors that are known exactly. This class generates
00071 // empty MeasurementSets (only coordinates filled in) that can be filled 
00072 // with predicted data.
00073 // </motivation>
00074 //
00075 // <todo asof="$DATE:$">
00076 //# A List of bugs, limitations, extensions or planned refinements.
00077 // <li>     The amount of information to be specified by the user
00078 //          could be much larger. For the moment it has been restricted to
00079 //          what is needed for testing the synthesis imaging code. Already
00080 //          it is possible to create MeasurementSets that cannot be processed
00081 //          yet.
00082 // </todo>
00083 
00084 class MSSimulator
00085 {
00086 public: 
00087   
00088   // Default constructor - use this, then invoke initAnt, initFeed, initSpWindow,
00089   // initConfig.
00090   MSSimulator();
00091   
00092   // Copy constructor - for completeness only
00093   MSSimulator(const MSSimulator & mss);
00094   
00095   //# Destructor
00096   ~MSSimulator();
00097   
00098 //# Operators
00099   // Assignment
00100   MSSimulator & operator=(const MSSimulator &);
00101   
00102   // set the antenna and array data.
00103   // This is held in MSSimulator vectors, and is then written into
00104   // the appropriate MS Tables when writeMS() and its helper function
00105   // extendMS() are called.   The same model is used for the Fields,
00106   // SpWindows, Feeds, and Times information below.
00107   void initAnt(const String& telname,
00108                const Vector<Double>& x, 
00109                const Vector<Double>& y, 
00110                const Vector<Double>& z,
00111                const Vector<Float>& dishDiameter,
00112                const Vector<String>& mount,
00113                const Vector<String>& name,
00114                const String& coordsystem,
00115                const MPosition& mRefLocation);
00116 
00117   // set the observed fields
00118   void initFields(const uInt nSources,
00119                   const Vector<String>& sourceName, 
00120                   const Vector<MDirection>& sourceDirection,
00121                   const Vector<Int>& intsPerPointing,
00122                   const Vector<Int>& mosPointingsX,
00123                   const Vector<Int>& mosPointingsY,
00124                   const Vector<Float>& mosSpacing);
00125 
00126 
00127   // set the Feeds;  brain dead version
00128   void initFeeds(const String& mode);
00129 
00130   // set the spectral windows information
00131   void initSpWindows(const uInt nSpWindows,
00132                      const Vector<String>& spWindowName,
00133                      const Vector<Int>& nChan,
00134                      const Vector<Quantity>& startFreq,
00135                      const Vector<Quantity>& freqInc,
00136                      const Vector<Quantity>& freqRes,
00137                      const Vector<String>& stokesString);
00138 
00139   void setFractionBlockageLimit(const Double fraclimit) 
00140     { fractionBlockageLimit_p = fraclimit; }
00141 
00142   void setElevationLimit(const Quantity& ellimit) 
00143     { elevationLimit_p = ellimit; }
00144 
00145   void setAutoCorrelationWt(const Float autocorrwt) 
00146     { autoCorrelationWt_p = autocorrwt; }
00147 
00148   void setTimes(const Quantity& qIntegrationTime, 
00149                 const Quantity& qGapTime, 
00150                 const Bool      useHourAngles,
00151                 const Quantity& qStartTime, 
00152                 const Quantity& qStopTime, 
00153                 const MEpoch&   qRefTime );
00154 
00155   // Write out a simulated MeasurementSet with the given name
00156   void writeMS(const String& msname); 
00157   void extendMS(MeasurementSet & ms);
00158 
00159   
00160 private:
00161 
00162 //# Data Members
00163   Int nSources_p, nSpWindows_p, nAnt_p, nFeed_p, nTimes_p;
00164   Double Tstart_p, Tend_p, Tint_p, Tgap_p;
00165   Quantity  qIntegrationTime_p, qGapTime_p, qStartTime_p, qStopTime_p;
00166   MEpoch mRefTime_p;
00167   Bool useHourAngles_p;
00168 
00169   Vector<Double> mosSpacing_p, startFreq_p, freqInc_p, freqRes_p,
00170       arrayXYZ_p, antDiam_p;
00171   Vector<Int> nChan_p, nIntFld_p, nIntSpW_p, nCorr_p, antId_p, feedAntId_p,
00172       feedId_p, feedSpWId_p, feedBeamId_p, feedNumRec_p;
00173   Matrix<Int> nMos_p,stokesTypes_p;
00174   Cube<Double> beamOffset_p;
00175   Cube<Complex> polResp_p;
00176   Vector<String> srcName_p, antName_p, mountType_p, spWindowName_p;
00177   Matrix<String> feedPol_p;
00178   Matrix<Double> radec_p, antXYZ_p, feedXYZ_p, feedAngle_p;
00179   MPosition refPosition_p;
00180   String  radecRefFrame_p, telescope_p;
00181   Double  fractionBlockageLimit_p;
00182   Quantity elevationLimit_p;
00183 
00184   Float autoCorrelationWt_p;
00185 
00186 //# Constructors
00187 
00188 //# Secure Member Functions
00189   
00190   void local2global(Vector<Double>& xReturned,
00191                     Vector<Double>& yReturned,
00192                     Vector<Double>& zReturned,
00193                     const MPosition& mRefLocation,
00194                     const Vector<Double>& xIn,
00195                     const Vector<Double>& yIn,
00196                     const Vector<Double>& zIn);
00197 
00198   void longlat2global(Vector<Double>& xReturned,
00199                       Vector<Double>& yReturned,
00200                       Vector<Double>& zReturned,
00201                       const MPosition& mRefLocation,
00202                       const Vector<Double>& xIn,
00203                       const Vector<Double>& yIn,
00204                       const Vector<Double>& zIn);
00205 
00206   // Returns the fractional blockage of one antenna by another
00207   // We will want to put this somewhere else eventually, but I don't yet know where!
00208   // Till then.
00209   // fraction1: fraction of antenna 1 that is blocked by 2
00210   // fraction2: fraction of antenna 2 that is blocked by 1
00211   // hint: at least one of the two will be 0.0
00212   void  blockage(Double &fraction1, Double &fraction2,
00213                  const Vector<Double>& uvw,             // uvw in same units as diam!
00214                  const Double diam1, const Double diam2);
00215 
00216 };
00217 
00218 
00219 } //# NAMESPACE CASA - END
00220 
00221 #endif
00222 
00223 
00224 
00225 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines