casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
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.
106  MIRIADImage(const String& name, const MaskSpecifier&);
107 
108  // Copy constructor (reference semantics)
109  MIRIADImage(const MIRIADImage& other);
110 
111  // Destructor does nothing
112  ~MIRIADImage();
113 
114  // Assignment (reference semantics)
115  MIRIADImage& operator=(const MIRIADImage& other);
116 
117  // Function to open a MIRIAD image.
118  static LatticeBase* openMIRIADImage (const String& name,
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;
169  virtual Lattice<Bool>& pixelMask();
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>
291  void crackHeader (CoordinateSystem& cSys,
292  IPosition& shape, ImageInfo& imageInfo,
293  Unit& brightnessUnit, Record& miscInfo,
294  LogIO&os);
295 
296 // </group>
297 };
298 
299 
300 
301 } //# NAMESPACE CASACORE - END
302 
303 #endif
void setup()
Setup the object (used by constructors).
virtual Bool setUnits(const Unit &newUnits)
Function which get and set the units associated with the image pixels (i.e.
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:118
virtual const LatticeRegion * getRegionPtr() const
Get the region used.
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
Class providing native access to MIRIAD images.
Definition: MIRIADImage.h:99
virtual void clearCache()
Clears and frees up the caches, but the maximum allowed cache size is unchanged from when setCacheSiz...
virtual Bool setMiscInfo(const RecordInterface &newInfo)
virtual const Unit & units() const
virtual uInt maximumCacheSize() const
Maximum size - not necessarily all used.
virtual Bool isMasked() const
Has the object really a mask? The MIRIADImage always has a pixel mask and never has a region mask so ...
virtual Bool isWritable() const
The MIRIADImage is not writable.
TiledShape shape_p
Float scale_p; Float offset_p; Short magic_p;.
Definition: MIRIADImage.h:268
virtual void resize(const TiledShape &newShape)
Function which changes the shape of the MIRIADImage.
void crackHeader(CoordinateSystem &cSys, IPosition &shape, ImageInfo &imageInfo, Unit &brightnessUnit, Record &miscInfo, LogIO &os)
virtual uInt advisedMaxPixels() const
Returns the maximum recommended number of pixels for a cursor.
A non-templated, abstract base class for array-like objects.
Definition: LatticeBase.h:80
virtual const Lattice< Bool > & pixelMask() const
Get access to the pixelmask.
ostream-like interface to creating log messages.
Definition: LogIO.h:167
virtual void showCacheStatistics(ostream &os) const
Report on cache success.
virtual Bool doGetSlice(Array< Float > &buffer, const Slicer &theSlice)
Do the actual get of the data.
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 Bool hasPixelMask() const
MIRIADimage always has a pixel mask so should return True.
static void registerOpenFunction()
Register the open function.
MIRIADImage & operator=(const MIRIADImage &other)
Assignment (reference semantics)
defines physical units
Definition: Unit.h:189
virtual Bool isPersistent() const
The lattice is persistent.
void open()
Open the image (used by setup and reopen).
void getImageAttributes(CoordinateSystem &cSys, IPosition &shape, ImageInfo &info, Unit &brightnessUnit, Record &miscInfo, Bool &hasBlanks, const String &name)
Fish things out of the MIRIAD file.
Define the shape and tile shape.
Definition: TiledShape.h:96
static LatticeBase * openMIRIADImage(const String &name, const MaskSpecifier &)
Function to open a MIRIAD image.
virtual void doPutSlice(const Array< Float > &sourceBuffer, const IPosition &where, const IPosition &stride)
The MIRIADImage is not writable, so this throws an exception.
MaskSpecifier maskSpec_p
Definition: MIRIADImage.h:260
Referenced counted pointer for constant data.
Definition: CountedPtr.h:80
A base class for astronomical images.
Class to specify which mask to use in an image.
Definition: MaskSpecifier.h:69
virtual IPosition shape() const
return the shape of the MIRIADImage
virtual void setMaximumCacheSize(uInt howManyPixels)
Set the maximum (allowed) cache size as indicated.
void reopenIfNeeded() const
Reopen the image if needed.
Definition: MIRIADImage.h:275
virtual String name(Bool stripPath=False) const
Returns the name of the disk file.
virtual void tempClose()
Temporarily close the image.
MIRIADImage(const String &name)
Construct a MIRIADImage from the disk MIRIAD dataset name and apply mask.
virtual ImageInterface< Float > * cloneII() const
Make a copy of the object with new (reference semantics).
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
DataType dataType() const
Return the (internal) data type (TpFloat or TpShort).
Definition: MIRIADImage.h:228
~MIRIADImage()
Destructor does nothing.
const ImageInfo & imageInfo() const
The ImageInfo object contains some miscellaneous information about the image which unlike that stored...
const Bool False
Definition: aipstype.h:44
virtual const RecordInterface & miscInfo() const
Functions which get and set the units associated with the image pixels (i.e.
Specify which elements to extract from an n-dimensional array.
Definition: Slicer.h:288
virtual String imageType() const
Get the image type (returns MIRIADImage).
CountedPtr< TiledFileAccess > pTiledFile_p
Definition: MIRIADImage.h:263
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.
String: the storage and methods of handling collections of characters.
Definition: String.h:225
virtual void reopen()
Reopen a temporarily closed image.
An optionally strided region in a Lattice.
Definition: LatticeRegion.h:74
Abstract base class for Record classes.
virtual Bool isPaged() const
The lattice is paged to disk.
Miscellaneous information related to an image.
Definition: ImageInfo.h:92
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 doGetMaskSlice(Array< Bool > &buffer, const Slicer &section)
Do the actual get of the mask data.
Interconvert pixel and world coordinates.
unsigned int uInt
Definition: aipstype.h:51
Lattice< Bool > * pPixelMask_p
Definition: MIRIADImage.h:264
virtual Bool ok() const
Check class invariants.