casacore
Loading...
Searching...
No Matches
FITSMask.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: casa-feedback@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#ifndef LATTICES_FITSMASK_H
27#define LATTICES_FITSMASK_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/casa/Arrays/Array.h>
32#include <casacore/lattices/Lattices/Lattice.h>
33
34namespace casacore { // # NAMESPACE CASACORE - BEGIN
35
36// # Forward Declarations
37class TiledFileAccess;
38
39// <summary>
40// Provides an on-the-fly mask for FITS images
41// </summary>
42
43// <use visibility=export>
44
45// <reviewed reviewer="" date="" tests="" demos="">
46// </reviewed>
47
48// <prerequisite>
49// <li> <linkto class="Lattice">Lattice</linkto>
50// <li> <linkto class="FITSImage">FITSImage</linkto>
51// </prerequisite>
52
53// <etymology>
54// This class provides a pixel mask for the FITSImage class.
55// </etymology>
56
57// <synopsis>
58// Masked values are indicated in FITS images via magic
59// value blanking. This class provides an on-the-fly mask.
60// The doGetSlice function reads the data values and returns
61// an Array<Bool> which is True (good) or False (bad - blanked)
62//
63// Because FITSMask inherits from Lattice<Bool> it can be
64// used as the private pixel mask data member for FITSImage
65// returned by the MaskedLattice::pixelMask() functions
66//
67// The FITSMask object is constructed from a TiledFileAccess
68// object. This must be the same one that the FITSImage
69// object constructs internally. It is shared by both
70// FITSImage and FITSMask.
71//
72// </synopsis>
73//
74// <example>
75// <srcblock>
76// </srcblock>
77// </example>
78
79// <motivation>
80// FITSImage provides native access to FITS image files
81// and needede an efficient way to handle the pixel mask
82// other than iterating all the way through the image
83// first to set a mask.
84// </motivation>
85
86// # <todo asof="yyyy/mm/dd">
87// # <li> add this feature
88// # <li> fix this bug
89// # <li> start discussion of this possible extension
90// # </todo>
91
92class FITSMask : public Lattice<Bool> {
93 public:
94 // Constructor (for 32 bit floating point). The pointer is not cloned,
95 // just copied.
96 FITSMask(TiledFileAccess* tiledFileAccess);
97
98 // Constructor (for 8 bit integers). The pointer is not cloned, just copied
99 // The scale, offset, magic blanking values must come from
100 // the FITS header ('bscale', 'bzero', 'blank')
101 FITSMask(TiledFileAccess* tiledFileAccess, Float scale, Float offset, uChar magic,
102 Bool hasBlanks);
103
104 // Constructor (for 16 bit integers). The pointer is not cloned, just copied
105 // The scale, offset, magic blanking values must come from
106 // the FITS header ('bscale', 'bzero', 'blank')
107 FITSMask(TiledFileAccess* tiledFileAccess, Float scale, Float offset, Short magic,
108 Bool hasBlanks);
109
110 // Constructor (for 32 bit integers). The pointer is not cloned, just copied
111 // The scale, offset, magic blanking values must come from
112 // the FITS header ('bscale', 'bzero', 'blank')
113 FITSMask(TiledFileAccess* tiledFileAccess, Float scale, Float offset, Int magic, Bool hasBlanks);
114
115 // Copy constructor (reference semantics). The TiledFileAccess pointer
116 // is just copied.
117 FITSMask(const FITSMask& other);
118
119 // Destructor
120 virtual ~FITSMask();
121
122 // The assignment operator with reference semantics.
123 // The TiledFileAccess pointer is just copied.
125
126 // Make a copy of the object (reference semantics).
127 virtual Lattice<Bool>* clone() const;
128
129 // Is the FITSMask writable? Returns False. Although it is not hard
130 // to implement writing of the mask, data values would be lost
131 // because of magic blanking.
132 virtual Bool isWritable() const;
133
134 // Return the shape of the Lattice including all degenerate
135 // axes (ie. axes with a length of one)
137
138 // Do the actual getting of an array of values.
139 virtual Bool doGetSlice(Array<Bool>& buffer, const Slicer& section);
140
141 // Do the actual getting of an array of values. Throws an exception.
142 virtual void doPutSlice(const Array<Bool>& sourceBuffer, const IPosition& where,
143 const IPosition& stride);
144
145 // Set the switch for also filtering 0.0 (besides NaNs).
146 virtual void setFilterZero(Bool filterZero);
147
148 private:
149 // Mask out ONLY NaN's
150 void filterNaN(Bool* pMask, const float* pData, uInt nelems);
151
152 // Mask out NaN's and values 0.0
153 void filterZeroNaN(Bool* pMask, const Float* pData, uInt nelems);
154
155 //
164};
165
166} // namespace casacore
167
168#endif
virtual void doPutSlice(const Array< Bool > &sourceBuffer, const IPosition &where, const IPosition &stride)
Do the actual getting of an array of values.
TiledFileAccess * itsTiledFilePtr
Definition FITSMask.h:156
FITSMask & operator=(const FITSMask &other)
The assignment operator with reference semantics.
IPosition shape() const
Return the shape of the Lattice including all degenerate axes (ie.
FITSMask(TiledFileAccess *tiledFileAccess)
Constructor (for 32 bit floating point).
void filterZeroNaN(Bool *pMask, const Float *pData, uInt nelems)
Mask out NaN's and values 0.0.
virtual ~FITSMask()
Destructor.
FITSMask(TiledFileAccess *tiledFileAccess, Float scale, Float offset, Short magic, Bool hasBlanks)
Constructor (for 16 bit integers).
Array< Float > itsBuffer
Definition FITSMask.h:157
virtual Lattice< Bool > * clone() const
Make a copy of the object (reference semantics).
void filterNaN(Bool *pMask, const float *pData, uInt nelems)
Mask out ONLY NaN's.
virtual void setFilterZero(Bool filterZero)
Set the switch for also filtering 0.0 (besides NaNs).
virtual Bool doGetSlice(Array< Bool > &buffer, const Slicer &section)
Do the actual getting of an array of values.
FITSMask(TiledFileAccess *tiledFileAccess, Float scale, Float offset, uChar magic, Bool hasBlanks)
Constructor (for 8 bit integers).
FITSMask(const FITSMask &other)
Copy constructor (reference semantics).
virtual Bool isWritable() const
Is the FITSMask writable?
FITSMask(TiledFileAccess *tiledFileAccess, Float scale, Float offset, Int magic, Bool hasBlanks)
Constructor (for 32 bit integers).
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
unsigned char uChar
Definition aipstype.h:45
int offset(int, int) const
compute a linear offset from array indicies
short Short
Definition aipstype.h:46
unsigned int uInt
Definition aipstype.h:49
float Float
Definition aipstype.h:52
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40