CalInterp.h
Go to the documentation of this file.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 CALTABLES_CALINTERP_H
00029 #define CALTABLES_CALINTERP_H
00030 #include <casa/aips.h>
00031 #include <casa/BasicSL/Constants.h>
00032 #include <synthesis/CalTables/CalSet.h>
00033 #include <casa/OS/File.h>
00034 #include <casa/Logging/LogMessage.h>
00035 #include <casa/Logging/LogSink.h>
00036
00037 namespace casa {
00038
00039
00040 class CalInterp
00041 {
00042 public:
00043
00044
00045 CalInterp() {};
00046
00047
00048 CalInterp(CalSet<Complex>& cs,
00049 const String& timetype,
00050 const String& freqtype);
00051
00052
00053 virtual ~CalInterp();
00054
00055
00056
00057 void setSpwMap(const Vector<Int>& spwmap) {spwMap_ = spwmap; setSpwOK();};
00058
00059
00060 Bool interpolate(const Double& time,
00061 const Int& spw,
00062 const Vector<Double>& freq=Vector<Double>());
00063
00064
00065 Bool interpTime(const Double& time);
00066
00067
00068 void interpFreq(const Vector<Double>& freq);
00069
00070
00071 Double slotTime() { return csTimes()(currSlot()); };
00072
00073
00074 inline Cube<Complex>& result() { return r; };
00075 inline Cube<Bool>& resultOK() { return ok; };
00076
00077
00078 inline Vector<Bool> spwOK() { return spwOK_; };
00079
00080
00081 void setSpwOK();
00082
00083 protected:
00084
00085
00086 Bool findSlot(const Double& time);
00087
00088 void updTimeCoeff();
00089
00090 void interpTimeCalc(const Double& time);
00091
00092 void initFreqInterp(const Vector<Double> freq);
00093
00094 void calcAPC();
00095
00096 void updFreqCoeff();
00097
00098 void interpFreqCalc();
00099
00100 void finalize();
00101
00102 void inflTimeC();
00103 void inflFreqC();
00104 void deflTimeC();
00105 void deflFreqC();
00106 void deflFreqA();
00107
00108
00109 inline Int& nSpw() { return cs_->nSpw(); };
00110 inline Int& nPar() { return cs_->nPar(); };
00111 inline Int& nElem() { return cs_->nElem(); };
00112
00113
00114 inline String& timeType() { return timeType_; };
00115 inline Bool nearestT() { return (timeType()=="nearest"); };
00116 inline Bool linearT() { return (timeType()=="linear"); };
00117 inline Bool aipslinT() { return (timeType()=="aipslin"); };
00118 inline String& freqType() { return freqType_; };
00119 inline Bool nearestF() { return (freqType()=="nearest"); };
00120 inline Bool linearF() { return (freqType()=="linear"); };
00121 inline Bool aipslinF() { return (freqType()=="aipslin"); };
00122
00123 inline Vector<Int>& spwMap() { return spwMap_; };
00124 inline Int spwMap(const Int& spw) { return ((spwMap_(spw)>-1) ? spwMap_(spw) : spw); };
00125
00126
00127 inline Int& currSpw() { return currSpw_; };
00128 inline Int currSpwMap() { return spwMap(currSpw()); };
00129 inline Int& currSlot() { return currSlot_(currSpw()); };
00130 inline Int& nFreq() { return nFreq_(currSpw()); };
00131 inline Vector<Double>& datFreq() { return (*datFreq_[currSpw()]); };
00132 inline Bool& finit() { return finit_(currSpw()); };
00133 inline Double& lastTime() { return lastTime_(currSpw_); };
00134 inline Bool& exactTime() { return exactTime_; };
00135
00136
00137 inline Int& nTime() { return cs_->nTime(currSpwMap()); };
00138 inline Int& nChan() { return cs_->nChan(currSpwMap()); }
00139 inline Vector<Double>& csTimes() { return cs_->time(currSpwMap()); };
00140 inline Vector<Double>& csFreq() { return cs_->frequencies(currSpwMap()); };
00141 inline Array<Complex>& csPar() { return cs_->par(currSpwMap()); };
00142 inline Array<Bool>& csParOK() { return cs_->parOK(currSpwMap()); };
00143
00144
00145 inline IPosition& ip4d() { return (*ip4d_[currSpw_]); };
00146 inline IPosition& ip3d() { return (*ip3d_[currSpw_]); };
00147 inline IPosition& ip2d() { return (*ip2d_[currSpw_]); };
00148
00149
00150 inline Double& t0() {return t0_(currSpw_);};
00151 inline Double& tS() {return tS_(currSpw_);};
00152 inline Int& lastlo() {return lastlo_(currSpw_); };
00153
00154 inline Vector<Int>& ch0() {return (*ch0_[currSpw_]); };
00155 inline Vector<Bool>& ef() {return (*ef_[currSpw_]); };
00156 inline Vector<Double>& df() {return (*df_[currSpw_]); };
00157 inline Vector<Double>& fdf() {return (*df_[currSpw_]); };
00158
00159
00160 inline Array<Float>& tAC() {return (*tAC_[currSpw()]); };
00161 inline Array<Float>& tPC() {return (*tPC_[currSpw()]); };
00162 inline Array<Complex>& tCC() {return (*tCC_[currSpw()]); };
00163 inline Cube<Bool>& tOk() {return (*tOk_[currSpw()]); };
00164
00165
00166 inline Array<Float>& fAC() {return (*fAC_[currSpw()]); };
00167 inline Array<Float>& fPC() {return (*fPC_[currSpw()]); };
00168 inline Array<Complex>& fCC() {return (*fCC_[currSpw()]); };
00169 inline Cube<Bool>& fOk() {return (*fOk_[currSpw()]); };
00170
00171 inline void rPart(Array<Complex>& c,Array<Float>& rp) { return part(c,0,rp); };
00172 inline void iPart(Array<Complex>& c,Array<Float>& ip) { return part(c,1,ip); };
00173
00174 void asFloatArr(const Array<Complex>& in, Array<Float>& out);
00175
00176 void part(const Array<Complex>& c, const Int& which, Array<Float>& f);
00177
00178 private:
00179
00180
00181 CalSet<Complex>* cs_;
00182
00183
00184 String timeType_, freqType_;
00185
00186
00187 Vector<Int> spwMap_;
00188
00189
00190 Vector<Bool> spwOK_;
00191
00192
00193 Vector<Double> lastTime_;
00194
00195
00196 Vector<Bool> finit_;
00197
00198
00199 Vector<Int> nFreq_;
00200
00201
00202 PtrBlock<Vector<Double>*> solFreq_;
00203 PtrBlock<Vector<Double>*> datFreq_;
00204
00205 Int currSpw_;
00206 Vector<Int> currSlot_;
00207
00208
00209 Bool exactTime_;
00210
00211 Cube<Float> a,p;
00212 Cube<Complex> c;
00213 Cube<Bool> ok;
00214
00215 Cube<Complex> r, r_;
00216
00217
00218 PtrBlock<IPosition*> ip4d_;
00219 PtrBlock<IPosition*> ip3d_;
00220 PtrBlock<IPosition*> ip2d_;
00221
00222
00223 Vector<Double> t0_;
00224 Vector<Double> tS_;
00225 Vector<Int> lastlo_;
00226
00227
00228 PtrBlock<Array<Float>*> tAC_, tPC_;
00229 PtrBlock<Array<Complex>*> tCC_;
00230 PtrBlock<Cube<Bool>*> tOk_;
00231
00232
00233 Cube<Float> tA_, tP_;
00234 Cube<Complex> tC_;
00235
00236
00237 PtrBlock<Vector<Int>*> ch0_;
00238 PtrBlock<Vector<Bool>*> ef_;
00239 PtrBlock<Vector<Double>*> df_;
00240 PtrBlock<Vector<Double>*> fdf_;
00241
00242
00243 PtrBlock<Array<Float>*> fAC_, fPC_;
00244 PtrBlock<Array<Complex>*> fCC_;
00245 PtrBlock<Cube<Bool>*> fOk_;
00246
00247
00248 Cube<Float> fA_, fP_;
00249 Cube<Complex> fC_;
00250
00251 LogSink logSink_p;
00252 LogSink& logSink() {return logSink_p;};
00253
00254 Bool verbose_;
00255
00256 };
00257
00258
00259 }
00260
00261 #endif