casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
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 
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
Lattice< Bool > * pPixelMask_p
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...
FITSQualityImage(const String &name)
Construct a FITSQualityImage from the FITS file name and extensions specified in the input...
virtual void tempCloseData()
virtual Bool isPersistent() const
The lattice is persistent.
void setup()
Setup the object (used by constructors).
virtual void setCacheSizeFromPath(const IPosition &sliceShape, const IPosition &windowStart, const IPosition &windowLength, const IPosition &axisPath)
Set the cache size as to &quot;fit&quot; the indicated path.
virtual String imageType() const
Get the image type (returns FITSImage).
Class providing native access to FITS Error images.
DataType dataType() const
Return the (internal) data type (TpFloat or TpShort).
virtual IPosition shape() const
Return the shape of the FITSImage.
virtual const LatticeRegion * getRegionPtr() const
Get the region used.
virtual Bool isPaged() const
The lattice is paged to disk.
virtual Bool doGetSlice(Array< Float > &buffer, const Slicer &theSlice)
Do the actual get of the data.
virtual Bool ok() const
Check class invariants.
virtual String name(Bool stripPath=False) const
Returns the name of the disk file.
virtual void resize(const TiledShape &newShape)
Function which changes the shape of the FITSQualityImage.
Bool checkInput()
Make sure the input is compatible.
virtual void setMaximumCacheSize(uInt howManyPixels)
Set the maximum (allowed) cache size as indicated.
virtual uInt advisedMaxPixels() const
Returns the maximum recommended number of pixels for a cursor.
uInt whichErrorHDU() const
Return the error HDU number.
Define the shape and tile shape.
Definition: TiledShape.h:99
void getExtInfo()
Get the extension indices from an extension expression.
A base class for astronomical images.
virtual ImageInterface< Float > * cloneII() const
Make a copy of the object with new (reference semantics).
virtual Bool isWritable() const
The FITSImage is not writable.
virtual IPosition doNiceCursorShape(uInt maxPixels) const
Help the user pick a cursor for most efficient access if they only want pixel values and don&#39;t care a...
virtual uInt maximumCacheSize() const
Maximum size - not necessarily all used.
void reopenIfNeeded() const
Reopen the image if needed.
virtual void tempCloseError()
FITSErrorImage * fitsError() const
Get the FITS error.
virtual Bool doGetMaskSlice(Array< Bool > &buffer, const Slicer &section)
Do the actual get of the mask data.
virtual void doPutSlice(const Array< Float > &sourceBuffer, const IPosition &where, const IPosition &stride)
The FITSQualityImage is not writable, so this throws an exception.
virtual void tempClose()
Temporarily close the image.
virtual const Lattice< Bool > & pixelMask() const
Get access to the pixelmask.
FITSImage * fitsData() const
Get the FITS data.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual Bool hasPixelMask() const
FITSQualityImage always has a pixel mask so returns True.
ErrorType
The enum describes which types of error images exist.
virtual void setCacheSizeInTiles(uInt howManyTiles)
Set the actual cache size for this Array to be be big enough for the indicated number of tiles...
Class providing native access to FITS Quality Images.
virtual void clearCache()
Clears and frees up the caches, but the maximum allowed cache size is unchanged from when setCacheSiz...
virtual void showCacheStatistics(ostream &os) const
Report on cache success.
const Bool False
Definition: aipstype.h:44
Class providing native access to FITS images.
Definition: FITSImage.h:108
A hierarchical collection of named fields of various types.
Definition: TableRecord.h:182
const TableRecord & miscInfo() const
Often we have miscellaneous information we want to attach to an image.
Specify which elements to extract from an n-dimensional array.
Definition: Slicer.h:289
FITSQualityImage & operator=(const FITSQualityImage &other)
Assignment (reference semantics).
virtual void reopen()
Reopen a temporarily closed image.
~FITSQualityImage()
Destructor.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
An optionally strided region in a Lattice.
Definition: LatticeRegion.h:74
FITSErrorImage::ErrorType errType_p
virtual Bool isMasked() const
Has the object really a mask? The FITSQualityImage always has a pixel mask and never has a region mas...
unsigned int uInt
Definition: aipstype.h:51
uInt whichDataHDU() const
Return the data HDU number.
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42