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