casa
$Rev:20696$
|
00001 //# FITSQualityImage.h: Class providing native access to FITS images 00002 //# Copyright (C) 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: FITSQualityImage.h 20495 2009-01-19 00:50:41Z Malte.Marquarding $ 00027 00028 #ifndef IMAGES_FITSQUALITYIMAGE_H 00029 #define IMAGES_FITSQUALITYIMAGE_H 00030 00031 00032 //# Includes 00033 #include <images/Images/FITSErrorImage.h> 00034 #include <images/Images/ImageInterface.h> 00035 00036 namespace casa { //# NAMESPACE CASA - BEGIN 00037 00038 //# Forward Declarations 00039 template <class T> class Array; 00040 template <class T> class Lattice; 00041 // 00042 class FITSImage; 00043 class FITSQualityMask; 00044 class IPosition; 00045 class Slicer; 00046 00047 // <summary> 00048 // Class providing native access to FITS Quality Images. 00049 // </summary> 00050 00051 // <use visibility=export> 00052 00053 // <reviewed reviewer="" date="" tests="tFITSQualityImage.cc"> 00054 // </reviewed> 00055 00056 // <prerequisite> 00057 // <li> <linkto class=FITSImage>FITSImage</linkto> 00058 // <li> <linkto class=FITSErrorImage>FITSErrorImage</linkto> 00059 // </prerequisite> 00060 00061 // <etymology> 00062 // The class provides access to a quality image via two extensions 00063 // in the corresponding FITS file. 00064 // </etymology> 00065 00066 // <synopsis> 00067 // A FITSQualityImage provides native access to FITS images by accessing 00068 // the data and the error values via the classes FITSImage and 00069 // FITSErrorImage, respectively. A QualityCoordinate connects these 00070 // two layers. The FITSQualityImage is read only. 00071 // </synopsis> 00072 00073 // <example> 00074 // <srcblock> 00075 // FITSQualityImage fitsQIStat("im.fits", 1, 2); 00076 // LogIO logger(or); 00077 // ImageStatistics<Float> stats(fitsQIStat, logger); 00078 // Bool ok = stats.display(); 00079 // </srcblock> 00080 // </example> 00081 00082 // <motivation> 00083 // This provides access to FITS Quality Images 00084 // </motivation> 00085 00086 //# <todo asof="2011/06/17"> 00087 //# </todo> 00088 00089 class FITSQualityImage: public ImageInterface<Float> 00090 { 00091 public: 00092 // Construct a FITSQualityImage from the FITS file name and extensions 00093 // specified in the input. 00094 explicit FITSQualityImage(const String& name); 00095 00096 // Construct a FITSQualityImage from the disk FITS file name and extensions. 00097 explicit FITSQualityImage(const String& name, uInt whichDataHDU, uInt whichErrorHDU); 00098 00099 // Copy constructor (reference semantics) 00100 FITSQualityImage(const FITSQualityImage& other); 00101 00102 // Destructor 00103 ~FITSQualityImage(); 00104 00105 // Assignment (reference semantics). 00106 FITSQualityImage& operator=(const FITSQualityImage& other); 00107 00108 //# ImageInterface virtual functions 00109 00110 // Make a copy of the object with new (reference semantics). 00111 virtual ImageInterface<Float>* cloneII() const; 00112 00113 // Given the misc-info of a CASA image (with quality-axis) 00114 // the misc-info of the data sub-image and the error sub-image 00115 // are produced. This ensures that, if written to FITS, the 00116 // data and error extensions have the all necessary keywords. 00117 Bool static qualFITSInfo(String &error, TableRecord &dataExtMiscInfo, TableRecord &errorExtMiscInfo, 00118 const TableRecord &miscInfo); 00119 00120 // Get the FITS data 00121 FITSImage *fitsData() const {return fitsdata_p;}; 00122 00123 // Get the FITS error 00124 FITSErrorImage *fitsError() const {return fitserror_p;}; 00125 00126 // Get the image type (returns FITSImage). 00127 virtual String imageType() const; 00128 00129 // Function which changes the shape of the FITSQualityImage. 00130 // Throws an exception as FITSQualityImage is not writable. 00131 virtual void resize(const TiledShape& newShape); 00132 00133 // Has the object really a mask? The FITSQualityImage always 00134 // has a pixel mask and never has a region mask so this 00135 // always returns True 00136 virtual Bool isMasked() const; 00137 00138 // FITSQualityImage always has a pixel mask so returns True 00139 virtual Bool hasPixelMask() const; 00140 00141 // Get access to the pixelmask. FITSQualityImage always has a pixel mask. 00142 // <group> 00143 virtual const Lattice<Bool>& pixelMask() const; 00144 virtual Lattice<Bool>& pixelMask(); 00145 // </group> 00146 00147 00148 // Get the region used. There is no region. 00149 // Always returns 0. 00150 virtual const LatticeRegion* getRegionPtr() const; 00151 00152 // Do the actual get of the data. 00153 // Returns False as the data do not reference another Array 00154 virtual Bool doGetSlice (Array<Float>& buffer, const Slicer& theSlice); 00155 00156 // The FITSQualityImage is not writable, so this throws an exception. 00157 virtual void doPutSlice (const Array<Float>& sourceBuffer, 00158 const IPosition& where, 00159 const IPosition& stride); 00160 00161 // Do the actual get of the mask data. The return value is always 00162 // False, thus the buffer does not reference another array. 00163 virtual Bool doGetMaskSlice (Array<Bool>& buffer, const Slicer& section); 00164 00165 //# LatticeBase virtual functions 00166 00167 // The lattice is paged to disk. 00168 virtual Bool isPaged() const; 00169 00170 // The lattice is persistent. 00171 virtual Bool isPersistent() const; 00172 00173 // The FITSImage is not writable. 00174 virtual Bool isWritable() const; 00175 00176 // Returns the name of the disk file. 00177 virtual String name (Bool stripPath=False) const; 00178 00179 // Return the shape of the FITSImage. 00180 virtual IPosition shape() const; 00181 00182 // Returns the maximum recommended number of pixels for a cursor. This is 00183 // the number of pixels in a tile. 00184 virtual uInt advisedMaxPixels() const; 00185 00186 // Help the user pick a cursor for most efficient access if they only want 00187 // pixel values and don't care about the order or dimension of the 00188 // cursor. 00189 virtual IPosition doNiceCursorShape (uInt maxPixels) const; 00190 00191 // Check class invariants. 00192 virtual Bool ok() const; 00193 00194 // Temporarily close the image. 00195 virtual void tempClose(); 00196 virtual void tempCloseData(); 00197 virtual void tempCloseError(); 00198 00199 // Reopen a temporarily closed image. 00200 virtual void reopen(); 00201 00202 // Return the (internal) data type (TpFloat or TpShort). 00203 DataType dataType () const; 00204 00205 // Return the data HDU number 00206 uInt whichDataHDU () const 00207 { return whichDataHDU_p; } 00208 00209 // Return the error HDU number 00210 uInt whichErrorHDU () const 00211 { return whichErrorHDU_p; } 00212 00213 // Maximum size - not necessarily all used. In pixels. 00214 virtual uInt maximumCacheSize() const; 00215 00216 // Set the maximum (allowed) cache size as indicated. 00217 virtual void setMaximumCacheSize (uInt howManyPixels); 00218 00219 // Set the cache size as to "fit" the indicated path. 00220 virtual void setCacheSizeFromPath (const IPosition& sliceShape, 00221 const IPosition& windowStart, 00222 const IPosition& windowLength, 00223 const IPosition& axisPath); 00224 00225 // Set the actual cache size for this Array to be be big enough for the 00226 // indicated number of tiles. This cache is not shared with PagedArrays 00227 // in other rows and is always clipped to be less than the maximum value 00228 // set using the setMaximumCacheSize member function. 00229 // tiles. Tiles are cached using a first in first out algorithm. 00230 virtual void setCacheSizeInTiles (uInt howManyTiles); 00231 00232 // Clears and frees up the caches, but the maximum allowed cache size is 00233 // unchanged from when setCacheSize was called 00234 virtual void clearCache(); 00235 00236 // Report on cache success. 00237 virtual void showCacheStatistics (ostream& os) const; 00238 00239 private: 00240 String name_p; 00241 String fullname_p; 00242 FITSImage *fitsdata_p; 00243 FITSErrorImage *fitserror_p; 00244 Lattice<Bool> *pPixelMask_p; 00245 TiledShape shape_p; 00246 uInt whichDataHDU_p; 00247 uInt whichErrorHDU_p; 00248 uInt whichMaskHDU_p; 00249 FITSErrorImage::ErrorType errType_p; 00250 Bool isClosed_p; 00251 Bool isDataClosed_p; 00252 Bool isErrorClosed_p; 00253 00254 // Reopen the image if needed. 00255 void reopenIfNeeded() const; 00256 void reopenDataIfNeeded(); 00257 void reopenErrorIfNeeded(); 00258 00259 // Get the extension indices from an 00260 // extension expression. 00261 void getExtInfo(); 00262 00263 // Setup the object (used by constructors). 00264 void setup(); 00265 00266 // Make sure the input is compatible. 00267 Bool checkInput(); 00268 }; 00269 00270 00271 00272 } //# NAMESPACE CASA - END 00273 00274 #endif 00275 00276