casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
LatticeTwoPtCorr.h
Go to the documentation of this file.
00001 //# LatticeTwoPtCorr.h: compute two-point correlation functions from a lattice
00002 //# Copyright (C) 1997,1998,1999,2000,2001,2003
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 //#
00027 //# $Id: LatticeTwoPtCorr.h 20652 2009-07-06 05:04:32Z Malte.Marquarding $
00028 
00029 #ifndef LATTICES_LATTICETWOPTCORR_H
00030 #define LATTICES_LATTICETWOPTCORR_H
00031 
00032 //# Includes
00033 #include <casa/aips.h>
00034 
00035 
00036 namespace casa { //# NAMESPACE CASA - BEGIN
00037 
00038 //# Forward Declarations
00039 
00040 template <class T> class MaskedLattice;
00041 template <class T> class Lattice;
00042 class IPosition;
00043 class LogIO;
00044 class String;
00045 
00046 // <summary>
00047 // Compute two point auto-correlation functions from a lattice
00048 // </summary>
00049 
00050 // <use visibility=export>
00051 
00052 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00053 // </reviewed>
00054 
00055 // <prerequisite>
00056 //   <li> <linkto class="MaskedLattice">MaskedLattice</linkto>
00057 // </prerequisite>
00058 
00059 // <synopsis>
00060 // This class allows you to compute two point correlation functions
00061 // from lattices over planes of the specified two axes.
00062 // At present, only autocorrelation is implemented and only
00063 // the structure function is available.
00064 //
00065 // The structure function is
00066 // <src>S(x,y) = < [lat(i,j) - lat(i+x,j+y)]**2 ></src>
00067 // where x and y are absolute integer shifts (or lags).
00068 // </synopsis>
00069 // <example>
00070 // <srcblock>
00071 // </srcblock>
00072 // </example>
00073 
00074 
00075 // <todo asof="yyyy/mm/dd">
00076 // <li> Add additional algorithms other than the structure function
00077 // <li> Allow cross correlation algorithms as well as autocorrelation
00078 // </todo>
00079 
00080 
00081 template <class T> class LatticeTwoPtCorr
00082 {
00083 public:
00084 
00085 enum Method {
00086 
00087 // Undefined
00088    UNDEFINED,
00089 
00090 // Structure Function
00091    STRUCTUREFUNCTION,
00092 
00093 // nMethods
00094    NMETHODS
00095 };
00096 
00097 
00098 // Default constructor
00099    LatticeTwoPtCorr()
00100    {}
00101 
00102 // Destructor
00103    ~LatticeTwoPtCorr()
00104    {}
00105 
00106 // Compute specified autocorrelation function for the planes of the given TWO axes.
00107 // If the output lattice has a mask, it will first be set to False (bad)
00108 // and then any output pixel with some contributing values will be set to
00109 // True (good).
00110 // <group>
00111    void autoCorrelation (MaskedLattice<T>& out, const MaskedLattice<T>& in,
00112                          const IPosition& axes, Method method,
00113                          Bool showProgress=True) const;
00114 // </group>
00115 
00116 // Helper function to provide output lattice shape give the input shape
00117 // and the axes to find the structure function over.
00118    static IPosition setUpShape (const IPosition& inShape, const IPosition& axes);
00119 
00120 // Helper functions to convert method types to and from strings
00121 // <group>
00122    static Method fromString (const String& method);
00123    static String toString (Method method);
00124 // </group>
00125 
00126 private:
00127 // Function Pointer typedef
00128    typedef T (LatticeTwoPtCorr<T>::*FuncPtr)(T d1, T d2) const;
00129 
00130 // Do the iteration work 
00131    void autoCorrelation (MaskedLattice<T>& out, const MaskedLattice<T>& in,
00132                          const IPosition& axes, 
00133                          FuncPtr,                
00134                          Bool showProgress) const;
00135 
00136 // Check Output lattice shape
00137    void check (LogIO& os, const MaskedLattice<T>& latOut,
00138                const MaskedLattice<T>& latIn,
00139                const IPosition& axes) const;
00140 
00141 // Compute structure function
00142    T structureFunction (T d1, T d2) const {return ((d1 - d2)*(d1-d2));};
00143 };
00144 
00145 
00146 } //# NAMESPACE CASA - END
00147 
00148 #ifndef CASACORE_NO_AUTO_TEMPLATES
00149 #include <lattices/Lattices/LatticeTwoPtCorr.tcc>
00150 #endif //# CASACORE_NO_AUTO_TEMPLATES
00151 #endif