casacore
Loading...
Searching...
No Matches
ImageAttrGroup.h
Go to the documentation of this file.
1//# ImageAttrGroup.h: Abstract base class for an image attributes group
2//# Copyright (C) 2012
3//# Associated Universities, Inc. Washington DC, USA.
4//#
5//# This library is free software; you can redistribute it and/or modify it
6//# under the terms of the GNU Library General Public License as published by
7//# the Free Software Foundation; either version 2 of the License, or (at your
8//# option) any later version.
9//#
10//# This library is distributed in the hope that it will be useful, but WITHOUT
11//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13//# License for more details.
14//#
15//# You should have received a copy of the GNU Library General Public License
16//# along with this library; if not, write to the Free Software Foundation,
17//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18//#
19//# Correspondence concerning AIPS++ should be addressed as follows:
20//# Internet email: casa-feedback@nrao.edu.
21//# Postal address: AIPS++ Project Office
22//# National Radio Astronomy Observatory
23//# 520 Edgemont Road
24//# Charlottesville, VA 22903-2475 USA
25
26#ifndef IMAGES_IMAGEATTRGROUP_H
27#define IMAGES_IMAGEATTRGROUP_H
28
29
30//# Includes
31#include <casacore/casa/aips.h>
32#include <casacore/casa/Containers/ValueHolder.h>
33#include <casacore/casa/Arrays/Vector.h>
34
35namespace casacore {
36
37// <summary>
38// Abstract base class for an image attributes group.
39// </summary>
40
41// <use visibility=export>
42
43// <reviewed reviewer="" date="" tests="tPagedmage.cc" demos="dPagedImage.cc">
44// </reviewed>
45
46// <prerequisite>
47// <li> <linkto class=ImageInterface>ImageInterface</linkto>
48// </prerequisite>
49
50// <etymology>
51// This class makes it possible to store extra attributes with an image to
52// describe atrbitrary meta information.
53// </etymology>
54
55// <synopsis>
56// For LOFAR it is needed to store extra meta information and be possible to
57// convert it from casacore table format to HDF5 format and vice-versa.
58// Furthermore, it must be possible to access the information in a way that
59// arbitrary attributes can be stored and retrieved in a way that is agnostic
60// to the format the image is stored in. It must also work fine for an image
61// stored in FITS format, be it that such an image cannot have such attributes.
62//
63// The attributes are divided into groups. A group resides in a subtable
64// of a casacore image or in a group of an HDF5 image. This class handles
65// the attributes of a group. It can get and put the attribute values, as well
66// as their unit and measure info (type and reference frame type).
67// For HDF5 images the unit is stored in attribute <src>attrname>_UNIT</src>
68// and the measure info in <src>attrname>_MEASINFO</src>. For casacore images
69// that info is stored as TableMeasure info in the column keywords.
70//
71// All attributes in a group must have the same number of values, where each
72// value can be a scalar or (small) array. The unit and measure info have
73// only one value, thus all values of an attribute have the same unit.
74// </synopsis>
75
76// <example>
77// This example shows how to get attributes from an image.
78// <srcblock>
79// // Open the image.
80// PagedImage<Float> myimage ("image.name");
81// // Open the attribute handler.
82// ImageAttrHandler& attrHandler = myimage.attrHandler();
83// // Get access to attibute group LOFAR_SOURCE.
84// ImageAttrGroup& lofarSource = attrHandler.openGroup ("LOFAR_SOURCE");
85// // Get the names of all attributes in this group.
86// Vector<String> attrNames = lofarSource.attrNames();
87// // Get the value of the ATTRNAME attribute (if there).
88// if (lofarSource.hasAttr ("ATTRNAME)) {
89// ValueHolder vh (lofarSource.getData ("ATTRNAME"));
90// Vector<String> name = vh.asString();
91// }
92// </srcblock>
93// The following example shows how to add a group and attribute.
94// <srcblock>
95// // Open the image.
96// PagedImage<Float> myimage ("image.name");
97// // Open the attribute handler.
98// ImageAttrHandler& attrHandler = myimage.attrHandler();
99// // Add attribute group LOFAR_SOURCE.
100// ImageAttrGroup& lofarSource = attrHandler.createGroup (LOFAR_SOURCE);
101// // Add an attribute which has unit Hz.
102// // The value has 2 values (e.g. for 2 frequency bands).
103// Vector<double> freqs(2);
104// freqs[0]=4.5e7; freqs[1]=5.5e7;
105// lofarSource.putData ("CENTER_FREQ", ValueHolder(freqs),
106// Vector<String(1,"Hz"));
107// </srcblock>
108// </example>
109//
110// <motivation>
111// LOFAR needed functionality to store arbitrary attributes.
112// </motivation>
113
115{
116public:
117 // Default constructor.
120
122
123 // Get the number of rows in the group.
124 virtual uInt nrows() const = 0;
125
126 // Test if an attribute exists.
127 virtual Bool hasAttr (const String& attrName) const = 0;
128
129 // Get all attribute names.
130 virtual Vector<String> attrNames() const = 0;
131
132 // Get the datatype of a attribute.
133 // It returns TpOther if the attribute is not defined.
134 virtual DataType dataType (const String& attrName) const = 0;
135
136 // Get the data of the given attribute in the given row
137 virtual ValueHolder getData (const String& attrName, uInt rownr) = 0;
138
139 // Get the data of all attributes in a rows.
140 virtual Record getDataRow (uInt rownr) = 0;
141
142 // Get the possible units of the values.
143 // An empty vector is returned if the attribute has no units.
144 virtual Vector<String> getUnit (const String& attrName) = 0;
145
146 // Get the possible measure info as type and Ref.
147 // An empty vector is returned if the attribute has no MEASINFO.
148 virtual Vector<String> getMeasInfo (const String& attrName) = 0;
149
150 // Put the data of the given attribute in the given row.
151 // If the row or attribute is new, it will be added. Note that the
152 // new row must be directly after the last row in the group.
153 // <br>If not empty, the units and MEASINFO will be put as column keywords.
154 // The MEASINFO vector must be given as type,Ref.
155 virtual void putData (const String& attrName, uInt rownr,
156 const ValueHolder& data,
157 const Vector<String>& units = Vector<String>(),
158 const Vector<String>& measInfo = Vector<String>()) = 0;
159};
160
161} //# NAMESPACE CASACORE - END
162
163#endif
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 Bool hasAttr(const String &attrName) const =0
Test if an attribute exists.
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.
ImageAttrGroup()
Default constructor.
virtual uInt nrows() const =0
Get the number of rows in the group.
virtual Vector< String > getUnit(const String &attrName)=0
Get the possible units of the values.
virtual Vector< String > attrNames() const =0
Get all attribute names.
virtual Record getDataRow(uInt rownr)=0
Get the data of all attributes in a rows.
virtual Vector< String > getMeasInfo(const String &attrName)=0
Get the possible measure info as type and Ref.
String: the storage and methods of handling collections of characters.
Definition String.h:223
this file contains all the compiler specific defines
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40