Loading...
Searching...
No Matches
MIRIADImage.h
Go to the documentation of this file.
//# MIRIADImage.h: Class providing native access to MIRIAD images
//# Copyright (C) 2001
//# Associated Universities, Inc. Washington DC, USA.
//#
//# This library is free software; you can redistribute it and/or modify it
//# under the terms of the GNU Library General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or (at your
//# option) any later version.
//#
//# This library is distributed in the hope that it will be useful, but WITHOUT
//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
//# License for more details.
//#
//# You should have received a copy of the GNU Library General Public License
//# along with this library; if not, write to the Free Software Foundation,
//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
//#
//# Correspondence concerning AIPS++ should be addressed as follows:
//# Internet email: casa-feedback@nrao.edu.
//# Postal address: AIPS++ Project Office
//# National Radio Astronomy Observatory
//# 520 Edgemont Road
//# Charlottesville, VA 22903-2475 USA
#ifndef IMAGES_MIRIADIMAGE_H
#define IMAGES_MIRIADIMAGE_H
//# Includes
#include <casacore/casa/aips.h>
#include <casacore/images/Images/ImageInterface.h>
#include <casacore/images/Images/MaskSpecifier.h>
#include <casacore/tables/DataMan/TiledFileAccess.h>
#include <casacore/lattices/Lattices/TiledShape.h>
#include <casacore/casa/Arrays/ArrayFwd.h>
#include <casacore/casa/Containers/Record.h>
#include <casacore/casa/BasicSL/String.h>
#include <casacore/casa/Utilities/DataType.h>
namespace casacore { //# NAMESPACE CASACORE - BEGIN
//# Forward Declarations
template <class T> class Lattice;
//
class MaskSpecifier;
class IPosition;
class Slicer;
class CoordinateSystem;
class FITSMask;
class FitsInput;
// <summary>
// Class providing native access to MIRIAD images.
// </summary>
// <use visibility=export>
// <reviewed reviewer="" date="" tests="tMIRIADImage.cc">
// </reviewed>
// <prerequisite>
// <li> <linkto class=ImageInterface>ImageInterface</linkto>
// <li> <linkto class=FITSMask>FITSMask</linkto>
// </prerequisite>
// <etymology>
// This class provides native access to MIRIAD images.
// </etymology>
// <synopsis>
// A MIRIADImage provides native access to MIRIAD images by accessing them
// with the TiledFileAccess class. -- or -- the native miriad I/O routines.
// The MIRIADImage is read only. -- really -- ??
//
// </synopsis>
// <example>
// <srcblock>
// MIRIADImage im("cube1");
// LogIO logger(or);
// ImageStatistics<Float> stats(im, logger);
// Bool ok = stats.display(); // Display statistics
// </srcblock>
// </example>
// <motivation>
// This provides native access to MIRIAD images.
// </motivation>
//# <todo asof="2001/09/10">
//# </todo>
class MIRIADImage: public ImageInterface<Float>
{
public:
// Construct a MIRIADImage from the disk MIRIAD dataset name and apply mask.
explicit MIRIADImage(const String& name);
// Construct a MIRIADImage from the disk MIRIAD file name and apply mask or not.
MIRIADImage(const String& name, const MaskSpecifier&);
// Copy constructor (reference semantics)
MIRIADImage(const MIRIADImage& other);
// Destructor does nothing
~MIRIADImage();
// Assignment (reference semantics)
MIRIADImage& operator=(const MIRIADImage& other);
// Function to open a MIRIAD image.
static LatticeBase* openMIRIADImage (const String& name,
const MaskSpecifier&);
// Register the open function.
static void registerOpenFunction();
//# ImageInterface virtual functions
// Make a copy of the object with new (reference semantics).
virtual ImageInterface<Float>* cloneII() const;
// Get the image type (returns MIRIADImage).
virtual String imageType() const;
// Function which changes the shape of the MIRIADImage.
// Throws an exception as MIRIADImage is not writable.
virtual void resize(const TiledShape& newShape);
// Functions which get and set the units associated with the image
// pixels (i.e. the "brightness" unit). Initially the unit is empty.
// Although the MIRIADimage is not writable, you can change the
// unit in the MIRIADImage object, but it will not be changed
// in the MIRIAD disk file.
// <group>
#if 0
virtual Bool setUnits(const Unit& newUnits);
virtual Unit units() const;
#endif
// </group>
// Often we have miscellaneous information we want to attach to an image.
// Although MIRIADImage is not writable, you can set a new
// MiscInfo record, but it will not be stored with the MIRIAD file
// <group>
virtual const RecordInterface &miscInfo() const;
virtual Bool setMiscInfo(const RecordInterface &newInfo);
// </group>
//# MaskedLattice virtual functions
// Has the object really a mask? The MIRIADImage always
// has a pixel mask and never has a region mask so this
// should always return True
virtual Bool isMasked() const;
// MIRIADimage always has a pixel mask so should return True
virtual Bool hasPixelMask() const;
// Get access to the pixelmask. MIRIADImage always has a pixel mask.
// <group>
virtual const Lattice<Bool>& pixelMask() const;
virtual Lattice<Bool>& pixelMask();
// </group>
// Do the actual get of the mask data. The return value is always
// False, thus the buffer does not reference another array.
virtual Bool doGetMaskSlice (Array<Bool>& buffer, const Slicer& section);
// Get the region used. There is no region.
// Always returns 0.
virtual const LatticeRegion* getRegionPtr() const;
//# Lattice virtual functions
// Do the actual get of the data.
// Returns False as the data do not reference another Array
virtual Bool doGetSlice (Array<Float>& buffer, const Slicer& theSlice);
// The MIRIADImage is not writable, so this throws an exception.
virtual void doPutSlice (const Array<Float>& sourceBuffer,
const IPosition& where,
const IPosition& stride);
//# LatticeBase virtual functions
// The lattice is paged to disk.
virtual Bool isPaged() const;
// The lattice is persistent.
virtual Bool isPersistent() const;
// The MIRIADImage is not writable.
virtual Bool isWritable() const;
// Returns the name of the disk file.
virtual String name (Bool stripPath=False) const;
// return the shape of the MIRIADImage
virtual IPosition shape() const;
// Returns the maximum recommended number of pixels for a cursor. This is
// the number of pixels in a tile.
virtual uInt advisedMaxPixels() const;
// Help the user pick a cursor for most efficient access if they only want
// pixel values and don't care about the order or dimension of the
// cursor.
virtual IPosition doNiceCursorShape (uInt maxPixels) const;
// Temporarily close the image.
virtual void tempClose();
// Reopen a temporarily closed image.
virtual void reopen();
// Check class invariants.
virtual Bool ok() const;
// Return the (internal) data type (TpFloat or TpShort).
DataType dataType () const
{ return dataType_p; }
// Maximum size - not necessarily all used. In pixels.
virtual uInt maximumCacheSize() const;
// Set the maximum (allowed) cache size as indicated.
virtual void setMaximumCacheSize (uInt howManyPixels);
// Set the cache size as to "fit" the indicated path.
virtual void setCacheSizeFromPath (const IPosition& sliceShape,
const IPosition& windowStart,
const IPosition& windowLength,
const IPosition& axisPath);
// Set the actual cache size for this Array to be be big enough for the
// indicated number of tiles. This cache is not shared with PagedArrays
// in other rows and is always clipped to be less than the maximum value
// set using the setMaximumCacheSize member function.
// tiles. Tiles are cached using a first in first out algorithm.
virtual void setCacheSizeInTiles (uInt howManyTiles);
// Clears and frees up the caches, but the maximum allowed cache size is
// unchanged from when setCacheSize was called
virtual void clearCache();
// Report on cache success.
virtual void showCacheStatistics (ostream& os) const;
private:
String name_p; // filename, as given
Int tno_p; // miriad file handle
MaskSpecifier maskSpec_p;
Unit unit_p;
Record rec_p;
std::shared_ptr<TiledFileAccess> pTiledFile_p;
Lattice<Bool>* pPixelMask_p;
// Float scale_p;
// Float offset_p;
// Short magic_p;
TiledShape shape_p;
Bool hasBlanks_p;
DataType dataType_p; // always float's for miriad
Int64 fileOffset_p; // always 4 for direct (tiled) access
Bool isClosed_p;
// Reopen the image if needed.
void reopenIfNeeded() const
{ if (isClosed_p) const_cast<MIRIADImage*>(this)->reopen(); }
// Setup the object (used by constructors).
void setup();
// Open the image (used by setup and reopen).
void open();
// Fish things out of the MIRIAD file
void getImageAttributes (CoordinateSystem& cSys,
IPosition& shape, ImageInfo& info,
Unit& brightnessUnit, Record& miscInfo,
Bool& hasBlanks, const String& name);
// <group>
void crackHeader (CoordinateSystem& cSys,
IPosition& shape, ImageInfo& imageInfo,
Unit& brightnessUnit, Record& miscInfo,
LogIO&os);
// </group>
};
} //# NAMESPACE CASACORE - END
#endif
casacore::Array
Definition Array.h:155
casacore::CoordinateSystem
Definition CoordinateSystem.h:215
casacore::FITSMask
Definition FITSMask.h:95
casacore::FitsInput
fixed-length sequential blocked FITS input
Definition fitsio.h:154
casacore::IPosition
Definition IPosition.h:117
casacore::ImageInfo
Definition ImageInfo.h:90
casacore::ImageInterface< Float >::setUnits
virtual Bool setUnits(const Unit &newUnits)
casacore::ImageInterface< Float >::units
virtual const Unit & units() const
Definition ImageInterface.h:180
casacore::ImageInterface< Float >::imageInfo
const ImageInfo & imageInfo() const
Definition ImageInterface.h:238
casacore::ImageInterface< Float >::ImageInterface
ImageInterface()
casacore::LatticeBase
Definition LatticeBase.h:79
casacore::LatticeRegion
Definition LatticeRegion.h:72
casacore::Lattice
Definition Lattice.h:230
casacore::LogIO
Definition LogIO.h:165
casacore::MIRIADImage::isWritable
virtual Bool isWritable() const
The MIRIADImage is not writable.
casacore::MIRIADImage::reopen
virtual void reopen()
Reopen a temporarily closed image.
casacore::MIRIADImage::setMiscInfo
virtual Bool setMiscInfo(const RecordInterface &newInfo)
casacore::MIRIADImage::doNiceCursorShape
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...
casacore::MIRIADImage::isClosed_p
Bool isClosed_p
Definition MIRIADImage.h:270
casacore::MIRIADImage::setMaximumCacheSize
virtual void setMaximumCacheSize(uInt howManyPixels)
Set the maximum (allowed) cache size as indicated.
casacore::MIRIADImage::doPutSlice
virtual void doPutSlice(const Array< Float > &sourceBuffer, const IPosition &where, const IPosition &stride)
The MIRIADImage is not writable, so this throws an exception.
casacore::MIRIADImage::setCacheSizeInTiles
virtual void setCacheSizeInTiles(uInt howManyTiles)
Set the actual cache size for this Array to be be big enough for the indicated number of tiles.
casacore::MIRIADImage::hasPixelMask
virtual Bool hasPixelMask() const
MIRIADimage always has a pixel mask so should return True.
casacore::MIRIADImage::operator=
MIRIADImage & operator=(const MIRIADImage &other)
Assignment (reference semantics).
casacore::MIRIADImage::resize
virtual void resize(const TiledShape &newShape)
Function which changes the shape of the MIRIADImage.
casacore::MIRIADImage::advisedMaxPixels
virtual uInt advisedMaxPixels() const
Returns the maximum recommended number of pixels for a cursor.
casacore::MIRIADImage::clearCache
virtual void clearCache()
Clears and frees up the caches, but the maximum allowed cache size is unchanged from when setCacheSiz...
casacore::MIRIADImage::dataType
DataType dataType() const
Return the (internal) data type (TpFloat or TpShort).
Definition MIRIADImage.h:226
casacore::MIRIADImage::dataType_p
DataType dataType_p
Definition MIRIADImage.h:268
casacore::MIRIADImage::name
virtual String name(Bool stripPath=False) const
Returns the name of the disk file.
casacore::MIRIADImage::pPixelMask_p
Lattice< Bool > * pPixelMask_p
Definition MIRIADImage.h:262
casacore::MIRIADImage::tempClose
virtual void tempClose()
Temporarily close the image.
casacore::MIRIADImage::MIRIADImage
MIRIADImage(const MIRIADImage &other)
Copy constructor (reference semantics).
casacore::MIRIADImage::pixelMask
virtual Lattice< Bool > & pixelMask()
casacore::MIRIADImage::isPaged
virtual Bool isPaged() const
The lattice is paged to disk.
casacore::MIRIADImage::doGetMaskSlice
virtual Bool doGetMaskSlice(Array< Bool > &buffer, const Slicer &section)
Do the actual get of the mask data.
casacore::MIRIADImage::fileOffset_p
Int64 fileOffset_p
Definition MIRIADImage.h:269
casacore::MIRIADImage::getImageAttributes
void getImageAttributes(CoordinateSystem &cSys, IPosition &shape, ImageInfo &info, Unit &brightnessUnit, Record &miscInfo, Bool &hasBlanks, const String &name)
Fish things out of the MIRIAD file.
casacore::MIRIADImage::MIRIADImage
MIRIADImage(const String &name)
Construct a MIRIADImage from the disk MIRIAD dataset name and apply mask.
casacore::MIRIADImage::MIRIADImage
MIRIADImage(const String &name, const MaskSpecifier &)
Construct a MIRIADImage from the disk MIRIAD file name and apply mask or not.
casacore::MIRIADImage::miscInfo
virtual const RecordInterface & miscInfo() const
Functions which get and set the units associated with the image pixels (i.e.
casacore::MIRIADImage::pixelMask
virtual const Lattice< Bool > & pixelMask() const
Get access to the pixelmask.
casacore::MIRIADImage::isMasked
virtual Bool isMasked() const
Has the object really a mask?
casacore::MIRIADImage::rec_p
Record rec_p
Definition MIRIADImage.h:260
casacore::MIRIADImage::shape_p
TiledShape shape_p
Float scale_p; Float offset_p; Short magic_p;.
Definition MIRIADImage.h:266
casacore::MIRIADImage::name_p
String name_p
Definition MIRIADImage.h:256
casacore::MIRIADImage::isPersistent
virtual Bool isPersistent() const
The lattice is persistent.
casacore::MIRIADImage::maskSpec_p
MaskSpecifier maskSpec_p
Definition MIRIADImage.h:258
casacore::MIRIADImage::shape
virtual IPosition shape() const
return the shape of the MIRIADImage
casacore::MIRIADImage::openMIRIADImage
static LatticeBase * openMIRIADImage(const String &name, const MaskSpecifier &)
Function to open a MIRIAD image.
casacore::MIRIADImage::maximumCacheSize
virtual uInt maximumCacheSize() const
Maximum size - not necessarily all used.
casacore::MIRIADImage::tno_p
Int tno_p
Definition MIRIADImage.h:257
casacore::MIRIADImage::hasBlanks_p
Bool hasBlanks_p
Definition MIRIADImage.h:267
casacore::MIRIADImage::reopenIfNeeded
void reopenIfNeeded() const
Reopen the image if needed.
Definition MIRIADImage.h:273
casacore::MIRIADImage::open
void open()
Open the image (used by setup and reopen).
casacore::MIRIADImage::cloneII
virtual ImageInterface< Float > * cloneII() const
Make a copy of the object with new (reference semantics).
casacore::MIRIADImage::unit_p
Unit unit_p
Definition MIRIADImage.h:259
casacore::MIRIADImage::registerOpenFunction
static void registerOpenFunction()
Register the open function.
casacore::MIRIADImage::getRegionPtr
virtual const LatticeRegion * getRegionPtr() const
Get the region used.
casacore::MIRIADImage::setup
void setup()
Setup the object (used by constructors).
casacore::MIRIADImage::ok
virtual Bool ok() const
Check class invariants.
casacore::MIRIADImage::pTiledFile_p
std::shared_ptr< TiledFileAccess > pTiledFile_p
Definition MIRIADImage.h:261
casacore::MIRIADImage::~MIRIADImage
~MIRIADImage()
Destructor does nothing.
casacore::MIRIADImage::crackHeader
void crackHeader(CoordinateSystem &cSys, IPosition &shape, ImageInfo &imageInfo, Unit &brightnessUnit, Record &miscInfo, LogIO &os)
casacore::MIRIADImage::doGetSlice
virtual Bool doGetSlice(Array< Float > &buffer, const Slicer &theSlice)
Do the actual get of the data.
casacore::MIRIADImage::imageType
virtual String imageType() const
Get the image type (returns MIRIADImage).
casacore::MIRIADImage::setCacheSizeFromPath
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.
casacore::MIRIADImage::showCacheStatistics
virtual void showCacheStatistics(ostream &os) const
Report on cache success.
casacore::MaskSpecifier
Definition MaskSpecifier.h:68
casacore::Slicer
Definition Slicer.h:287
casacore::String
String: the storage and methods of handling collections of characters.
Definition String.h:223
casacore::TiledShape
Definition TiledShape.h:95
casacore::Unit
Definition Unit.h:187
casacore::Record
Record()
casacore
this file contains all the compiler specific defines
Definition mainpage.dox:28
casacore::False
const Bool False
Definition aipstype.h:42
casacore::uInt
unsigned int uInt
Definition aipstype.h:49
casacore::Int64
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size).
Definition aipsxtype.h:36
casacore::RecordInterface
RecordInterface()
The default constructor creates an empty record with a variable structure.
casacore::Int
int Int
Definition aipstype.h:48
casacore::Bool
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40