casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
casa::ImageProxy Class Reference

#include <ImageProxy.h>

List of all members.

Public Member Functions

 ImageProxy ()
 Default constructor is needed for Boost-Python.
 ImageProxy (const Vector< String > &names, Int axis)
 Construct from the concatenation of the images along the axis.
 ImageProxy (const String &name, const String &mask, const vector< ImageProxy > &images)
 Construct from a string that contains an image name or image expression.
 ImageProxy (const vector< ImageProxy > &images, Int axis, Int dummy1=0, Int dummy2=0)
 Construct from the concatenation of the image objects along the axis.
 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.
 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.
 ImageProxy (const ImageProxy &)
 Copy constructor (reference semantics).
ImageProxyoperator= (const ImageProxy &)
 Assignment (reference semantics).
 ~ImageProxy ()
LatticeExprNode makeNode () const
 Turn the ImageProxy into a LatticeExprNode.
Bool isPersistent () const
 Is the image persistent or temporary.
String name (Bool stripPath=False) const
 Get the name of the image.
IPosition shape () const
 Get the shape of the image.
uInt ndim () const
 Get the dimensionality of the image.
uInt size () const
 Get the size of the image (nr of pixels).
String dataType () const
 Get the data type of the image.
ValueHolder getData (const IPosition &blc, const IPosition &trc, const IPosition &inc)
 Get a chunk of data.
ValueHolder getMask (const IPosition &blc, const IPosition &trc, const IPosition &inc)
 Get a chunk of the mask.
void putData (const ValueHolder &, const IPosition &blc, const IPosition &inc)
 Put a chunk of data.
void putMask (const ValueHolder &value, const IPosition &blc, const IPosition &inc)
 Put a chunk of the mask.
Bool hasLock (Bool writeLock=False)
 Does the image have a read or write lock?
void lock (Bool writeLock=False, Int nattempts=0)
 Try to acquire a read or write lock.
void unlock ()
 Release the lock acquired by lock().
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.
String unit () const
 Get the brightness unit.
Record coordSys () const
 Get the coordinate system.
Vector< DoubletoWorld (const Vector< Double > &pixel, Bool reverseAxes)
 Convert a pixel coordinate to world coordinates.
Record imageInfo () const
 Get the image info.
Record miscInfo () const
 Get the miscellaneous info.
Vector< Stringhistory () const
 Get the history.
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.
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.
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.
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.
LatticeBasegetLattice () const
 
      

Static Public Member Functions

static LatticeBaseopenImageOrExpr (const String &str, const MaskSpecifier &, const Block< LatticeExprNode > &nodes)
 Open an image in the file/table with the given name.
static IPosition adjustBlc (const IPosition &blc, const IPosition &shp)
 Check and adjust blc, trc, or inc using the shape.
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.
void openImage (const String &name, const String &mask, const vector< ImageProxy > &images)
 Open the image (which can also be an expression.
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.
void concatImages (const std::vector< ImageProxy > &images, Int axis)
 Form a concatenated image.
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 (LatticeBase *lattice)
 Setup the pointers for the various image data types.
void centreRefPix (CoordinateSystem &cSys, const IPosition &shape) const
 Centre all axes except the Stokes one.
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.
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.
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.
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.
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.
CoordinateSystem makeCoordinateSystem (const Record &coordinates, const IPosition &shape) const
 Make a coordinate system from the Record.

Private Attributes

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

Detailed Description

Synopsis

Definition at line 50 of file ImageProxy.h.


Constructor & Destructor Documentation

Default constructor is needed for Boost-Python.

casa::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.

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

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

It is opened using ImageOpener.

casa::ImageProxy::ImageProxy ( const 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.

casa::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.

casa::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.

Copy constructor (reference semantics).

casa::ImageProxy::ImageProxy ( LatticeBase ) [explicit, private]

Form an ImageProxy object from an existing image object.


Member Function Documentation

static IPosition casa::ImageProxy::adjustBlc ( const IPosition blc,
const IPosition shp 
) [static]

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

static IPosition casa::ImageProxy::adjustInc ( const IPosition inc,
const IPosition shp 
) [static]
static IPosition casa::ImageProxy::adjustTrc ( const IPosition trc,
const IPosition shp 
) [static]
void casa::ImageProxy::centreRefPix ( CoordinateSystem cSys,
const IPosition shape 
) const [private]

Centre all axes except the Stokes one.

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

Form a concatenated image.

void casa::ImageProxy::concatImagesComplex ( const std::vector< ImageProxy > &  images,
Int  axis 
) [private]
void casa::ImageProxy::concatImagesDComplex ( const std::vector< ImageProxy > &  images,
Int  axis 
) [private]
void casa::ImageProxy::concatImagesDouble ( const std::vector< ImageProxy > &  images,
Int  axis 
) [private]
void casa::ImageProxy::concatImagesFloat ( const std::vector< ImageProxy > &  images,
Int  axis 
) [private]

Get the coordinate system.

Get the data type of the image.

template<typename T >
void casa::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 casa::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 casa::ImageProxy::getData ( const IPosition blc,
const IPosition trc,
const IPosition inc 
)

Get a chunk of data.

      

Definition at line 287 of file ImageProxy.h.

References itsLattice.

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

Get a chunk of the mask.

Does the image have a read or write lock?

Get the history.

Get the image info.

Is the image persistent or temporary.

void casa::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 casa::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 casa::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.

Turn the ImageProxy into a LatticeExprNode.

template<typename T >
Record casa::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 casa::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.

Get the miscellaneous info.

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

Get the name of the image.

Get the dimensionality of the image.

void casa::ImageProxy::openImage ( const String name,
const String mask,
const vector< ImageProxy > &  images 
) [private]

Open the image (which can also be an expression.

Throw an exception if not succeeded.

static LatticeBase* casa::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-AIPS++ image types must have been registered to be known. If not successful, try to open it as an image expression.

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

Assignment (reference semantics).

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

Put a chunk of data.

void casa::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 casa::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 casa::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 casa::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 casa::ImageProxy::setup ( LatticeBase lattice) [private]

Setup the pointers for the various image data types.

Get the shape of the image.

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

Record casa::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. fn 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 casa::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.

void casa::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> casa::ImageProxy::toWorld ( const Vector< Double > &  pixel,
Bool  reverseAxes 
)

Convert a pixel coordinate to world coordinates.

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

Get the brightness unit.

Release the lock acquired by lock().


Member Data Documentation

Definition at line 380 of file ImageProxy.h.

Definition at line 378 of file ImageProxy.h.

Definition at line 379 of file ImageProxy.h.

Definition at line 377 of file ImageProxy.h.

Definition at line 376 of file ImageProxy.h.

Definition at line 375 of file ImageProxy.h.

Referenced by getLattice().


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