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_SYNTHESISIMAGER_H
00028 #define SYNTHESIS_SYNTHESISIMAGER_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 <measures/Measures/MDirection.h>
00037 #include<synthesis/ImagerObjects/SynthesisUtilMethods.h>
00038
00039 #include<synthesis/ImagerObjects/SIMapperCollection.h>
00040 #include <msvis/MSVis/ViFrequencySelection.h>
00041
00042
00043 #include <synthesis/TransformMachines/FTMachine.h>
00044 #include <synthesis/TransformMachines/ATerm.h>
00045
00046 namespace casa {
00047
00048
00049 class MeasurementSet;
00050 template<class T> class ImageInterface;
00051 class SIIterBot;
00052 class VisImagingWeight;
00053
00054
00055
00056 class SynthesisImager
00057 {
00058 public:
00059
00060
00061 SynthesisImager();
00062 virtual ~SynthesisImager();
00063
00064
00065
00066
00067
00068 virtual Bool selectData(const SynthesisParamsSelect& selpars);
00069
00070
00071
00072 virtual Bool selectData(const String& msname,
00073 const String& spw="*",
00074 const String& freqBeg="",
00075 const String& freqEnd="",
00076 const MFrequency::Types freqFrame=MFrequency::LSRK,
00077 const String& field="*",
00078 const String& antenna="",
00079 const String& timestr="",
00080 const String& scan="",
00081 const String& obs="",
00082 const String& state="",
00083 const String& uvdist="",
00084 const String& taql="",
00085 const Bool usescratch=False,
00086 const Bool readonly=False,
00087 const Bool incrementModel=False);
00088
00089 virtual Bool defineImage(SynthesisParamsImage& impars, const SynthesisParamsGrid& gridpars);
00090
00091
00092
00094 virtual Bool defineImage(const String& imagename, const Int nx, const Int ny,
00095 const Quantity& cellx, const Quantity& celly,
00096 const String& stokes,
00097 const MDirection& phaseCenter,
00098 const Int nchan,
00099 const Quantity& freqStart,
00100 const Quantity& freqStep,
00101 const Vector<Quantity>& restFreq,
00102 const Int facets=1,
00103
00104 const String ftmachine="gridft",
00105 const Int nTaylorTerms=1,
00106 const Quantity& refFreq = Quantity(0,"Hz"),
00107 const Projection& projection=Projection::SIN,
00108 const Quantity& distance=Quantity(0,"m"),
00109 const MFrequency::Types& freqFrame=MFrequency::LSRK,
00110 const Bool trackSource=False,
00111 const MDirection& trackDir=MDirection(Quantity(0.0, "deg"), Quantity(90.0, "deg")),
00112 const Bool overwrite=False,
00113 const Float padding=1.0,
00114 const Bool useAutocorr=False,
00115 const bool useDoublePrec=True,
00116 const Int wprojplanes=1,
00117 const String convFunc="SF",
00118
00119 const String startmodel="",
00120
00121 const Bool aTermOn = True,
00122 const Bool psTermOn = True,
00123 const Bool mTermOn = False,
00124 const Bool wbAWP = True,
00125 const String cfCache = "",
00126 const Bool doPointing = False,
00127 const Bool doPBCorr = True,
00128 const Bool conjBeams = True,
00129 const Float computePAStep=360.0,
00130 const Float rotatePAStep=5.0
00131 );
00132
00133 virtual Bool defineImage(CountedPtr<SIImageStore> imstor,
00134 const String& ftmachine);
00135
00136 Record getcsys() {return itsCsysRec;};
00137 Int updateNchan() {return itsNchan;};
00138
00139
00140
00141
00142
00143 virtual Vector<SynthesisParamsSelect> tuneSelectData();
00144
00145
00146
00147
00148
00149 virtual void setComponentList(const ComponentList& cl,
00150 Bool sdgrid=False);
00151 virtual Bool weight(const String& type="natural",
00152 const String& rmode="norm",
00153 const Quantity& noise=Quantity(0.0, "Jy"),
00154 const Double robust=0.0,
00155 const Quantity& fieldofview=Quantity(0.0, "arcsec"),
00156 const Int npixels=0,
00157 const Bool multiField=False,
00158 const String& filtertype=String("Gaussian"),
00159 const Quantity& filterbmaj=Quantity(0.0,"deg"),
00160 const Quantity& filterbmin=Quantity(0.0,"deg"),
00161 const Quantity& filterbpa=Quantity(0.0,"deg") );
00162
00163 Bool getWeightDensity();
00164 virtual Bool setWeightDensity();
00165
00166
00167 void resetMappers();
00168
00169 CountedPtr<SIImageStore> imageStore(const Int id=0);
00170
00171
00172 void executeMajorCycle(Record& controls);
00173
00174
00175 void makePSF();
00176
00177
00178 virtual Bool makePB();
00179
00180 virtual void predictModel();
00181
00182
00183
00184
00185 virtual void dryGridding(const Vector<String>& cfList);
00186 virtual void fillCFCache(const Vector<String>& cfList, const String& ftmName, const String& cfcPath,
00187 const Bool& psTermOn, const Bool& aTermOn);
00188 virtual void reloadCFCache();
00189
00190 static String doubleToString(const Double& df);
00191
00192 protected:
00193
00195
00196
00197 void createFTMachine(CountedPtr<FTMachine>& theFT,
00198 CountedPtr<FTMachine>& theIFT,
00199 const String& ftname,
00200 const uInt nTaylorTerms=1,
00201 const String mType="default",
00202 const Int facets=1,
00203
00204 const Int wprojplane=1,
00205 const Float padding=1.0,
00206 const Bool useAutocorr=False,
00207 const Bool useDoublePrec=True,
00208 const String gridFunction=String("SF"),
00209
00210 const Bool aTermOn = True,
00211 const Bool psTermOn = True,
00212 const Bool mTermOn = False,
00213 const Bool wbAWP = True,
00214 const String cfCache = "",
00215 const Bool doPointing = False,
00216 const Bool doPBCorr = True,
00217 const Bool conjBeams = True,
00218 const Float computePAStep = 360.0,
00219 const Float rotatePAStep = 5.0,
00220 const String interpolation = String("linear"),
00221 const Bool freqFrameValid = True,
00222 const Int cache=1000000000,
00223 const Int tile=16,
00224 const String stokes="I",
00225 const String imageNamePrefix="");
00226
00227 void createMosFTMachine(CountedPtr<FTMachine>& theFT, CountedPtr<FTMachine>& theIFT, const Float padding, const Bool useAutoCorr, const Bool useDoublePrec, const Float rotatePAStep, const String Stokes="I");
00228
00229
00230 CountedPtr<SIImageStore> createIMStore(String imageName,
00231 CoordinateSystem& cSys,
00232 IPosition imShape,
00233 const Bool overwrite,
00234 ROMSColumns& msc,
00235 String mappertype="default",
00236 uInt ntaylorterms=1,
00237 Quantity distance=Quantity(0.0, "m"),
00238 uInt facets=1,
00239 Bool useweightimage=False,
00240 Vector<String> startmodel=Vector<String>(0));
00241
00242
00243 CountedPtr<SIMapper> createSIMapper(String mappertype,
00244 CountedPtr<SIImageStore> imagestore,
00245 CountedPtr<FTMachine> ftmachine,
00246 CountedPtr<FTMachine> iftmachine,
00247 uInt ntaylorterms=1);
00248
00249 Block<CountedPtr<SIImageStore> > createFacetImageStoreList(
00250 CountedPtr<SIImageStore> imagestore,
00251 Int facets);
00252
00253 Block<CountedPtr<SIImageStore> > createChanChunkImageStoreList(
00254 CountedPtr<SIImageStore> imagestore,
00255 Int chanchunks);
00256
00257 Bool toUseWeightImage(CountedPtr<FTMachine>& ftm, String mappertype);
00258
00259 virtual void createVisSet(const Bool writeaccess=False);
00260
00261 void createAWPFTMachine(CountedPtr<FTMachine>& theFT, CountedPtr<FTMachine>& theIFT,
00262 const String& ftmName,
00263 const Int facets,
00264
00265 const Int wprojPlane,
00266 const Float padding,
00267 const Bool useAutocorr,
00268 const Bool useDoublePrec,
00269 const String gridFunction,
00270
00271 const Bool aTermOn,
00272 const Bool psTermOn,
00273 const Bool mTermOn,
00274 const Bool wbAWP,
00275 const String cfCache,
00276 const Bool doPointing,
00277 const Bool doPBCorr,
00278 const Bool conjBeams,
00279 const Float computePAStep,
00280 const Float rotatePAStep,
00281 const Int cache,
00282 const Int tile,
00283 const String imageNamePrefix="");
00284 ATerm* createTelescopeATerm(const MeasurementSet& ms, const Bool& isATermOn);
00285
00286
00287 void getVPRecord(Record &rec, PBMath::CommonPB &kpb, String telescop);
00288
00289
00290 virtual void runMajorCycle(const Bool dopsf=False, const Bool savemodel=False);
00291
00292
00293 virtual void runMajorCycle2(const Bool dopsf=False, const Bool savemodel=False);
00294
00299
00300
00301
00302 void appendToMapperList(String imagename,
00303 CoordinateSystem& csys,
00304 IPosition imshape,
00305 CountedPtr<FTMachine>& ftm,
00306 CountedPtr<FTMachine>& iftm,
00307 Quantity distance=Quantity(0.0, "m"),
00308 Int facets=1,
00309 Int chanchunks=1,
00310 const Bool overwrite=False,
00311 String mappertype=String("default"),
00312 Float padding=1.0,
00313 uInt ntaylorterms=1,
00314 Vector<String> startmodel=Vector<String>(0));
00315
00316 virtual void unlockMSs();
00317
00318 Bool makePBImage(const String& telescopeName,
00319 Bool useSymmetricBeam, Double diam);
00320 Bool makePBImage(const String telescop);
00321 virtual Bool makePrimaryBeam(PBMath& pbMath);
00322
00324
00325 SIMapperCollection itsMappers;
00327 CountedPtr<SIImageStore> unFacettedImStore_p;
00328 CountedPtr<SIImageStore> unChanChunkedImStore_p;
00329
00330 Bool itsDataLoopPerMapper;
00331
00332 CoordinateSystem itsMaxCoordSys;
00333 IPosition itsMaxShape;
00334 Record itsCsysRec;
00335 Int itsNchan;
00336
00337 String itsVpTable;
00338 Bool itsMakeVP;
00339
00341
00342
00343 Vector<SynthesisParamsSelect> dataSel_p;
00344
00345
00346
00348 Block<const MeasurementSet *> mss_p;
00349 vi::FrequencySelections fselections_p;
00350 CountedPtr<vi::VisibilityIterator2> vi_p;
00351
00352
00354 Bool useViVb2_p;
00355 Block<MeasurementSet> mss4vi_p;
00356 VisibilityIterator* wvi_p;
00357 ROVisibilityIterator* rvi_p;
00358 Block<Vector<Int> > blockNChan_p;
00359 Block<Vector<Int> > blockStart_p;
00360 Block<Vector<Int> > blockStep_p;
00361 Block<Vector<Int> > blockSpw_p;
00362 Matrix<Double> mssFreqSel_p;
00363
00364 Cube<Int > chanSel_p;
00365
00367 Bool writeAccess_p;
00368 MPosition mLocation_p;
00369 MDirection phaseCenter_p;
00370 Int facetsStore_p,chanChunksStore_p;
00371 VisImagingWeight imwgt_p;
00372 Bool imageDefined_p;
00373 Bool useScratch_p,readOnly_p;
00374
00375
00376
00377 FTMachine::Type datacol_p;
00378
00379 Int nMajorCycles;
00380
00381 };
00382
00383
00384 }
00385
00386 #endif