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