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