00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef SYNTHESIS_CALCORRUPTOR_H
00029 #define SYNTHESIS_CALCORRUPTOR_H
00030
00031
00032 #include <casa/BasicMath/Random.h>
00033 #include <scimath/Mathematics/FFTServer.h>
00034 #include <casa/Containers/Record.h>
00035 #include <ms/MeasurementSets/MSAntennaColumns.h>
00036 #include <ms/MeasurementSets/MSColumns.h>
00037 #include <synthesis/MeasurementComponents/VisCal.h>
00038
00039 using namespace std;
00040
00041
00042 #include <atmosphere/ATM/ATMRefractiveIndexProfile.h>
00043 #include <atmosphere/ATM/ATMPercent.h>
00044 #include <atmosphere/ATM/ATMPressure.h>
00045 #include <atmosphere/ATM/ATMNumberDensity.h>
00046 #include <atmosphere/ATM/ATMMassDensity.h>
00047 #include <atmosphere/ATM/ATMTemperature.h>
00048 #include <atmosphere/ATM/ATMLength.h>
00049 #include <atmosphere/ATM/ATMInverseLength.h>
00050 #include <atmosphere/ATM/ATMOpacity.h>
00051 #include <atmosphere/ATM/ATMHumidity.h>
00052 #include <atmosphere/ATM/ATMFrequency.h>
00053 #include <atmosphere/ATM/ATMWaterVaporRadiometer.h>
00054 #include <atmosphere/ATM/ATMWVRMeasurement.h>
00055 #include <atmosphere/ATM/ATMProfile.h>
00056 #include <atmosphere/ATM/ATMSpectralGrid.h>
00057 #include <atmosphere/ATM/ATMRefractiveIndex.h>
00058 #include <atmosphere/ATM/ATMSkyStatus.h>
00059 #include <atmosphere/ATM/ATMAngle.h>
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081 namespace casa {
00082
00083
00084
00085 class CalCorruptor {
00086
00087 public:
00088
00089 CalCorruptor(const Int nSim);
00090 virtual ~CalCorruptor();
00091 inline uInt& nSim() { return nSim_; };
00092 inline Bool& times_initialized() { return times_initialized_; };
00093 inline Int& curr_slot() { return curr_slot_; };
00094 inline Double& curr_time() { return curr_time_; };
00095 inline Double& startTime() { return starttime_; };
00096 inline Double& stopTime() { return stoptime_; };
00097 inline Double& slot_time(const Int i) { return slot_times_(i); };
00098 inline Double& slot_time() { return slot_times_(curr_slot()); };
00099 inline Vector<Double>& slot_times() { return slot_times_; };
00100 inline Float& amp() { return amp_;};
00101 virtual void initialize() {};
00102
00103
00104 void initialize(const Float amp, const Record& simpar) {
00105 amp_=amp;
00106 simpar_=simpar;
00107 };
00108 inline Record& simpar() {return simpar_;}
00109 inline String& mode() { return mode_; };
00110
00111 void setEvenSlots(const Double& dt);
00112 virtual Complex simPar(const VisIter& vi, VisCal::Type type,Int ipar);
00113
00114 inline uInt& nPar() { return nPar_; };
00115 inline uInt& nChan() { return fnChan_[currSpw()]; };
00116 inline const uInt& focusChan() {return curr_chan_[currSpw()];};
00117 inline const Double& focusFreq() {return curr_freq_;};
00118 virtual void setFocusChan(Int chan) {
00119 curr_chan_[currSpw()]=chan;
00120
00121
00122 Double fRes(fWidth()[currSpw()]/Double(fnChan()[currSpw()]));
00123 curr_freq_=fRefFreq()[currSpw()]+chan*fRes;
00124 };
00125
00126 virtual void setCurrTime(const Double& time);
00127
00128
00129 inline uInt& prtlev() { return prtlev_; };
00130 inline uInt& nAnt() { return nAnt_; };
00131 inline uInt& nSpw() { return nSpw_; };
00132 inline uInt& currAnt() { return curr_ant_; };
00133 inline uInt& currAnt2() { return curr_ant2_; };
00134 inline uInt& currSpw() { return curr_spw_; };
00135 inline Vector<Float>& fRefFreq() { return fRefFreq_; };
00136 inline Vector<Float>& fWidth() { return fWidth_; };
00137 inline Vector<uInt>& fnChan() { return fnChan_; };
00138 inline Vector<uInt>& currChans() { return curr_chan_; };
00139
00140 inline Bool& freqDepPar() { return freqdep_; };
00141
00142 protected:
00143
00144 uInt nSim_;
00145 Int curr_slot_;
00146 Bool times_initialized_,freqdep_;
00147 uInt nPar_;
00148 Double curr_time_,starttime_,stoptime_,curr_freq_;
00149 Float amp_;
00150 Vector<Double> slot_times_;
00151 Record simpar_;
00152 String mode_;
00153
00154 uInt prtlev_;
00155 uInt nAnt_,curr_ant_,nSpw_,curr_spw_,curr_ant2_;
00156 Vector<Float> fRefFreq_,fWidth_;
00157 Vector<uInt> fnChan_,curr_chan_;
00158
00159 private:
00160
00161 };
00162
00163
00164
00165
00166
00167
00168
00169 class ANoiseCorruptor : public CalCorruptor {
00170
00171 public:
00172 ANoiseCorruptor(): CalCorruptor(1) {};
00173 virtual ~ANoiseCorruptor();
00174 virtual void initialize() {
00175 initialize(1234,1.0);
00176 }
00177 void initialize(const Int seed, const Float amp) {
00178 rndGen_p = new MLCG(seed);
00179 nDist_p = new Normal(rndGen_p, 0.0, 1.0);
00180 amp_=amp;
00181 };
00182 virtual Complex simPar(const VisIter& vi,VisCal::Type type,Int ipar);
00183 virtual Complex simPar();
00184
00185 private:
00186 MLCG *rndGen_p;
00187 Normal *nDist_p;
00188 };
00189
00190
00191
00192
00193
00194
00195
00196 class DJonesCorruptor : public CalCorruptor {
00197
00198 public:
00199 DJonesCorruptor(): CalCorruptor(1) {};
00200 virtual ~DJonesCorruptor();
00201 virtual void initialize() {
00202 initialize(1234,Complex(1.0,1.0),Complex(0.0));
00203 }
00204 void initialize(const Int seed, const Complex camp, const Complex offset) {
00205 rndGen_p = new MLCG(seed);
00206 nDist_p = new Normal(rndGen_p, 0.0, 1.0);
00207 camp_=camp;
00208 offset_=offset;
00209 };
00210 virtual Complex simPar(const VisIter& vi,VisCal::Type type,Int ipar);
00211 inline Complex& camp() { return camp_; };
00212 inline Complex& offset() { return offset_; };
00213
00214 private:
00215 MLCG *rndGen_p;
00216 Normal *nDist_p;
00217 Complex camp_,offset_;
00218 };
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228 class fBM {
00229
00230 public:
00231
00232 fBM(uInt i1);
00233 fBM(uInt i1, uInt i2);
00234 fBM(uInt i1, uInt i2, uInt i3);
00235
00236 inline Bool& initialized() { return initialized_; };
00237 void initialize(const Int seed, const Float beta);
00238
00239 inline Array<Float> data() { return *data_; };
00240 inline Float data(uInt i1) { return data_->operator()(IPosition(1,i1)); };
00241 inline Float data(uInt i1, uInt i2) { return data_->operator()(IPosition(2,i1,i2)); };
00242 inline Float data(uInt i1, uInt i2, uInt i3) { return data_->operator()(IPosition(3,i1,i2,i3)); };
00243
00244
00245 private:
00246 Bool initialized_;
00247 Array<Float>* data_;
00248
00249 };
00250
00251
00252
00253
00254
00255
00256 class AtmosCorruptor : public CalCorruptor {
00257
00258 public:
00259 AtmosCorruptor();
00260 AtmosCorruptor(const Int nSim);
00261 virtual ~AtmosCorruptor();
00262
00263 Float& pwv(const Int i);
00264 Vector<Float>* pwv();
00265 void initAtm();
00266 inline Float& mean_pwv() { return mean_pwv_; };
00267
00268 inline Matrix<Float>& screen() { return *screen_p; };
00269 inline Float screen(const Int i, const Int j) {
00270 return screen_p->operator()(i,j); };
00271 using CalCorruptor::initialize;
00272 virtual void initialize(const Int rxType);
00273
00274 void initialize(const VisIter& vi, const Record& simpar, VisCal::Type type, const Int rxType);
00275 Vector<Double> antDiams;
00276
00277 void initialize(const Int Seed, const Float Beta, const Float scale, const Int rxType);
00278 void initialize(const Int Seed, const Float Beta, const Float scale, const Int rxType,
00279 const ROMSAntennaColumns& antcols);
00280
00281 Complex cphase(const Int islot);
00282 Complex cphase(const Int ix, const Int iy, const Int islot);
00283 inline Vector<Float>& antx() { return antx_; };
00284 inline Vector<Float>& anty() { return anty_; };
00285 inline Float& windspeed() { return windspeed_; };
00286 inline Float& pixsize() { return pixsize_; };
00287
00288 inline Float& tauscale() { return tauscale_; };
00289 Float tsys(const Float& airmass);
00290 Float opac(const Int ichan);
00291 inline Float& spilleff() { return spilleff_; };
00292
00293 inline Float& tground() { return tground_; };
00294 inline Float& tatmos() { return tatmos_; };
00295 inline Float& trx() { return trx_; };
00296 inline Float& tcmb() { return tcmb_; };
00297 inline Int& rxType() { return rxtype_; };
00298
00299 inline Double& Rtground() { return Rtground_; };
00300 inline Double& Rtatmos() { return Rtatmos_; };
00301
00302 inline Double& Rtcmb() { return Rtcmb_; };
00303 inline Float& senscoeff() { return sensitivityCoeff_; };
00304
00305 virtual Complex simPar(const VisIter& vi, VisCal::Type type,Int ipar);
00306
00307 inline Vector<uInt>& ATMnChan() { return ATMnChan_; };
00308 inline Vector<uInt>& ATMchanMap(uInt ispw) { return ATMchanMap_[ispw]; };
00309
00310 virtual void setFocusChan(Int chan) {
00311 curr_chan_[currSpw()]=chan;
00312
00313
00314 Double fRes(fWidth()[currSpw()]/Double(fnChan()[currSpw()]));
00315 curr_freq_=fRefFreq()[currSpw()]+chan*fRes;
00316
00317 double hn_k = 0.04799274551*1e-9*focusFreq();
00318 Rtcmb() = 1./(exp(hn_k/tcmb())-1.);
00319 Rtground() = 1./(exp(hn_k/tground())-1.);
00320
00321 Rtatmos() = 1./(exp(hn_k/tatmos())-1.);
00322 };
00323
00324 virtual void setCurrTime(const Double& time);
00325
00326 protected:
00327
00328 private:
00329 Int rxtype_;
00330 Float mean_pwv_,windspeed_,pixsize_,tauscale_,
00331 tground_,spilleff_,trx_,tatmos_,tcmb_;
00332 Double Rtatmos_,Rtcmb_,Rtground_;
00333 Matrix<Float>* screen_p;
00334
00335 atm::AtmProfile *itsatm;
00336 atm::RefractiveIndexProfile *itsRIP;
00337 atm::SkyStatus *itsSkyStatus;
00338 atm::SpectralGrid *itsSpecGrid;
00339
00340 Vector<uInt> ATMnChan_;
00341 Vector<Vector<uInt> > ATMchanMap_;
00342
00343 PtrBlock<Vector<Float>*> pwv_p;
00344 Vector<Float> antx_,anty_;
00345
00346 Vector<Float> airMass_;
00347 Bool airMassValid_;
00348 Double airMassTime_;
00349 Float sensitivityCoeff_;
00350 };
00351
00352
00353
00354
00355
00356 class GJonesCorruptor : public CalCorruptor {
00357
00358 public:
00359 GJonesCorruptor(const Int nSim);
00360 virtual ~GJonesCorruptor();
00361
00362
00363 Matrix<Complex>* drift();
00364 inline Float& tsys() { return tsys_; };
00365 virtual void initialize();
00366 void initialize(const Int Seed, const Float Beta, const Float scale);
00367 Complex gain(const Int icorr, const Int islot);
00368 virtual Complex simPar(const VisIter& vi, VisCal::Type type,Int ipar);
00369
00370
00371 void initialize(const Int seed, const Complex camp) {
00372 rndGen_p = new MLCG(seed);
00373 nDist_p = new Normal(rndGen_p, 0.0, 1.0);
00374 camp_=camp;
00375 };
00376 inline Complex& camp() { return camp_; };
00377
00378 protected:
00379
00380 private:
00381 Float tsys_;
00382 PtrBlock<Matrix<Complex>*> drift_p;
00383
00384 MLCG *rndGen_p;
00385 Normal *nDist_p;
00386 Complex camp_;
00387 };
00388
00389
00390
00391
00392
00393 }
00394 #endif