casacore
Public Member Functions | List of all members
casacore::ImageAttrGroup Class Referenceabstract

More...

#include <ImageAttrGroup.h>

Public Member Functions

 ImageAttrGroup ()
 Default constructor. More...
 
virtual ~ImageAttrGroup ()
 
virtual uInt nrows () const =0
 Get the number of rows in the group. More...
 
virtual Bool hasAttr (const String &attrName) const =0
 Test if an attribute exists. More...
 
virtual Vector< StringattrNames () const =0
 Get all attribute names. More...
 
virtual DataType dataType (const String &attrName) const =0
 Get the datatype of a attribute. More...
 
virtual ValueHolder getData (const String &attrName, uInt rownr)=0
 Get the data of the given attribute in the given row. More...
 
virtual Record getDataRow (uInt rownr)=0
 Get the data of all attributes in a rows. More...
 
virtual Vector< StringgetUnit (const String &attrName)=0
 Get the possible units of the values. More...
 
virtual Vector< StringgetMeasInfo (const String &attrName)=0
 Get the possible measure info as type and Ref. More...
 
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. More...
 

Detailed Description

Abstract base class for an image attributes group.

Intended use:

Public interface

Review Status

Test programs:
tPagedmage
Demo programs:
dPagedImage

Prerequisite

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();
}
virtual Vector< String > attrNames() const =0
Get all attribute names.
ImageAttrGroup()
Default constructor.

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"));

Motivation

LOFAR needed functionality to store arbitrary attributes.

Definition at line 116 of file ImageAttrGroup.h.

Constructor & Destructor Documentation

◆ ImageAttrGroup()

casacore::ImageAttrGroup::ImageAttrGroup ( )
inline

Default constructor.

Definition at line 120 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::ImageAttrGroupHDF5, and casacore::ImageAttrGroupCasa.

◆ 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::ImageAttrGroupHDF5, and casacore::ImageAttrGroupCasa.

◆ 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::ImageAttrGroupHDF5, and casacore::ImageAttrGroupCasa.

◆ getDataRow()

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

Get the data of all attributes in a rows.

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

◆ 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::ImageAttrGroupHDF5, and casacore::ImageAttrGroupCasa.

◆ 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::ImageAttrGroupHDF5, and casacore::ImageAttrGroupCasa.

◆ hasAttr()

virtual Bool casacore::ImageAttrGroup::hasAttr ( const String attrName) const
pure virtual

Test if an attribute exists.

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

◆ nrows()

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

Get the number of rows in the group.

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

◆ putData()

virtual void casacore::ImageAttrGroup::putData ( const String attrName,
uInt  rownr,
const ValueHolder data,
const Vector< String > &  units = VectorString >(),
const Vector< String > &  measInfo = VectorString >() 
)
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::ImageAttrGroupHDF5, and casacore::ImageAttrGroupCasa.


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