casacore
FITSQualityImage.h
Go to the documentation of this file.
1 //# FITSQualityImage.h: Class providing native access to FITS images
2 //# Copyright (C) 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 //# $Id$
27 
28 #ifndef IMAGES_FITSQUALITYIMAGE_H
29 #define IMAGES_FITSQUALITYIMAGE_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
34 #include <casacore/images/Images/FITSErrorImage.h>
35 #include <casacore/images/Images/ImageInterface.h>
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 //# Forward Declarations
40 template <class T> class Array;
41 template <class T> class Lattice;
42 //
43 class FITSImage;
44 class FITSQualityMask;
45 class IPosition;
46 class Slicer;
47 
48 // <summary>
49 // Class providing native access to FITS Quality Images.
50 // </summary>
51 
52 // <use visibility=export>
53 
54 // <reviewed reviewer="" date="" tests="tFITSQualityImage.cc">
55 // </reviewed>
56 
57 // <prerequisite>
58 // <li> <linkto class=FITSImage>FITSImage</linkto>
59 // <li> <linkto class=FITSErrorImage>FITSErrorImage</linkto>
60 // </prerequisite>
61 
62 // <etymology>
63 // The class provides access to a quality image via two extensions
64 // in the corresponding FITS file.
65 // </etymology>
66 
67 // <synopsis>
68 // A FITSQualityImage provides native access to FITS images by accessing
69 // the data and the error values via the classes FITSImage and
70 // FITSErrorImage, respectively. A QualityCoordinate connects these
71 // two layers. The FITSQualityImage is read only.
72 // </synopsis>
73 
74 // <example>
75 // <srcblock>
76 // FITSQualityImage fitsQIStat("im.fits", 1, 2);
77 // LogIO logger(or);
78 // ImageStatistics<Float> stats(fitsQIStat, logger);
79 // Bool ok = stats.display();
80 // </srcblock>
81 // </example>
82 
83 // <motivation>
84 // This provides access to FITS Quality Images
85 // </motivation>
86 
87 //# <todo asof="2011/06/17">
88 //# </todo>
89 
90 class FITSQualityImage: public ImageInterface<Float>
91 {
92 public:
93  // Construct a FITSQualityImage from the FITS file name and extensions
94  // specified in the input.
95  explicit FITSQualityImage(const String& name);
96 
97  // Construct a FITSQualityImage from the disk FITS file name and extensions.
99 
100  // Copy constructor (reference semantics)
101  FITSQualityImage(const FITSQualityImage& other);
102 
103  // Destructor
105 
106  // Assignment (reference semantics).
108 
109  //# ImageInterface virtual functions
110 
111  // Make a copy of the object with new (reference semantics).
112  virtual ImageInterface<Float>* cloneII() const;
113 
114  // Given the misc-info of a CASA image (with quality-axis)
115  // the misc-info of the data sub-image and the error sub-image
116  // are produced. This ensures that, if written to FITS, the
117  // data and error extensions have the all necessary keywords.
118  Bool static qualFITSInfo(String &error, TableRecord &dataExtMiscInfo, TableRecord &errorExtMiscInfo,
119  const TableRecord &miscInfo);
120 
121  // Get the FITS data
122  FITSImage *fitsData() const {return fitsdata_p;};
123 
124  // Get the FITS error
126 
127  // Get the image type (returns FITSImage).
128  virtual String imageType() const;
129 
130  // Function which changes the shape of the FITSQualityImage.
131  // Throws an exception as FITSQualityImage is not writable.
132  virtual void resize(const TiledShape& newShape);
133 
134  // Has the object really a mask? The FITSQualityImage always
135  // has a pixel mask and never has a region mask so this
136  // always returns True
137  virtual Bool isMasked() const;
138 
139  // FITSQualityImage always has a pixel mask so returns True
140  virtual Bool hasPixelMask() const;
141 
142  // Get access to the pixelmask. FITSQualityImage always has a pixel mask.
143  // <group>
144  virtual const Lattice<Bool>& pixelMask() const;
145  virtual Lattice<Bool>& pixelMask();
146  // </group>
147 
148 
149  // Get the region used. There is no region.
150  // Always returns 0.
151  virtual const LatticeRegion* getRegionPtr() const;
152 
153  // Do the actual get of the data.
154  // Returns False as the data do not reference another Array
155  virtual Bool doGetSlice (Array<Float>& buffer, const Slicer& theSlice);
156 
157  // The FITSQualityImage is not writable, so this throws an exception.
158  virtual void doPutSlice (const Array<Float>& sourceBuffer,
159  const IPosition& where,
160  const IPosition& stride);
161 
162  // Do the actual get of the mask data. The return value is always
163  // False, thus the buffer does not reference another array.
164  virtual Bool doGetMaskSlice (Array<Bool>& buffer, const Slicer& section);
165 
166  //# LatticeBase virtual functions
167 
168  // The lattice is paged to disk.
169  virtual Bool isPaged() const;
170 
171  // The lattice is persistent.
172  virtual Bool isPersistent() const;
173 
174  // The FITSImage is not writable.
175  virtual Bool isWritable() const;
176 
177  // Returns the name of the disk file.
178  virtual String name (Bool stripPath=False) const;
179 
180  // Return the shape of the FITSImage.
181  virtual IPosition shape() const;
182 
183  // Returns the maximum recommended number of pixels for a cursor. This is
184  // the number of pixels in a tile.
185  virtual uInt advisedMaxPixels() const;
186 
187  // Help the user pick a cursor for most efficient access if they only want
188  // pixel values and don't care about the order or dimension of the
189  // cursor.
190  virtual IPosition doNiceCursorShape (uInt maxPixels) const;
191 
192  // Check class invariants.
193  virtual Bool ok() const;
194 
195  // Temporarily close the image.
196  virtual void tempClose();
197  virtual void tempCloseData();
198  virtual void tempCloseError();
199 
200  // Reopen a temporarily closed image.
201  virtual void reopen();
202 
203  // Return the (internal) data type (TpFloat or TpShort).
204  DataType dataType () const;
205 
206  // Return the data HDU number
208  { return whichDataHDU_p; }
209 
210  // Return the error HDU number
212  { return whichErrorHDU_p; }
213 
214  // Maximum size - not necessarily all used. In pixels.
215  virtual uInt maximumCacheSize() const;
216 
217  // Set the maximum (allowed) cache size as indicated.
218  virtual void setMaximumCacheSize (uInt howManyPixels);
219 
220  // Set the cache size as to "fit" the indicated path.
221  virtual void setCacheSizeFromPath (const IPosition& sliceShape,
222  const IPosition& windowStart,
223  const IPosition& windowLength,
224  const IPosition& axisPath);
225 
226  // Set the actual cache size for this Array to be be big enough for the
227  // indicated number of tiles. This cache is not shared with PagedArrays
228  // in other rows and is always clipped to be less than the maximum value
229  // set using the setMaximumCacheSize member function.
230  // tiles. Tiles are cached using a first in first out algorithm.
231  virtual void setCacheSizeInTiles (uInt howManyTiles);
232 
233  // Clears and frees up the caches, but the maximum allowed cache size is
234  // unchanged from when setCacheSize was called
235  virtual void clearCache();
236 
237  // Report on cache success.
238  virtual void showCacheStatistics (ostream& os) const;
239 
240 private:
254 
255  // Reopen the image if needed.
256  void reopenIfNeeded() const;
257  void reopenDataIfNeeded();
258  void reopenErrorIfNeeded();
259 
260  // Get the extension indices from an
261  // extension expression.
262  void getExtInfo();
263 
264  // Setup the object (used by constructors).
265  void setup();
266 
267  // Make sure the input is compatible.
268  Bool checkInput();
269 };
270 
271 
272 
273 } //# NAMESPACE CASACORE - END
274 
275 #endif
276 
277 
casacore::FITSQualityImage::fitsdata_p
FITSImage * fitsdata_p
Definition: FITSQualityImage.h:243
casacore::ImageInterface
A base class for astronomical images.
Definition: ImageFITSConverter.h:48
casacore::Slicer
Specify which elements to extract from an n-dimensional array.
Definition: Slicer.h:289
casacore::FITSQualityImage::isErrorClosed_p
Bool isErrorClosed_p
Definition: FITSQualityImage.h:253
casacore::FITSQualityImage::operator=
FITSQualityImage & operator=(const FITSQualityImage &other)
Assignment (reference semantics).
casacore::FITSQualityImage::checkInput
Bool checkInput()
Make sure the input is compatible.
casacore::IPosition
A Vector of integers, for indexing into Array<T> objects.
Definition: IPosition.h:119
casacore::FITSQualityImage::reopenDataIfNeeded
void reopenDataIfNeeded()
casacore::FITSQualityImage::getRegionPtr
virtual const LatticeRegion * getRegionPtr() const
Get the region used.
casacore::FITSQualityImage::isWritable
virtual Bool isWritable() const
The FITSImage is not writable.
casacore::FITSQualityImage::errType_p
FITSErrorImage::ErrorType errType_p
Definition: FITSQualityImage.h:250
casacore::ImageInterface< Float >::miscInfo
const TableRecord & miscInfo() const
Often we have miscellaneous information we want to attach to an image.
Definition: ImageInterface.h:228
casacore::TableRecord
A hierarchical collection of named fields of various types.
Definition: TableRecord.h:182
casacore::FITSQualityImage
Class providing native access to FITS Quality Images.
Definition: FITSQualityImage.h:90
casacore::FITSQualityImage::imageType
virtual String imageType() const
Get the image type (returns FITSImage).
casacore::FITSQualityImage::tempClose
virtual void tempClose()
Temporarily close the image.
casacore::FITSQualityImage::getExtInfo
void getExtInfo()
Get the extension indices from an extension expression.
casacore::FITSErrorImage::ErrorType
ErrorType
The enum describes which types of error images exist.
Definition: FITSErrorImage.h:85
casacore::FITSQualityImage::shape
virtual IPosition shape() const
Return the shape of the FITSImage.
casacore::FITSQualityImage::isPaged
virtual Bool isPaged() const
The lattice is paged to disk.
casacore::FITSQualityImage::setCacheSizeInTiles
virtual void setCacheSizeInTiles(uInt howManyTiles)
Set the actual cache size for this Array to be be big enough for the indicated number of tiles.
casacore::FITSQualityImage::FITSQualityImage
FITSQualityImage(const String &name)
Construct a FITSQualityImage from the FITS file name and extensions specified in the input.
casacore::FITSQualityImage::clearCache
virtual void clearCache()
Clears and frees up the caches, but the maximum allowed cache size is unchanged from when setCacheSiz...
casacore::FITSQualityImage::name
virtual String name(Bool stripPath=False) const
Returns the name of the disk file.
casacore::LatticeRegion
An optionally strided region in a Lattice.
Definition: LatticeRegion.h:74
casacore::FITSQualityImage::isMasked
virtual Bool isMasked() const
Has the object really a mask? The FITSQualityImage always has a pixel mask and never has a region mas...
casacore::FITSQualityImage::qualFITSInfo
static Bool qualFITSInfo(String &error, TableRecord &dataExtMiscInfo, TableRecord &errorExtMiscInfo, const TableRecord &miscInfo)
Given the misc-info of a CASA image (with quality-axis) the misc-info of the data sub-image and the e...
casacore::FITSQualityImage::tempCloseData
virtual void tempCloseData()
casacore::FITSQualityImage::reopen
virtual void reopen()
Reopen a temporarily closed image.
casacore::FITSQualityImage::setCacheSizeFromPath
virtual void setCacheSizeFromPath(const IPosition &sliceShape, const IPosition &windowStart, const IPosition &windowLength, const IPosition &axisPath)
Set the cache size as to "fit" the indicated path.
casacore::FITSErrorImage
Class providing native access to FITS Error images.
Definition: FITSErrorImage.h:79
casacore::FITSQualityImage::fitsData
FITSImage * fitsData() const
Get the FITS data.
Definition: FITSQualityImage.h:122
casacore::FITSQualityImage::whichDataHDU
uInt whichDataHDU() const
Return the data HDU number.
Definition: FITSQualityImage.h:207
casacore::FITSQualityImage::fullname_p
String fullname_p
Definition: FITSQualityImage.h:242
casacore::FITSQualityImage::cloneII
virtual ImageInterface< Float > * cloneII() const
Make a copy of the object with new (reference semantics).
casacore::False
const Bool False
Definition: aipstype.h:44
casacore::uInt
unsigned int uInt
Definition: aipstype.h:51
casacore::FITSQualityImage::~FITSQualityImage
~FITSQualityImage()
Destructor.
casacore::FITSQualityImage::isPersistent
virtual Bool isPersistent() const
The lattice is persistent.
casacore::FITSQualityImage::resize
virtual void resize(const TiledShape &newShape)
Function which changes the shape of the FITSQualityImage.
casacore::FITSQualityImage::maximumCacheSize
virtual uInt maximumCacheSize() const
Maximum size - not necessarily all used.
casacore::FITSQualityImage::advisedMaxPixels
virtual uInt advisedMaxPixels() const
Returns the maximum recommended number of pixels for a cursor.
casacore::FITSQualityImage::doGetSlice
virtual Bool doGetSlice(Array< Float > &buffer, const Slicer &theSlice)
Do the actual get of the data.
casacore::FITSQualityImage::whichMaskHDU_p
uInt whichMaskHDU_p
Definition: FITSQualityImage.h:249
casacore
this file contains all the compiler specific defines
Definition: mainpage.dox:28
casacore::FITSQualityImage::reopenErrorIfNeeded
void reopenErrorIfNeeded()
casacore::FITSQualityImage::ok
virtual Bool ok() const
Check class invariants.
casacore::FITSQualityImage::dataType
DataType dataType() const
Return the (internal) data type (TpFloat or TpShort).
casacore::FITSQualityImage::hasPixelMask
virtual Bool hasPixelMask() const
FITSQualityImage always has a pixel mask so returns True.
casacore::FITSQualityImage::pixelMask
virtual const Lattice< Bool > & pixelMask() const
Get access to the pixelmask.
casacore::FITSQualityImage::reopenIfNeeded
void reopenIfNeeded() const
Reopen the image if needed.
casacore::FITSQualityImage::showCacheStatistics
virtual void showCacheStatistics(ostream &os) const
Report on cache success.
casacore::FITSImage
Class providing native access to FITS images.
Definition: FITSImage.h:108
casacore::FITSQualityImage::whichErrorHDU_p
uInt whichErrorHDU_p
Definition: FITSQualityImage.h:248
casacore::FITSQualityImage::name_p
String name_p
Definition: FITSQualityImage.h:241
casacore::FITSQualityImage::pPixelMask_p
Lattice< Bool > * pPixelMask_p
Definition: FITSQualityImage.h:245
casacore::FITSQualityImage::isDataClosed_p
Bool isDataClosed_p
Definition: FITSQualityImage.h:252
casacore::Lattice< Bool >
casacore::FITSQualityImage::tempCloseError
virtual void tempCloseError()
casacore::FITSQualityImage::setup
void setup()
Setup the object (used by constructors).
casacore::Array< Float >
casacore::FITSQualityImage::doPutSlice
virtual void doPutSlice(const Array< Float > &sourceBuffer, const IPosition &where, const IPosition &stride)
The FITSQualityImage is not writable, so this throws an exception.
casacore::FITSQualityImage::doGetMaskSlice
virtual Bool doGetMaskSlice(Array< Bool > &buffer, const Slicer &section)
Do the actual get of the mask data.
casacore::String
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::FITSQualityImage::whichDataHDU_p
uInt whichDataHDU_p
Definition: FITSQualityImage.h:247
casacore::Bool
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::FITSQualityImage::fitsError
FITSErrorImage * fitsError() const
Get the FITS error.
Definition: FITSQualityImage.h:125
casacore::FITSQualityImage::doNiceCursorShape
virtual IPosition doNiceCursorShape(uInt maxPixels) const
Help the user pick a cursor for most efficient access if they only want pixel values and don't care a...
casacore::FITSQualityImage::setMaximumCacheSize
virtual void setMaximumCacheSize(uInt howManyPixels)
Set the maximum (allowed) cache size as indicated.
casacore::FITSQualityImage::shape_p
TiledShape shape_p
Definition: FITSQualityImage.h:246
casacore::FITSQualityImage::whichErrorHDU
uInt whichErrorHDU() const
Return the error HDU number.
Definition: FITSQualityImage.h:211
casacore::TiledShape
Define the shape and tile shape.
Definition: TiledShape.h:99
casacore::FITSQualityImage::isClosed_p
Bool isClosed_p
Definition: FITSQualityImage.h:251
casacore::FITSQualityImage::fitserror_p
FITSErrorImage * fitserror_p
Definition: FITSQualityImage.h:244