casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
FITSQualityMask.h
Go to the documentation of this file.
00001  //# FITSMask.h: A Lattice that can be used for temporary storage
00002 //# Copyright (C) 1997,1998,1999,2000,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 //#
00027 //# $Id: FITSMask.h 18093 2004-11-30 17:51:10Z ddebonis $
00028 
00029 #ifndef LATTICES_FITSQUALMASK_H
00030 #define LATTICES_FITSQUALMASK_H
00031 
00032 //# Includes
00033 #include <casa/Arrays/Array.h>
00034 #include <lattices/Lattices/Lattice.h>
00035 
00036 namespace casa { //# NAMESPACE CASA - BEGIN
00037 
00038 //# Forward Declarations
00039 class FITSImage;
00040 class FITSErrorImage;
00041 
00042 // <summary>
00043 // Provides an on-the-fly mask for FITS quality images
00044 // </summary>
00045 
00046 // <use visibility=export>
00047 
00048 // <reviewed reviewer="" date="" tests="" demos="">
00049 // </reviewed>
00050 
00051 // <prerequisite>
00052 //   <li> <linkto class="Lattice">Lattice</linkto>
00053 //   <li> <linkto class="FITSImage">FITSQualityImage</linkto>
00054 // </prerequisite>
00055 
00056 // <etymology>
00057 // This class provides a pixel mask for the FITSQualityImage class.
00058 // </etymology>
00059 
00060 // <synopsis>
00061 // Masked values are indicated in FITS images via magic
00062 // value blanking.  This class provides an on-the-fly mask.
00063 // The doGetSlice function reads the data values and returns
00064 // an Array<Bool> which is True (good) or False (bad - blanked)
00065 //
00066 // Because FITSMask inherits from Lattice<Bool> it can be
00067 // used as the private pixel mask data member for FITSQualityImage
00068 // returned by the MaskedLattice::pixelMask() functions
00069 //
00070 // The FITSQualityMask object is constructed from the FITSImage objects
00071 // of the data and the error extension. These must be the same one that
00072 // the FITSQUalityImage object constructs internally.  They shared by both
00073 // FITSImage and FITSMask.
00074 //
00075 // </synopsis>
00076 //
00077 // <example>
00078 // <srcblock>
00079 // </srcblock>
00080 // </example>
00081 
00082 // <motivation>
00083 // FITSQualityImage provides access to FITS images with a data and and error
00084 // extension. It needed an efficient way to handle the pixel mask
00085 // other than iterating all the way through the image
00086 // first to set a mask.
00087 // </motivation>
00088 
00089 //# <todo asof="yyyy/mm/dd">
00090 //#   <li> add this feature
00091 //#   <li> fix this bug
00092 //#   <li> start discussion of this possible extension
00093 //# </todo>
00094 
00095 
00096 class FITSQualityMask : public Lattice<Bool>
00097 {
00098 public:
00099 
00100         // The pointers are not cloned, just copied.
00101         FITSQualityMask (FITSImage *fitsData, FITSErrorImage *fitsError);
00102 
00103         // Copy constructor (reference semantics).
00104         FITSQualityMask (const FITSQualityMask& other) ;
00105     
00106         // Destructor
00107         virtual ~FITSQualityMask();
00108 
00109         // The assignment operator with reference semantics.
00110         FITSQualityMask& operator= (const FITSQualityMask& other);
00111 
00112         // Make a copy of the object (reference semantics).
00113         virtual Lattice<Bool>* clone() const;
00114 
00115   // Is the FITSMask writable? Returns False. Although it is not hard
00116   // to implement writing of the mask, data values would be lost
00117   // because of magic blanking. 
00118   virtual Bool isWritable() const;
00119 
00120   // Return the shape of the Lattice including all degenerate 
00121   // axes (ie. axes with a length of one) 
00122   IPosition shape() const;
00123 
00124   // Do the actual getting of an array of values.
00125   virtual Bool doGetSlice (Array<Bool>& buffer, const Slicer& section);
00126 
00127   // Do the actual getting of an array of values. Throws an exception.
00128   virtual void doPutSlice (const Array<Bool>& sourceBuffer,
00129                            const IPosition& where,
00130                            const IPosition& stride);
00131 
00132   // Set the switch for filtering 0.0
00133   virtual void setFilterZero(Bool filterZero);
00134 
00135 private:
00136   FITSQualityMask();
00137 
00138   // Mask out ONLY NaN's
00139   Bool filterNaN(bool* pMask, const float* pData, const uInt nelems);
00140 
00141   // Mask out NaN's and values 0.0
00142   Bool filterZeroNaN(Bool* pMask, const Float* pData, const uInt nelems);
00143 
00144   //
00145   FITSImage      *itsFitsData;
00146   FITSErrorImage *itsFitsError;
00147   Array<Float>    itsBuffer;
00148   Bool            itsFilterZero;
00149 };
00150 
00151 
00152 
00153 } //# NAMESPACE CASA - END
00154 
00155 #endif