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
00029 #ifndef SYNTHESIS_SKYEQUATION_H
00030 #define SYNTHESIS_SKYEQUATION_H
00031
00032 #include <casa/aips.h>
00033 #include <casa/Arrays/Matrix.h>
00034 #include <casa/BasicSL/Complex.h>
00035 #include <casa/Logging/LogMessage.h>
00036 #include <casa/Logging/LogSink.h>
00037 #include <synthesis/TransformMachines/FTMachine.h>
00038 #include <msvis/MSVis/VisBuffer.h>
00039 #include <ms/MeasurementSets/MSMainEnums.h>
00040
00041 namespace casa {
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120 class SkyJones;
00121 class SkyModel;
00122 class VisSet;
00123 class FTMachine;
00124 class SkyComponent;
00125 class ComponentList;
00126 class ComponentFTMachine;
00127 class UVWMachine;
00128 class ROVisibilityIterator;
00129 class VisibilityIterator;
00130
00131 template <class T> class ImageInterface;
00132 template <class T> class TempImage;
00133
00134 class SkyEquation {
00135 public:
00136
00137
00138
00139 SkyEquation(SkyModel& sm, VisSet& vs, FTMachine& ft);
00140
00141
00142
00143
00144 SkyEquation(SkyModel& sm, VisSet& vs, FTMachine& ft,
00145 ComponentFTMachine& cft, Bool noModelcol=False);
00146
00147
00148
00149 SkyEquation(SkyModel& sm, ROVisibilityIterator& vi, FTMachine& ft,
00150 ComponentFTMachine& cft, Bool noModelCol);
00151
00152
00153
00154 SkyEquation(SkyModel& sm, VisSet& vs, FTMachine& ft, FTMachine& ift);
00155
00156
00157
00158
00159
00160 SkyEquation(SkyModel& sm, VisSet& vs, FTMachine& ft, FTMachine& ift,
00161 ComponentFTMachine& cft);
00162
00163
00164
00165 SkyModel& skyModel() {return *sm_;};
00166
00167
00168 VisSet& visSet() {return *vs_;};
00169
00170
00171 FTMachine& fTMachine() {return *ft_;};
00172
00173
00174 FTMachine& iFTMachine() {return *ift_;};
00175
00176
00177 ComponentFTMachine& componentFTMachine() {return *cft_;};
00178
00179
00180 virtual ~SkyEquation();
00181
00182
00183 SkyEquation& operator=(const SkyEquation& other);
00184
00185
00186 SkyEquation(const SkyEquation& other);
00187
00188
00189
00190 void setSkyJones(SkyJones& j);
00191
00192
00193
00194 virtual void makeApproxPSF(Int model, ImageInterface<Float>& PSF);
00195
00196
00197 virtual void makeApproxPSF(PtrBlock<ImageInterface<Float> *>& PSFs);
00198
00199
00200 virtual void makeComplexXFRs();
00201
00202
00203
00204
00205
00206 virtual void predict(Bool incremental=False, MS::PredefinedColumns Type=MS::MODEL_DATA);
00207
00208
00209
00210
00211 virtual void gradientsChiSquared(const Matrix<Bool>& required, SkyJones& sj);
00212 virtual void gradientsChiSquared(Bool incremental, Bool commitToMS=False);
00213
00214
00215
00216
00217
00218 virtual Bool solveSkyModel();
00219 virtual Bool solveSkyJones(SkyJones& sj);
00220
00221
00222
00223 void setImagePlaneWeighting(const String& type, const Float minPB,
00224 const Float constPB)
00225 {scaleType_p = type; minPB_p = minPB; constPB_p = constPB;}
00226
00227
00228 virtual void lock();
00229 virtual void unlock();
00230
00231
00232 virtual String associatedMSName();
00233
00234
00235
00236 virtual void getCoverageImage(Int model, ImageInterface<Float>& im);
00237
00238
00239 virtual void doFlatNoise(Bool doFlat=False){doflat_p=doFlat;};
00240
00241
00242 virtual void getWeightImage(const Int, ImageInterface<Float>&){};
00243
00244 virtual Bool isNewFTM(){return False;}
00245
00246 protected:
00247
00248
00249
00250
00251
00252 virtual void incrementGradientsChiSquared();
00253
00254
00255
00256
00257 virtual void fullGradientsChiSquared(Bool incremental=False);
00258
00259 SkyEquation() {};
00260
00261
00262 Bool ok();
00263
00264
00265
00266 virtual void initializeGet(const VisBuffer& vb, Int row, Int model,
00267 Bool incremental);
00268
00269
00270 virtual VisBuffer& get(VisBuffer& vb, Int model, Bool incremental, MS::PredefinedColumns Type=MS::MODEL_DATA);
00271 virtual void finalizeGet();
00272 virtual void initializePut(const VisBuffer &vb, Int model);
00273
00274 virtual void put(const VisBuffer& vb, Int model, Bool dopsf=False, FTMachine::Type col=FTMachine::OBSERVED);
00275
00276 virtual void finalizePut(const VisBuffer& vb, Int Model);
00277
00278
00279
00280
00281
00282
00283
00284 virtual void changedSkyJonesLogic(const VisBuffer& vb,
00285 Bool& firstOneChanges,
00286 Bool& internalChanges);
00287
00288
00289 virtual Bool changedSkyJones(const VisBuffer& vb, Int row);
00290
00291
00292
00293 virtual Bool changedFTMachine(const VisBuffer& vb);
00294 virtual Bool changedIFTMachine(const VisBuffer& vb);
00295
00296
00297
00298
00299 virtual Bool changedSkyJonesBuffer(const VisBuffer& vb, Int row1, Int& row2);
00300
00301 virtual void resetSkyJones();
00302 virtual void assertSkyJones(const VisBuffer& vb, Int row);
00303 virtual ImageInterface<Complex>& applySkyJones(const VisBuffer& vb, Int row,
00304 ImageInterface<Float>& in,
00305 ImageInterface<Complex>& out);
00306 virtual void applySkyJonesInv(const VisBuffer& vb, Int row,
00307 ImageInterface<Complex>& in,
00308 ImageInterface<Float>& work,
00309 ImageInterface<Float>& out);
00310 virtual void applySkyJonesSquare(const VisBuffer& vb, Int row,
00311 Matrix<Float>& weights,
00312 ImageInterface<Float>& work,
00313 ImageInterface<Float>& ggS);
00314
00315
00316
00317
00318 virtual void initializePutXFR(const VisBuffer &vb, Int model, Int numXFR);
00319 virtual void putXFR(const VisBuffer& vb, Int model, Int& numXFR);
00320 virtual void finalizePutXFR(const VisBuffer& vb, Int Model, Int numXFR);
00321
00322
00323
00324
00325 virtual void initializePutConvolve(const VisBuffer &vb, Int model,
00326 Int numXFR);
00327 virtual void putConvolve(const VisBuffer& vb, Int model, Int& numXFR);
00328 virtual void finalizePutConvolve(const VisBuffer& vb, Int Model, Int numXFR);
00329
00330
00331
00332
00333 virtual VisBuffer& get(VisBuffer& vb, const SkyComponent& component);
00334 virtual VisBuffer& get(VisBuffer& vb, const ComponentList& components);
00335
00336
00337 SkyComponent& applySkyJones(SkyComponent& corruptedComponent,
00338 const VisBuffer& vb,
00339 Int row);
00340
00341
00342
00343 virtual void fixImageScale();
00344
00345
00346
00347 virtual void scaleImage(Int model, Bool incremental);
00348 virtual void unScaleImage(Int model, Bool incremental);
00349 virtual void scaleImage(Int model=0);
00350 virtual void unScaleImage(Int model=0);
00351 virtual void scaleDeltaImage(Int model=0);
00352 virtual void unScaleDeltaImage(Int model=0);
00353
00354
00355
00356
00357
00358 virtual void checkVisIterNumRows(ROVisibilityIterator& vi);
00359
00360
00361 virtual void predictComponents(Bool& incremental, Bool& initialized, MS::PredefinedColumns Type=MS::MODEL_DATA);
00362
00363
00364
00365 SkyModel* sm_;
00366
00367
00368 VisSet* vs_;
00369
00370 VisibilityIterator* wvi_p;
00371 ROVisibilityIterator* rvi_p;
00372
00373
00374
00375
00376 FTMachine* ft_;
00377 FTMachine* ift_;
00378 ComponentFTMachine* cft_;
00379
00380
00381
00382
00383 SkyJones* ej_;
00384 SkyJones* dj_;
00385 SkyJones* tj_;
00386 SkyJones* fj_;
00387
00388
00389
00390
00391 Float chisq, sumwt;
00392 Float ggSMax_p;
00393
00394
00395 LogSink logSink_p;
00396 LogSink& logSink() {return logSink_p;};
00397
00398 Int iDebug_p;
00399
00400
00401
00402
00403
00404
00405 mutable VisBufferAutoPtr vb_p;
00406
00407 Float minPB_p;
00408 Float constPB_p;
00409 String scaleType_p;
00410
00411 Bool isPSFWork_p;
00412
00413 Bool noModelCol_p;
00414
00415 Vector<Bool> modelIsEmpty_p;
00416
00417
00418
00419
00420 Bool isBeginingOfSkyJonesCache_p;
00421 Bool doflat_p;
00422 };
00423
00424 }
00425
00426 #endif
00427
00428
00429
00430
00431