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