casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
LELSpectralIndex.h
Go to the documentation of this file.
00001 //# LELSpectralIndex.h: LEL function to calculate spectral index/
00002 //# Copyright (C) 2001
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: LELSpectralIndex.h 20229 2008-01-29 15:19:06Z gervandiepen $
00027 
00028 #ifndef LATTICES_LELSPECTRALINDEX_H
00029 #define LATTICES_LELSPECTRALINDEX_H
00030 
00031 
00032 //# Includes
00033 #include <lattices/Lattices/LELFunction.h>
00034 #include <casa/Containers/Block.h>
00035 
00036 namespace casa { //# NAMESPACE CASA - BEGIN
00037 
00038 //# Forward Declarations
00039 
00040 
00041 // <summary>
00042 // This LEL class handles calculation of the spectral index.
00043 // </summary>
00044 
00045 // <use visibility=local>
00046 
00047 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00048 // </reviewed>
00049 
00050 // <prerequisite>
00051 //   <li> <linkto class="Lattice"> Lattice</linkto>
00052 //   <li> <linkto class="LatticeExpr"> LatticeExpr</linkto>
00053 //   <li> <linkto class="LatticeExprNode"> LatticeExprNode</linkto>
00054 //   <li> <linkto class="LELInterface"> LELInterface</linkto>
00055 //   <li> <linkto class="LELFunctionEnums"> LELFunctionEnums</linkto>
00056 // </prerequisite>
00057 
00058 // <synopsis>
00059 // This LEL letter class is derived from LELInterface. It is used to
00060 // construct LEL objects that calculate the sepectral index from 2 other
00061 // LEL expression (usually images).
00062 // It operates on real types (Float,Double) 
00063 // </synopsis> 
00064 
00065 // <motivation>
00066 // This is a separate class (instead of being part of a LELFunction class),
00067 // because the calculation of the spectral index requires extra variables
00068 // (the frequencies) and some more complicated code.
00069 // </motivation>
00070 
00071 template<class T> class LELSpectralIndex : public LELInterface<T>
00072 {
00073   //# Make members of parent class known.
00074 protected:
00075   using LELInterface<T>::setAttr;
00076 
00077 public: 
00078   // Constructor takes operation and expressions to be operated upon
00079   LELSpectralIndex (const Block<LatticeExprNode>& expr);
00080 
00081   // Destructor 
00082   ~LELSpectralIndex();
00083 
00084   // Recursively evaluate the expression 
00085   virtual void eval (LELArray<T>& result,
00086                      const Slicer& section) const;
00087 
00088   // Get the result of a scalar subexpression.
00089   // Throws an exception as it is not possible.
00090    virtual LELScalar<T> getScalar() const;
00091 
00092   // Do further preparations (e.g. optimization) on the expression.
00093   // Returns False.
00094    virtual Bool prepareScalarExpr();
00095 
00096   // Get class name
00097   virtual String className() const;
00098 
00099   // Handle locking/syncing of a lattice in a lattice expression.
00100   // <group>
00101   virtual Bool lock (FileLocker::LockType, uInt nattempts);
00102   virtual void unlock();
00103   virtual Bool hasLock (FileLocker::LockType) const;
00104   virtual void resync();
00105   // </group>
00106 
00107 private:
00108   Int itsFreqAxis;
00109   Block<Double> itsLogFreq;       //# log(f0/f1)
00110   LatticeExprNode arg0_p;
00111   LatticeExprNode arg1_p;
00112 };
00113 
00114 
00115 
00116 } //# NAMESPACE CASA - END
00117 
00118 #ifndef CASACORE_NO_AUTO_TEMPLATES
00119 #include <lattices/Lattices/LELSpectralIndex.tcc>
00120 #endif //# CASACORE_NO_AUTO_TEMPLATES
00121 #endif