MomentFit.h

Go to the documentation of this file.
00001 //# MomentFit.h:
00002 //# Copyright (C) 1997,1999,2000,2001,2002
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 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: MomentCalculator.h 20299 2008-04-03 05:56:44Z gervandiepen $
00027 
00028 #ifndef IMAGEANALYSIS_MOMENTFIT_H
00029 #define IMAGEANALYSIS_MOMENTFIT_H
00030 
00031 #include <casa/aips.h>
00032 #include <coordinates/Coordinates/CoordinateSystem.h>
00033 #include <coordinates/Coordinates/SpectralCoordinate.h>
00034 #include <lattices/LatticeMath/LineCollapser.h>
00035 #include <scimath/Functionals/Gaussian1D.h>
00036 #include <scimath/Mathematics/NumericTraits.h>
00037 #include <casa/Arrays/Vector.h>
00038 #include <casa/Logging/LogIO.h>
00039 
00040 namespace casa {
00041 
00042 template <class T> class MomentsBase;
00043 
00044 // <summary> Compute moments from a Gaussian fitted to a profile</summary>
00045 // <use visibility=export>
00046 // 
00047 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00048 // </reviewed>
00049 // 
00050 // <prerequisite>
00051 //   <li> <linkto class="MomentsBase">MomentsBase</linkto>
00052 //   <li> <linkto class="ImageMoments">ImageMoments</linkto>
00053 //   <li> <linkto class="MSMoments">MSMoments</linkto>
00054 //   <li> <linkto class="LatticeApply">LatticeApply</linkto>
00055 //   <li> <linkto class="MomentCalcBase">MomentCalcBase</linkto>
00056 //   <li> <linkto class="LineCollapser">LineCollapser</linkto>
00057 // </prerequisite>
00058 //
00059 // <synopsis>
00060 //  This concrete class is derived from the abstract base class MomentCalcBase
00061 //  which provides an interface layer to the ImageMoments or MSMoments driver class.  
00062 //  ImageMoments or MSMoments creates a MomentFit object and passes it to the LatticeApply
00063 //  function, lineMultiApply. This function iterates through a given lattice,
00064 //  and invokes the <src>multiProcess</src> member function of MomentFit on each vector
00065 //  of pixels that it extracts from the input lattice.  The <src>multiProcess</src>
00066 //  function returns a vector of moments which are inserted into the output
00067 //  lattices also supplied to the LatticeApply function.
00068 // 
00069 //  MomentFit computes moments by fitting a Gaussian to each profile.  The
00070 //  moments are then computed from that fit.   The fitting can be done either
00071 //  interactively or automatically.
00072 // 
00073 //  The constructor takes MomentsBase object that is actually an ImageMoments or 
00074 //  an MSMoments object; the one that is constructing
00075 //  the MomentFit object of course.   There is much control information embodied
00076 //  in the state of the ImageMoments object.  This information is extracted by the
00077 //  MomentCalcBase class and passed on to MomentFit for consumption.
00078 //   
00079 //  See the <linkto class="MomentsBase">MomentsBase</linkto>, 
00080 //  <linkto class="ImageMoments">ImageMoments</linkto>, and 
00081 //  <linkto class="MSMoments">MSMoments</linkto>
00082 //  for discussion about the moments that are available for computation.
00083 //  
00084 // </synopsis>
00085 //
00086 // <example>
00087 // This example comes from ImageMoments.   outPt is a pointer block holding
00088 // pointers to the output lattices.   os_P is a LogIO object.
00089 //                                     
00090 // <srcBlock>
00091 // 
00094 //
00095 //   MomentCalcBase<T>* pMomentCalculator = 0;
00096 //   if (clipMethod || smoothClipMethod) {
00097 //      pMomentCalculator = new MomentClip<T>(pSmoothedImage, *this, os_p, outPt.nelements());
00098 //   } else if (windowMethod) {
00099 //      pMomentCalculator = new MomentWindow<T>(pSmoothedImage, *this, os_p, outPt.nelements());
00100 //   } else if (fitMethod) {
00101 //      pMomentCalculator = new MomentFit<T>(*this, os_p, outPt.nelements());
00102 //   }
00103 //
00105 //
00106 //   LatticeApply<T>::lineMultiApply(outPt, *pInImage_p, *pMomentCalculator,   
00107 //                                   momentAxis_p, pProgressMeter);
00108 //   delete pMomentCalculator;
00109 // </srcBlock>
00110 // </example>
00111 //
00112 // <motivation>
00113 // </motivation>
00114 //
00115 // <note role=tip>
00116 // Note that there are is assignment operator or copy constructor.
00117 // Do not use the ones the system would generate either.
00118 // </note>
00119 //
00120 // <todo asof="yyyy/mm/dd">
00121 // </todo>
00122 
00123 template <class T> class MomentFit : public MomentCalcBase<T>
00124 {
00125 public:
00126 
00127 // Constructor.  We need the ImageMoments or MSMoments object which is calling us, 
00128 // its logger, and the number of output lattices it has created.
00129    MomentFit(MomentsBase<T>& iMom,
00130              LogIO& os,
00131              const uInt nLatticeOut);
00132 
00133 // Destructor (does nothing).
00134   virtual ~MomentFit();
00135 
00136 // This function is not implemented and throws an exception.
00137    virtual void process(T& out,
00138                         Bool& outMask,
00139                         const Vector<T>& in,
00140                         const Vector<Bool>& inMask,
00141                         const IPosition& pos);
00142 
00143 // This function returns a vector of numbers from each input vector.
00144 // the output vector contains the moments known to the ImageMoments
00145 // or MSMoments object passed into the constructor.
00146    virtual void multiProcess(Vector<T>& out,
00147                              Vector<Bool>& outMask,
00148                              const Vector<T>& in,
00149                              const Vector<Bool>& inMask,
00150                              const IPosition& pos);
00151 
00152 private:
00153    MomentsBase<T>& iMom_p;
00154    LogIO os_p;
00155    T stdDeviation_p, peakSNR_p;
00156    Bool doFit_p;
00157    Gaussian1D<T> gauss_p;
00158 
00159   //# Make members of parent class known.
00160 protected:
00161   using MomentCalcBase<T>::constructorCheck;
00162   using MomentCalcBase<T>::setPosLabel;
00163   using MomentCalcBase<T>::selectMoments_p;
00164   using MomentCalcBase<T>::calcMoments_p;
00165   using MomentCalcBase<T>::calcMomentsMask_p;
00166   using MomentCalcBase<T>::doMedianI_p;
00167   using MomentCalcBase<T>::doMedianV_p;
00168   using MomentCalcBase<T>::doAbsDev_p;
00169   using MomentCalcBase<T>::cSys_p;
00170   using MomentCalcBase<T>::doCoordProfile_p;
00171   using MomentCalcBase<T>::doCoordRandom_p;
00172   using MomentCalcBase<T>::pixelIn_p;
00173   using MomentCalcBase<T>::worldOut_p;
00174   using MomentCalcBase<T>::sepWorldCoord_p;
00175   using MomentCalcBase<T>::integratedScaleFactor_p;
00176   using MomentCalcBase<T>::momAxisType_p;
00177   using MomentCalcBase<T>::nFailed_p;
00178   using MomentCalcBase<T>::abcissa_p;
00179 };
00180 
00181 }
00182 
00183 #ifndef CASACORE_NO_AUTO_TEMPLATES
00184 #include <imageanalysis/ImageAnalysis/MomentFit.tcc>
00185 #endif
00186 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1