casacore
NewMSSimulator.h
Go to the documentation of this file.
1 //# NewMSSimulator.h: this defines the MeasurementSet Simulator
2 //# Copyright (C) 1995-2009
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: aips2-request@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_NEWMSSIMULATOR_H
29 #define MS_NEWMSSIMULATOR_H
30 
31 
32 //# Includes
33 #include <memory>
34 #include <casacore/casa/aips.h>
35 #include <casacore/casa/BasicSL/String.h>
36 #include <casacore/casa/Arrays/Vector.h>
37 #include <casacore/casa/Arrays/Matrix.h>
38 #include <casacore/casa/Arrays/Cube.h>
39 #include <casacore/casa/BasicSL/Complex.h>
40 #include <casacore/casa/Quanta/Quantum.h>
41 #include <casacore/measures/Measures/MPosition.h>
42 #include <casacore/measures/Measures/MEpoch.h>
43 #include <casacore/measures/Measures/MFrequency.h>
44 #include <casacore/measures/Measures/MDirection.h>
45 
46 #include <casacore/tables/DataMan/TiledDataStManAccessor.h>
47 
48 namespace casacore { //# NAMESPACE CASACORE - BEGIN
49 
50 //# Forward Declarations
51 class MeasurementSet;
52 
53 // <category lib=aips module="ModuleName">
54 // <summary> Create an empty MeasurementSet from observation and telescope descriptions. </summary>
55 // <reviewed reviewer="" date="" tests="">
56 //
57 // <prerequisite>
58 //# Classes you should understand before using this one.
59 // <li> MeasurementSet
60 // </prerequisite>
61 //
62 // <etymology>
63 // MS is from MeasurementSet, Simulator refers to the generation of
64 // 'fake' data from a set of parameters for instrument and sources.
65 // </etymology>
66 //
67 // <synopsis>
68 // This class creates a MeasurementSet from a set of parameters for instrument
69 // and sources. It does not simulate the data, only the coordinates of a
70 // measurement. The application "simulator" uses this class to create a true
71 // simulated MS with perfect or corrupted data.
72 // </synopsis>
73 //
74 // <motivation>
75 // To test calibration and imaging programs it is necessary to have flawless
76 // data and data with errors that are known exactly. This class generates
77 // empty MeasurementSets (only coordinates filled in) that can be filled
78 // with predicted data.
79 // </motivation>
80 //
81 // <todo asof="$DATE:$">
82 //# A List of bugs, limitations, extensions or planned refinements.
83 // <li> The amount of information to be specified by the user
84 // could be much larger. For the moment it has been restricted to
85 // what is needed for testing the synthesis imaging code. Already
86 // it is possible to create MeasurementSets that cannot be processed
87 // yet.
88 // </todo>
89 
91 {
92 public:
93 
94  // Constructor from name only
96 
97  // Constructor from existing MS
99 
100  // Copy constructor - for completeness only
102 
103  //# Destructor
105 
106 //# Operators
107  // Assignment
109 
110  // Set maximum amount of data (bytes) to be written into any one
111  // scratch column hypercube
112  void setMaxData(const Double maxData=2e9) {maxData_p=maxData;}
113 
114  // set the antenna and array data. These are written immediately to the
115  // existing MS. The same model is used for the other init infor.
116  void initAnt(const String& telname,
117  const Vector<Double>& x,
118  const Vector<Double>& y,
119  const Vector<Double>& z,
120  const Vector<Double>& dishDiameter,
121  const Vector<Double>& offset,
122  const Vector<String>& mount,
123  const Vector<String>& name,
124  const Vector<String>& padname,
125  const String& coordsystem,
126  const MPosition& mRefLocation);
127  // get the info back
128  bool getAnt(String& telescope, Int& nAnt, Matrix<Double>* antXYZ,
129  Vector<Double>& antDiam, Vector<Double>& offset,
130  Vector<String>& mount, Vector<String>& name, Vector<String>& padname,
131  String& coordsystem, MPosition& mRefLocation );
132 
133  // set the observed fields
134  void initFields(const String& sourceName,
135  const MDirection& sourceDirection,
136  const String& calCode);
137 
138  bool getFields(Int& nField,
139  Vector<String>& sourceName,
140  Vector<MDirection>& sourceDirection,
141  Vector<String>& calCode);
142 
143  // set the Feeds; brain dead version
144  void initFeeds(const String& mode);
145 
146  bool getFeedMode(String& mode);
147 
148  // set the Feeds; Smart version
149  void initFeeds(const String& mode,
150  const Vector<Double>& x,
151  const Vector<Double>& y,
152  const Vector<String>& pol);
153 
154  // set the spectral windows information
155  void initSpWindows(const String& spWindowName,
156  const Int& nChan,
157  const Quantity& startFreq,
158  const Quantity& freqInc,
159  const Quantity& freqRes,
160  const MFrequency::Types& freqType,
161  const String& stokesString);
162 
163  bool getSpWindows(Int& nSpw,
164  Vector<String>& spWindowName,
165  Vector<Int>& nChan,
166  Vector<Quantity>& startFreq,
167  Vector<Quantity>& freqInc,
168  Vector<String>& stokesString);
169 
170  void setFractionBlockageLimit(const Double fraclimit)
171  { fractionBlockageLimit_p = fraclimit; }
172 
173  void setElevationLimit(const Quantity& ellimit)
174  { elevationLimit_p = ellimit; }
175 
176  void setAutoCorrelationWt(const Float autocorrwt)
177  { autoCorrelationWt_p = autocorrwt; }
178 
179  void settimes(const Quantity& qIntegrationTime,
180  const Bool useHourAngles,
181  const MEpoch& mRefTime);
182 
183  void observe(const String& sourceName,
184  const String& spWindowName,
185  const Quantity& qStartTime,
186  const Quantity& qStopTime,
187  const Bool add_observation=True,
188 //# from int ASDM2MSFiller::addUniqueState(
189 //# defaults for ALMA as known on 20100831
190  const Bool state_sig=True,
191  const Bool state_ref=True,
192  const double& state_cal=0.,
193  const double& state_load=0.,
194  const unsigned int state_sub_scan=1,
195  const String& state_obs_mode="OBSERVE_TARGET.ON_SOURCE",
196  const String& observername="CASA simulator",
197  const String& projectname="CASA simulation");
198 
199 
200  void observe(const Vector<String>& sourceNames,
201  const String& spWindowName,
202  const Vector<Quantity>& qStartTimes,
203  const Vector<Quantity>& qStopTimes,
204  const Vector<MDirection>& directions,
205  const Bool add_observation=True,
206 //# from int ASDM2MSFiller::addUniqueState(
207 //# defaults for ALMA as known on 20100831
208  const Bool state_sig=True,
209  const Bool state_ref=True,
210  const double& state_cal=0.,
211  const double& state_load=0.,
212  const unsigned int state_sub_scan=1,
213  const String& state_obs_mode="OBSERVE_TARGET.ON_SOURCE",
214  const String& observername="CASA simulator",
215  const String& projectname="CASA simulation");
216 
218 
219 
220 private:
221 
222  // Prevent use of default constructor
224 
225 //# Data Members
240 
242 
244 
246 
247  void local2global(Vector<Double>& xReturned,
248  Vector<Double>& yReturned,
249  Vector<Double>& zReturned,
250  const MPosition& mRefLocation,
251  const Vector<Double>& xIn,
252  const Vector<Double>& yIn,
253  const Vector<Double>& zIn);
254 
256  Vector<Double>& yReturned,
257  Vector<Double>& zReturned,
258  const MPosition& mRefLocation,
259  const Vector<Double>& xIn,
260  const Vector<Double>& yIn,
261  const Vector<Double>& zIn);
262 
263  // Returns the fractional blockage of one antenna by another
264  // We will want to put this somewhere else eventually, but I don't yet know where!
265  // Till then.
266  // fraction1: fraction of antenna 1 that is blocked by 2
267  // fraction2: fraction of antenna 2 that is blocked by 1
268  // hint: at least one of the two will be 0.0
269  void blockage(Double &fraction1, Double &fraction2,
270  const Vector<Double>& uvw, // uvw in same units as diam!
271  const Double diam1, const Double diam2);
272 
275 
276  void addHyperCubes(const Int id, const Int nBase, const Int nChan, const Int nCorr);
277 
278  void defaults();
279 
280  Bool calcAntUVW(MEpoch& epoch, MDirection& refdir,
281  Matrix<Double>& uvwAnt);
282 
283 
284 };
285 
286 
287 } //# NAMESPACE CASACORE - END
288 
289 #endif
290 
291 
292 
293 
Referenced counted pointer for constant data.
Definition: CountedPtr.h:81
Types
Types of known MFrequencies Warning: The order defines the order in the translation matrix FromTo in...
Definition: MFrequency.h:176
void longlat2global(Vector< Double > &xReturned, Vector< Double > &yReturned, Vector< Double > &zReturned, const MPosition &mRefLocation, const Vector< Double > &xIn, const Vector< Double > &yIn, const Vector< Double > &zIn)
void blockage(Double &fraction1, Double &fraction2, const Vector< Double > &uvw, const Double diam1, const Double diam2)
Returns the fractional blockage of one antenna by another We will want to put this somewhere else eve...
void observe(const String &sourceName, const String &spWindowName, const Quantity &qStartTime, const Quantity &qStopTime, const Bool add_observation=True, const Bool state_sig=True, const Bool state_ref=True, const double &state_cal=0., const double &state_load=0., const unsigned int state_sub_scan=1, const String &state_obs_mode="OBSERVE_TARGET.ON_SOURCE", const String &observername="CASA simulator", const String &projectname="CASA simulation")
void initFields(const String &sourceName, const MDirection &sourceDirection, const String &calCode)
set the observed fields
TiledDataStManAccessor flagAcc_p
void initFeeds(const String &mode)
set the Feeds; brain dead version
void setFractionBlockageLimit(const Double fraclimit)
TiledDataStManAccessor sigmaAcc_p
void local2global(Vector< Double > &xReturned, Vector< Double > &yReturned, Vector< Double > &zReturned, const MPosition &mRefLocation, const Vector< Double > &xIn, const Vector< Double > &yIn, const Vector< Double > &zIn)
void setElevationLimit(const Quantity &ellimit)
NewMSSimulator(MeasurementSet &)
Constructor from existing MS.
NewMSSimulator(const String &)
Constructor from name only.
Bool calcAntUVW(MEpoch &epoch, MDirection &refdir, Matrix< Double > &uvwAnt)
NewMSSimulator(const NewMSSimulator &mss)
Copy constructor - for completeness only.
TiledDataStManAccessor scratchDataAcc_p
bool getSpWindows(Int &nSpw, Vector< String > &spWindowName, Vector< Int > &nChan, Vector< Quantity > &startFreq, Vector< Quantity > &freqInc, Vector< String > &stokesString)
void setAutoCorrelationWt(const Float autocorrwt)
bool getFeedMode(String &mode)
bool getFields(Int &nField, Vector< String > &sourceName, Vector< MDirection > &sourceDirection, Vector< String > &calCode)
casacore::CountedPtr< MeasurementSet > ms_p
void observe(const Vector< String > &sourceNames, const String &spWindowName, const Vector< Quantity > &qStartTimes, const Vector< Quantity > &qStopTimes, const Vector< MDirection > &directions, const Bool add_observation=True, const Bool state_sig=True, const Bool state_ref=True, const double &state_cal=0., const double &state_load=0., const unsigned int state_sub_scan=1, const String &state_obs_mode="OBSERVE_TARGET.ON_SOURCE", const String &observername="CASA simulator", const String &projectname="CASA simulation")
String formatTime(const Double)
void initAnt(const String &telname, const Vector< Double > &x, const Vector< Double > &y, const Vector< Double > &z, const Vector< Double > &dishDiameter, const Vector< Double > &offset, const Vector< String > &mount, const Vector< String > &name, const Vector< String > &padname, const String &coordsystem, const MPosition &mRefLocation)
set the antenna and array data.
TiledDataStManAccessor dataAcc_p
void initFeeds(const String &mode, const Vector< Double > &x, const Vector< Double > &y, const Vector< String > &pol)
set the Feeds; Smart version
String formatDirection(const MDirection &)
casacore::CountedPtr< MeasurementSet > getMs() const
void initSpWindows(const String &spWindowName, const Int &nChan, const Quantity &startFreq, const Quantity &freqInc, const Quantity &freqRes, const MFrequency::Types &freqType, const String &stokesString)
set the spectral windows information
void addHyperCubes(const Int id, const Int nBase, const Int nChan, const Int nCorr)
bool getAnt(String &telescope, Int &nAnt, Matrix< Double > *antXYZ, Vector< Double > &antDiam, Vector< Double > &offset, Vector< String > &mount, Vector< String > &name, Vector< String > &padname, String &coordsystem, MPosition &mRefLocation)
get the info back
void settimes(const Quantity &qIntegrationTime, const Bool useHourAngles, const MEpoch &mRefTime)
NewMSSimulator()
Prevent use of default constructor.
void setMaxData(const Double maxData=2e9)
Set maximum amount of data (bytes) to be written into any one scratch column hypercube.
NewMSSimulator & operator=(const NewMSSimulator &)
Assignment.
String: the storage and methods of handling collections of characters.
Definition: String.h:225
this file contains all the compiler specific defines
Definition: mainpage.dox:28
float Float
Definition: aipstype.h:54
int Int
Definition: aipstype.h:50
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
const Bool True
Definition: aipstype.h:43
double Double
Definition: aipstype.h:55