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 #ifndef SYNTHESIS_CALIBRATER_H
00028 #define SYNTHESIS_CALIBRATER_H
00029
00030 #include <casa/aips.h>
00031 #include <casa/OS/Timer.h>
00032 #include <casa/Containers/Record.h>
00033 #include <ms/MeasurementSets/MeasurementSet.h>
00034 #include <measures/Measures/MRadialVelocity.h>
00035 #include <synthesis/MeasurementEquations/VisEquation.h>
00036 #include <synthesis/MeasurementComponents/VisCal.h>
00037 #include <synthesis/MeasurementComponents/SolvableVisCal.h>
00038 #include <synthesis/MeasurementComponents/VisCalGlobals.h>
00039 #include <casa/Logging/LogIO.h>
00040 #include <casa/Logging/LogSink.h>
00041 #include <ms/MeasurementSets/MSHistoryHandler.h>
00042 #include <ms/MSSel/MSSelection.h>
00043 #include <msvis/MSVis/VisibilityProcessing.h>
00044 #include <msvis/MSVis/ViFrequencySelection.h>
00045
00046
00047 namespace casa {
00048
00049
00050
00051 class Calibrater
00052 {
00053
00054 public:
00055
00056 Calibrater();
00057
00058
00059
00060 Calibrater(String msname);
00061
00062
00063 Calibrater(const Calibrater&);
00064 Calibrater& operator=(const Calibrater&);
00065
00066
00067 ~Calibrater();
00068
00069
00070
00071 void selectvis(const String& time="",
00072 const String& spw="",
00073 const String& scan="",
00074 const String& field="",
00075 const String& intent="",
00076 const String& obsIDs="",
00077 const String& baseline="",
00078 const String& uvrange="",
00079 const String& chanmode="none",
00080 const Int& nchan=1,
00081 const Int& start=0,
00082 const Int& step=1,
00083 const MRadialVelocity& mStart=MRadialVelocity(),
00084 const MRadialVelocity& mStep=MRadialVelocity(),
00085 const String& msSelect="");
00086
00087
00088 Bool setapply (const String& type,
00089 const Double& t,
00090 const String& table,
00091 const String& spw,
00092 const String& field,
00093 const String& interp,
00094 const Bool& calwt,
00095 const Vector<Int>& spwmap,
00096 const Vector<Double>& opacity);
00097
00098 Bool setapply (const String& type,
00099 const Record& applypar);
00100
00101
00102 Bool setcallib(Record callib);
00103 Bool setcallib2(Record callib);
00104 Bool validatecallib(Record callib);
00105
00106 Bool setmodel(const String& modelImage);
00107 Bool setModel(const Vector<Double>& stokes);
00108
00109
00110 Bool setsolve (const String& type,
00111 const String& solint,
00112 const String& table,
00113 const Bool append,
00114 const Double preavg,
00115 const String& apmode="AP",
00116 const Int minblperant=4,
00117 const String& refant="",
00118 const Bool solnorm=False,
00119 const Float minsnr=0.0f,
00120 const String& combine="",
00121 const Int fillgaps=0,
00122 const String& cfcache="",
00123 const Double painc=360.0,
00124 const Int fitorder=0,
00125 const Float fraction=0.1,
00126 const Int numedge=-1,
00127 const String& radius="",
00128 const Bool smooth=True);
00129
00130
00131 Bool setsolvebandpoly(const String& table,
00132 const Bool& append,
00133 const String& solint,
00134 const String& combine,
00135 const Vector<Int>& degree,
00136 const Bool& visnorm,
00137 const Bool& solnorm,
00138 const Int& maskcenter,
00139 const Float& maskedge,
00140 const String& refant);
00141
00142
00143 Bool setsolvegainspline(const String& table,
00144 const Bool& append,
00145 const String& mode,
00146 const Double& splinetime,
00147 const Double& preavg,
00148 const Int& numpoint,
00149 const Double& phasewrap,
00150 const String& refant);
00151
00152 Bool setsolve (const String& type,
00153 const Record& solvepar);
00154
00155
00156 Bool unsetapply(const Int& which=-1);
00157
00158
00159
00160 Bool unsetsolve();
00161
00162
00163 Bool reset(const Bool& apply=True,
00164 const Bool& solve=True);
00165
00166
00167
00168 Bool correct(String mode="calflag");
00169 Bool correct2(String mode="calflag");
00170
00171
00172
00173 Bool corrupt();
00174
00175
00176 Bool initWeights(String wtmode, Bool dowtsp=False);
00177 Bool initWeights(Bool doBT=True, Bool dowtsp=False);
00178 Bool initWeightsWithTsys(String wtmode, Bool dowtsp=False, String tsystable="",
00179 String gainfield="", String interp="linear", Vector<Int> spwmap=Vector<Int>());
00180
00181
00182 Bool solve();
00183
00184
00185 Vector<Double> modelfit(const Int& iter,
00186 const String& stype,
00187 const Vector<Double>& par,
00188 const Vector<Bool>& vary,
00189 const String& file);
00190
00191
00192 void fluxscale(const String& infile,
00193 const String& outfile,
00194 const String& refFields,
00195 const Vector<Int>& refSpwMap,
00196 const String& tranFields,
00197 const Bool& append,
00198 const Float& inGainThres,
00199 const String& antSel,
00200 const String& timerangeSel,
00201 const String& scanSel,
00202 SolvableVisCal::fluxScaleStruct& oFluxScaleFactor,
00203 Vector<Int>& tranidx,
00204 const String& oListFile,
00205 const Bool& incremental,
00206 const Int& fitorder,
00207 const Bool& display);
00208
00209
00210 void fluxscale(const String& infile,
00211 const String& outfile,
00212 const Vector<Int>& refField,
00213 const Vector<Int>& refSpwMap,
00214 const Vector<Int>& tranField,
00215 const Bool& append,
00216 const Float& inGainThres,
00217 const String& antSel,
00218 const String& timerangeSel,
00219 const String& scanSel,
00220 SolvableVisCal::fluxScaleStruct& oFluxScaleFactor,
00221 const String& oListFile,
00222 const Bool& incremental,
00223 const Int& fitorder,
00224 const Bool& display);
00225
00226
00227 void accumulate(const String& intab,
00228 const String& incrtab,
00229 const String& outtab,
00230 const String& fields,
00231 const String& calFields,
00232 const String& interp="linear",
00233 const Double& t=-1.0,
00234 const Vector<Int>& spwmap=Vector<Int>(1,-1));
00235
00236
00237 void specifycal(const String& type,
00238 const String& caltable,
00239 const String& time,
00240 const String& spw,
00241 const String& antenna,
00242 const String& pol,
00243 const Vector<Double>& parameter,
00244 const String& infile);
00245
00246
00247 Bool smooth(const String& infile,
00248 String& outfile,
00249 const String& smoothtype,
00250 const Double& smoothtime,
00251 const String& fields);
00252
00253
00254
00255 Bool listCal(const String& infile,
00256 const String& field,
00257 const String& antenna,
00258 const String& spw,
00259 const String& listfile="",
00260 const Int& pagerows=50);
00261
00262
00263
00264
00265
00266
00267 Bool initialize(MeasurementSet& inputMS,
00268 Bool compress=True,
00269 Bool addScratch=True, Bool addModel=True);
00270
00271
00272 Bool initCalSet(const Int& calSet);
00273
00274
00275 Bool state();
00276 Bool applystate();
00277 Bool solvestate();
00278
00279 Record& getActRec() {return actRec_;};
00280
00281 Bool cleanup();
00282
00283
00284 static Bool updateCalTable(const String& caltable);
00285
00286
00287 VisEquation* ve() { return ve_p; };
00288
00289 private:
00290
00291 LogIO sink_p;
00292 LogIO& logSink();
00293
00294
00295 void writeHistory(LogIO& os,
00296 Bool cliCommand=False);
00297
00298
00299 String timerString();
00300 Timer timer_p;
00301
00302 VisibilityIterator::DataColumn configureForCorrection ();
00303
00304
00305 void selectChannel(const String& spw);
00306
00307
00308 void initChanMask();
00309
00310
00311 void selectChannel(const String& mode,
00312 const Int& nchan, const Int& start, const Int& step,
00313 const MRadialVelocity& mStart,
00314 const MRadialVelocity& mStep);
00315
00316
00317 Vector<Int> getRefantIdxList(const String& refant);
00318
00319 Vector<Int> getAntIdx(const String& antenna);
00320
00321
00322 Vector<Int> getFieldIdx(const String& fields);
00323
00324
00325 Vector<Int> getSpwIdx(const String& spws);
00326
00327
00328 Matrix<Int> getChanIdx(const String& spws);
00329
00330
00331 Bool calWt();
00332
00333
00334 Bool ok();
00335
00336
00337
00338 Bool summarize_uncalspws(const Vector<Bool>& uncalspw, const String& origin,
00339 Bool strictflag=False);
00340
00341
00342 void getRawPhaseVisSet(Vector<Int>& spwid);
00343
00344
00345 Bool genericGatherAndSolve();
00346
00347
00348 String msname_p;
00349 MeasurementSet* ms_p;
00350 MeasurementSet* mssel_p;
00351 MeasurementSet* msselRaw_p;
00352
00353
00354 MSSelection* mss_p;
00355 vi::FrequencySelections* frequencySelections_p;
00356
00357
00358 VisSet* vs_p;
00359 VisSet* rawvs_p;
00360 VisEquation* ve_p;
00361
00362
00363 PtrBlock<VisCal*> vc_p;
00364 SolvableVisCal* svc_p;
00365
00366
00367 String dataMode_p;
00368 Int dataNchan_p, dataStart_p, dataStep_p;
00369 MRadialVelocity mDataStart_p, mDataStep_p;
00370
00371
00372 Double phasewrap_p;
00373 Int splinepoint_p;
00374
00375
00376 Int histLockCounter_p;
00377 MSHistoryHandler *hist_p;
00378 Table historytab_p;
00379
00380
00381 PtrBlock<Vector<Bool>*> chanmask_;
00382
00383
00384 Record actRec_;
00385
00386 };
00387
00388 }
00389
00390 #endif