casa
$Rev:20696$
|
00001 //# SpectralCollapser.h: Header file for class SpectralCollapser 00002 //# Copyright (C) 1998,1999,2000,2001,2003 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This program is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU General Public License as published by the Free 00007 //# Software Foundation; either version 2 of the License, or (at your option) 00008 //# any later version. 00009 //# 00010 //# This program 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 General Public License for 00013 //# more details. 00014 //# 00015 //# You should have received a copy of the GNU General Public License along 00016 //# with this program; if not, write to the Free Software Foundation, Inc., 00017 //# 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: tSubImage.cc 20567 2009-04-09 23:12:39Z gervandiepen $ 00027 00028 #ifndef IMAGEANALYSIS_SPECTRALCOLLAPSER_H 00029 #define IMAGEANALYSIS_SPECTRALCOLLAPSER_H 00030 00031 #include <images/Images/ImageInterface.h> 00032 00033 #include <casa/namespace.h> 00034 00035 namespace casa { 00036 00037 template <class T> class SubImage; 00038 00039 class SpectralCollapser { 00040 // <summary> 00041 // Class to collapse an image along the spectral axis. 00042 // </summary> 00043 00044 // <reviewed reviewer="" date="" tests="" demos=""> 00045 // </reviewed> 00046 00047 // <prerequisite> 00048 // <li> <linkto class=ImageCollapser>ImageCollapser</linkto> 00049 // </prerequisite> 00050 00051 // <etymology> 00052 // Collapses an image along the spectral axis 00053 // </etymology> 00054 00055 // <synopsis> 00056 // Helper class to collapse an image along the spectral axis. The spectral 00057 // range to combine is provided interactively from the profiler. The class 00058 // transforms the range to the channels to be combined. The actual image\ 00059 // combination is then done with the class "ImageCollapser". 00060 // </synopsis> 00061 00062 public: 00063 // The different collapse types 00064 enum CollapseType { 00065 PMEAN, 00066 PMEDIAN, 00067 PSUM, 00068 CUNKNOWN 00069 //PVRMSE, 00070 }; 00071 00072 enum CollapseError { 00073 PNOERROR, 00074 PERMSE, 00075 PPROPAG, 00076 EUNKNOWN 00077 }; 00078 00079 // Constructor 00080 SpectralCollapser(ImageInterface<Float> * image); 00081 00082 // Constructor 00083 SpectralCollapser(ImageInterface<Float> * image, const String storePath); 00084 00085 // Destructor 00086 virtual ~SpectralCollapser(); 00087 00088 // Parameters: 00089 // <src>specVals</src> - the vector of spectral values 00090 // <src>startVal</src> - the spectral value to start the collapse 00091 // <src>endVal</src> - the spectral value to end the collapse 00092 // <src>unit</src> - the unit of the spectral values 00093 // <src>collType</src> - the collapse type (e.g. "mean" or "median") 00094 // <src>collError</src> - information on what the error 00095 // <src>outname</src> - name of the collapsed image (output) 00096 // <src>msg</src> - message string (output) 00097 virtual Bool collapse(const Vector<Float> &specVals, const Float startVal, const Float endVal, 00098 const String &unit, const SpectralCollapser::CollapseType &collType, const SpectralCollapser::CollapseError &collError, String &outname, String &msg); 00099 00100 String summaryHeader() const; 00101 00102 void collapseTypeToVector(const SpectralCollapser::CollapseType &collType, Vector<Int> &momentVec); 00103 00104 // Convert from string to collapse type 00105 static void stringToCollapseType(const String &text, SpectralCollapser::CollapseType &collType); 00106 00107 // Convert from string to error type 00108 static void stringToCollapseError(const String &text, SpectralCollapser::CollapseError &collError); 00109 00110 // Convert from collapse type to string 00111 static void collapseTypeToString(const SpectralCollapser::CollapseType &collType, String &strCollType); 00112 00113 // Convert from error type to string 00114 static void collapseErrorToString(const SpectralCollapser::CollapseError &collError, String &strCollError); 00115 00116 private: 00117 ImageInterface<Float> * _image; 00118 LogIO *_log; 00119 00120 String _storePath; 00121 String _all; // = CasacRegionManager::ALL; 00122 IPosition _specAxis; 00123 Bool _hasQualAxis; 00124 00125 // Disallow default constructor 00126 SpectralCollapser(); 00127 00128 void _setUp(); 00129 Bool _cleanTmpData(const String &tmpFileName) const; 00130 Bool _cleanTmpData(const String &tmpData, const String &tmpError) const; 00131 Bool _getQualitySubImg(const ImageInterface<Float>* image, const Bool &data, SubImage<Float> &qualitySub); 00132 Bool _getQualitySubImgs(ImageInterface<Float>* image, SubImage<Float> &subData, SubImage<Float> &subError) const; 00133 Bool _getOutputName(const String &wcsInp, String &outImg, String &outImgData, String &outImgError) const; 00134 Bool _collapse(const ImageInterface<Float> *image, const String &aggString, 00135 const String& chanInp, const String& outname) const; 00136 Bool _moments(const ImageInterface<Float> *image, const Vector<Int> &momentVec, 00137 const Int & startIndex, const Int &endIndex, const String& outname); 00138 Bool _mergeDataError(const String &outImg, const String &dataImg, const String &errorImg, const Float &normError=1.0) const; 00139 void _addMiscInfo(const String &outName, const String &wcsInput, const String &chanInput, 00140 const SpectralCollapser::CollapseType &collType, const SpectralCollapser::CollapseError &collError) const; 00141 void _collTypeToImCollString(const SpectralCollapser::CollapseType &collType, String &colType) const; 00142 void _collErrorToImCollString(const SpectralCollapser::CollapseError &collError, String &colError) const ; 00143 00144 }; 00145 } 00146 00147 #endif