casa
$Rev:20696$
|
00001 //# tSubImage.cc: Test program for class SubImage 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_IMAGETASK_H 00029 #define IMAGEANALYSIS_IMAGETASK_H 00030 00031 #include <imageanalysis/ImageAnalysis/ImageInputProcessor.h> 00032 00033 #include <casa/IO/FiledesIO.h> 00034 00035 #include <memory> 00036 00037 #include <casa/namespace.h> 00038 00039 namespace casa { 00040 00041 class ImageTask { 00042 // <summary> 00043 // Virtual base class for image tasking. 00044 // </summary> 00045 00046 // <reviewed reviewer="" date="" tests="" demos=""> 00047 // </reviewed> 00048 00049 // <prerequisite> 00050 // </prerequisite> 00051 00052 // <etymology> 00053 // Image tasking 00054 // </etymology> 00055 00056 // <synopsis> 00057 // Virtual base class for image tasking. 00058 // </synopsis> 00059 00060 public: 00061 00062 // verbosity levels 00063 enum Verbosity { 00064 QUIET, 00065 WHISPER, 00066 LOW, 00067 NORMAL, 00068 HIGH, 00069 NOISY, 00070 DEAFENING 00071 }; 00072 00073 virtual ~ImageTask(); 00074 00075 virtual String getClass() const = 0; 00076 00077 inline void setStretch(const Bool stretch) { _stretch = stretch;} 00078 00079 void setLogfile(const String& lf); 00080 00081 void setLogfileAppend(const Bool a); 00082 00083 void setRegion(const Record& region); 00084 00085 void setMask(const String& mask) { _mask = mask; } 00086 00087 void setVerbosity(Verbosity verbosity) { _verbosity = verbosity; } 00088 00089 protected: 00090 00091 // if <src>outname</src> is empty, no image will be written 00092 // if <src>overwrite</src> is True, if image already exists it will be removed 00093 // if <src>overwrite</src> is False, if image already exists exception will be thrown 00094 00095 ImageTask( 00096 const ImageInterface<Float> *const &image, 00097 const String& region, const Record *const ®ionPtr, 00098 const String& box, const String& chanInp, 00099 const String& stokes, const String& maskInp, 00100 const String& outname, const Bool overwrite 00101 ); 00102 00103 virtual CasacRegionManager::StokesControl _getStokesControl() const = 0; 00104 00105 virtual vector<ImageInputProcessor::OutputStruct> _getOutputStruct(); 00106 00107 // does the lion's share of constructing the object, ie checks validity of 00108 // inputs, etc. 00109 00110 virtual void _construct(Bool verbose=True); 00111 00112 inline const ImageInterface<Float>* _getImage() const {return _image;} 00113 00114 inline const String& _getMask() const {return _mask;} 00115 00116 inline const Record* _getRegion() const {return &_regionRecord;} 00117 00118 inline void _setStokes(const String& stokes) { _stokesString = stokes; } 00119 00120 inline const String& _getStokes() const {return _stokesString;} 00121 00122 inline const String& _getChans() const {return _chan;} 00123 00124 inline const String& _getOutname() const {return _outname; } 00125 00126 // Represents the minimum set of coordinates necessary for the 00127 // task to function. 00128 virtual vector<Coordinate::Type> _getNecessaryCoordinates() const = 0; 00129 00130 void _removeExistingOutfileIfNecessary() const; 00131 00132 static void _removeExistingFileIfNecessary( 00133 const String& filename, const Bool overwrite 00134 ); 00135 00136 String _summaryHeader() const; 00137 00138 inline const std::auto_ptr<LogIO>& _getLog() const {return _log;} 00139 00140 inline void _setSupportsLogfile(const Bool b) { _logfileSupport=b;} 00141 00142 Bool _hasLogfileSupport() const {return _logfileSupport;} 00143 00144 inline Bool _getStretch() const {return _stretch;} 00145 00146 const String& _getLogfile() const; 00147 00148 Bool _writeLogfile( 00149 const String& output, const Bool open=True, 00150 const Bool close=True 00151 ); 00152 00153 Bool _openLogfile(); 00154 00155 void _closeLogfile() const; 00156 00157 virtual inline Bool _supportsMultipleRegions() {return False;} 00158 00159 // Create a TempImage or PagedImage depending if _outname is empty or not. Generally meant 00160 // for the image to be returned to the UI or the final image product that the user will want. 00161 // values=0 => the pixel values from the subimage will be used 00162 // mask=0 => the mask attached to the subimage, if any will be used, outShape=0 => use subImage shape, coordsys=0 => use subImage coordinate 00163 // system 00164 std::auto_ptr<ImageInterface<Float> > _prepareOutputImage( 00165 const ImageInterface<Float> *const subImage, const Array<Float> *const values=0, 00166 const ArrayLattice<Bool> *const mask=0, 00167 const IPosition *const outShape=0, const CoordinateSystem *const coordsys=0 00168 ) const; 00169 00170 Verbosity _getVerbosity() const { return _verbosity; } 00171 00172 private: 00173 const ImageInterface<Float> *const _image; 00174 std::auto_ptr<LogIO> _log; 00175 const Record *const _regionPtr; 00176 Record _regionRecord; 00177 String _region, _box, _chan, _stokesString, _mask, _outname, _logfile; 00178 Bool _overwrite, _stretch, _logfileSupport, _logfileAppend; 00179 Int _logFD; 00180 std::auto_ptr<FiledesIO> _logFileIO; 00181 Verbosity _verbosity; 00182 00183 00184 00185 00186 }; 00187 } 00188 00189 #endif