LCOV - code coverage report
Current view: top level - synthesis/ImagerObjects - SynthesisImagerVi2.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 5 0.0 %
Date: 2024-10-10 11:40:37 Functions: 0 0 -

          Line data    Source code
       1             : //# SynthesisImagerVi2.h: Imager functionality sits here; 
       2             : //# Copyright (C) 2016
       3             : //# Associated Universities, Inc. Washington DC, USA.
       4             : //#
       5             : //# This library is free software; you can redistribute it and/or modify it
       6             : //# under the terms of the GNU Library General Public License as published by
       7             : //# the Free Software Foundation; either version 2 of the License, or (at your
       8             : //# option) any later version.
       9             : //#
      10             : //# This library is distributed in the hope that it will be useful, but WITHOUT
      11             : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      12             : //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
      13             : //# License for more details.
      14             : //#
      15             : //# You should have received a copy of the GNU Library General Public License
      16             : //# along with this library; if not, write to the Free Software Foundation,
      17             : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
      18             : //#
      19             : //# Correspondence concerning AIPS++ should be addressed as follows:
      20             : //#        Internet email: casa-feedback@nrao.edu.
      21             : //#        Postal address: AIPS++ Project Office
      22             : //#                        National Radio Astronomy Observatory
      23             : //#                        520 Edgemont Road
      24             : //#
      25             : //# $Id$
      26             : #ifndef SYNTHESIS_SYNTHESISIMAGERVI2_H
      27             : #define SYNTHESIS_SYNTHESISIMAGERVI2_H
      28             : 
      29             : #include <synthesis/ImagerObjects/SynthesisImager.h>
      30             : #include <synthesis/TransformMachines2/FTMachine.h>
      31             : #include <msvis/MSVis/ViFrequencySelection.h>
      32             : #include <msvis/MSVis/VisibilityIterator2.h>
      33             : #include <msvis/MSVis/VisBuffer2.h>
      34             : 
      35             : namespace casacore{
      36             : 
      37             : class MeasurementSet;
      38             : template<class T> class ImageInterface;
      39             : }
      40             : 
      41             : namespace casa { //# NAMESPACE CASA - BEGIN
      42             : class VisImagingWeight;
      43             :  class SynthesisImagerVi2  : public SynthesisImager
      44             : {
      45             : 
      46             : public:
      47             :   // Default constructor
      48             : 
      49             :   SynthesisImagerVi2();
      50             :   virtual ~SynthesisImagerVi2();
      51             :   using SynthesisImager::selectData;
      52             :   virtual casacore::Bool selectData(const SynthesisParamsSelect& selpars);
      53             :   virtual casacore::Bool defineImage(SynthesisParamsImage& impars, const SynthesisParamsGrid& gridpars);
      54             :   virtual casacore::Vector<SynthesisParamsSelect> tuneSelectData();
      55             :   virtual casacore::Bool defineImage(casacore::CountedPtr<SIImageStore> imstor, const casacore::String& ftmachine);
      56             :   //Define image via a predefined SIImageStore object and ftmachines
      57             :   virtual casacore::Bool defineImage(casacore::CountedPtr<SIImageStore> imstor, 
      58             :                                      const casacore::Record& ftmachine, const casacore::Record& invftmachine);
      59             :   //This version is for premade imstor but passing extra parameters that may be needed to 
      60             :   //make facets 
      61             :   virtual casacore::Bool defineImage(casacore::CountedPtr<SIImageStore> imstor, 
      62             :                                      SynthesisParamsImage& impars, const SynthesisParamsGrid& gridpars);
      63             :   virtual casacore::Bool weight(const casacore::String& type="natural", 
      64             :               const casacore::String& rmode="norm",
      65           0 :               const casacore::Quantity& noise=casacore::Quantity(0.0, "Jy"), 
      66             :               const casacore::Double robust=0.0,
      67           0 :               const casacore::Quantity& fieldofview=casacore::Quantity(0.0, "arcsec"),
      68             :               const casacore::Int npixels=0, 
      69             :               const casacore::Bool multiField=false,
      70             :               const casacore::Bool useCubeBriggs=false,
      71             :               const casacore::String& filtertype=casacore::String("Gaussian"),
      72           0 :               const casacore::Quantity& filterbmaj=casacore::Quantity(0.0,"deg"),
      73           0 :               const casacore::Quantity& filterbmin=casacore::Quantity(0.0,"deg"),
      74           0 :               const casacore::Quantity& filterbpa=casacore::Quantity(0.0,"deg"),
      75             :           casacore::Double fracBW=0.0);
      76             :   //set the weight from a Record generated from SynthesisUtils::fillWeightRecord
      77             :   virtual casacore::Bool weight(const Record& inrec);
      78             :   //set the weight density to the visibility iterator
      79             :   //the default is to set it from the imagestore griwt() image
      80             :   //Otherwise it will use this image passed here; useful for parallelization to
      81             :   //share one grid to all children process
      82             :   casacore::Bool setWeightDensity(const casacore::String& imagename=casacore::String(""));
      83             :   
      84             :   void predictModel();
      85             :   //make primary beam for standard gridder
      86             :   bool makePB();
      87             :   virtual void makeSdImage(casacore::Bool dopsf=false);
      88             :   ///This should replace makeSDImage and makePSF etc in the long run
      89             :   ///But for now you can do the following images i.e string recognized by type
      90             :   ///"observed", "model", "corrected", "psf", "residual", "singledish-observed", 
      91             :   ///"singledish", "coverage", "holography", "holography-observed"
      92             :   ///For holography the FTmachine should be SDGrid and the baselines
      93             :   //selected should be those that are pointed up with the antenna which is rastering.
      94             :   virtual void makeImage(casacore::String type, const casacore::String& imagename, const casacore::String& complexImage=casacore::String(""), const Int whichModel=0);
      95             : 
      96             :   void dryGridding(const casacore::Vector<casacore::String>& cfList);
      97             :   void fillCFCache(const casacore::Vector<casacore::String>& cfList,
      98             :                    const casacore::String& ftmName,
      99             :                    const casacore::String& cfcPath,
     100             :                    const casacore::Bool& psTermOn,
     101             :                    const casacore::Bool& aTermOn,
     102             :                    const casacore::Bool& conjBeams);
     103             :   void reloadCFCache();
     104             :   ///load the weightimage in the A projection FT machines if it has already been done
     105             :   //this can be called only after defineimage
     106             :   bool loadMosaicSensitivity();
     107             :   ///
     108             :   bool makeMosaicSensitivity();
     109             :   //Some access methods
     110             :   casacore::CountedPtr<vi::VisibilityIterator2> getVi();
     111             :   casacore::CountedPtr<refim::FTMachine> getFTM(const casacore::Int whichfield=0,
     112             :                                                                                                 casacore::Bool ift=true);
     113             : 
     114             :  protected:
     115             :   virtual void makeComplexCubeImage(const casacore::String& cimage, const refim::FTMachine::Type imtype, const Int whichModel=0);
     116             :   void appendToMapperList(casacore::String imagename, 
     117             :                           casacore::CoordinateSystem& csys, 
     118             :                           casacore::IPosition imshape,
     119             :                           casacore::CountedPtr<refim::FTMachine>& ftm,
     120             :                           casacore::CountedPtr<refim::FTMachine>& iftm,
     121             :                           casacore::Quantity distance=casacore::Quantity(0.0, "m"), 
     122             :                           casacore::Int facets=1, 
     123             :                           casacore::Int chanchunks=1,
     124             :                           const casacore::Bool overwrite=false,
     125             :                           casacore::String mappertype=casacore::String("default"),
     126             :                           casacore::Float padding=1.0,
     127             :                           casacore::uInt ntaylorterms=1,
     128             :                           const casacore::Vector<casacore::String> &startmodel=casacore::Vector<casacore::String>(0));
     129             :   virtual void unlockMSs();
     130             :   virtual void lockMSs();
     131             :   virtual void lockMS(MeasurementSet& ms);
     132             :   virtual void createVisSet(const casacore::Bool writeaccess=false);
     133             :   void createFTMachine(casacore::CountedPtr<casa::refim::FTMachine>& theFT, 
     134             :           casacore::CountedPtr<casa::refim::FTMachine>& theIFT,
     135             :           const casacore::String& ftname,
     136             :           const casacore::uInt nTaylorTerms=1,
     137             :           const casacore::String mType="default",
     138             :           const casacore::Int facets=1,
     139             :           //------------------------------
     140             :           const casacore::Int wprojplane=1,
     141             :           const casacore::Float padding=1.0,
     142             :           const casacore::Bool useAutocorr=false,
     143             :           const casacore::Bool useDoublePrec=true,
     144             :           const casacore::String gridFunction=casacore::String("SF"),
     145             :           //------------------------------
     146             :           const casacore::Bool aTermOn    = true,
     147             :           const casacore::Bool psTermOn   = true,
     148             :           const casacore::Bool mTermOn    = false,
     149             :           const casacore::Bool wbAWP      = true,
     150             :           const casacore::String cfCache  = "",
     151             :           const casacore::Bool usePointing = false,
     152             :           // const casacore::Vector<casacore::Float>
     153             :           //       pointingOffsetSigDev=std::vector<casacore::Float>({10,10}),
     154             :           const std::vector<float> pointingOffsetSigDev = {10,10},
     155             :           const casacore::Bool doPBCorr   = true,
     156             :           const casacore::Bool conjBeams  = true,
     157             :           const casacore::Float computePAStep   = 360.0,
     158             :           const casacore::Float rotatePAStep    = 5.0,
     159             :           const casacore::String interpolation = casacore::String("linear"),
     160             :           const casacore::Bool freqFrameValid = true,
     161             :           const casacore::Int cache=1000000000,
     162             :           const casacore::Int tile=16,
     163             :           const casacore::String stokes="I",
     164             :           const casacore::String imageNamePrefix="",
     165             :           const casacore::String &pointingDirCol=casacore::String("direction"),
     166             :           const casacore::String &convertFirst=casacore::String("never"),
     167             :           const casacore::Float skyPosThreshold=0.0,
     168             :           const casacore::Int convSupport=-1,
     169             :           const casacore::Quantity &truncateSize=casacore::Quantity(-1),
     170             :           const casacore::Quantity &gwidth=casacore::Quantity(-1),
     171             :           const casacore::Quantity &jwidth=casacore::Quantity(-1),
     172             :           const casacore::Float minWeight=0.1,
     173             :           const casacore::Bool clipMinMax=false,
     174             :           const casacore::Bool pseudoI=false);
     175             : 
     176             :   void createAWPFTMachine(casacore::CountedPtr<refim::FTMachine>& theFT, casacore::CountedPtr<refim::FTMachine>& theIFT, 
     177             :                           const casacore::String& ftmName,
     178             :                           const casacore::Int facets,          
     179             :                           //----------------------------
     180             :                           const casacore::Int wprojPlane,     
     181             :                           const casacore::Float padding,      
     182             :                           const casacore::Bool useAutocorr,   
     183             :                           const casacore::Bool useDoublePrec, 
     184             :                           const casacore::String gridFunction,
     185             :                           //---------------------------
     186             :                           const casacore::Bool aTermOn,      
     187             :                           const casacore::Bool psTermOn,     
     188             :                           const casacore::Bool mTermOn,      
     189             :                           const casacore::Bool wbAWP,        
     190             :                           const casacore::String cfCache,    
     191             :                           const casacore::Bool usePointing,
     192             :                           /* const casacore::Vector<casacore::Float> pointingOffsetSigDev, */
     193             :                           const vector<float> pointingOffsetSigDev,
     194             :                           const casacore::Bool doPBCorr,     
     195             :                           const casacore::Bool conjBeams,    
     196             :                           const casacore::Float computePAStep,
     197             :                           const casacore::Float rotatePAStep, 
     198             :                           const casacore::Int cache,          
     199             :                           const casacore::Int tile,
     200             :                           const casacore::String imageNamePrefix="");
     201             : 
     202             :   void createSDFTMachine(casacore::CountedPtr<refim::FTMachine>& theFT,
     203             :       casacore::CountedPtr<refim::FTMachine>& theIFT,
     204             :       const casacore::String &pointingDirCol,
     205             :       const casacore::String &convertFirst,
     206             :       const casacore::Float skyPosThreshold,
     207             :       const casacore::Bool doPBCorr,
     208             :       const casacore::Float rotatePAStep,
     209             :       const casacore::String& gridFunction,
     210             :       const casacore::Int convSupport,
     211             :       const casacore::Quantity& truncateSize,
     212             :       const casacore::Quantity& gwidth,
     213             :       const casacore::Quantity& jwidth,
     214             :       const casacore::Float minWeight,
     215             :       const casacore::Bool clipMinMax,
     216             :       const casacore::Int cache,
     217             :       const casacore::Int tile,
     218             :       const casacore::String &stokes,
     219             :       const casacore::Bool pseudoI=false);
     220             :  
     221             : // Do the major cycle
     222             :   virtual void runMajorCycle(const casacore::Bool dopsf=false,  const casacore::Bool savemodel=false);
     223             :   //Version for cubes
     224             :   virtual void runMajorCycleCube(const casacore::Bool dopsf=false, const casacore::Record controlrec=casacore::Record());
     225             :   // Version of major cycle code with mappers in a loop outside vi/vb.
     226             :   virtual void runMajorCycle2(const casacore::Bool dopsf=false, const casacore::Bool savemodel=false);
     227             :   
     228             :   virtual bool runCubeGridding(casacore::Bool dopsf=false, const casacore::Record controlrec=casacore::Record());
     229             :   
     230             :  
     231             :  void createMosFTMachine(casacore::CountedPtr<casa::refim::FTMachine>& theFT,
     232             :                          casacore::CountedPtr<casa::refim::FTMachine>&  theIFT,
     233             :                          const casacore::Float  padding,
     234             :                          const casacore::Bool useAutoCorr,
     235             :                          const casacore::Bool useDoublePrec,
     236             :                          const casacore::Float rotatePAStep,
     237             :                          const casacore::String Stokes="I", const casacore::Bool doConjBeam=false);
     238             :   casacore::CountedPtr<SIMapper> createSIMapper(casacore::String mappertype,  
     239             :                                       casacore::CountedPtr<SIImageStore> imagestore, //// make this inside !!!!!
     240             :                                       casacore::CountedPtr<refim::FTMachine> ftmachine,
     241             :                                       casacore::CountedPtr<refim::FTMachine> iftmachine,
     242             :                                       casacore::uInt ntaylorterms=1);
     243             : 
     244             :   // Calculate apparent sensitivity (for _Visibility_ spectrum)
     245             :   //  _Image_ spectral grid TBD
     246             :   virtual casacore::Record apparentSensitivity();
     247             : 
     248             :   
     249             :   bool makePrimaryBeam(PBMath& pbMath);
     250             :   void  andFreqSelection(const casacore::Int msId, const casacore::Int spwId,  const casacore::Double freqBeg, const casacore::Double freqEnd, const casacore::MFrequency::Types frame);
     251             :   void andChanSelection(const casacore::Int msId, const casacore::Int spwId, const casacore::Int startchan, const casacore::Int endchan);
     252             :   void tuneChunk(const casacore::Int gmap);
     253             :   //Set up tracking direction ; return False if no tracking is set.
     254             :   //return Direction of moving source is in the frame of vb.phaseCenter() at the time of the first row of the vb ..or if useImageEpoch is set at the obsTime in the image header
     255             :   casacore::Bool getMovingDirection(const vi::VisBuffer2& vb,  casacore::MDirection& movingDir, const casacore::Bool useImageEpoch=false);
     256             : 
     257             :   std::tuple<TcleanProcessingInfo, casacore::Vector<casacore::Int>, casacore::Vector<casacore::Int> > nSubCubeFitInMemory(const casacore::Int fudge_factor, const casacore::IPosition& imshape, const casacore::Float padding=1.0);
     258             : 
     259             :   void updateImageBeamSet(casacore::Record& returnRec);
     260             : 
     261             :    // Other Options
     262             :   //casacore::Block<const casacore::MeasurementSet *> mss_p;
     263             :   casacore::CountedPtr<vi::VisibilityIterator2>  vi_p;
     264             :   casacore::CountedPtr<vi::FrequencySelections> fselections_p;
     265             :   std::vector<std::pair<casacore::Int, casacore::Double> >freqBegs_p;
     266             :   std::vector<std::pair<casacore::Int, casacore::Double> > freqEnds_p;
     267             :   std::vector<std::pair<casacore::Int, casacore::Double> > freqSpws_p;
     268             :   //map <msid, map<spwid, vector(nchan, start)> >
     269             :   std::map<casacore::Int, std::map<casacore::Int, casacore::Vector<casacore::Int> > >  channelSelections_p;
     270             :   //    ///temporary variable as we carry that for tunechunk
     271             :   casacore::MFrequency::Types selFreqFrame_p;
     272             :   casacore::Vector<SynthesisParamsImage> imparsVec_p;
     273             :   casacore::Vector<SynthesisParamsGrid> gridparsVec_p;
     274             :   casacore::Record weightParams_p;
     275             :   /// need this as writing imageinfo often seems to truncate psf size back to
     276             :   /// 0 and back to normal size...so do it only once
     277             :   casacore::ImageInfo cubePsfImageInfo_p;
     278             : };
     279             : } //# NAMESPACE CASA - END
     280             : 
     281             : #endif
     282             : 

Generated by: LCOV version 1.16