SynthesisImager.h

Go to the documentation of this file.
00001 //# SynthesisImager.h: Imager functionality sits here; 
00002 //# Copyright (C) 2012-2013
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#
00025 //# $Id$
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 { //# NAMESPACE CASA - BEGIN
00047 
00048 // Forward declarations
00049 class MeasurementSet;
00050 template<class T> class ImageInterface;
00051  class SIIterBot;
00052  class VisImagingWeight;
00053 
00054 // <summary> Class that contains functions needed for imager </summary>
00055 
00056 class SynthesisImager 
00057 {
00058  public:
00059   // Default constructor
00060 
00061   SynthesisImager();
00062   virtual ~SynthesisImager();
00063 
00064   // Copy constructor and assignment operator
00065   //Imager(const Imager&);
00066   //Imager& operator=(const Imager&);
00067 
00068   virtual Bool selectData(const SynthesisParamsSelect& selpars);
00069  
00070 
00071   // make all pure-inputs const
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   //When having a facetted image ...call with (facets > 1)  first and  once only ..
00092   //Easier to keep track of the imstores that way
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                            //                      const Int chanchunks=1,
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                            //                      const String vptable="",
00119                            const String startmodel="",
00120                            // The extra params for WB-AWP
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   //Define image via a predefine SIImageStore object
00133   virtual Bool defineImage(CountedPtr<SIImageStore> imstor, 
00134                            const String& ftmachine);
00135 
00136   Record getcsys() {return itsCsysRec;};
00137   Int updateNchan() {return itsNchan;};
00138 
00139   //Function to tune the data selection to intersect with image definition chosen
00140   //This is to optimize the data selection so that unnecessary data is not parsed despite the user
00141   // deciding to select so.
00142   // defineimage has to be run first (and thus selectData prior to that) otherwise an exception is thrown
00143   virtual Vector<SynthesisParamsSelect> tuneSelectData();
00144 
00145   //Defining componentlist to use while degriding
00146   //This should be called once...if multiple lists are used..they can be merged in one
00147   //if sdgrid=True then image plane degridding is done
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   //the following get rid of the mappers in this object
00167   void resetMappers();
00168 
00169   CountedPtr<SIImageStore> imageStore(const Int id=0);
00170 
00171   //Record getMajorCycleControls();
00172   void executeMajorCycle(Record& controls);
00173 
00174   // make the psf images  i.e grid weight rather than data
00175   void makePSF();
00176 
00177 
00178   virtual Bool makePB();
00179   
00180   virtual void predictModel();
00181   //  void makeImage();
00182   /* Access method to the Loop Controller held in this class */
00183   //SIIterBot& getLoopControls();
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   // Choose between different types of FTMs
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   // Choose between different types of ImageStore types (single term, multiterm, faceted)
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   // Choose between different types of Mappers (single term, multiterm, imagemosaic, faceted)
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   // void setPsfFromOneFacet();
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   // Get VP record
00287   void getVPRecord(Record &rec, PBMath::CommonPB &kpb, String telescop);
00288 
00289   // Do the major cycle
00290   virtual void runMajorCycle(const Bool dopsf=False, const Bool savemodel=False);
00291 
00292   // Version of major cycle code with mappers in a loop outside vi/vb.
00293   virtual void runMajorCycle2(const Bool dopsf=False, const Bool savemodel=False);
00294 
00299   //  void appendToMapperList(String imagename, CoordinateSystem& csys, String ftmachine,
00300   //                      Quantity distance=Quantity(0.0, "m"), Int facets=1, const Bool overwrite=False);
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   // Data Selection
00343   Vector<SynthesisParamsSelect> dataSel_p;
00344   // Image Definition
00345   // Imaging/Gridding
00346 
00348   Block<const MeasurementSet *> mss_p;
00349   vi::FrequencySelections fselections_p;
00350   CountedPtr<vi::VisibilityIterator2>  vi_p;
00351 
00352   // Other Options
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   //the 'channel flags' to handle various channel selections in the spw parameter
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   //  Bool freqFrameValid_p;
00376 
00377   FTMachine::Type datacol_p;
00378 
00379   Int nMajorCycles;
00380 
00381 };
00382 
00383 
00384 } //# NAMESPACE CASA - END
00385 
00386 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1