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