NewMSSimulator.h

Go to the documentation of this file.
00001 //# NewMSSimulator.h: this defines the MeasurementSet Simulator
00002 //# Copyright (C) 1995-2009
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_NEWMSSIMULATOR_H
00029 #define MS_NEWMSSIMULATOR_H
00030 
00031 
00032 //# Includes
00033 #include <casacore/casa/aips.h>
00034 #include <casacore/casa/BasicSL/String.h>
00035 #include <casacore/casa/Arrays/Vector.h>
00036 #include <casacore/casa/Arrays/Matrix.h>
00037 #include <casacore/casa/Arrays/Cube.h>
00038 #include <casacore/casa/BasicSL/Complex.h>
00039 #include <casacore/casa/Quanta/Quantum.h>
00040 #include <casacore/measures/Measures/MPosition.h>
00041 #include <casacore/measures/Measures/MEpoch.h>
00042 #include <casacore/measures/Measures/MFrequency.h>
00043 #include <casacore/measures/Measures/MDirection.h>
00044 
00045 #include <casacore/tables/DataMan/TiledDataStManAccessor.h>
00046 
00047 namespace casacore { //# NAMESPACE CASACORE - BEGIN
00048 
00049 //# Forward Declarations
00050 class MeasurementSet;
00051 
00052 // <category lib=aips module="ModuleName">
00053 // <summary> Create an empty MeasurementSet from observation and telescope descriptions. </summary>
00054 // <reviewed reviewer="" date="" tests="">
00055 //
00056 // <prerequisite>
00057 //# Classes you should understand before using this one.
00058 //  <li> MeasurementSet
00059 // </prerequisite>
00060 //
00061 // <etymology>
00062 // MS is from MeasurementSet, Simulator refers to the generation of
00063 // 'fake' data from a set of parameters for instrument and sources.
00064 // </etymology>
00065 //
00066 // <synopsis> 
00067 // This class creates a MeasurementSet from a set of parameters for instrument
00068 // and sources. It does not simulate the data, only the coordinates of a 
00069 // measurement. The application "simulator" uses this class to create a true
00070 // simulated MS with perfect or corrupted data.
00071 // </synopsis> 
00072 //
00073 // <motivation>
00074 // To test calibration and imaging programs it is necessary to have flawless
00075 // data and data with errors that are known exactly. This class generates
00076 // empty MeasurementSets (only coordinates filled in) that can be filled 
00077 // with predicted data.
00078 // </motivation>
00079 //
00080 // <todo asof="$DATE:$">
00081 //# A List of bugs, limitations, extensions or planned refinements.
00082 // <li>     The amount of information to be specified by the user
00083 //          could be much larger. For the moment it has been restricted to
00084 //          what is needed for testing the synthesis imaging code. Already
00085 //          it is possible to create MeasurementSets that cannot be processed
00086 //          yet.
00087 // </todo>
00088 
00089 class NewMSSimulator
00090 {
00091 public: 
00092   
00093   // Constructor from name only
00094   NewMSSimulator(const String&);
00095 
00096   // Constructor from existing MS
00097   NewMSSimulator(MeasurementSet&);
00098 
00099   // Copy constructor - for completeness only
00100   NewMSSimulator(const NewMSSimulator & mss);
00101   
00102   //# Destructor
00103   ~NewMSSimulator();
00104   
00105 //# Operators
00106   // Assignment
00107   NewMSSimulator & operator=(const NewMSSimulator &);
00108   
00109   // Set maximum amount of data (bytes) to be written into any one
00110   // scratch column hypercube
00111   void setMaxData(const Double maxData=2e9) {maxData_p=maxData;}
00112   
00113   // set the antenna and array data. These are written immediately to the
00114   // existing MS. The same model is used for the other init infor.
00115   void initAnt(const String& telname,
00116                const Vector<Double>& x, 
00117                const Vector<Double>& y, 
00118                const Vector<Double>& z,
00119                const Vector<Double>& dishDiameter,
00120                const Vector<Double>& offset,
00121                const Vector<String>& mount,
00122                const Vector<String>& name,
00123                const Vector<String>& padname,
00124                const String& coordsystem,
00125                const MPosition& mRefLocation);
00126   // get the info back 
00127   bool getAnt(String& telescope, Int& nAnt, Matrix<Double>* antXYZ, 
00128               Vector<Double>& antDiam, Vector<Double>& offset,
00129               Vector<String>& mount, Vector<String>& name, Vector<String>& padname,
00130               String& coordsystem, MPosition& mRefLocation );
00131 
00132   // set the observed fields
00133   void initFields(const String& sourceName, 
00134                   const MDirection& sourceDirection,
00135                   const String& calCode);
00136 
00137   bool getFields(Int& nField,
00138                  Vector<String>& sourceName, 
00139                  Vector<MDirection>& sourceDirection,
00140                  Vector<String>& calCode);
00141 
00142   // set the Feeds;  brain dead version
00143   void initFeeds(const String& mode);
00144 
00145   bool getFeedMode(String& mode);
00146 
00147   // set the Feeds;  Smart version
00148   void initFeeds(const String& mode,
00149                  const Vector<Double>& x,
00150                  const Vector<Double>& y,
00151                  const Vector<String>& pol);
00152 
00153   // set the spectral windows information
00154   void initSpWindows(const String& spWindowName,
00155                      const Int& nChan,
00156                      const Quantity& startFreq,
00157                      const Quantity& freqInc,
00158                      const Quantity& freqRes,
00159                      const MFrequency::Types& freqType,
00160                      const String& stokesString);
00161 
00162   bool getSpWindows(Int& nSpw,
00163                     Vector<String>& spWindowName,
00164                     Vector<Int>& nChan,
00165                     Vector<Quantity>& startFreq,
00166                     Vector<Quantity>& freqInc,
00167                     Vector<String>& stokesString);
00168 
00169   void setFractionBlockageLimit(const Double fraclimit) 
00170     { fractionBlockageLimit_p = fraclimit; }
00171 
00172   void setElevationLimit(const Quantity& ellimit) 
00173     { elevationLimit_p = ellimit; }
00174 
00175   void setAutoCorrelationWt(const Float autocorrwt) 
00176     { autoCorrelationWt_p = autocorrwt; }
00177 
00178   void settimes(const Quantity& qIntegrationTime, 
00179                 const Bool      useHourAngles,
00180                 const MEpoch&   mRefTime);
00181 
00182   void observe(const String& sourceName,
00183                const String& spWindowName,
00184                const Quantity& qStartTime, 
00185                const Quantity& qStopTime,
00186                const Bool add_observation=True,
00187 //# from int ASDM2MSFiller::addUniqueState(
00188 //# defaults for ALMA as known on 20100831
00189                const Bool state_sig=True,
00190                const Bool state_ref=True,
00191                const double& state_cal=0.,
00192                const double& state_load=0.,
00193                const unsigned int state_sub_scan=1,
00194                const String& state_obs_mode="OBSERVE_TARGET.ON_SOURCE",
00195                const String& observername="CASA simulator",
00196                const String& projectname="CASA simulation");
00197 
00198 
00199   void observe(const Vector<String>& sourceNames,
00200                const String& spWindowName,
00201                const Vector<Quantity>& qStartTimes, 
00202                const Vector<Quantity>& qStopTimes,
00203                const Vector<MDirection>& directions,
00204                const Bool add_observation=True,
00205 //# from int ASDM2MSFiller::addUniqueState(
00206 //# defaults for ALMA as known on 20100831
00207                const Bool state_sig=True,
00208                const Bool state_ref=True,
00209                const double& state_cal=0.,
00210                const double& state_load=0.,
00211                const unsigned int state_sub_scan=1,
00212                const String& state_obs_mode="OBSERVE_TARGET.ON_SOURCE",
00213                const String& observername="CASA simulator",
00214                const String& projectname="CASA simulation");
00215 
00216   MeasurementSet * getMs () const;
00217 
00218 
00219 private:
00220 
00221   // Prevent use of default constructor
00222   NewMSSimulator() {}
00223 
00224 //# Data Members
00225   Double fractionBlockageLimit_p;
00226   Quantity elevationLimit_p;
00227   Float autoCorrelationWt_p;
00228   String telescope_p;
00229   Quantity qIntegrationTime_p;
00230   Bool useHourAngle_p;
00231   Bool hourAngleDefined_p;
00232   MEpoch mRefTime_p;
00233   Double t_offset_p;
00234   Double dataWritten_p;
00235   Int hyperCubeID_p;
00236   Bool hasHyperCubes_p;
00237   Int lastSpWID_p;
00238   Int lastNchan_p;
00239 
00240   MeasurementSet* ms_p;
00241 
00242   TiledDataStManAccessor dataAcc_p, scratchDataAcc_p, sigmaAcc_p, flagAcc_p;
00243 
00244   Double maxData_p;
00245 
00246   void local2global(Vector<Double>& xReturned,
00247                     Vector<Double>& yReturned,
00248                     Vector<Double>& zReturned,
00249                     const MPosition& mRefLocation,
00250                     const Vector<Double>& xIn,
00251                     const Vector<Double>& yIn,
00252                     const Vector<Double>& zIn);
00253 
00254   void longlat2global(Vector<Double>& xReturned,
00255                       Vector<Double>& yReturned,
00256                       Vector<Double>& zReturned,
00257                       const MPosition& mRefLocation,
00258                       const Vector<Double>& xIn,
00259                       const Vector<Double>& yIn,
00260                       const Vector<Double>& zIn);
00261 
00262   // Returns the fractional blockage of one antenna by another
00263   // We will want to put this somewhere else eventually, but I don't yet know where!
00264   // Till then.
00265   // fraction1: fraction of antenna 1 that is blocked by 2
00266   // fraction2: fraction of antenna 2 that is blocked by 1
00267   // hint: at least one of the two will be 0.0
00268   void  blockage(Double &fraction1, Double &fraction2,
00269                  const Vector<Double>& uvw,             // uvw in same units as diam!
00270                  const Double diam1, const Double diam2);
00271 
00272   String formatDirection(const MDirection&);
00273   String formatTime(const Double);
00274 
00275   void addHyperCubes(const Int id, const Int nBase, const Int nChan, const Int nCorr);
00276 
00277   void defaults();
00278 
00279   Bool calcAntUVW(MEpoch& epoch, MDirection& refdir, 
00280                         Matrix<Double>& uvwAnt);
00281 
00282 
00283 };
00284 
00285 
00286 } //# NAMESPACE CASACORE - END
00287 
00288 #endif
00289 
00290 
00291 
00292 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1