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_CTPATCHEDINTERP_H
00029 #define CALTABLES_CTPATCHEDINTERP_H
00030
00031 #include <synthesis/CalTables/NewCalTable.h>
00032 #include <synthesis/CalTables/CTTimeInterp1.h>
00033 #include <synthesis/CalTables/RIorAParray.h>
00034 #include <synthesis/CalTables/VisCalEnum.h>
00035 #include <scimath/Mathematics/InterpolateArray1D.h>
00036 #include <casa/Arrays/Array.h>
00037 #include <casa/Arrays/Matrix.h>
00038 #include <casa/Arrays/Cube.h>
00039 #include <ms/MeasurementSets/MeasurementSet.h>
00040 #include <ms/MeasurementSets/MSField.h>
00041 #include <ms/MeasurementSets/MSColumns.h>
00042 #include <casa/aips.h>
00043
00044
00045
00046
00047
00048
00049 namespace casa {
00050
00051
00052 class CTPatchedInterp
00053 {
00054 public:
00055
00056
00057 CTPatchedInterp(NewCalTable& ct,
00058 VisCalEnum::MatrixType mtype,
00059 Int nPar,
00060 const String& timetype,
00061 const String& freqtype,
00062 const String& fieldtype,
00063 Vector<Int> spwmap=Vector<Int>(),
00064 Vector<Int> fldmap=Vector<Int>());
00065
00066
00067 CTPatchedInterp(NewCalTable& ct,
00068 VisCalEnum::MatrixType mtype,
00069 Int nPar,
00070 const String& timetype,
00071 const String& freqtype,
00072 const String& fieldtype,
00073 const MeasurementSet& ms,
00074 Vector<Int> spwmap=Vector<Int>());
00075
00076
00077 CTPatchedInterp(NewCalTable& ct,
00078 VisCalEnum::MatrixType mtype,
00079 Int nPar,
00080 const String& timetype,
00081 const String& freqtype,
00082 const String& fieldtype,
00083 const ROMSColumns& mscol,
00084 Vector<Int> spwmap=Vector<Int>());
00085
00086
00087
00088 virtual ~CTPatchedInterp();
00089
00090
00091
00092 Bool interpolate(Int obs, Int fld, Int spw, Double time, Double freq=-1.0);
00093 Bool interpolate(Int obs, Int fld, Int spw, Double time, const Vector<Double>& freq);
00094
00095
00096 Array<Float>& resultF(Int obs, Int fld, Int spw) { return result_(spw,fld,thisobs(obs)); };
00097 Array<Complex> resultC(Int obs, Int fld, Int spw) { return RIorAPArray(result_(spw,fld,thisobs(obs))).c(); };
00098 Array<Bool>& rflag(Int obs, Int fld, Int spw) { return resFlag_(spw,fld,thisobs(obs)); };
00099
00100
00101 Array<Float>& tresultF(Int obs, Int fld, Int spw) { return timeResult_(spw,fld,thisobs(obs)); };
00102 Array<Bool>& tresultFlag(Int obs, Int fld, Int spw) { return timeResFlag_(spw,fld,thisobs(obs)); };
00103
00104
00105 Bool spwOK(Int spw) const;
00106 Bool spwInOK(Int spw) const;
00107
00108
00109
00110
00111
00112 void state();
00113
00114 private:
00115
00116
00117 CTPatchedInterp() :mtype_(VisCalEnum::GLOBAL) {};
00118
00119
00120 void sliceTable();
00121 void makeInterpolators();
00122
00123 Int thisobs(Int obs) { return (byObs_?obs:0); };
00124
00125
00126
00127
00128
00129 void setDefFldMap() {fldMap_.resize(nMSFld_); fldMap_.set(0);};
00130 void setFldMap(const MSField& msfld);
00131 void setFldMap(const ROMSFieldColumns& fcol);
00132 void setFldMap(Vector<Int>& fldmap);
00133
00134
00135
00136
00137 void calcAltFld();
00138
00139
00140
00141 void setDefSpwMap() {spwMap_.resize(nMSSpw_); indgen(spwMap_);};
00142 void setSpwMap(Vector<Int>& spwmap);
00143
00144
00145
00146
00147
00148 void setDefAntMap() {antMap_.resize(nMSAnt_); indgen(antMap_);};
00149
00150
00151
00152
00153
00154 void setElemMap();
00155
00156
00157 void resampleInFreq(Matrix<Float>& fres,Matrix<Bool>& fflg,const Vector<Double>& fout,
00158 Matrix<Float>& tres,Matrix<Bool>& tflg,const Vector<Double>& fin);
00159 void resampleFlagsInFreq(Vector<Bool>& flgout,const Vector<Double>& fout,
00160 Vector<Bool>& flgin,const Vector<Double>& fin);
00161
00162
00163 inline Int blnidx(const Int& a1, const Int& a2, const Int& nAnt) { return a1*nAnt-a1*(a1+1)/2+a2; };
00164
00165
00166 InterpolateArray1D<Double,Float>::InterpolationMethod ftype(String& strtype);
00167
00168
00169
00170
00171
00172 NewCalTable ct_;
00173
00174
00175 VisCalEnum::MatrixType mtype_;
00176
00177
00178 Bool isCmplx_;
00179
00180
00181 Int nPar_, nFPar_;
00182
00183
00184 String timeType_, freqType_;
00185
00186 InterpolateArray1D<Double,Float>::InterpolationMethod ia1dmethod_;
00187
00188
00189 Bool byObs_,byField_;
00190
00191
00192 Vector<Int> nChanIn_;
00193 Vector<Vector<Double> > freqIn_;
00194
00195
00196
00197
00198 Int nMSObs_, nMSFld_, nMSSpw_, nMSAnt_, nMSElem_;
00199
00200
00201 Vector<Int> altFld_;
00202
00203
00204
00205 Int nCTObs_, nCTFld_, nCTSpw_, nCTAnt_, nCTElem_;
00206
00207
00208 Vector<Bool> spwInOK_;
00209
00210
00211
00212 Vector<Int> fldMap_, spwMap_, antMap_, elemMap_;
00213
00214
00215 Vector<Bool> conjTab_;
00216
00217
00218 Cube<Cube<Float> > timeResult_,freqResult_;
00219 Cube<Cube<Bool> > timeResFlag_,freqResFlag_;
00220
00221
00222
00223
00224 Cube<Cube<Float> > result_;
00225 Cube<Cube<Bool> > resFlag_;
00226
00227
00228 Array<NewCalTable*> ctSlices_;
00229
00230
00231
00232 Array<CTTimeInterp1*> tI_;
00233 Array<Bool> tIdel_;
00234
00235 Vector<Int> lastFld_,lastObs_;
00236
00237
00238 };
00239
00240
00241 }
00242
00243 #endif