casacore
FITSQualityMask.h
Go to the documentation of this file.
1  //# FITSMask.h: A Lattice that can be used for temporary storage
2 //# Copyright (C) 1997,1998,1999,2000,2001,2002
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //#
27 //# $Id$
28 
29 #ifndef LATTICES_FITSQUALMASK_H
30 #define LATTICES_FITSQUALMASK_H
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
34 #include <casacore/casa/Arrays/Array.h>
35 #include <casacore/lattices/Lattices/Lattice.h>
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 //# Forward Declarations
40 class FITSImage;
41 class FITSErrorImage;
42 
43 // <summary>
44 // Provides an on-the-fly mask for FITS quality images
45 // </summary>
46 
47 // <use visibility=export>
48 
49 // <reviewed reviewer="" date="" tests="" demos="">
50 // </reviewed>
51 
52 // <prerequisite>
53 // <li> <linkto class="Lattice">Lattice</linkto>
54 // <li> <linkto class="FITSImage">FITSQualityImage</linkto>
55 // </prerequisite>
56 
57 // <etymology>
58 // This class provides a pixel mask for the FITSQualityImage class.
59 // </etymology>
60 
61 // <synopsis>
62 // Masked values are indicated in FITS images via magic
63 // value blanking. This class provides an on-the-fly mask.
64 // The doGetSlice function reads the data values and returns
65 // an Array<Bool> which is True (good) or False (bad - blanked)
66 //
67 // Because FITSMask inherits from Lattice<Bool> it can be
68 // used as the private pixel mask data member for FITSQualityImage
69 // returned by the MaskedLattice::pixelMask() functions
70 //
71 // The FITSQualityMask object is constructed from the FITSImage objects
72 // of the data and the error extension. These must be the same one that
73 // the FITSQUalityImage object constructs internally. They shared by both
74 // FITSImage and FITSMask.
75 //
76 // </synopsis>
77 //
78 // <example>
79 // <srcblock>
80 // </srcblock>
81 // </example>
82 
83 // <motivation>
84 // FITSQualityImage provides access to FITS images with a data and and error
85 // extension. It needed an efficient way to handle the pixel mask
86 // other than iterating all the way through the image
87 // first to set a mask.
88 // </motivation>
89 
90 //# <todo asof="yyyy/mm/dd">
91 //# <li> add this feature
92 //# <li> fix this bug
93 //# <li> start discussion of this possible extension
94 //# </todo>
95 
96 
97 class FITSQualityMask : public Lattice<Bool>
98 {
99 public:
100 
101  // The pointers are not cloned, just copied.
102  FITSQualityMask (FITSImage *fitsData, FITSErrorImage *fitsError);
103 
104  // Copy constructor (reference semantics).
106 
107  // Destructor
108  virtual ~FITSQualityMask();
109 
110  // The assignment operator with reference semantics.
112 
113  // Make a copy of the object (reference semantics).
114  virtual Lattice<Bool>* clone() const;
115 
116  // Is the FITSMask writable? Returns False. Although it is not hard
117  // to implement writing of the mask, data values would be lost
118  // because of magic blanking.
119  virtual Bool isWritable() const;
120 
121  // Return the shape of the Lattice including all degenerate
122  // axes (ie. axes with a length of one)
123  IPosition shape() const;
124 
125  // Do the actual getting of an array of values.
126  virtual Bool doGetSlice (Array<Bool>& buffer, const Slicer& section);
127 
128  // Do the actual getting of an array of values. Throws an exception.
129  virtual void doPutSlice (const Array<Bool>& sourceBuffer,
130  const IPosition& where,
131  const IPosition& stride);
132 
133  // Set the switch for filtering 0.0
134  virtual void setFilterZero(Bool filterZero);
135 
136 private:
138 
139  // Mask out ONLY NaN's
140  Bool filterNaN(bool* pMask, const float* pData, const uInt nelems);
141 
142  // Mask out NaN's and values 0.0
143  Bool filterZeroNaN(Bool* pMask, const Float* pData, const uInt nelems);
144 
145  //
150 };
151 
152 
153 
154 } //# NAMESPACE CASACORE - END
155 
156 #endif
Bool filterNaN(bool *pMask, const float *pData, const uInt nelems)
Mask out ONLY NaN's.
virtual void doPutSlice(const Array< Bool > &sourceBuffer, const IPosition &where, const IPosition &stride)
Do the actual getting of an array of values.
virtual ~FITSQualityMask()
Destructor.
virtual void setFilterZero(Bool filterZero)
Set the switch for filtering 0.0.
FITSQualityMask(FITSImage *fitsData, FITSErrorImage *fitsError)
The pointers are not cloned, just copied.
virtual Bool doGetSlice(Array< Bool > &buffer, const Slicer &section)
Do the actual getting of an array of values.
virtual Lattice< Bool > * clone() const
Make a copy of the object (reference semantics).
virtual Bool isWritable() const
Is the FITSMask writable? Returns False.
Bool filterZeroNaN(Bool *pMask, const Float *pData, const uInt nelems)
Mask out NaN's and values 0.0.
FITSQualityMask(const FITSQualityMask &other)
Copy constructor (reference semantics).
FITSErrorImage * itsFitsError
IPosition shape() const
Return the shape of the Lattice including all degenerate axes (ie.
FITSQualityMask & operator=(const FITSQualityMask &other)
The assignment operator with reference semantics.
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:51
float Float
Definition: aipstype.h:54
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42