casacore
MIRIADImage.h
Go to the documentation of this file.
1 //# MIRIADImage.h: Class providing native access to MIRIAD images
2 //# Copyright (C) 2001
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_MIRIADIMAGE_H
29 #define IMAGES_MIRIADIMAGE_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
34 #include <casacore/images/Images/ImageInterface.h>
35 #include <casacore/images/Images/MaskSpecifier.h>
36 #include <casacore/tables/DataMan/TiledFileAccess.h>
37 #include <casacore/lattices/Lattices/TiledShape.h>
38 #include <casacore/casa/Arrays/ArrayFwd.h>
39 #include <casacore/casa/Containers/Record.h>
40 #include <casacore/casa/BasicSL/String.h>
41 #include <casacore/casa/Utilities/DataType.h>
42 
43 
44 namespace casacore { //# NAMESPACE CASACORE - BEGIN
45 
46 //# Forward Declarations
47 template <class T> class Lattice;
48 //
49 class MaskSpecifier;
50 class IPosition;
51 class Slicer;
52 class CoordinateSystem;
53 class FITSMask;
54 class FitsInput;
55 
56 
57 // <summary>
58 // Class providing native access to MIRIAD images.
59 // </summary>
60 
61 // <use visibility=export>
62 
63 // <reviewed reviewer="" date="" tests="tMIRIADImage.cc">
64 // </reviewed>
65 
66 // <prerequisite>
67 // <li> <linkto class=ImageInterface>ImageInterface</linkto>
68 // <li> <linkto class=FITSMask>FITSMask</linkto>
69 // </prerequisite>
70 
71 // <etymology>
72 // This class provides native access to MIRIAD images.
73 // </etymology>
74 
75 // <synopsis>
76 // A MIRIADImage provides native access to MIRIAD images by accessing them
77 // with the TiledFileAccess class. -- or -- the native miriad I/O routines.
78 // The MIRIADImage is read only. -- really -- ??
79 //
80 // </synopsis>
81 
82 // <example>
83 // <srcblock>
84 // MIRIADImage im("cube1");
85 // LogIO logger(or);
86 // ImageStatistics<Float> stats(im, logger);
87 // Bool ok = stats.display(); // Display statistics
88 // </srcblock>
89 // </example>
90 
91 // <motivation>
92 // This provides native access to MIRIAD images.
93 // </motivation>
94 
95 //# <todo asof="2001/09/10">
96 //# </todo>
97 
98 
99 class MIRIADImage: public ImageInterface<Float>
100 {
101 public:
102  // Construct a MIRIADImage from the disk MIRIAD dataset name and apply mask.
103  explicit MIRIADImage(const String& name);
104 
105  // Construct a MIRIADImage from the disk MIRIAD file name and apply mask or not.
107 
108  // Copy constructor (reference semantics)
109  MIRIADImage(const MIRIADImage& other);
110 
111  // Destructor does nothing
113 
114  // Assignment (reference semantics)
116 
117  // Function to open a MIRIAD image.
119  const MaskSpecifier&);
120 
121  // Register the open function.
122  static void registerOpenFunction();
123 
124  //# ImageInterface virtual functions
125 
126  // Make a copy of the object with new (reference semantics).
127  virtual ImageInterface<Float>* cloneII() const;
128 
129  // Get the image type (returns MIRIADImage).
130  virtual String imageType() const;
131 
132  // Function which changes the shape of the MIRIADImage.
133  // Throws an exception as MIRIADImage is not writable.
134  virtual void resize(const TiledShape& newShape);
135 
136  // Functions which get and set the units associated with the image
137  // pixels (i.e. the "brightness" unit). Initially the unit is empty.
138  // Although the MIRIADimage is not writable, you can change the
139  // unit in the MIRIADImage object, but it will not be changed
140  // in the MIRIAD disk file.
141  // <group>
142 #if 0
143  virtual Bool setUnits(const Unit& newUnits);
144  virtual Unit units() const;
145 #endif
146  // </group>
147 
148  // Often we have miscellaneous information we want to attach to an image.
149  // Although MIRIADImage is not writable, you can set a new
150  // MiscInfo record, but it will not be stored with the MIRIAD file
151  // <group>
152  virtual const RecordInterface &miscInfo() const;
153  virtual Bool setMiscInfo(const RecordInterface &newInfo);
154  // </group>
155 
156  //# MaskedLattice virtual functions
157 
158  // Has the object really a mask? The MIRIADImage always
159  // has a pixel mask and never has a region mask so this
160  // should always return True
161  virtual Bool isMasked() const;
162 
163  // MIRIADimage always has a pixel mask so should return True
164  virtual Bool hasPixelMask() const;
165 
166  // Get access to the pixelmask. MIRIADImage always has a pixel mask.
167  // <group>
168  virtual const Lattice<Bool>& pixelMask() const;
170  // </group>
171 
172  // Do the actual get of the mask data. The return value is always
173  // False, thus the buffer does not reference another array.
174  virtual Bool doGetMaskSlice (Array<Bool>& buffer, const Slicer& section);
175 
176  // Get the region used. There is no region.
177  // Always returns 0.
178  virtual const LatticeRegion* getRegionPtr() const;
179 
180 
181  //# Lattice virtual functions
182 
183  // Do the actual get of the data.
184  // Returns False as the data do not reference another Array
185  virtual Bool doGetSlice (Array<Float>& buffer, const Slicer& theSlice);
186 
187  // The MIRIADImage is not writable, so this throws an exception.
188  virtual void doPutSlice (const Array<Float>& sourceBuffer,
189  const IPosition& where,
190  const IPosition& stride);
191 
192  //# LatticeBase virtual functions
193 
194  // The lattice is paged to disk.
195  virtual Bool isPaged() const;
196 
197  // The lattice is persistent.
198  virtual Bool isPersistent() const;
199 
200  // The MIRIADImage is not writable.
201  virtual Bool isWritable() const;
202 
203  // Returns the name of the disk file.
204  virtual String name (Bool stripPath=False) const;
205 
206  // return the shape of the MIRIADImage
207  virtual IPosition shape() const;
208 
209  // Returns the maximum recommended number of pixels for a cursor. This is
210  // the number of pixels in a tile.
211  virtual uInt advisedMaxPixels() const;
212 
213  // Help the user pick a cursor for most efficient access if they only want
214  // pixel values and don't care about the order or dimension of the
215  // cursor.
216  virtual IPosition doNiceCursorShape (uInt maxPixels) const;
217 
218  // Temporarily close the image.
219  virtual void tempClose();
220 
221  // Reopen a temporarily closed image.
222  virtual void reopen();
223 
224  // Check class invariants.
225  virtual Bool ok() const;
226 
227  // Return the (internal) data type (TpFloat or TpShort).
228  DataType dataType () const
229  { return dataType_p; }
230 
231  // Maximum size - not necessarily all used. In pixels.
232  virtual uInt maximumCacheSize() const;
233 
234  // Set the maximum (allowed) cache size as indicated.
235  virtual void setMaximumCacheSize (uInt howManyPixels);
236 
237  // Set the cache size as to "fit" the indicated path.
238  virtual void setCacheSizeFromPath (const IPosition& sliceShape,
239  const IPosition& windowStart,
240  const IPosition& windowLength,
241  const IPosition& axisPath);
242 
243  // Set the actual cache size for this Array to be be big enough for the
244  // indicated number of tiles. This cache is not shared with PagedArrays
245  // in other rows and is always clipped to be less than the maximum value
246  // set using the setMaximumCacheSize member function.
247  // tiles. Tiles are cached using a first in first out algorithm.
248  virtual void setCacheSizeInTiles (uInt howManyTiles);
249 
250  // Clears and frees up the caches, but the maximum allowed cache size is
251  // unchanged from when setCacheSize was called
252  virtual void clearCache();
253 
254  // Report on cache success.
255  virtual void showCacheStatistics (ostream& os) const;
256 
257 private:
258  String name_p; // filename, as given
259  Int tno_p; // miriad file handle
265  // Float scale_p;
266  // Float offset_p;
267  // Short magic_p;
270  DataType dataType_p; // always float's for miriad
271  Int64 fileOffset_p; // always 4 for direct (tiled) access
273 
274 // Reopen the image if needed.
275  void reopenIfNeeded() const
276  { if (isClosed_p) const_cast<MIRIADImage*>(this)->reopen(); }
277 
278 // Setup the object (used by constructors).
279  void setup();
280 
281 // Open the image (used by setup and reopen).
282  void open();
283 
284 // Fish things out of the MIRIAD file
286  IPosition& shape, ImageInfo& info,
287  Unit& brightnessUnit, Record& miscInfo,
288  Bool& hasBlanks, const String& name);
289 
290 // <group>
293  Unit& brightnessUnit, Record& miscInfo,
294  LogIO&os);
295 
296 // </group>
297 };
298 
299 
300 
301 } //# NAMESPACE CASACORE - END
302 
303 #endif
Referenced counted pointer for constant data.
Definition: CountedPtr.h:81
virtual Bool setUnits(const Unit &newUnits)
Function which get and set the units associated with the image pixels (i.e.
const ImageInfo & imageInfo() const
The ImageInfo object contains some miscellaneous information about the image which unlike that stored...
virtual const Unit & units() const
virtual const Lattice< Bool > & pixelMask() const
Get access to the pixelmask.
virtual Bool isWritable() const
The MIRIADImage is not writable.
virtual void reopen()
Reopen a temporarily closed image.
virtual Bool setMiscInfo(const RecordInterface &newInfo)
static LatticeBase * openMIRIADImage(const String &name, const MaskSpecifier &)
Function to open a MIRIAD image.
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...
virtual void setMaximumCacheSize(uInt howManyPixels)
Set the maximum (allowed) cache size as indicated.
virtual void doPutSlice(const Array< Float > &sourceBuffer, const IPosition &where, const IPosition &stride)
The MIRIADImage is not writable, so this throws an exception.
virtual void setCacheSizeInTiles(uInt howManyTiles)
Set the actual cache size for this Array to be be big enough for the indicated number of tiles.
virtual Bool hasPixelMask() const
MIRIADimage always has a pixel mask so should return True.
virtual void resize(const TiledShape &newShape)
Function which changes the shape of the MIRIADImage.
virtual uInt advisedMaxPixels() const
Returns the maximum recommended number of pixels for a cursor.
virtual void clearCache()
Clears and frees up the caches, but the maximum allowed cache size is unchanged from when setCacheSiz...
DataType dataType() const
Return the (internal) data type (TpFloat or TpShort).
Definition: MIRIADImage.h:228
virtual String name(Bool stripPath=False) const
Returns the name of the disk file.
virtual const RecordInterface & miscInfo() const
Functions which get and set the units associated with the image pixels (i.e.
Lattice< Bool > * pPixelMask_p
Definition: MIRIADImage.h:264
virtual void tempClose()
Temporarily close the image.
MIRIADImage(const MIRIADImage &other)
Copy constructor (reference semantics)
virtual Bool isPaged() const
The lattice is paged to disk.
virtual ImageInterface< Float > * cloneII() const
Make a copy of the object with new (reference semantics).
virtual Bool doGetMaskSlice(Array< Bool > &buffer, const Slicer &section)
Do the actual get of the mask data.
void getImageAttributes(CoordinateSystem &cSys, IPosition &shape, ImageInfo &info, Unit &brightnessUnit, Record &miscInfo, Bool &hasBlanks, const String &name)
Fish things out of the MIRIAD file.
MIRIADImage(const String &name)
Construct a MIRIADImage from the disk MIRIAD dataset name and apply mask.
MIRIADImage(const String &name, const MaskSpecifier &)
Construct a MIRIADImage from the disk MIRIAD file name and apply mask or not.
virtual const LatticeRegion * getRegionPtr() const
Get the region used.
virtual Lattice< Bool > & pixelMask()
virtual Bool isMasked() const
Has the object really a mask? The MIRIADImage always has a pixel mask and never has a region mask so ...
TiledShape shape_p
Float scale_p; Float offset_p; Short magic_p;.
Definition: MIRIADImage.h:268
CountedPtr< TiledFileAccess > pTiledFile_p
Definition: MIRIADImage.h:263
virtual Bool isPersistent() const
The lattice is persistent.
MIRIADImage & operator=(const MIRIADImage &other)
Assignment (reference semantics)
MaskSpecifier maskSpec_p
Definition: MIRIADImage.h:260
virtual IPosition shape() const
return the shape of the MIRIADImage
virtual uInt maximumCacheSize() const
Maximum size - not necessarily all used.
void reopenIfNeeded() const
Reopen the image if needed.
Definition: MIRIADImage.h:275
void open()
Open the image (used by setup and reopen).
static void registerOpenFunction()
Register the open function.
void setup()
Setup the object (used by constructors).
virtual Bool ok() const
Check class invariants.
~MIRIADImage()
Destructor does nothing.
void crackHeader(CoordinateSystem &cSys, IPosition &shape, ImageInfo &imageInfo, Unit &brightnessUnit, Record &miscInfo, LogIO &os)
virtual Bool doGetSlice(Array< Float > &buffer, const Slicer &theSlice)
Do the actual get of the data.
virtual String imageType() const
Get the image type (returns MIRIADImage).
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.
virtual void showCacheStatistics(ostream &os) const
Report on cache success.
String: the storage and methods of handling collections of characters.
Definition: String.h:225
this file contains all the compiler specific defines
Definition: mainpage.dox:28
const Bool False
Definition: aipstype.h:44
unsigned int uInt
Definition: aipstype.h:51
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
Definition: aipsxtype.h:38
int Int
Definition: aipstype.h:50
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42