LCOV - code coverage report
Current view: top level - synthesis/MeasurementComponents - SkyModel.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 1 6 16.7 %
Date: 2024-10-12 00:35:29 Functions: 1 6 16.7 %

          Line data    Source code
       1             : //# SkyModel.h: Definition for SkyModel
       2             : //# Copyright (C) 1996,1997,1998,1999,2000,2002
       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 adressed 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             : //#                        Charlottesville, VA 22903-2475 USA
      25             : //#
      26             : //#
      27             : //# $Id$
      28             : 
      29             : #ifndef SYNTHESIS_SKYMODEL_H
      30             : #define SYNTHESIS_SKYMODEL_H
      31             : 
      32             : #include <casacore/casa/aips.h>
      33             : #include <synthesis/MeasurementEquations/Iterate.h>
      34             : #include <synthesis/TransformMachines/StokesImageUtil.h>
      35             : #include <casacore/images/Images/ImageInterface.h>
      36             : #include <components/ComponentModels/ComponentList.h>
      37             : #include <casacore/casa/BasicSL/String.h>
      38             : 
      39             : namespace casa { //# NAMESPACE CASA - BEGIN
      40             : 
      41             : //forward declarations
      42             : class SkyEquation;
      43             : 
      44             : // <summary> 
      45             : // Sky Model: Model the Sky Brightness for the SkyEquation
      46             : // </summary>
      47             : 
      48             : // <use visibility=export>
      49             : 
      50             : // <reviewed reviewer="" date="" tests="" demos="">
      51             : 
      52             : // <prerequisite>
      53             : //   <li> casacore::Matrix module
      54             : //   <li> casacore::Vector module
      55             : //   <li> MeasurementComponents module
      56             : //   <li> VisSet module
      57             : // </prerequisite>
      58             : //
      59             : // <etymology>
      60             : // SkyModel describes an interface for Models to be used in
      61             : // the SkyEquation. It is an Abstract Base Class: most methods
      62             : // must be defined in derived classes.
      63             : // </etymology>
      64             : //
      65             : // <synopsis> 
      66             : // A SkyModel contains a number of separate models. The interface to
      67             : // SkyEquation is via an image per model. SkyEquation uses this image to
      68             : // calculate Fourier transforms, etc. Some (most) SkyModels are
      69             : // solvable: the SkyEquation can be used by the SkyModel to return
      70             : // gradients with respect to itself (via the image interface). Thus
      71             : // for a SkyModel to solve for itself, it calls the SkyEquation
      72             : // methods to get gradients of chi-squared with respect to the
      73             : // image pixel values (thus returning an image: basically a residual
      74             : // image). The SkyModel then uses these gradients as appropriate to
      75             : // update itself.
      76             : //
      77             : // The following examples illustrate how a SkyModel can  be
      78             : // used:
      79             : // <ul>
      80             : // <li> Simple cleaning: one model. The gradient gives the
      81             : // residual image. A special method gives a PSF.
      82             : // <li> Cleaning with visibility-based subtraction: one model. The
      83             : // gradient can be calculated as needed (using the SkyEquation)
      84             : // to produce the correct residual image.
      85             : // <li> Wide-field imaging: one model per patch of the sky
      86             : // that is to be imaged.
      87             : // <li> Non-coplanar baselines imaging: one model per facet of
      88             : // the polyhedron. At the end of processing all facets are combined
      89             : // into one overall image.
      90             : // <li> Mosaicing: one model per primary beam pointing. Each model
      91             : // is derived (as needed) by cutting out a patch from the full-field
      92             : // mosaic.
      93             : // </ul>
      94             : // </synopsis> 
      95             : //
      96             : // <example>
      97             : // <srcblock>
      98             : //      // Read the VisSet from disk
      99             : //      VisSet vs("3c84.MS");
     100             : //
     101             : //      // Create an ImageSkyModel from an image on disk
     102             : //      ImageSkyModel ism(casacore::PagedImage<casacore::Float>("3c84.modelImage"));
     103             : //
     104             : //      // Make an FTMachine: here we use a simple Grid and FT.
     105             : //      GridFT ft;
     106             : //
     107             : //      SkyEquation se(ism, vs, ft);
     108             : //
     109             : //      // Predict the visibility set
     110             : //      se.predict();
     111             : //
     112             : //      // Make a Clean Image and write it out
     113             : //      HogbomCleanImageSkyModel csm(ism);
     114             : //      if (csm.solve()) {
     115             : //        casacore::PagedImage<casacore::Float> cleanImage=csm.image(0);
     116             : //        cleanImage.setName("3c84.cleanImage");
     117             : //      }
     118             : //
     119             : // </srcblock>
     120             : // </example>
     121             : //
     122             : // <motivation>
     123             : // The properties of a model of the sky must be described
     124             : // for the SkyEquation.
     125             : // </motivation>
     126             : //
     127             : // <todo asof="97/10/01">
     128             : // <li> Multiple images in SkyModel
     129             : // <li> ComponentModel
     130             : // </todo>
     131             : 
     132             : class SkyModel : public Iterate {
     133             : 
     134             : public:
     135             :   
     136             :   enum PolRep {
     137             :     CIRCULAR=StokesImageUtil::CIRCULAR,
     138             :     LINEAR=StokesImageUtil::LINEAR
     139             :   };
     140             : 
     141          37 :   SkyModel() : itsAlgorithm(""), itsSubAlgorithm(""), imageRegion_p(0), isImageNormalized_p(false) { }  
     142             : 
     143             :   // Number of models contained
     144             :   virtual casacore::Int numberOfModels() = 0;
     145             : 
     146             :   // MFS : Number of taylor terms per model
     147             :   virtual casacore::Int numberOfTaylorTerms() = 0;
     148             : 
     149             :   // MFS : Reference Frequency
     150             :   virtual casacore::Double getReferenceFrequency() = 0;
     151             : 
     152             :   // MFS : Index of Taylor term in array of nmodels x ntaylorterms
     153             :   virtual casacore::Int getTaylorIndex(casacore::Int index=0) = 0;
     154             : 
     155             :   // Is this SkyModel solveable?
     156             :   virtual casacore::Bool isSolveable(casacore::Int model=0) = 0;
     157             : 
     158             :   // Is there a flux scale image associated with this model?
     159             :   virtual casacore::Bool doFluxScale(casacore::Int model=0) = 0;
     160             : 
     161             :   // Initialize for gradient search
     162             :   virtual void initializeGradients() = 0;
     163             : 
     164             :   // Finalize for gradient search
     165             :   virtual void finalizeGradients() = 0;
     166             : 
     167             :   // Return the component list
     168             :   virtual ComponentList& componentList() = 0;
     169             : 
     170             :   // Return the component list
     171             :   virtual casacore::Bool hasComponentList() = 0;
     172             : 
     173             :   // Image interface for this model (casacore::Stokes representation)
     174             :   virtual casacore::ImageInterface<casacore::Float>& image(casacore::Int model=0) = 0;
     175             : 
     176             :   // Increment in the image
     177             :   virtual casacore::ImageInterface<casacore::Float>& deltaImage(casacore::Int model=0) = 0;
     178             : 
     179             :   // casacore::Complex image (needed for e.g. RR,RL,LR,LL)
     180             :   virtual casacore::ImageInterface<casacore::Complex>& cImage(casacore::Int model=0) = 0;
     181             : 
     182             :   // casacore::Complex XFR
     183             :   virtual casacore::ImageInterface<casacore::Complex>& XFR(casacore::Int model=0, casacore::Int numXFR=0) = 0;
     184             :   virtual casacore::Bool hasXFR(casacore::Int model=0) = 0;
     185             : 
     186             :   // PSF 
     187             :   virtual casacore::ImageInterface<casacore::Float>& PSF(casacore::Int model=0) = 0;
     188             : 
     189             :   // Gradient of chi-squared wrt pixels
     190             :   virtual casacore::ImageInterface<casacore::Float>& gS(casacore::Int model=0) = 0;
     191             : 
     192             :   // Grad Grad chi-squared wrt pixels (diagonal elements only)
     193             :   virtual casacore::ImageInterface<casacore::Float>& ggS(casacore::Int model=0) = 0;
     194             : 
     195             :   // FluxScale image:   image * fluxScale => true brightness distribution
     196             :   virtual casacore::ImageInterface<casacore::Float>& fluxScale(casacore::Int model=0) = 0;
     197             :   
     198             :   // Work image
     199             :   virtual casacore::ImageInterface<casacore::Float>& work(casacore::Int model=0) = 0;
     200             : 
     201             :   // Add to Sum weights, Chi-Squared
     202             :   virtual void addStatistics(casacore::Float sumwt, casacore::Float chisq) = 0;
     203             : 
     204             :   // Weight per model (channels, polarizations)
     205             :   virtual casacore::Matrix<casacore::Float>& weight(casacore::Int model=0) = 0;
     206             : 
     207             :   // Solve for this SkyModel
     208             :   virtual casacore::Bool solve (SkyEquation& se) = 0;
     209             : 
     210             :   // Is this model empty
     211             :   virtual casacore::Bool isEmpty(casacore::Int model=0) = 0;
     212             : 
     213             :   virtual casacore::Int getModelIndex(casacore::uInt field=0, casacore::uInt taylor=0) = 0;
     214             : 
     215             :   //set Algorithm (e.g clean, mem, nnls)
     216           0 :   void setAlgorithm(const casacore::String& alg) {itsAlgorithm = alg;}
     217             :     
     218             :   // get  Algorithm
     219           0 :   const casacore::String getAlgorithm() { return itsAlgorithm; }
     220             : 
     221             :   // set Sub Algorithm
     222           0 :   void setSubAlgorithm(const casacore::String& alg) { itsSubAlgorithm = alg; }
     223             : 
     224             :   // get Sub Algorithm
     225             :   const casacore::String getSubAlgorithm() { return itsSubAlgorithm; }
     226             : 
     227             :   // Set the imageregion that will be used for the next XFR generation
     228             :   // <group>
     229             :   void setImageRegion( casacore::ImageRegion& ir ) { imageRegion_p = &ir; }
     230             :   // use the default shape
     231             :   void unsetImageRegion() { imageRegion_p = 0; }
     232             :   // </group>
     233             : 
     234           0 :   void setImageNormalization(casacore::Bool val) {isImageNormalized_p = val;};
     235           0 :   casacore::Bool isImageNormalized() {return isImageNormalized_p;};
     236             : 
     237             :   //set and get memory usage model
     238             :   virtual void setMemoryUse(casacore::Bool memuse)=0;
     239             :   virtual casacore::Bool getMemoryUse()=0;
     240             :   
     241             : protected:
     242             :   casacore::String itsAlgorithm;
     243             :   casacore::String itsSubAlgorithm;
     244             :   // this casacore::ImageRegion is used to suggest the shape for the
     245             :   // XFR.  If null, then just use the shape of image(model)
     246             :   casacore::ImageRegion *imageRegion_p;
     247             :   casacore::Bool isImageNormalized_p;
     248             : 
     249             : private:
     250             : };
     251             : 
     252             : 
     253             : } //# NAMESPACE CASA - END
     254             : 
     255             : #endif

Generated by: LCOV version 1.16