Loading...
Searching...
No Matches
FITSMask.h
Go to the documentation of this file.
//# FITSMask.h: A Lattice that can be used for temporary storage
//# Copyright (C) 1997,1998,1999,2000,2001,2002
//# Associated Universities, Inc. Washington DC, USA.
//#
//# This library is free software; you can redistribute it and/or modify it
//# under the terms of the GNU Library General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or (at your
//# option) any later version.
//#
//# This library is distributed in the hope that it will be useful, but WITHOUT
//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
//# License for more details.
//#
//# You should have received a copy of the GNU Library General Public License
//# along with this library; if not, write to the Free Software Foundation,
//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
//#
//# Correspondence concerning AIPS++ should be addressed as follows:
//# Internet email: casa-feedback@nrao.edu.
//# Postal address: AIPS++ Project Office
//# National Radio Astronomy Observatory
//# 520 Edgemont Road
//# Charlottesville, VA 22903-2475 USA
#ifndef LATTICES_FITSMASK_H
#define LATTICES_FITSMASK_H
//# Includes
#include <casacore/casa/aips.h>
#include <casacore/casa/Arrays/Array.h>
#include <casacore/lattices/Lattices/Lattice.h>
namespace casacore { //# NAMESPACE CASACORE - BEGIN
//# Forward Declarations
class TiledFileAccess;
// <summary>
// Provides an on-the-fly mask for FITS images
// </summary>
// <use visibility=export>
// <reviewed reviewer="" date="" tests="" demos="">
// </reviewed>
// <prerequisite>
// <li> <linkto class="Lattice">Lattice</linkto>
// <li> <linkto class="FITSImage">FITSImage</linkto>
// </prerequisite>
// <etymology>
// This class provides a pixel mask for the FITSImage class.
// </etymology>
// <synopsis>
// Masked values are indicated in FITS images via magic
// value blanking. This class provides an on-the-fly mask.
// The doGetSlice function reads the data values and returns
// an Array<Bool> which is True (good) or False (bad - blanked)
//
// Because FITSMask inherits from Lattice<Bool> it can be
// used as the private pixel mask data member for FITSImage
// returned by the MaskedLattice::pixelMask() functions
//
// The FITSMask object is constructed from a TiledFileAccess
// object. This must be the same one that the FITSImage
// object constructs internally. It is shared by both
// FITSImage and FITSMask.
//
// </synopsis>
//
// <example>
// <srcblock>
// </srcblock>
// </example>
// <motivation>
// FITSImage provides native access to FITS image files
// and needede an efficient way to handle the pixel mask
// other than iterating all the way through the image
// first to set a mask.
// </motivation>
//# <todo asof="yyyy/mm/dd">
//# <li> add this feature
//# <li> fix this bug
//# <li> start discussion of this possible extension
//# </todo>
class FITSMask : public Lattice<Bool>
{
public:
// Constructor (for 32 bit floating point). The pointer is not cloned,
// just copied.
FITSMask (TiledFileAccess* tiledFileAccess);
// Constructor (for 8 bit integers). The pointer is not cloned, just copied
// The scale, offset, magic blanking values must come from
// the FITS header ('bscale', 'bzero', 'blank')
FITSMask (TiledFileAccess* tiledFileAccess, Float scale, Float offset,
uChar magic, Bool hasBlanks);
// Constructor (for 16 bit integers). The pointer is not cloned, just copied
// The scale, offset, magic blanking values must come from
// the FITS header ('bscale', 'bzero', 'blank')
FITSMask (TiledFileAccess* tiledFileAccess, Float scale, Float offset,
Short magic, Bool hasBlanks);
// Constructor (for 32 bit integers). The pointer is not cloned, just copied
// The scale, offset, magic blanking values must come from
// the FITS header ('bscale', 'bzero', 'blank')
FITSMask (TiledFileAccess* tiledFileAccess, Float scale, Float offset,
Int magic, Bool hasBlanks);
// Copy constructor (reference semantics). The TiledFileAccess pointer
// is just copied.
FITSMask (const FITSMask& other) ;
// Destructor
virtual ~FITSMask();
// The assignment operator with reference semantics.
// The TiledFileAccess pointer is just copied.
FITSMask& operator= (const FITSMask& other);
// Make a copy of the object (reference semantics).
virtual Lattice<Bool>* clone() const;
// Is the FITSMask writable? Returns False. Although it is not hard
// to implement writing of the mask, data values would be lost
// because of magic blanking.
virtual Bool isWritable() const;
// Return the shape of the Lattice including all degenerate
// axes (ie. axes with a length of one)
IPosition shape() const;
// Do the actual getting of an array of values.
virtual Bool doGetSlice (Array<Bool>& buffer, const Slicer& section);
// Do the actual getting of an array of values. Throws an exception.
virtual void doPutSlice (const Array<Bool>& sourceBuffer,
const IPosition& where,
const IPosition& stride);
// Set the switch for also filtering 0.0 (besides NaNs).
virtual void setFilterZero (Bool filterZero);
private:
// Mask out ONLY NaN's
void filterNaN (Bool* pMask, const float* pData, uInt nelems);
// Mask out NaN's and values 0.0
void filterZeroNaN (Bool* pMask, const Float* pData, uInt nelems);
//
TiledFileAccess* itsTiledFilePtr;
Array<Float> itsBuffer;
Float itsScale, itsOffset;
Short itsUCharMagic;
Short itsShortMagic;
Int itsLongMagic;
Bool itsHasIntBlanks;
Bool itsFilterZero;
};
} //# NAMESPACE CASACORE - END
#endif
casacore::Array
Definition Array.h:155
casacore::FITSMask::doPutSlice
virtual void doPutSlice(const Array< Bool > &sourceBuffer, const IPosition &where, const IPosition &stride)
Do the actual getting of an array of values.
casacore::FITSMask::itsTiledFilePtr
TiledFileAccess * itsTiledFilePtr
Definition FITSMask.h:163
casacore::FITSMask::itsScale
Float itsScale
Definition FITSMask.h:165
casacore::FITSMask::operator=
FITSMask & operator=(const FITSMask &other)
The assignment operator with reference semantics.
casacore::FITSMask::shape
IPosition shape() const
Return the shape of the Lattice including all degenerate axes (ie.
casacore::FITSMask::itsLongMagic
Int itsLongMagic
Definition FITSMask.h:168
casacore::FITSMask::FITSMask
FITSMask(TiledFileAccess *tiledFileAccess)
Constructor (for 32 bit floating point).
casacore::FITSMask::filterZeroNaN
void filterZeroNaN(Bool *pMask, const Float *pData, uInt nelems)
Mask out NaN's and values 0.0.
casacore::FITSMask::itsShortMagic
Short itsShortMagic
Definition FITSMask.h:167
casacore::FITSMask::itsFilterZero
Bool itsFilterZero
Definition FITSMask.h:170
casacore::FITSMask::itsUCharMagic
Short itsUCharMagic
Definition FITSMask.h:166
casacore::FITSMask::~FITSMask
virtual ~FITSMask()
Destructor.
casacore::FITSMask::itsOffset
Float itsOffset
Definition FITSMask.h:165
casacore::FITSMask::FITSMask
FITSMask(TiledFileAccess *tiledFileAccess, Float scale, Float offset, Short magic, Bool hasBlanks)
Constructor (for 16 bit integers).
casacore::FITSMask::itsBuffer
Array< Float > itsBuffer
Definition FITSMask.h:164
casacore::FITSMask::clone
virtual Lattice< Bool > * clone() const
Make a copy of the object (reference semantics).
casacore::FITSMask::filterNaN
void filterNaN(Bool *pMask, const float *pData, uInt nelems)
Mask out ONLY NaN's.
casacore::FITSMask::itsHasIntBlanks
Bool itsHasIntBlanks
Definition FITSMask.h:169
casacore::FITSMask::setFilterZero
virtual void setFilterZero(Bool filterZero)
Set the switch for also filtering 0.0 (besides NaNs).
casacore::FITSMask::doGetSlice
virtual Bool doGetSlice(Array< Bool > &buffer, const Slicer &section)
Do the actual getting of an array of values.
casacore::FITSMask::FITSMask
FITSMask(TiledFileAccess *tiledFileAccess, Float scale, Float offset, uChar magic, Bool hasBlanks)
Constructor (for 8 bit integers).
casacore::FITSMask::FITSMask
FITSMask(const FITSMask &other)
Copy constructor (reference semantics).
casacore::FITSMask::isWritable
virtual Bool isWritable() const
Is the FITSMask writable?
casacore::FITSMask::FITSMask
FITSMask(TiledFileAccess *tiledFileAccess, Float scale, Float offset, Int magic, Bool hasBlanks)
Constructor (for 32 bit integers).
casacore::IPosition
Definition IPosition.h:117
casacore::Lattice< Bool >::Lattice
Lattice()
Definition Lattice.h:405
casacore::Slicer
Definition Slicer.h:287
casacore::TiledFileAccess
Definition TiledFileAccess.h:91
casacore
this file contains all the compiler specific defines
Definition mainpage.dox:28
casacore::uChar
unsigned char uChar
Definition aipstype.h:45
casacore::offset
int offset(int, int) const
compute a linear offset from array indicies
casacore::Short
short Short
Definition aipstype.h:46
casacore::uInt
unsigned int uInt
Definition aipstype.h:49
casacore::Float
float Float
Definition aipstype.h:52
casacore::Int
int Int
Definition aipstype.h:48
casacore::Bool
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40