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_SYNTHESISUTILS_H
00028 #define SYNTHESIS_SYNTHESISUTILS_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 <casa/Arrays/IPosition.h>
00035 #include <casa/Quanta/Quantum.h>
00036 #include <casa/Quanta/QuantumHolder.h>
00037 #include <measures/Measures/MDirection.h>
00038 #include <casa/Quanta/MVAngle.h>
00039 #include <measures/Measures/MFrequency.h>
00040 #include <casa/Utilities/DataType.h>
00041 #include <stdcasa/StdCasa/CasacSupport.h>
00042 #include <coordinates/Coordinates/Projection.h>
00043 #include <coordinates/Coordinates/DirectionCoordinate.h>
00044 #include <coordinates/Coordinates/SpectralCoordinate.h>
00045 #include <coordinates/Coordinates/CoordinateSystem.h>
00046 #include <scimath/Mathematics/GaussianBeam.h>
00047
00048 #include <msvis/MSVis/VisibilityIterator.h>
00049 #include <msvis/MSVis/VisibilityIterator2.h>
00050
00051
00052 namespace casa {
00053
00054 class SynthesisParams;
00055 class SynthesisParamsImage;
00056 class SynthesisParamsSelect;
00057
00058 class SynthesisUtilMethods
00059 {
00060 public:
00061 enum VBSTATES {NOVALIDROWS=-1};
00062
00063
00064 SynthesisUtilMethods();
00065 ~SynthesisUtilMethods();
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 Record continuumDataPartition(Record &selpars, const Int npart);
00084
00085
00086
00087
00088
00089
00090 static Record cubeDataPartition(const Record &selpars, const Int npart, const Double freqBeg, const Double freqEnd, const MFrequency::Types eltype=MFrequency::LSRK);
00091
00092
00093
00094
00095 static Record cubeDataPartition(const Record& selpars, const Vector<Double>& freqBeg, const Vector<Double>& freqEnd, const MFrequency::Types frame=MFrequency::LSRK);
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116 static Record cubeDataImagePartition(const Record & selpars, const CoordinateSystem&
00117 incsys, const Int npart, const Int nchannel,
00118 Vector<CoordinateSystem>& outCsys,
00119 Vector<Int>& outnChan);
00120
00121
00122 Record cubeImagePartition(Record &impars, Int npart);
00123
00124
00125
00126
00127
00128
00129
00130 static Int validate(const VisBuffer& vb);
00131 static Int validate(const vi::VisBuffer2& vb);
00132
00133
00134 static Int getOptimumSize(const Int npix);
00135
00136 static Int parseLine(char* line);
00137 static void getResource(String label="",String fname="");
00138
00139 protected:
00140 static String mergeSpwSel(const Vector<Int>& fspw, const Vector<Int>& fstart, const Vector<Int>& fnchan, const Matrix<Int>& spwsel);
00141
00142 static Vector<uInt> primeFactors(uInt n, Bool douniq=True);
00143
00144 };
00145
00146 class SynthesisParams
00147 {
00148 public:
00149 SynthesisParams(){};
00150 virtual ~SynthesisParams(){};
00152 virtual SynthesisParams& operator= (const SynthesisParams& ){ return *this;};
00153 virtual void fromRecord(const Record &inrec)=0;
00154 virtual void setDefaults()=0;
00155 virtual String verify()const =0 ;
00156 virtual Record toRecord() const =0;
00157 protected:
00158
00159 String readVal(const Record &rec, String id, String& val) const ;
00160 String readVal(const Record &rec, String id, Int& val) const ;
00161 String readVal(const Record &rec, String id, Float& val) const;
00162 String readVal(const Record &rec, String id, Bool& val) const ;
00163 String readVal(const Record &rec, String id, Vector<Int>& val) const;
00164 String readVal(const Record &rec, String id, Vector<Float>& val) const ;
00165 String readVal(const Record &rec, String id, Vector<String>& val) const ;
00166 String stringToQuantity(String instr, Quantity& qa) const;
00167 String stringToMDirection(String instr, MDirection& md) const ;
00168 String readVal(const Record &rec, String id, Quantity& val) const;
00169 String readVal(const Record &rec, String id, MDirection& val) const ;
00170
00171 String MDirectionToString(MDirection val) const;
00172 String QuantityToString(Quantity val) const;
00173 String recordQMToString(const Record &rec) const ;
00174 };
00175
00176 class SynthesisParamsSelect : public SynthesisParams
00177 {
00178 public:
00179
00180 SynthesisParamsSelect();
00181 SynthesisParamsSelect(const SynthesisParamsSelect& other);
00182 ~SynthesisParamsSelect();
00183
00184
00185 virtual SynthesisParamsSelect& operator=(const SynthesisParamsSelect& other);
00186 void fromRecord(const Record &inrec);
00187 void setDefaults();
00188 String verify() const;
00189 Record toRecord() const;
00190
00191 String msname, spw, freqbeg, freqend;
00192 MFrequency::Types freqframe;
00193 String field, antenna, timestr, scan, obs, state, uvdist,taql,intent;
00194 Bool usescratch,readonly,incrmodel;
00195
00196 String datacolumn;
00197
00198 };
00199
00200
00201
00202 class SynthesisParamsImage: public SynthesisParams
00203 {
00204 public:
00205
00206 SynthesisParamsImage();
00207 ~SynthesisParamsImage();
00208
00209 void fromRecord(const Record &inrec);
00210 void setDefaults();
00211 String verify() const;
00212 Record toRecord()const ;
00213
00214
00215 CoordinateSystem buildCoordinateSystem(ROVisibilityIterator* rvi);
00216 CoordinateSystem buildCoordinateSystem(vi::VisibilityIterator2& vi2);
00217 CoordinateSystem buildCoordinateSystemCore(MeasurementSet& msobj,
00218 Vector<Int> spwids, Int fld,
00219 Double freqmin, Double freqmax,
00220 Double datafstart, Double datafend);
00221
00222 Vector<Int> decideNPolPlanes(const String& stokes) const;
00223 IPosition shp() const;
00224 Bool getImFreq(Vector<Double>& ChanFreq, Vector<Double>& ChanWidth,
00225 Double& refPix, String& specmode,
00226 const MEpoch& obsEpoch, const MPosition& obsPosition,
00227 const Vector<Double>& dataChanFreqs, const Vector<Double>& dataFreqRes,
00228 const MFrequency::Types& dataFrame, const Quantity& qrestfreq,
00229 const Double& freqmin, const Double& freqmax,
00230 const MDirection& phaseCenter );
00231
00232 String findSpecMode(const String& mode) const;
00233 String MDopToVelString(Record &rec);
00234 Record getcsys() const;
00235
00236
00237 Record updateParams(const Record &impar);
00238
00239
00240 String imageName, stokes;
00241 Vector<String> startModel;
00242 Vector<Int> imsize;
00243 Vector<Quantity> cellsize;
00244 Projection projection;
00245 Bool useNCP;
00246 MDirection phaseCenter;
00247 Int phaseCenterFieldId;
00248
00249
00250 Int nchan, nTaylorTerms, chanStart, chanStep;
00251 Quantity freqStart, freqStep, refFreq, velStart, velStep;
00252 MFrequency::Types freqFrame;
00253 MFrequency mFreqStart, mFreqStep;
00254 MRadialVelocity mVelStart, mVelStep;
00255 Vector<Quantity> restFreq;
00256 String start, step, frame, veltype, mode, reffreq, sysvel, sysvelframe;
00257
00258
00259 String qmframe, mveltype;
00260 String tststr;
00261
00262 Record startRecord, stepRecord, reffreqRecord, sysvelRecord, restfreqRecord;
00263
00264 Record csysRecord, csys;
00265 Vector<Int> imshape;
00266
00267
00268 Bool freqFrameValid;
00269
00270 Bool overwrite;
00271
00272 String deconvolver;
00273
00274 };
00275
00276
00277 class SynthesisParamsGrid: public SynthesisParams
00278 {
00279 public:
00280
00281 SynthesisParamsGrid();
00282 ~SynthesisParamsGrid();
00283
00284 void fromRecord(const Record &inrec);
00285 void setDefaults();
00286 String verify() const;
00287 Record toRecord() const;
00288
00289 String imageName;
00290
00291
00292 String gridder, ftmachine, convFunc, vpTable;
00293 Int wprojplanes;
00294 Bool useDoublePrec, useAutoCorr;
00295 Float padding;
00296
00297
00298 Int facets;
00299
00300
00301 Int chanchunks;
00302
00303
00304 String interpolation;
00305
00306
00307 Quantity distance;
00308 MDirection trackDir;
00309 Bool trackSource;
00310
00311
00312 Bool aTermOn, psTermOn,mTermOn,wbAWP,doPointing, doPBCorr, conjBeams;
00313 String cfCache;
00314 Float computePAStep, rotatePAStep;
00315
00316
00317 String mType;
00318
00319 };
00320
00321
00322 class SynthesisParamsDeconv: public SynthesisParams
00323 {
00324 public:
00325
00326 SynthesisParamsDeconv();
00327 ~SynthesisParamsDeconv();
00328
00329 void fromRecord(const Record &inrec);
00330 void setDefaults();
00331 String verify() const;
00332 Record toRecord() const;
00333
00334 String imageName, algorithm;
00335 Vector<String> startModel;
00336 Int deconvolverId;
00337 Int nTaylorTerms;
00338 Vector<Float> scales;
00339 Float scalebias;
00340 String maskString;
00341 String maskType;
00342 Vector<String> maskList;
00343 String autoMaskAlgorithm;
00344 Float pbMask;
00345 String maskThreshold;
00346 String maskResolution;
00347 Float fracOfPeak;
00348 Float maskResByBeam;
00349 Int nMask;
00350 Bool autoAdjust;
00351
00352
00353
00354 Bool interactive;
00355
00356 GaussianBeam restoringbeam;
00357 String usebeam;
00358
00359 };
00360
00361
00362 }
00363
00364 #endif