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: 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_FITSMASK_H
30#define LATTICES_FITSMASK_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
37namespace casacore { //# NAMESPACE CASACORE - BEGIN
38
39//# Forward Declarations
40class TiledFileAccess;
41
42
43// <summary>
44// Provides an on-the-fly mask for FITS 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">FITSImage</linkto>
55// </prerequisite>
56
57// <etymology>
58// This class provides a pixel mask for the FITSImage 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 FITSImage
69// returned by the MaskedLattice::pixelMask() functions
70//
71// The FITSMask object is constructed from a TiledFileAccess
72// object. This must be the same one that the FITSImage
73// object constructs internally. It is shared by both
74// FITSImage and FITSMask.
75//
76// </synopsis>
77//
78// <example>
79// <srcblock>
80// </srcblock>
81// </example>
82
83// <motivation>
84// FITSImage provides native access to FITS image files
85// and needede 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
97class FITSMask : public Lattice<Bool>
98{
99public:
100
101 // Constructor (for 32 bit floating point). The pointer is not cloned,
102 // just copied.
103 FITSMask (TiledFileAccess* tiledFileAccess);
104
105 // Constructor (for 8 bit integers). The pointer is not cloned, just copied
106 // The scale, offset, magic blanking values must come from
107 // the FITS header ('bscale', 'bzero', 'blank')
108 FITSMask (TiledFileAccess* tiledFileAccess, Float scale, Float offset,
109 uChar magic, Bool hasBlanks);
110
111 // Constructor (for 16 bit integers). The pointer is not cloned, just copied
112 // The scale, offset, magic blanking values must come from
113 // the FITS header ('bscale', 'bzero', 'blank')
114 FITSMask (TiledFileAccess* tiledFileAccess, Float scale, Float offset,
115 Short magic, Bool hasBlanks);
116
117 // Constructor (for 32 bit integers). The pointer is not cloned, just copied
118 // The scale, offset, magic blanking values must come from
119 // the FITS header ('bscale', 'bzero', 'blank')
120 FITSMask (TiledFileAccess* tiledFileAccess, Float scale, Float offset,
121 Int magic, Bool hasBlanks);
122
123 // Copy constructor (reference semantics). The TiledFileAccess pointer
124 // is just copied.
125 FITSMask (const FITSMask& other) ;
126
127 // Destructor
128 virtual ~FITSMask();
129
130 // The assignment operator with reference semantics.
131 // The TiledFileAccess pointer is just copied.
133
134 // Make a copy of the object (reference semantics).
135 virtual Lattice<Bool>* clone() const;
136
137 // Is the FITSMask writable? Returns False. Although it is not hard
138 // to implement writing of the mask, data values would be lost
139 // because of magic blanking.
140 virtual Bool isWritable() const;
141
142 // Return the shape of the Lattice including all degenerate
143 // axes (ie. axes with a length of one)
145
146 // Do the actual getting of an array of values.
147 virtual Bool doGetSlice (Array<Bool>& buffer, const Slicer& section);
148
149 // Do the actual getting of an array of values. Throws an exception.
150 virtual void doPutSlice (const Array<Bool>& sourceBuffer,
151 const IPosition& where,
152 const IPosition& stride);
153
154 // Set the switch for also filtering 0.0 (besides NaNs).
155 virtual void setFilterZero (Bool filterZero);
156
157private:
158
159 // Mask out ONLY NaN's
160 void filterNaN (Bool* pMask, const float* pData, uInt nelems);
161
162 // Mask out NaN's and values 0.0
163 void filterZeroNaN (Bool* pMask, const Float* pData, uInt nelems);
164
165//
174};
175
176
177
178} //# NAMESPACE CASACORE - END
179
180#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:166
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:167
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:47
short Short
Definition aipstype.h:48
unsigned int uInt
Definition aipstype.h:51
float Float
Definition aipstype.h:54
int Int
Definition aipstype.h:50
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:42