Loading...
Searching...
No Matches
casacore::ImageAttrGroup Class Referenceabstract
images package (libcasa_images) » Images_module

More...

`#include <ImageAttrGroup.h>`

## Public Member Functions

| ImageAttrGroup ()
| Default constructor.
virtual | ~ImageAttrGroup ()
virtual uInt | nrows () const =0
| Get the number of rows in the group.
virtual Bool | hasAttr (const String &attrName) const =0
| Test if an attribute exists.
virtual Vector< String > | attrNames () const =0
| Get all attribute names.
virtual DataType | dataType (const String &attrName) const =0
| Get the datatype of a attribute.
virtual ValueHolder | getData (const String &attrName, uInt rownr)=0
| Get the data of the given attribute in the given row.
virtual Record | getDataRow (uInt rownr)=0
| Get the data of all attributes in a rows.
virtual Vector< String > | getUnit (const String &attrName)=0
| Get the possible units of the values.
virtual Vector< String > | getMeasInfo (const String &attrName)=0
| Get the possible measure info as type and Ref.
virtual void | putData (const String &attrName, uInt rownr, const ValueHolder &data, const Vector< String > &units=Vector< String >(), const Vector< String > &measInfo=Vector< String >())=0
| Put the data of the given attribute in the given row.

## Detailed Description

Abstract base class for an image attributes group.

### Intended use:

Public interface

### Review Status

Test programs:
  tPagedmage
Demo programs:
  dPagedImage

### Prerequisite

- ImageInterface

### Etymology

This class makes it possible to store extra attributes with an image to describe atrbitrary meta information.

### Synopsis

For LOFAR it is needed to store extra meta information and be possible to convert it from casacore table format to HDF5 format and vice-versa. Furthermore, it must be possible to access the information in a way that arbitrary attributes can be stored and retrieved in a way that is agnostic to the format the image is stored in. It must also work fine for an image stored in FITS format, be it that such an image cannot have such attributes.

The attributes are divided into groups. A group resides in a subtable of a casacore image or in a group of an HDF5 image. This class handles the attributes of a group. It can get and put the attribute values, as well as their unit and measure info (type and reference frame type). For HDF5 images the unit is stored in attribute attrname>_UNIT and the measure info in attrname>_MEASINFO. For casacore images that info is stored as TableMeasure info in the column keywords.

All attributes in a group must have the same number of values, where each value can be a scalar or (small) array. The unit and measure info have only one value, thus all values of an attribute have the same unit.

### Example

This example shows how to get attributes from an image.

// Open the image.
PagedImage<Float> myimage ("image.name");
// Open the attribute handler.
ImageAttrHandler& attrHandler = myimage.attrHandler();
// Get access to attibute group LOFAR_SOURCE.
ImageAttrGroup& lofarSource = attrHandler.openGroup ("LOFAR_SOURCE");
// Get the names of all attributes in this group.
Vector<String> attrNames = lofarSource.attrNames();
// Get the value of the ATTRNAME attribute (if there).
if (lofarSource.hasAttr ("ATTRNAME)) {
ValueHolder vh (lofarSource.getData ("ATTRNAME"));
Vector<String> name = vh.asString();
}
casacore::ImageAttrGroup::hasAttr
virtual Bool hasAttr(const String &attrName) const =0
Test if an attribute exists.
casacore::ImageAttrGroup::ImageAttrGroup
ImageAttrGroup()
Default constructor.
Definition ImageAttrGroup.h:117
casacore::ImageAttrGroup::attrNames
virtual Vector< String > attrNames() const =0
Get all attribute names.
casacore::ImageAttrHandler
Definition ImageAttrHandler.h:90
casacore::ImageAttrHandler::openGroup
virtual ImageAttrGroup & openGroup(const String &groupName)
Get access to a group.
casacore::PagedImage
Definition PagedImage.h:134
casacore::Vector
Definition Vector.h:82

The following example shows how to add a group and attribute.

// Open the image.
PagedImage<Float> myimage ("image.name");
// Open the attribute handler.
ImageAttrHandler& attrHandler = myimage.attrHandler();
// Add attribute group LOFAR_SOURCE.
ImageAttrGroup& lofarSource = attrHandler.createGroup (LOFAR_SOURCE);
// Add an attribute which has unit Hz.
// The value has 2 values (e.g. for 2 frequency bands).
Vector<double> freqs(2);
freqs[0]=4.5e7; freqs[1]=5.5e7;
lofarSource.putData ("CENTER_FREQ", ValueHolder(freqs),
Vector<String(1,"Hz"));
casacore::ImageAttrGroup::putData
virtual void putData(const String &attrName, uInt rownr, const ValueHolder &data, const Vector< String > &units=Vector< String >(), const Vector< String > &measInfo=Vector< String >())=0
Put the data of the given attribute in the given row.
casacore::ImageAttrHandler::createGroup
virtual ImageAttrGroup & createGroup(const String &groupName)
Create an attribute group with the given name.
casacore::String
String: the storage and methods of handling collections of characters.
Definition String.h:223
casacore::ValueHolder
Definition ValueHolder.h:66

### Motivation

LOFAR needed functionality to store arbitrary attributes.

Definition at line 113 of file ImageAttrGroup.h.

## Constructor & Destructor Documentation

## ImageAttrGroup()

casacore::ImageAttrGroup::ImageAttrGroup | ( |  | ) |

inline

Default constructor.

Definition at line 117 of file ImageAttrGroup.h.

## ~ImageAttrGroup()

virtual casacore::ImageAttrGroup::~ImageAttrGroup | ( |  | ) |

virtual

## Member Function Documentation

## attrNames()

virtual Vector< String > casacore::ImageAttrGroup::attrNames | ( |  | ) | const

pure virtual

Get all attribute names.

Implemented in casacore::ImageAttrGroupCasa, and casacore::ImageAttrGroupHDF5.

## dataType()

virtual DataType casacore::ImageAttrGroup::dataType | ( | const String & | attrName | ) | const

pure virtual

Get the datatype of a attribute.

It returns TpOther if the attribute is not defined.

Implemented in casacore::ImageAttrGroupCasa, and casacore::ImageAttrGroupHDF5.

## getData()

virtual ValueHolder casacore::ImageAttrGroup::getData | ( | const String & | attrName,
|  | uInt | rownr )

pure virtual

Get the data of the given attribute in the given row.

Implemented in casacore::ImageAttrGroupCasa, and casacore::ImageAttrGroupHDF5.

## getDataRow()

virtual Record casacore::ImageAttrGroup::getDataRow | ( | uInt | rownr | ) |

pure virtual

Get the data of all attributes in a rows.

Implemented in casacore::ImageAttrGroupCasa, and casacore::ImageAttrGroupHDF5.

References casacore::Record().

## getMeasInfo()

virtual Vector< String > casacore::ImageAttrGroup::getMeasInfo | ( | const String & | attrName | ) |

pure virtual

Get the possible measure info as type and Ref.

An empty vector is returned if the attribute has no MEASINFO.

Implemented in casacore::ImageAttrGroupCasa, and casacore::ImageAttrGroupHDF5.

## getUnit()

virtual Vector< String > casacore::ImageAttrGroup::getUnit | ( | const String & | attrName | ) |

pure virtual

Get the possible units of the values.

An empty vector is returned if the attribute has no units.

Implemented in casacore::ImageAttrGroupCasa, and casacore::ImageAttrGroupHDF5.

## hasAttr()

virtual Bool casacore::ImageAttrGroup::hasAttr | ( | const String & | attrName | ) | const

pure virtual

Test if an attribute exists.

Implemented in casacore::ImageAttrGroupCasa, and casacore::ImageAttrGroupHDF5.

## nrows()

virtual uInt casacore::ImageAttrGroup::nrows | ( |  | ) | const

pure virtual

Get the number of rows in the group.

Implemented in casacore::ImageAttrGroupCasa, and casacore::ImageAttrGroupHDF5.

## putData()

virtual void casacore::ImageAttrGroup::putData | ( | const String & | attrName,
|  | uInt | rownr,
|  | const ValueHolder & | data,
|  | const Vector< String > & | units = Vector< String >(),
|  | const Vector< String > & | measInfo = Vector< String >() )

pure virtual

Put the data of the given attribute in the given row.

If the row or attribute is new, it will be added. Note that the new row must be directly after the last row in the group.
If not empty, the units and MEASINFO will be put as column keywords. The MEASINFO vector must be given as type,Ref.

Implemented in casacore::ImageAttrGroupCasa, and casacore::ImageAttrGroupHDF5.

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

- images/Images/ImageAttrGroup.h