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