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_CLPATCHPANEL_H
00029 #define CALTABLES_CLPATCHPANEL_H
00030
00031 #include <synthesis/CalTables/NewCalTable.h>
00032 #include <synthesis/CalTables/CTColumns.h>
00033 #include <synthesis/CalTables/CTTimeInterp1.h>
00034 #include <synthesis/CalTables/RIorAParray.h>
00035 #include <synthesis/CalTables/VisCalEnum.h>
00036 #include <scimath/Mathematics/InterpolateArray1D.h>
00037 #include <casa/Arrays/Array.h>
00038 #include <casa/Arrays/Matrix.h>
00039 #include <casa/Arrays/Cube.h>
00040 #include <ms/MeasurementSets/MeasurementSet.h>
00041 #include <ms/MeasurementSets/MSField.h>
00042 #include <ms/MeasurementSets/MSColumns.h>
00043 #include <casa/aips.h>
00044
00045
00046
00047
00048
00049
00050 namespace casa {
00051
00052
00053
00054 class CalPatchKey
00055 {
00056 public:
00057 CalPatchKey(IPosition keyids);
00058 virtual ~CalPatchKey() {};
00059 virtual Bool operator<(const CalPatchKey& other) const;
00060 virtual String print() const =0;
00061 private:
00062 Vector<Int> cpk_;
00063 };
00064
00065 class MSCalPatchKey : virtual public CalPatchKey
00066 {
00067 public:
00068 MSCalPatchKey(Int obs,Int fld,Int ent,Int spw,Int ant=-1);
00069 virtual ~MSCalPatchKey(){};
00070 virtual String print() const;
00071 private:
00072 Int obs_,fld_,ent_,spw_,ant_;
00073 };
00074
00075
00076 class CTCalPatchKey : virtual public CalPatchKey
00077 {
00078 public:
00079 CTCalPatchKey(Int clsl,Int obs,Int fld,Int spw,Int ant=-1);
00080 virtual ~CTCalPatchKey(){};
00081 virtual String print() const;
00082 private:
00083 Int clsl_,obs_,fld_,spw_,ant_;
00084 };
00085
00086
00087 class CalMap
00088 {
00089 public:
00090
00091
00092 CalMap();
00093
00094
00095 CalMap(const Vector<Int>& calmap);
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107 Int operator()(Int msid) const;
00108
00109
00110
00111 Vector<Int> ctids(const Vector<Int>& msids) const;
00112
00113
00114 Vector<Int> msids(Int ctid,const Vector<Int>& superset=Vector<Int>()) const;
00115
00116
00117 Vector<Int> vmap() const { return vcalmap_; };
00118
00119 protected:
00120 Vector<Int> vcalmap_;
00121
00122 };
00123
00124 class FieldCalMap : public CalMap
00125 {
00126 public:
00127
00128
00129 FieldCalMap();
00130
00131
00132 FieldCalMap(const Vector<Int>& calmap);
00133
00134
00135 FieldCalMap(const String fieldcalmap, const MeasurementSet& ms, const NewCalTable& ct);
00136
00137 private:
00138
00139
00140 void setNearestFieldMap(const MeasurementSet& ms, const NewCalTable& ct);
00141 void setNearestFieldMap(const NewCalTable& ctasms, const NewCalTable& ct);
00142 void setNearestFieldMap(const ROMSFieldColumns& msfc, const ROCTColumns& ctc);
00143
00144
00145 void setSelectedFieldMap(const String& fieldsel,
00146 const MeasurementSet& ms,const NewCalTable& ct);
00147
00148
00149 String fieldcalmap_;
00150
00151
00152 };
00153
00154
00155
00156
00157
00158
00159 class CalLibSlice
00160 {
00161 public:
00162 CalLibSlice(String obs,String fld, String ent, String spw,
00163 String tinterp,String finterp,
00164 Vector<Int> obsmap=Vector<Int>(1,-1),
00165 Vector<Int> fldmap=Vector<Int>(1,-1),
00166 Vector<Int> spwmap=Vector<Int>(1,-1),
00167 Vector<Int> antmap=Vector<Int>(1,-1));
00168 CalLibSlice(const Record& clslice,
00169 const MeasurementSet& ms=MeasurementSet(),
00170 const NewCalTable& ct=NewCalTable());
00171
00172
00173 String obs,fld,ent,spw;
00174 String tinterp,finterp;
00175 CalMap obsmap, fldmap, spwmap, antmap;
00176
00177
00178 static Bool validateCLS(const Record& clslice);
00179
00180
00181 Record asRecord();
00182
00183 String state();
00184
00185 };
00186
00187
00188 class CLPPResult
00189 {
00190 public:
00191
00192 CLPPResult();
00193 CLPPResult(const IPosition& shape);
00194 CLPPResult(uInt nPar,uInt nFPar,uInt nChan,uInt nelem);
00195 CLPPResult& operator=(const CLPPResult& other);
00196
00197 void resize(uInt nPar,uInt nFPar,uInt nChan,uInt nelem);
00198
00199 Matrix<Float> operator()(Int ielem) { return result_.xyPlane(ielem); };
00200 Matrix<Float> result(Int ielem) { return result_.xyPlane(ielem); };
00201 Matrix<Bool> resultFlag(Int ielem) { return resultFlag_.xyPlane(ielem); };
00202
00203 Cube<Float> result_;
00204 Cube<Bool> resultFlag_;
00205
00206
00207
00208 };
00209
00210
00211
00212
00213
00214 class MSSelectableTable;
00215
00216 class CLPatchPanel
00217 {
00218 public:
00219
00220
00221 CLPatchPanel(const String& ctname,
00222 const Record& callib,
00223 VisCalEnum::MatrixType mtype,
00224 Int nPar);
00225
00226
00227 CLPatchPanel(const String& ctname,
00228 const MeasurementSet& ms,
00229 const Record& callib,
00230 VisCalEnum::MatrixType mtype,
00231 Int nPar);
00232
00233
00234 virtual ~CLPatchPanel();
00235
00236
00237
00238
00239 Bool interpolate(Cube<Complex>& resultC, Cube<Bool>& resFlag,
00240 Int obs, Int fld, Int ent, Int spw,
00241 Double time, Double freq=-1.0);
00242
00243 Bool interpolate(Cube<Float>& resultR, Cube<Bool>& resFlag,
00244 Int obs, Int fld, Int ent, Int spw,
00245 Double time, Double freq=-1.0);
00246
00247
00248
00249
00250
00251 Bool interpolate(Cube<Complex>& resultC, Cube<Bool>& resFlag,
00252 Int obs, Int fld, Int ent, Int spw,
00253 Double time, const Vector<Double>& freq);
00254
00255 Bool interpolate(Cube<Float>& resultR, Cube<Bool>& resFlag,
00256 Int obs, Int fld, Int ent, Int spw,
00257 Double time, const Vector<Double>& freq);
00258
00259
00260
00261
00262 Bool getTresult(Cube<Float>& resultR, Cube<Bool>& resFlag,
00263 Int obs, Int fld, Int ent, Int spw);
00264
00265
00266
00267
00268 const Vector<Double>& refFreqIn() { return refFreqIn_; };
00269
00270
00271 void listmappings();
00272 void state();
00273
00274 private:
00275
00276
00277 CLPatchPanel() :mtype_(VisCalEnum::GLOBAL) {};
00278
00279
00280
00281
00282 void selectOnCTorMS(Table& ctout,MSSelectableTable& msst,
00283 const String& obs, const String& fld,
00284 const String& ent,
00285 const String& spw, const String& ant,
00286 const String& taql);
00287 void selectOnMS(MeasurementSet& msout,const MeasurementSet& msin,
00288 const String& obs, const String& fld,
00289 const String& ent,
00290 const String& spw, const String& ant);
00291 void selectOnCT(NewCalTable& ctout,const NewCalTable& ctin,
00292 const String& obs, const String& fld,
00293 const String& spw, const String& ant1);
00294
00295
00296 Vector<Int> getCLuniqueObsIds(NewCalTable& ct) {return getCLuniqueIds(ct,"obs"); };
00297 Vector<Int> getCLuniqueFldIds(NewCalTable& ct) {return getCLuniqueIds(ct,"fld"); };
00298 Vector<Int> getCLuniqueSpwIds(NewCalTable& ct) {return getCLuniqueIds(ct,"spw"); };
00299 Vector<Int> getCLuniqueIds(NewCalTable& ct, String vcol);
00300
00301
00302 Vector<Int> getMSuniqueIds(MeasurementSet& ms, String vcol);
00303
00304
00305
00306
00307
00308 void resampleInFreq(Matrix<Float>& fres,Matrix<Bool>& fflg,const Vector<Double>& fout,
00309 Matrix<Float>& tres,Matrix<Bool>& tflg,const Vector<Double>& fin,
00310 String finterp);
00311 void resampleFlagsInFreq(Vector<Bool>& flgout,const Vector<Double>& fout,
00312 Vector<Bool>& flgin,const Vector<Double>& fin,
00313 String finterp);
00314
00315
00316
00317
00318
00319 InterpolateArray1D<Double,Float>::InterpolationMethod ftype(String& strtype);
00320
00321
00322
00323
00324
00325
00326 NewCalTable ct_, ctasms_;
00327
00328
00329 MeasurementSet ms_;
00330
00331
00332 VisCalEnum::MatrixType mtype_;
00333
00334
00335 Bool isCmplx_;
00336
00337
00338 Int nPar_, nFPar_;
00339
00340
00341
00342
00343 Vector<Int> nChanIn_;
00344 Vector<Vector<Double> > freqIn_;
00345 Vector<Double> refFreqIn_;
00346
00347
00348
00349 Int nMSObs_, nMSFld_, nMSSpw_, nMSAnt_, nMSElem_;
00350
00351
00352
00353 Int nCTObs_, nCTFld_, nCTSpw_, nCTAnt_, nCTElem_;
00354
00355
00356 std::map<CTCalPatchKey,CLPPResult> clTres_;
00357 std::map<CTCalPatchKey,String> ciname_;
00358 std::map<CTCalPatchKey,CTTimeInterp1*> ci_;
00359
00360
00361 std::map<MSCalPatchKey,CLPPResult> msTres_,msFres_;
00362 std::map<MSCalPatchKey,String> msciname_;
00363 std::map<MSCalPatchKey,Int> ctspw_;
00364 std::map<MSCalPatchKey,String> finterp_;
00365 std::map<MSCalPatchKey,CTTimeInterp1*> msci_;
00366
00367
00368 Vector<Float*> lastresadd_;
00369
00370
00371
00372
00373
00374 Cube<Float> result_;
00375 Cube<Bool> resFlag_;
00376
00377 LogIO logsink_;
00378
00379
00380 };
00381
00382
00383 }
00384
00385 #endif