casa
$Rev:20696$
|
00001 //# DOnewsimulator: defines classes for simulator DO. 00002 //# Copyright (C) 1996,1997,1998,1999,2000,2001,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 //# 00027 //# $Id$ 00028 00029 #ifndef SYNTHESIS_SIMULATOR_H 00030 #define SYNTHESIS_SIMULATOR_H 00031 00032 #include <casa/aips.h> 00033 #include <casa/Quanta/Quantum.h> 00034 #include <measures/Measures/MPosition.h> 00035 #include <synthesis/TransformMachines/BeamSquint.h> 00036 #include <synthesis/TransformMachines/VPSkyJones.h> 00037 #include <synthesis/MeasurementEquations/VisEquation.h> 00038 //#include <synthesis/MeasurementComponents/EPJones.h> 00039 00040 #include <casa/namespace.h> 00041 namespace casa { //# NAMESPACE CASA - BEGIN 00042 class MeasurementSet; 00043 class VisSet; 00044 class VisCal; 00045 class ACoh; 00046 class SkyEquation; 00047 class ComponentList; 00048 class CleanImageSkyModel; 00049 class FTMachine; 00050 class ComponentFTMachine; 00051 class MEpoch; 00052 class NewMSSimulator; 00053 00054 00055 template<class T> class PagedImage; 00056 00057 00058 00059 // <summary>Simulates MeasurementSets from SkyModel and SkyEquation</summary> 00060 00061 00062 // <use visibility=export> 00063 00064 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00065 // </reviewed> 00066 00067 // <prerequisite> 00068 // <li> <linkto class="MeasurementSet">MeasurementSet</linkto> 00069 // <li> <linkto class="SkyEquation">SkyEquation</linkto> 00070 // <li> <linkto class="SkyModel">SkyModel</linkto> 00071 // </prerequisite> 00072 // 00073 // <etymology> 00074 // The name MUST have the 'DO' prefix as this class is derived from 00075 // ApplicationObject, and hence is classified as a distributed object. For the 00076 // same reason the rest of its name must be in lower case. This class 00077 // simulates visibility data, so it is called DOnewsimulator. 00078 // </etymology> 00079 // 00080 // <synopsis> 00081 // </synopsis> 00082 // 00083 // <motivation> 00084 // This class was written to make the simulation capability useful from glish 00085 // </motivation> 00086 // 00087 // <thrown> 00088 // <li> AipsError - if an error occurs 00089 // </thrown> 00090 // 00091 // <todo asof="1999/07/22"> 00092 // <li> everything 00093 // </todo> 00094 00095 class Simulator 00096 { 00097 00098 public: 00099 00100 Simulator(); 00101 // Construct from string 00102 Simulator(String& msname); 00103 00104 // "newsimulator" ctor 00105 Simulator(MeasurementSet &thems); 00106 00107 // Return the name of the MeasurementSet 00108 String name() const; 00109 00110 Simulator(const Simulator &other); 00111 00112 Simulator &operator=(const Simulator &other); 00113 00114 ~Simulator(); 00115 00116 Bool close(); 00117 00118 00119 // Select the data to be predicted or corrupted 00120 Bool setdata(const Vector<Int>& spectralwindowids, 00121 const Vector<Int>& fieldids, 00122 const String& msSelect); 00123 00124 Bool settimes(const Quantity& integrationTime, 00125 const Bool useHourAngle, 00126 const MEpoch& refTime); 00127 00128 // set the configuration; NOTE: the telname used 00129 // here will determine the Voltage Pattern to be used in the 00130 // simulation 00131 Bool setconfig(const String& telname, 00132 const Vector<Double>& x, 00133 const Vector<Double>& y, 00134 const Vector<Double>& z, 00135 const Vector<Double>& dishDiameter, 00136 const Vector<Double>& offset, 00137 const Vector<String>& mount, 00138 const Vector<String>& antName, 00139 const Vector<String>& padName, 00140 const String& coordsystem, 00141 const MPosition& referenceLocation); 00142 // get info back from e.g. loaded ms in newmssimulator 00143 Bool getconfig(); 00144 00145 // set the observed fields for the simulation 00146 Bool setfield(const String& sourceName, 00147 const MDirection& sourceDirection, 00148 const String& calCode, 00149 const Quantity& distance); 00150 00151 00152 // set automatic fields for a mosaic 00153 Bool setmosaicfield(const String& sourcename, const String& calcode, 00154 const MDirection& fieldcenter, 00155 const Int xmosp, const Int ymosp, 00156 const Quantity& mosspacing, const Quantity& distance); 00157 00158 00159 // set one or more spectral windows and their characteristics 00160 Bool setspwindow(const String& spwName, 00161 const Quantity& freq, 00162 const Quantity& deltafreq, 00163 const Quantity& freqresolution, 00164 const MFrequency::Types& freqType, 00165 const Int nchannels, 00166 const String& stokes); 00167 00168 // Set the simulated feed characteristics 00169 Bool setfeed(const String& mode, 00170 const Vector<Double>& x, 00171 const Vector<Double>& y, 00172 const Vector<String>& pol); 00173 00174 // Set the voltage pattern 00175 Bool setvp(const Bool dovp, 00176 const Bool defaultVP, 00177 const String& vpTable, 00178 const Bool doSquint, 00179 const Quantity &parAngleInc, 00180 const Quantity &skyPosThreshold, 00181 const Float &pbLimit); 00182 00183 // Set the random number generator seed for the addition of errors 00184 Bool setseed(const Int seed); 00185 00186 // Arrange to corrupt with existing calibration 00187 // (cf Calibrater setapply) 00188 Bool setapply (const String& type, 00189 const Double& t, 00190 const String& table, 00191 const String& spw, 00192 const String& field, 00193 const String& interp, 00194 const Bool& calwt, 00195 const Vector<Int>& spwmap, 00196 const Float& opacity); 00197 00198 // Apply antenna-based gain errors 00199 Bool setgain(const String& mode, 00200 const String& table, 00201 const Quantity& interval, 00202 const Vector<Double>& amplitude); 00203 00204 Bool settrop(const String& mode, 00205 const String& table, 00206 const Float pwv, 00207 const Float deltapwv, 00208 const Float beta, 00209 const Float windspeed); 00210 00211 // Apply antenna pointing and squint errors 00212 Bool setpointingerror(const String& epJTableName, 00213 const Bool applyPointingOffsets, 00214 const Bool doPBCorrection); 00215 00216 // Apply polarization leakage errors 00217 Bool setleakage(const String& mode, const String& table, 00218 //const Quantity& interval, 00219 const Vector<Double>& amplitude, 00220 const Vector<Double>& offset); 00221 00222 // Apply bandpass errors 00223 Bool setbandpass(const String& mode, const String& table, 00224 const Quantity& interval, const Vector<Double>& amplitude); 00225 00226 // Simulate the parallactic angle phase effect 00227 Bool setpa(const String& mode, const String& table, 00228 const Quantity& interval); 00229 00230 // Simulate quasi-realistic thermal noise, which can depend upon 00231 // elevation, bandwidth, antenna diameter, as expected 00232 Bool oldsetnoise(const String& mode, 00233 const String& table, 00234 const Quantity& simplenoise, 00235 const Float antefficiency, 00236 const Float correfficiency, 00237 const Float spillefficiency, 00238 const Float tau, 00239 const Float trx, 00240 const Float tatmos, 00241 const Float tcmb); 00242 00243 Bool setnoise(const String& mode, 00244 const String& caltable, 00245 const Quantity& simplenoise, 00246 // if blank, not stored 00247 // or ATM calculation 00248 const Quantity& pground, 00249 const Float relhum, 00250 const Quantity& altitude, 00251 const Quantity& waterheight, 00252 const Quantity& pwv, 00253 // user-specified tau and tatmos 00254 const Float tatmos, 00255 const Float tau, 00256 // 00257 const Float antefficiency, 00258 const Float spillefficiency, 00259 const Float correfficiency, 00260 const Float trx, 00261 const Float tground, 00262 const Float tcmb, 00263 const Bool OTF, 00264 const Float senscoeff, 00265 const Int rxtype); 00266 00267 // apply errors to the data in our MS 00268 // Bool corrupt(); 00269 Bool corrupt(); 00270 00271 // Set limits 00272 Bool setlimits(const Double shadowFraction, 00273 const Quantity& elevationLimit); 00274 00275 // Set autocorrelation weight 00276 Bool setauto(const Double autocorrwt); 00277 00278 00279 // add new visibilities as described by the set methods to an existing 00280 // or just created measurement set 00281 Bool observe(const String& sourcename, const String& spwname, 00282 const Quantity& startTime, 00283 const Quantity& stopTime, 00284 const Bool add_observation, 00285 const Bool state_sig, 00286 const Bool state_ref, 00287 const double& state_cal, 00288 const double& state_load, 00289 const unsigned int state_sub_scan, 00290 const String& state_obs_mode, 00291 const String& observername, 00292 const String& projectname); 00293 00294 00295 Bool observemany(const Vector<String>& sourcenames, const String& spwname, 00296 const Vector<Quantity>& startTimes, 00297 const Vector<Quantity>& stopTimes, 00298 const Vector<MDirection>& directions, 00299 const Bool add_observation, 00300 const Bool state_sig, 00301 const Bool state_ref, 00302 const double& state_cal, 00303 const double& state_load, 00304 const unsigned int state_sub_scan, 00305 const String& state_obs_mode, 00306 const String& observername, 00307 const String& projectname); 00308 00309 00310 // Given a model image, predict the visibilities onto the (u,v) coordinates 00311 // of our MS 00312 Bool predict(const Vector<String>& modelImage, 00313 const String& compList, 00314 const Bool incremental); 00315 00316 String state(); 00317 00318 Bool summary(); 00319 00320 Bool resetviscal(); 00321 Bool resetimcal(); 00322 Bool reset(); 00323 00324 // Set the processing options 00325 Bool setoptions(const String& ftmachine, const Int cache, const Int tile, 00326 const String& gridfunction, const MPosition& mLocation, 00327 const Float padding, const Int facets, 00328 const Double maxData,const Int wprojPlanes); 00329 00330 00331 // Set the print level 00332 inline void setPrtlev(const Int& prtlev) { prtlev_=prtlev; }; 00333 // Return print (cout) level 00334 inline Int& prtlev() { return prtlev_; }; 00335 00336 00337 private: 00338 00339 00340 // Arrange to corrupt with simulated calibration 00341 // (cf Calibrater setapply) 00342 Bool create_corrupt(Record& simpar); 00343 00344 // Prints an error message if the newsimulator DO is detached and returns True. 00345 Bool detached() const; 00346 00347 // set up some defaults 00348 void defaults(); 00349 00350 // Make a VisSet if needed 00351 void makeVisSet(); 00352 00353 // print out some help about create() 00354 // Format direction nicely 00355 String formatDirection(const MDirection& direction); 00356 00357 // Format time nicely 00358 String formatTime(const Double time); 00359 00360 // individual summary() functions 00361 // <group> 00362 Bool createSummary(LogIO& os); 00363 Bool configSummary(LogIO& os); 00364 Bool fieldSummary(LogIO& os); 00365 Bool spWindowSummary(LogIO& os); 00366 Bool feedSummary(LogIO& os); 00367 Bool timeSummary(LogIO& os); 00368 00369 Bool predictSummary(LogIO& os); 00370 Bool vpSummary(LogIO& os); 00371 Bool optionsSummary(LogIO& os); 00372 00373 Bool corruptSummary(LogIO& os); 00374 Bool noiseSummary(LogIO& os); 00375 // </group> 00376 00377 00378 // SkyEquation management 00379 // <group> 00380 Bool createSkyEquation( const Vector<String>& image, const String complist); 00381 void destroySkyEquation(); 00382 // </group> 00383 00384 String msname_p; 00385 MeasurementSet* ms_p; 00386 MeasurementSet* mssel_p; 00387 VisSet* vs_p; 00388 00389 Int seed_p; 00390 00391 ACoh *ac_p; 00392 00393 SkyEquation* se_p; 00394 CleanImageSkyModel* sm_p; 00395 FTMachine *ft_p; 00396 ComponentFTMachine *cft_p; 00397 00398 Int nmodels_p; 00399 PtrBlock<PagedImage<Float>* > images_p; 00400 ComponentList *componentList_p; 00401 00402 String ftmachine_p, gridfunction_p; 00403 Int cache_p, tile_p; 00404 MPosition mLocation_p; 00405 Float padding_p; 00406 Bool MSMayBeOK; 00407 Int facets_p; 00408 Int wprojPlanes_p; 00409 Long maxData_p; 00410 00411 00412 // info for coordinates and station locations 00413 // <group> 00414 Bool areStationCoordsSet_p; 00415 String telescope_p; 00416 Vector<Double> x_p; 00417 Vector<Double> y_p; 00418 Vector<Double> z_p; 00419 Vector<Double> diam_p; 00420 Vector<Double> offset_p; 00421 Vector<String> mount_p; 00422 Vector<String> antName_p; 00423 Vector<String> padName_p; 00424 String coordsystem_p; 00425 MPosition mRefLocation_p; 00426 // </group> 00427 00428 // info for observed field parameters 00429 // <group> 00430 00431 Int nField; 00432 Vector<String> sourceName_p; 00433 Vector<String> calCode_p; 00434 Vector<MDirection> sourceDirection_p; 00435 Vector<Quantity> distance_p; 00436 00437 // </group> 00438 // VisEquation handles corruption by visibility calibration effects 00439 VisEquation ve_p; 00440 // Generic container for any number of calibration effects to corrupt with 00441 PtrBlock<VisCal*> vc_p; 00442 00443 // info for spectral window parameters 00444 // <group> 00445 00446 // spectral windows data 00447 // <group> 00448 // RI 20091107 durn. whoever build this didn't enable multiple spw. 00449 // we'll at least get some functionality here, but there are probably 00450 // combinations of pols etc that won't properly report here. 00451 // better than now, when it doesn't even report more than one spw. 00452 Int nSpw; 00453 Vector<String> spWindowName_p; 00454 Vector<Int> nChan_p; 00455 Vector<Quantity> startFreq_p; 00456 Vector<Quantity> freqInc_p; 00457 Vector<Quantity> freqRes_p; 00458 Vector<String> stokesString_p; 00459 // </group> 00460 // </group> 00461 00462 00463 // Feed information (there will be much more coming, 00464 // but we are brain dead at this moment). 00465 String feedMode_p; 00466 Int nFeeds_p; 00467 Bool feedsHaveBeenSet; 00468 Bool feedsInitialized; 00469 00470 // Some times which are required for settimes 00471 // <group> 00472 Quantity integrationTime_p; 00473 Bool useHourAngle_p; 00474 MEpoch refTime_p; 00475 Bool timesHaveBeenSet_p; 00476 // </group> 00477 00478 // Some parameters for voltage pattern (vp): 00479 // <group> 00480 Bool doVP_p; // Do we apply VP or not? 00481 Bool doDefaultVP_p; // Do we use the default VP for this telescope? 00482 String vpTableStr_p; // Otherwise, use the VP specified in this Table 00483 Quantity parAngleInc_p; // Parallactic Angle increment 00484 Quantity skyPosThreshold_p; // a tolerance in the pointing center position 00485 Float pbLimit_p; // The PB level (in percentage) after which the PB is assumed to be zero 00486 BeamSquint::SquintType squintType_p; // Control of squint to use 00487 VPSkyJones* vp_p; // pointer to VPSkyJones for the sky equation 00488 VPSkyJones* gvp_p; // pointer to VPSkyJones for the sky equation 00489 // </group> 00490 00491 // Saving some information about the various corrupting terms 00492 // <group> 00493 String noisemode_p; 00494 // </group> 00495 00496 // Cache the newsimulator 00497 NewMSSimulator* sim_p; 00498 00499 // The Jones matrix to hold the antenna pointing offsets and the 00500 // associated table name. if applyPointingOffsets is False, only 00501 // VLA polarization squint will be included in EPJones. If 00502 // doPBCorrection is True, the model image will be divided by the 00503 // primary beam before being used to predict the visibilities. 00504 // <group> 00505 // EPJones *epJ_p; 00506 String epJTableName_p; 00507 Bool applyPointingOffsets_p; 00508 Bool doPBCorrection_p; 00509 // </group> 00510 00511 Int prtlev_; 00512 00513 }; 00514 00515 } //# NAMESPACE CASA - END 00516 00517 #endif