casacore
Loading...
Searching...
No Matches
TableMeasOffsetDesc.h
Go to the documentation of this file.
1// # TableMeasOffseDesc.h: Definition of an Offset measure in a Table.
2// # Copyright (C) 1997,1999,2000,2001
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 MEASURES_TABLEMEASOFFSETDESC_H
27#define MEASURES_TABLEMEASOFFSETDESC_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/casa/BasicSL/String.h>
32#include <casacore/measures/Measures/MeasureHolder.h>
33
34namespace casacore { // # NAMESPACE CASACORE - BEGIN
35
36// # Forward Declarations
38class Measure;
39class Table;
40class TableDesc;
41class TableRecord;
42class String;
43
44// <summary>
45// Definition of a Measure Offset in a Table.
46// </summary>
47
48// <use visibility=export>
49
50// <reviewed reviewer="Bob Garwood" date="1999/12/23" tests="tTableMeasures.cc">
51// </reviewed>
52
53// <prerequisite>
54// # Classes you should understand before using this one.
55// <li> <linkto module=Measures>Measures</linkto>
56// <li> <linkto module=Tables>Tables</linkto>
57// <li> <linkto class=TableMeasDesc>TableMeasDesc</linkto>
58// </prerequisite>
59
60// <synopsis>
61// This class assists in the definition of the offset component of a
62// TableMeasDesc
63// in the TableMeasures system. Four possibilities exist for specifying the
64// handling of measure offsets in a Measure column. These are:
65//
66// <ul>
67// <li> an offset is not used
68// <li> all measures in the column have the same offset
69// <li> a unique (and probably different) offset is stored for each row
70// <li> a unique offset is stored in each array element per (Array)column
71// row
72// </ul>
73//
74// Note that this last option is only relevant when using ArrayMeasColumns.
75//
76// Examples of each of these follow.
77// </synopsis>
78
79// <example>
80//<ol>
81// <li>Specifying a single fixed offset. Note that a Measure offset is itself
82// a measure
83// <srcblock>
84// // create an MEpoch to use as the offset in an MEpoch column
85// MEpoch offset(MVEpoch(MVTime(1996, 5, 17, (8+18./60.)/24.)), MEpoch::UTC);
86// TableMeasOffsetDesc offsetDesc(offset);
87// </srcblock>
88//
89// <li>Storing an offset per row needs an offset column. Measure offsets are
90// Measures so a Measure column is needed:
91// <srcblock>
92// // Need a column for the offsets. This is to be a Measure column,
93// // so the rules for creating a Measure column apply.
94// ArrayColumnDesc<Double> cdOffset("OffsetCol", "Variable Offset col");
95// ...
96// // add the column to the table
97// td.addColumn(cdOffset);
98// ...
99// // Create the Measure column to be used as the measure offset column
100// TableMeasValueDesc valDesc(td, "OffsetCol");
101// TableMeasDesc<MEpoch> offset(valDesc);
102// // Create the offset descriptor
103// TableMeasOffsetDesc offsetDesc(offset);
104//
105// </srcblock>
106//
107// <li>Storing an offset per array element per row requires one change in the
108// constructor used in the previous example:
109// <srcblock>
110// ...
111// // set up column and TableMeasDesc as before
112// ...
113// // Setting the asArray parameter to True in the constructor specifies
114// // per element offset storage
115// TableMeasOffsetDesc offsetDesc(offset, True);
116// </srcblock>
117// </ol>
118//
119// For an example of the use of the TableMeasOffsetDesc class in the context
120// of a full TableMeasDesc declaration see class
121// <linkto class="TableMeasDesc">TableMeasDesc</linkto>.
122// </example>
123
124// <motivation>
125// Creating the required keyword for the definition of a Measure
126// in a Table is somewhat complicated. This class assists in that
127// process.
128// </motivation>
129//
130// <thrown>
131// <li>AipsError during reconstruction of non-variable offset if a
132// component of the offset measure is missing in the column keywords or
133// is corrupt in some way.
134// <li>AipsError if getOffset() called on a variable offset object.
135// <li>AipsError during a reconstruct if the column doesn't have a Unit.
136// </thrown>
137//
138// # <todo asof="$DATE:$">
139// # A List of bugs, limitations, extensions or planned refinements.
140// # </todo>
141
143 public:
144 // Constructor which defines a constant (non-variable) offset. All
145 // measures in the columns will have the same offset.
147
148 // Constructor for defining a variable offset. If asArray is True then
149 // the offset is stored per array element. The default is for the
150 // offset to be stored (and hence variable) per row.
151 TableMeasOffsetDesc(const TableMeasDescBase& offsetColumn, Bool asArray = False);
152
153 // Copy constructor (copy semantics).
155
157
158 // Assignment operator (copy semantics).
160
161 // Reconstructs the TableMeasOffsetDesc from the measInfo TableRecord.
162 static TableMeasOffsetDesc* reconstruct(const TableRecord& measInfo, const String& prefix,
163 const Table& tab);
164
165 // Get the (non-variable) measure offset for this column. If it doesn't
166 // exist (thus if the offset is variable), an exception is thrown.
167 const Measure& getOffset() const;
168
169 // Returns True if the offset varies per row.
170 Bool isVariable() const { return (itsTMDesc != 0); }
171
172 // Returns True if the offset varies per array element.
173 Bool isArray() const { return (isVariable() && itsVarPerArr); }
174
175 // Gets the name of the column which stores the variable offset.
176 // "" is returned if the offset is not variable.
177 const String& columnName() const { return itsVarColName; }
178
179 // Reset the offset.
180 // It overwrites the value used when defining the TableMeasDesc.
181 // It is only possible if it was defined as fixed for the entire column.
183
184 // Write the information into the record.
185 // <group>
186 void write(TableDesc&, TableRecord& measInfo, const String& prefix);
187 void write(Table&, TableRecord& measInfo, const String& prefix);
188 // </group>
189
190 private:
191 TableMeasDescBase* itsTMDesc; // # Stores variable offset if applicable
192 MeasureHolder itsMeasure; // # The offset if non-variable.
193 String itsVarColName; // # "" if offset non-variable.
194 Bool itsVarPerArr; // # Is variable per array element.
195
196 // Constructor which uses the measInfo TableRecord.
197 TableMeasOffsetDesc(const TableRecord& measInfo, const String& prefix, const Table&);
198
199 // Write the actual keywords.
200 void writeKeys(TableRecord& measInfo, const String& prefix);
201};
202
203} // namespace casacore
204
205#endif
String: the storage and methods of handling collections of characters.
Definition String.h:355
TableMeasOffsetDesc(const TableMeasDescBase &offsetColumn, Bool asArray=False)
Constructor for defining a variable offset.
void resetOffset(const Measure &offset)
Reset the offset.
const String & columnName() const
Gets the name of the column which stores the variable offset.
void write(Table &, TableRecord &measInfo, const String &prefix)
const Measure & getOffset() const
Get the (non-variable) measure offset for this column.
void writeKeys(TableRecord &measInfo, const String &prefix)
Write the actual keywords.
TableMeasOffsetDesc(const TableMeasOffsetDesc &that)
Copy constructor (copy semantics).
TableMeasOffsetDesc(const TableRecord &measInfo, const String &prefix, const Table &)
Constructor which uses the measInfo TableRecord.
Bool isArray() const
Returns True if the offset varies per array element.
void write(TableDesc &, TableRecord &measInfo, const String &prefix)
Write the information into the record.
static TableMeasOffsetDesc * reconstruct(const TableRecord &measInfo, const String &prefix, const Table &tab)
Reconstructs the TableMeasOffsetDesc from the measInfo TableRecord.
TableMeasOffsetDesc & operator=(const TableMeasOffsetDesc &that)
Assignment operator (copy semantics).
Bool isVariable() const
Returns True if the offset varies per row.
TableMeasOffsetDesc(const Measure &offset)
Constructor which defines a constant (non-variable) offset.
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:42
int offset(int, int) const
compute a linear offset from array indicies
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40