FITSQualityImage.h

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

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1