casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
casacore::ImageProxy Class Reference

#include <ImageProxy.h>

Public Member Functions

 ImageProxy ()
 Default constructor is needed for Boost-Python. More...
 
 ImageProxy (const Vector< String > &names, Int axis)
 Construct from the concatenation of the images along the axis. More...
 
 ImageProxy (const String &name, const String &mask, const std::vector< ImageProxy > &images)
 Construct from a string that contains an image name or image expression. More...
 
 ImageProxy (const std::vector< ImageProxy > &images, Int axis, Int dummy1=0, Int dummy2=0)
 Construct from the concatenation of the image objects along the axis. More...
 
 ImageProxy (const ValueHolder &values, const ValueHolder &mask, const Record &coordinates, const String &imageName=String(), Bool overwrite=True, Bool asHDF5=False, const String &maskName=String(), const IPosition &tileShape=IPosition())
 Construct from a ValueHolder containing an Array of Float or Complex. More...
 
 ImageProxy (const IPosition &shape, const ValueHolder &value, const Record &coordinates, const String &imageName=String(), Bool overwrite=True, Bool asHDF5=False, const String &maskName=String(), const IPosition &tileShape=IPosition(), Int dummy=0)
 Construct from a shape. More...
 
 ImageProxy (const CountedPtr< LatticeBase > &)
 Construct from an existing image object. More...
 
 ImageProxy (const ImageProxy &)
 Copy constructor (reference semantics). More...
 
ImageProxyoperator= (const ImageProxy &)
 Assignment (reference semantics). More...
 
 ~ImageProxy ()
 
void close ()
 Close the image by setting all pointers to 0. More...
 
LatticeExprNode makeNode () const
 Turn the ImageProxy into a LatticeExprNode. More...
 
Bool isPersistent () const
 Is the image persistent or temporary. More...
 
String name (Bool stripPath=False) const
 Get the name of the image. More...
 
IPosition shape () const
 Get the shape of the image. More...
 
uInt ndim () const
 Get the dimensionality of the image. More...
 
uInt size () const
 Get the size of the image (nr of pixels). More...
 
String dataType () const
 Get the data type of the image. More...
 
DataType type () const
 
String imageType () const
 Get the image type (PagedImage, HDF5Image, etc.) More...
 
ValueHolder getData (const IPosition &blc, const IPosition &trc, const IPosition &inc)
 Get a chunk of data. More...
 
ValueHolder getMask (const IPosition &blc, const IPosition &trc, const IPosition &inc)
 Get a chunk of the mask. More...
 
void putData (const ValueHolder &, const IPosition &blc, const IPosition &inc)
 Put a chunk of data. More...
 
void putMask (const ValueHolder &value, const IPosition &blc, const IPosition &inc)
 Put a chunk of the mask. More...
 
Bool hasLock (Bool writeLock=False)
 Does the image have a read or write lock? More...
 
void lock (Bool writeLock=False, Int nattempts=0)
 Try to acquire a read or write lock. More...
 
void unlock ()
 Release the lock acquired by lock(). More...
 
Vector< StringattrGroupNames () const
 Get the names of the attribute groups. More...
 
void createAttrGroup (const String &groupName)
 Create a new attribute group. More...
 
Vector< StringattrNames (const String &groupName) const
 Get the names of all attributes in a group. More...
 
uInt attrNrows (const String &groupName) const
 Get the number of rows in an attribute group. More...
 
ValueHolder getAttr (const String &groupName, const String &attrName, uInt rownr) const
 Get the value of an attribute in a group row. More...
 
Record getAttrRow (const String &groupName, uInt rownr) const
 Get all attributes in a group row. More...
 
Vector< StringgetAttrUnit (const String &groupName, const String &attrName) const
 Get the unit(s) of an attribute in a group. More...
 
Vector< StringgetAttrMeas (const String &groupName, const String &attrName) const
 Get the measinfo of an attribute in a group. More...
 
void putAttr (const String &groupName, const String &attrName, uInt rownr, const ValueHolder &value, const Vector< String > &units, const Vector< String > &measInfo)
 Put the value, unit, and measinfo of an attribute in a group row. More...
 
ImageProxy subImage (const IPosition &blc, const IPosition &trc, const IPosition &inc, Bool dropDegenerate=True)
 Form a new (virtual) image being a subset of the image. More...
 
ImageProxy subImage2 (const IPosition &blc, const IPosition &trc, const IPosition &inc, Bool dropDegenerate, Bool preserveAxesOrder)
 Same with a new function name for backward compatibility with old pyrap. More...
 
String unit () const
 Get the brightness unit. More...
 
Record coordSys () const
 Get the coordinate system. More...
 
const CoordinateSystemcoordSysObject () const
 
Vector< DoubletoWorld (const Vector< Double > &pixel, Bool reverseAxes)
 Convert a pixel coordinate to world coordinate. More...
 
Vector< DoubletoPixel (const Vector< Double > &world, Bool reverseAxes)
 Convert a world coordinate to pixel coordinate. More...
 
Record imageInfo () const
 Get the image info. More...
 
const ImageInfoimageInfoObject () const
 
Record miscInfo () const
 Get the miscellaneous info. More...
 
Vector< Stringhistory () const
 Get the history. More...
 
void toFits (const String &fitsfile, Bool overwrite=True, Bool velocity=True, Bool optical=True, Int bitpix=-32, Double minpix=1, Double maxpix=-1) const
 Write the image in FITS format. More...
 
void saveAs (const String &fileName, Bool overwrite=True, Bool hdf5=False, Bool copyMask=True, const String &newMaskName=String(), const IPosition &newTileShape=IPosition()) const
 Write the image to an image file with the given name. More...
 
Record statistics (const Vector< Int > &axes, const String &mask, const ValueHolder &minMaxValues, Bool exclude=False, Bool robust=False) const
 Return the statistics for the given axes. More...
 
ImageProxy regrid (const Vector< Int > &axes=Vector< Int >(), const String &outfile=String(), Bool overwriteOutFile=True, const IPosition &outShape=IPosition(), const Record &coordSys=Record(), const String &method="linear", Int decimate=10, Bool replicate=False, Bool doRefChange=True, Bool forceRegrid=False)
 Regrid the image on the given axes to the given coordinate system. More...
 
LatticeBasegetLattice () const
 

Static Public Member Functions

static LatticeBaseopenImage (const String &name, const String &mask=String(), const std::vector< ImageProxy > &images=std::vector< ImageProxy >())
 Open the image (which can also be an expression). More...
 
static LatticeBaseopenImageOrExpr (const String &str, const MaskSpecifier &, const Block< LatticeExprNode > &nodes)
 Open an image in the file/table with the given name. More...
 
static IPosition adjustBlc (const IPosition &blc, const IPosition &shp)
 Check and adjust blc, trc, or inc using the shape. More...
 
static IPosition adjustTrc (const IPosition &trc, const IPosition &shp)
 
static IPosition adjustInc (const IPosition &inc, const IPosition &shp)
 

Private Member Functions

 ImageProxy (LatticeBase *)
 Form an ImageProxy object from an existing image object. More...
 
void checkNull () const
 Throw an exception if the object is null. More...
 
template<typename T >
void makeImage (const Array< T > &array, const Array< Bool > &mask, const IPosition &shape, const Record &coordinates, const String &fileName, Bool asHDF5, const String &maskName, const IPosition &tileShape)
 Make an image from an array or shape. More...
 
void concatImages (const std::vector< ImageProxy > &images, Int axis)
 Form a concatenated image. More...
 
void concatImagesFloat (const std::vector< ImageProxy > &images, Int axis)
 
void concatImagesDouble (const std::vector< ImageProxy > &images, Int axis)
 
void concatImagesComplex (const std::vector< ImageProxy > &images, Int axis)
 
void concatImagesDComplex (const std::vector< ImageProxy > &images, Int axis)
 
void setup ()
 Setup the pointers for the various image data types. More...
 
void setup (LatticeBase *lattice)
 Setup the pointers for the various image data types. More...
 
void centreRefPix (CoordinateSystem &cSys, const IPosition &shape) const
 Centre all axes except the Stokes one. More...
 
template<typename T >
void doPutMask (ImageInterface< T > &image, const ValueHolder &value, const IPosition &blc, const IPosition &inc)
 Put the mask and create it if needed. More...
 
template<typename T >
void saveImage (const String &fileName, Bool hdf5, Bool copyMask, const String &newMaskName, const IPosition &newTileShape, const ImageInterface< T > &image) const
 Copy the image to an image (PagedImage or HDF5Image) with the given name. More...
 
TiledShape makeTiledShape (const IPosition &newTileShape, const IPosition &shape, const IPosition &oldTileShape=IPosition()) const
 Form a tiled shape from the current shape and a possible new tile shape. More...
 
template<typename T >
Record makeStatistics (const ImageInterface< T > &image, const Vector< Int > &axes, const String &mask, const ValueHolder &minMaxValues, Bool exclude, Bool robust) const
 Calculate the statistics. More...
 
template<typename T >
ImageProxy doRegrid (const ImageInterface< T > &image, const Vector< Int > &axes, const String &outfile, const IPosition &shape, const Record &coordSys, const String &method, Int decimate, Bool replicate, Bool doRefChange, Bool force)
 Do the actual regridding. More...
 
CoordinateSystem makeCoordinateSystem (const Record &coordinates, const IPosition &shape) const
 Make a coordinate system from the Record. More...
 

Private Attributes

CountedPtr< LatticeBaseitsLattice
 
ImageInterface< Float > * itsImageFloat
 
ImageInterface< Double > * itsImageDouble
 
ImageInterface< Complex > * itsImageComplex
 
ImageInterface< DComplex > * itsImageDComplex
 
const CoordinateSystemitsCoordSys
 
ImageAttrHandleritsAttrHandler
 

Detailed Description

Synopsis

ImageProxy is a proxy to an image having data type Float, Double, Complex, or DComplex. Its primary purpose is to be bind the images module to Python through pyrap.images. However, it can also be used directly in C++.

An ImageProxy object can be constructed for an image stored on disk in Casacore, FITS, HDF5, or Miriad format. It can also be constructed given a shape or an N-dim array with values. Furthermore it can be constructed from a LEL expression (see class ImageExpr) or a vector of images to be concatenated (see class ImageConcat).

Many functions exist to operate on an ImageProxy object. For example:

Functions regrid and statistics can only be used for Float images. They throw an exception for images with other data types. Note that using a LEL expression it is possible to (virtually) convert an image with another type to a Float image.

Definition at line 76 of file ImageProxy.h.

Constructor & Destructor Documentation

casacore::ImageProxy::ImageProxy ( )

Default constructor is needed for Boost-Python.

casacore::ImageProxy::ImageProxy ( const Vector< String > &  names,
Int  axis 
)

Construct from the concatenation of the images along the axis.

The axis must be given as a Fortran-array axis. All images must be of the same data type.

casacore::ImageProxy::ImageProxy ( const String name,
const String mask,
const std::vector< ImageProxy > &  images 
)

Construct from a string that contains an image name or image expression.

It is opened using ImageOpener.

casacore::ImageProxy::ImageProxy ( const std::vector< ImageProxy > &  images,
Int  axis,
Int  dummy1 = 0,
Int  dummy2 = 0 
)

Construct from the concatenation of the image objects along the axis.

The axis must be given as a Fortran-array axis. All images must be of the same data type.

casacore::ImageProxy::ImageProxy ( const ValueHolder values,
const ValueHolder mask,
const Record coordinates,
const String imageName = String(),
Bool  overwrite = True,
Bool  asHDF5 = False,
const String maskName = String(),
const IPosition tileShape = IPosition() 
)

Construct from a ValueHolder containing an Array of Float or Complex.

If the name is empty it is created as a temporary image, otherwise as a PagedImage or HDF5Image. If the coordinates record is empty, default coordinates are used. A mask is created if the mask name or mask value is not empty.

casacore::ImageProxy::ImageProxy ( const IPosition shape,
const ValueHolder value,
const Record coordinates,
const String imageName = String(),
Bool  overwrite = True,
Bool  asHDF5 = False,
const String maskName = String(),
const IPosition tileShape = IPosition(),
Int  dummy = 0 
)

Construct from a shape.

If the name is empty it is created as a temporary image, otherwise as a PagedImage or HDF5Image. If the coordinates record is empty, default coordinates are used. A mask is created if the mask name is not empty.

casacore::ImageProxy::ImageProxy ( const CountedPtr< LatticeBase > &  )

Construct from an existing image object.

casacore::ImageProxy::ImageProxy ( const ImageProxy )

Copy constructor (reference semantics).

casacore::ImageProxy::~ImageProxy ( )
casacore::ImageProxy::ImageProxy ( LatticeBase )
explicitprivate

Form an ImageProxy object from an existing image object.

Member Function Documentation

static IPosition casacore::ImageProxy::adjustBlc ( const IPosition blc,
const IPosition shp 
)
static

Check and adjust blc, trc, or inc using the shape.

static IPosition casacore::ImageProxy::adjustInc ( const IPosition inc,
const IPosition shp 
)
static
static IPosition casacore::ImageProxy::adjustTrc ( const IPosition trc,
const IPosition shp 
)
static
Vector<String> casacore::ImageProxy::attrGroupNames ( ) const

Get the names of the attribute groups.

Vector<String> casacore::ImageProxy::attrNames ( const String groupName) const

Get the names of all attributes in a group.

uInt casacore::ImageProxy::attrNrows ( const String groupName) const

Get the number of rows in an attribute group.

void casacore::ImageProxy::centreRefPix ( CoordinateSystem cSys,
const IPosition shape 
) const
private

Centre all axes except the Stokes one.

void casacore::ImageProxy::checkNull ( ) const
private

Throw an exception if the object is null.

void casacore::ImageProxy::close ( )

Close the image by setting all pointers to 0.

void casacore::ImageProxy::concatImages ( const std::vector< ImageProxy > &  images,
Int  axis 
)
private

Form a concatenated image.

void casacore::ImageProxy::concatImagesComplex ( const std::vector< ImageProxy > &  images,
Int  axis 
)
private
void casacore::ImageProxy::concatImagesDComplex ( const std::vector< ImageProxy > &  images,
Int  axis 
)
private
void casacore::ImageProxy::concatImagesDouble ( const std::vector< ImageProxy > &  images,
Int  axis 
)
private
void casacore::ImageProxy::concatImagesFloat ( const std::vector< ImageProxy > &  images,
Int  axis 
)
private
Record casacore::ImageProxy::coordSys ( ) const

Get the coordinate system.

const CoordinateSystem& casacore::ImageProxy::coordSysObject ( ) const
void casacore::ImageProxy::createAttrGroup ( const String groupName)

Create a new attribute group.

String casacore::ImageProxy::dataType ( ) const

Get the data type of the image.

template<typename T >
void casacore::ImageProxy::doPutMask ( ImageInterface< T > &  image,
const ValueHolder value,
const IPosition blc,
const IPosition inc 
)
private

Put the mask and create it if needed.

template<typename T >
ImageProxy casacore::ImageProxy::doRegrid ( const ImageInterface< T > &  image,
const Vector< Int > &  axes,
const String outfile,
const IPosition shape,
const Record coordSys,
const String method,
Int  decimate,
Bool  replicate,
Bool  doRefChange,
Bool  force 
)
private

Do the actual regridding.

ValueHolder casacore::ImageProxy::getAttr ( const String groupName,
const String attrName,
uInt  rownr 
) const

Get the value of an attribute in a group row.

Vector<String> casacore::ImageProxy::getAttrMeas ( const String groupName,
const String attrName 
) const

Get the measinfo of an attribute in a group.

Record casacore::ImageProxy::getAttrRow ( const String groupName,
uInt  rownr 
) const

Get all attributes in a group row.

Vector<String> casacore::ImageProxy::getAttrUnit ( const String groupName,
const String attrName 
) const

Get the unit(s) of an attribute in a group.

ValueHolder casacore::ImageProxy::getData ( const IPosition blc,
const IPosition trc,
const IPosition inc 
)

Get a chunk of data.

LatticeBase* casacore::ImageProxy::getLattice ( ) const
inline

Definition at line 380 of file ImageProxy.h.

References itsLattice.

ValueHolder casacore::ImageProxy::getMask ( const IPosition blc,
const IPosition trc,
const IPosition inc 
)

Get a chunk of the mask.

Bool casacore::ImageProxy::hasLock ( Bool  writeLock = False)

Does the image have a read or write lock?

Vector<String> casacore::ImageProxy::history ( ) const

Get the history.

Record casacore::ImageProxy::imageInfo ( ) const

Get the image info.

const ImageInfo& casacore::ImageProxy::imageInfoObject ( ) const
String casacore::ImageProxy::imageType ( ) const

Get the image type (PagedImage, HDF5Image, etc.)

Bool casacore::ImageProxy::isPersistent ( ) const

Is the image persistent or temporary.

void casacore::ImageProxy::lock ( Bool  writeLock = False,
Int  nattempts = 0 
)

Try to acquire a read or write lock.

nattempts=0 means wait until acquired. Otherwise every second an attempt is done.

CoordinateSystem casacore::ImageProxy::makeCoordinateSystem ( const Record coordinates,
const IPosition shape 
) const
private

Make a coordinate system from the Record.

The cylindrical fix is applied if needed.

template<typename T >
void casacore::ImageProxy::makeImage ( const Array< T > &  array,
const Array< Bool > &  mask,
const IPosition shape,
const Record coordinates,
const String fileName,
Bool  asHDF5,
const String maskName,
const IPosition tileShape 
)
private

Make an image from an array or shape.

LatticeExprNode casacore::ImageProxy::makeNode ( ) const

Turn the ImageProxy into a LatticeExprNode.

template<typename T >
Record casacore::ImageProxy::makeStatistics ( const ImageInterface< T > &  image,
const Vector< Int > &  axes,
const String mask,
const ValueHolder minMaxValues,
Bool  exclude,
Bool  robust 
) const
private

Calculate the statistics.

TiledShape casacore::ImageProxy::makeTiledShape ( const IPosition newTileShape,
const IPosition shape,
const IPosition oldTileShape = IPosition() 
) const
private

Form a tiled shape from the current shape and a possible new tile shape.

Record casacore::ImageProxy::miscInfo ( ) const

Get the miscellaneous info.

String casacore::ImageProxy::name ( Bool  stripPath = False) const

Get the name of the image.

uInt casacore::ImageProxy::ndim ( ) const

Get the dimensionality of the image.

static LatticeBase* casacore::ImageProxy::openImage ( const String name,
const String mask = String(),
const std::vector< ImageProxy > &  images = std::vector< ImageProxy >() 
)
static

Open the image (which can also be an expression).

It throws an exception if not succeeded.

static LatticeBase* casacore::ImageProxy::openImageOrExpr ( const String str,
const MaskSpecifier ,
const Block< LatticeExprNode > &  nodes 
)
static

Open an image in the file/table with the given name.

The specified mask will be applied (default is default mask). A null pointer is returned for an unknown image type. Non-Casacore image types must have been registered to be known. If not successful, try to open it as an image expression.

ImageProxy& casacore::ImageProxy::operator= ( const ImageProxy )

Assignment (reference semantics).

void casacore::ImageProxy::putAttr ( const String groupName,
const String attrName,
uInt  rownr,
const ValueHolder value,
const Vector< String > &  units,
const Vector< String > &  measInfo 
)

Put the value, unit, and measinfo of an attribute in a group row.

The attribute or row is added if new.

void casacore::ImageProxy::putData ( const ValueHolder ,
const IPosition blc,
const IPosition inc 
)

Put a chunk of data.

void casacore::ImageProxy::putMask ( const ValueHolder value,
const IPosition blc,
const IPosition inc 
)

Put a chunk of the mask.

The mask will be created if not present yet. That will not be done if the entire mask is True.

ImageProxy casacore::ImageProxy::regrid ( const Vector< Int > &  axes = VectorInt >(),
const String outfile = String(),
Bool  overwriteOutFile = True,
const IPosition outShape = IPosition(),
const Record coordSys = Record(),
const String method = "linear",
Int  decimate = 10,
Bool  replicate = False,
Bool  doRefChange = True,
Bool  forceRegrid = False 
)

Regrid the image on the given axes to the given coordinate system.

The output is stored in the given file; it no file name is given a temporary image is made. If the output shape is empty, the old shape is used. replicate=True means replication rather than regridding.

void casacore::ImageProxy::saveAs ( const String fileName,
Bool  overwrite = True,
Bool  hdf5 = False,
Bool  copyMask = True,
const String newMaskName = String(),
const IPosition newTileShape = IPosition() 
) const

Write the image to an image file with the given name.

An exception is thrown if the name is the name of an already open image.

template<typename T >
void casacore::ImageProxy::saveImage ( const String fileName,
Bool  hdf5,
Bool  copyMask,
const String newMaskName,
const IPosition newTileShape,
const ImageInterface< T > &  image 
) const
private

Copy the image to an image (PagedImage or HDF5Image) with the given name.

A new tile shape can be given. If the image is masked, the mask can be copied as well.

void casacore::ImageProxy::setup ( )
private

Setup the pointers for the various image data types.

void casacore::ImageProxy::setup ( LatticeBase lattice)
private

Setup the pointers for the various image data types.

It takes over the lattice pointer.

IPosition casacore::ImageProxy::shape ( ) const

Get the shape of the image.

uInt casacore::ImageProxy::size ( ) const

Get the size of the image (nr of pixels).

Record casacore::ImageProxy::statistics ( const Vector< Int > &  axes,
const String mask,
const ValueHolder minMaxValues,
Bool  exclude = False,
Bool  robust = False 
) const

Return the statistics for the given axes.

E.g., if axes 0,1 is given in a 3-dim image, the statistics are calculated for each plane along the 3rd axis. MinMaxValues can be given to include or exclude (4th argument) pixels with values in the given range. If only one value is given, min=-abs(val) and max=abs(val). Robust statistics (Median, MedAbsDevMed, and Quartile) can be returned too.

ImageProxy casacore::ImageProxy::subImage ( const IPosition blc,
const IPosition trc,
const IPosition inc,
Bool  dropDegenerate = True 
)

Form a new (virtual) image being a subset of the image.

It uses preserveAxesOrder=False.

ImageProxy casacore::ImageProxy::subImage2 ( const IPosition blc,
const IPosition trc,
const IPosition inc,
Bool  dropDegenerate,
Bool  preserveAxesOrder 
)

Same with a new function name for backward compatibility with old pyrap.

void casacore::ImageProxy::toFits ( const String fitsfile,
Bool  overwrite = True,
Bool  velocity = True,
Bool  optical = True,
Int  bitpix = -32,
Double  minpix = 1,
Double  maxpix = -1 
) const

Write the image in FITS format.

See class ImageFITSConverter for a description of the arguments. Currently only a float image can be written to FITS.

Vector<Double> casacore::ImageProxy::toPixel ( const Vector< Double > &  world,
Bool  reverseAxes 
)

Convert a world coordinate to pixel coordinate.

if reverseAxes=True the input and output vector will be reversed (as needed for pyrap).

Vector<Double> casacore::ImageProxy::toWorld ( const Vector< Double > &  pixel,
Bool  reverseAxes 
)

Convert a pixel coordinate to world coordinate.

if reverseAxes=True the input and output vector will be reversed (as needed for pyrap).

DataType casacore::ImageProxy::type ( ) const
String casacore::ImageProxy::unit ( ) const

Get the brightness unit.

void casacore::ImageProxy::unlock ( )

Release the lock acquired by lock().

Member Data Documentation

ImageAttrHandler* casacore::ImageProxy::itsAttrHandler
private

Definition at line 476 of file ImageProxy.h.

const CoordinateSystem* casacore::ImageProxy::itsCoordSys
private

Definition at line 475 of file ImageProxy.h.

ImageInterface<Complex>* casacore::ImageProxy::itsImageComplex
private

Definition at line 473 of file ImageProxy.h.

ImageInterface<DComplex>* casacore::ImageProxy::itsImageDComplex
private

Definition at line 474 of file ImageProxy.h.

ImageInterface<Double>* casacore::ImageProxy::itsImageDouble
private

Definition at line 472 of file ImageProxy.h.

ImageInterface<Float>* casacore::ImageProxy::itsImageFloat
private

Definition at line 471 of file ImageProxy.h.

CountedPtr<LatticeBase> casacore::ImageProxy::itsLattice
private

Definition at line 470 of file ImageProxy.h.

Referenced by getLattice().


The documentation for this class was generated from the following file: